/
OAL_Effect.cpp
68 lines (52 loc) · 1.17 KB
/
OAL_Effect.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* Copyright 2007-2010 (C) - Frictional Games
*
* This file is part of OALWrapper
*
* For conditions of distribution and use, see copyright notice in LICENSE
*/
#include "OALWrapper/OAL_Effect.h"
#include "OALWrapper/OAL_Helper.h"
cOAL_Effect::cOAL_Effect() : iOAL_LowLevelObject("Effect"),
mbNeedsUpdate(true),
mpMutex(NULL)
{
mbStatus = CreateLowLevelID();
}
cOAL_Effect::~cOAL_Effect()
{
DestroyLowLevelID();
}
bool cOAL_Effect::CreateLowLevelID()
{
DEF_FUNC_NAME("cOAL_Effect::CreateLowLevelID()");
FUNC_USES_AL;
RUN_AL_FUNC(alGenEffects ( 1, &mlEffectId );)
return (!AL_ERROR_OCCURED && (IsValidObject()));
}
bool cOAL_Effect::DestroyLowLevelID()
{
DEF_FUNC_NAME("cOAL_Effect::DestroyLowLevelID()");
FUNC_USES_AL;
bool bSuccess = true;
if ( IsValidObject() )
{
RUN_AL_FUNC(alDeleteEffects( 1, &mlEffectId ));
bSuccess = bSuccess && !AL_ERROR_OCCURED;
}
return bSuccess;
}
bool cOAL_Effect::IsValidObject()
{
DEF_FUNC_NAME("cOAL_Effect::IsValidObject()");
FUNC_USES_AL;
return (alIsEffect(mlEffectId) == AL_TRUE);
}
void cOAL_Effect::Lock()
{
SDL_LockMutex(mpMutex);
}
void cOAL_Effect::Unlock()
{
SDL_UnlockMutex(mpMutex);
}