OSX Port in progress
Implemented ALDEBUG macro Corrected audio engine bugs
This commit is contained in:
@@ -176,6 +176,15 @@
|
||||
E497B954151BEDA600D3DC67 /* KRResource+fbx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E497B952151BEDA600D3DC67 /* KRResource+fbx.cpp */; };
|
||||
E497B95D151BF05F00D3DC67 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E497B95C151BF05F00D3DC67 /* CoreServices.framework */; };
|
||||
E497B95F151BF09600D3DC67 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E497B95E151BF09600D3DC67 /* SystemConfiguration.framework */; };
|
||||
E499BF1B16AE747C007FCDBE /* KRVector2.h in Headers */ = {isa = PBXBuildFile; fileRef = E497B943151BA93400D3DC67 /* KRVector2.h */; settings = {ATTRIBUTES = (); }; };
|
||||
E499BF1D16AE74FF007FCDBE /* KRTextureAnimated.h in Headers */ = {isa = PBXBuildFile; fileRef = E460292516681CFE00261BB9 /* KRTextureAnimated.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E499BF1E16AE751E007FCDBE /* KRSceneManager.h in Headers */ = {isa = PBXBuildFile; fileRef = E46C214915364DDB009CABF3 /* KRSceneManager.h */; };
|
||||
E499BF1F16AE753E007FCDBE /* KRCollider.h in Headers */ = {isa = PBXBuildFile; fileRef = 104A335D1672D31C001C8BA6 /* KRCollider.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E499BF2016AE755B007FCDBE /* KRPointLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A157152E555400F2044A /* KRPointLight.h */; };
|
||||
E499BF2116AE75A7007FCDBE /* KREngine-common.h in Headers */ = {isa = PBXBuildFile; fileRef = E46DBE841512B9E200D59F86 /* KREngine-common.h */; };
|
||||
E499BF2216AE760F007FCDBE /* krengine_osx.h in Headers */ = {isa = PBXBuildFile; fileRef = E4BBBB8C1512A40300F43B5B /* krengine_osx.h */; };
|
||||
E499BF2316AE7636007FCDBE /* krengine_osx-Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = E4BBBB8B1512A40300F43B5B /* krengine_osx-Prefix.pch */; };
|
||||
E499BF2516AE8C20007FCDBE /* KREngine.mm in Sources */ = {isa = PBXBuildFile; fileRef = E491016F13C99BDC0098455B /* KREngine.mm */; };
|
||||
E4AFC6B615F7C46800DDB4C8 /* KRAABB.cpp in Headers */ = {isa = PBXBuildFile; fileRef = E40BA45215EFF79500D7C3DD /* KRAABB.cpp */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E4AFC6B915F7C7B200DDB4C8 /* KROctree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4924C2415EE95E700B965C6 /* KROctree.cpp */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E4AFC6BB15F7C7D600DDB4C8 /* KROctreeNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4924C2915EE96AA00B965C6 /* KROctreeNode.cpp */; };
|
||||
@@ -999,6 +1008,10 @@
|
||||
E4F027D016979CE200D4427D /* KRAudioSample.h in Headers */,
|
||||
E4F027E01697BFFF00D4427D /* KRAudioBuffer.h in Headers */,
|
||||
E4943233169E08D200BCB891 /* KRReverbZone.h in Headers */,
|
||||
E499BF1B16AE747C007FCDBE /* KRVector2.h in Headers */,
|
||||
E499BF1E16AE751E007FCDBE /* KRSceneManager.h in Headers */,
|
||||
E499BF2016AE755B007FCDBE /* KRPointLight.h in Headers */,
|
||||
E499BF2116AE75A7007FCDBE /* KREngine-common.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -1068,6 +1081,10 @@
|
||||
E414F9AF1694DA37000B3D58 /* KRUnknown.h in Headers */,
|
||||
E4C454B3167BC04C003586CD /* KRMeshSphere.h in Headers */,
|
||||
E44F38251683B23000399B5D /* KRRenderSettings.h in Headers */,
|
||||
E499BF1D16AE74FF007FCDBE /* KRTextureAnimated.h in Headers */,
|
||||
E499BF1F16AE753E007FCDBE /* KRCollider.h in Headers */,
|
||||
E499BF2216AE760F007FCDBE /* krengine_osx.h in Headers */,
|
||||
E499BF2316AE7636007FCDBE /* krengine_osx-Prefix.pch in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -1220,6 +1237,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
E499BF2516AE8C20007FCDBE /* KREngine.mm in Sources */,
|
||||
10CC33A5168534F000BB9846 /* KRCamera.cpp in Sources */,
|
||||
E460292C166834AB00261BB9 /* KRTextureAnimated.cpp in Sources */,
|
||||
E461A17A152E5C9100F2044A /* KRMat4.cpp in Sources */,
|
||||
|
||||
@@ -20,18 +20,19 @@ KRAudioBuffer::KRAudioBuffer(KRAudioManager *manager, KRAudioSample *sound, int
|
||||
m_bytesPerFrame = bytesPerFrame;
|
||||
m_pData = NULL;
|
||||
|
||||
m_pSoundManager->makeCurrentContext();
|
||||
m_pData = m_pSoundManager->getBufferData(m_frameCount * m_bytesPerFrame);
|
||||
fn_populate(sound, index, m_pData->getStart());
|
||||
|
||||
m_pSoundManager->makeCurrentContext();
|
||||
alGenBuffers(1, &m_bufferID);
|
||||
alBufferData(m_bufferID, m_dataFormat, m_pData->getStart(), m_frameCount * m_bytesPerFrame, m_frameRate);
|
||||
|
||||
ALDEBUG(alGenBuffers(1, &m_bufferID));
|
||||
ALDEBUG(alBufferData(m_bufferID, m_dataFormat, m_pData->getStart(), m_frameCount * m_bytesPerFrame, m_frameRate));
|
||||
}
|
||||
|
||||
KRAudioBuffer::~KRAudioBuffer()
|
||||
{
|
||||
if(m_bufferID) {
|
||||
alDeleteBuffers(1, &m_bufferID);
|
||||
ALDEBUG(alDeleteBuffers(1, &m_bufferID));
|
||||
m_bufferID = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,35 +39,35 @@ ALvoid alcMacOSXRenderingQualityProc(const ALint value);
|
||||
KRAudioManager::KRAudioManager(KRContext &context) : KRContextObject(context)
|
||||
{
|
||||
// ----- Initialize OpenAL -----
|
||||
m_alDevice = alcOpenDevice(NULL);
|
||||
m_alContext=alcCreateContext(m_alDevice,NULL);
|
||||
alcMakeContextCurrent(m_alContext);
|
||||
ALDEBUG(m_alDevice = alcOpenDevice(NULL));
|
||||
ALDEBUG(m_alContext=alcCreateContext(m_alDevice,NULL));
|
||||
ALDEBUG(alcMakeContextCurrent(m_alContext));
|
||||
|
||||
// ----- Configure listener -----
|
||||
alDistanceModel(AL_EXPONENT_DISTANCE);
|
||||
ALDEBUG(alDistanceModel(AL_EXPONENT_DISTANCE));
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
alcMacOSXRenderingQualityProc(ALC_IPHONE_SPATIAL_RENDERING_QUALITY_HEADPHONES);
|
||||
ALDEBUG(alcMacOSXRenderingQualityProc(ALC_IPHONE_SPATIAL_RENDERING_QUALITY_HEADPHONES));
|
||||
#else
|
||||
alcMacOSXRenderingQualityProc(ALC_MAC_OSX_SPATIAL_RENDERING_QUALITY_HIGH);
|
||||
ALDEBUG(alcMacOSXRenderingQualityProc(ALC_MAC_OSX_SPATIAL_RENDERING_QUALITY_HIGH));
|
||||
#endif
|
||||
UInt32 setting = 1;
|
||||
alcASASetListenerProc(ALC_ASA_REVERB_ON, &setting, sizeof(setting));
|
||||
ALDEBUG(alcASASetListenerProc(ALC_ASA_REVERB_ON, &setting, sizeof(setting)));
|
||||
ALfloat global_reverb_level = -5.0f;
|
||||
alcASASetListenerProc(ALC_ASA_REVERB_GLOBAL_LEVEL, &global_reverb_level, sizeof(global_reverb_level));
|
||||
ALDEBUG(alcASASetListenerProc(ALC_ASA_REVERB_GLOBAL_LEVEL, &global_reverb_level, sizeof(global_reverb_level)));
|
||||
|
||||
setting = ALC_ASA_REVERB_ROOM_TYPE_MediumHall2;
|
||||
alcASASetListenerProc(ALC_ASA_REVERB_ROOM_TYPE, &setting, sizeof(setting));
|
||||
ALDEBUG(alcASASetListenerProc(ALC_ASA_REVERB_ROOM_TYPE, &setting, sizeof(setting)));
|
||||
|
||||
|
||||
ALfloat global_reverb_eq_gain = 0.0f;
|
||||
alcASASetListenerProc(ALC_ASA_REVERB_EQ_GAIN, &global_reverb_eq_gain, sizeof(global_reverb_eq_gain));
|
||||
ALDEBUG(alcASASetListenerProc(ALC_ASA_REVERB_EQ_GAIN, &global_reverb_eq_gain, sizeof(global_reverb_eq_gain)));
|
||||
|
||||
ALfloat global_reverb_eq_bandwidth = 0.0f;
|
||||
alcASASetListenerProc(ALC_ASA_REVERB_EQ_BANDWITH, &global_reverb_eq_bandwidth, sizeof(global_reverb_eq_bandwidth));
|
||||
ALDEBUG(alcASASetListenerProc(ALC_ASA_REVERB_EQ_BANDWITH, &global_reverb_eq_bandwidth, sizeof(global_reverb_eq_bandwidth)));
|
||||
|
||||
ALfloat global_reverb_eq_freq = 0.0f;
|
||||
alcASASetListenerProc(ALC_ASA_REVERB_EQ_FREQ, &global_reverb_eq_freq, sizeof(global_reverb_eq_freq));
|
||||
ALDEBUG(alcASASetListenerProc(ALC_ASA_REVERB_EQ_FREQ, &global_reverb_eq_freq, sizeof(global_reverb_eq_freq)));
|
||||
}
|
||||
|
||||
KRAudioManager::~KRAudioManager()
|
||||
@@ -77,11 +77,11 @@ KRAudioManager::~KRAudioManager()
|
||||
}
|
||||
|
||||
if(m_alContext) {
|
||||
alcDestroyContext(m_alContext);
|
||||
ALDEBUG(alcDestroyContext(m_alContext));
|
||||
m_alContext = 0;
|
||||
}
|
||||
if(m_alDevice) {
|
||||
alcCloseDevice(m_alDevice);
|
||||
ALDEBUG(alcCloseDevice(m_alDevice));
|
||||
m_alDevice = 0;
|
||||
}
|
||||
|
||||
@@ -92,12 +92,11 @@ KRAudioManager::~KRAudioManager()
|
||||
|
||||
void KRAudioManager::makeCurrentContext()
|
||||
{
|
||||
alcMakeContextCurrent(m_alContext);
|
||||
ALDEBUG(alcMakeContextCurrent(m_alContext));
|
||||
}
|
||||
|
||||
void KRAudioManager::setViewMatrix(const KRMat4 &viewMatrix)
|
||||
{
|
||||
makeCurrentContext();
|
||||
KRMat4 invView = viewMatrix;
|
||||
invView.invert();
|
||||
|
||||
@@ -107,10 +106,11 @@ void KRAudioManager::setViewMatrix(const KRMat4 &viewMatrix)
|
||||
|
||||
vectorUp.normalize();
|
||||
vectorForward.normalize();
|
||||
alcMakeContextCurrent(m_alContext);
|
||||
alListener3f(AL_POSITION, player_position.x, player_position.y, player_position.z);
|
||||
|
||||
makeCurrentContext();
|
||||
ALDEBUG(alListener3f(AL_POSITION, player_position.x, player_position.y, player_position.z));
|
||||
ALfloat orientation[] = {vectorForward.x, vectorForward.y, vectorForward.z, vectorUp.x, vectorUp.y, vectorUp.z};
|
||||
alListenerfv(AL_ORIENTATION, orientation);
|
||||
ALDEBUG(alListenerfv(AL_ORIENTATION, orientation));
|
||||
}
|
||||
|
||||
void KRAudioManager::add(KRAudioSample *sound)
|
||||
|
||||
@@ -219,7 +219,11 @@ KRAudioBuffer *KRAudioSample::getBuffer(int index)
|
||||
{
|
||||
openFile();
|
||||
|
||||
KRAudioBuffer *buffer = new KRAudioBuffer(getContext().getAudioManager(), this, index, m_dataFormat, m_totalFrames, m_frameRate, m_bytesPerFrame, PopulateBuffer);
|
||||
int maxFramesPerBuffer = KRENGINE_AUDIO_MAX_BUFFER_SIZE / m_bytesPerFrame;
|
||||
int startFrame = index * maxFramesPerBuffer;
|
||||
UInt32 frameCount = KRMIN(m_totalFrames - startFrame, maxFramesPerBuffer);
|
||||
|
||||
KRAudioBuffer *buffer = new KRAudioBuffer(getContext().getAudioManager(), this, index, m_dataFormat, frameCount, m_frameRate, m_bytesPerFrame, PopulateBuffer);
|
||||
|
||||
if(m_bufferCount == 1) {
|
||||
// [self closeFile]; // We don't need to hold on to a file handle if not streaming
|
||||
|
||||
@@ -48,7 +48,7 @@ KRAudioSource::KRAudioSource(KRScene &scene, std::string name) : KRNode(scene, n
|
||||
m_pitch = 1.0f;
|
||||
m_looping = false;
|
||||
|
||||
m_referenceDistance = 20.0f;
|
||||
m_referenceDistance = 1.0f;
|
||||
m_reverb = 0.0f;
|
||||
m_rolloffFactor = 2.0f;
|
||||
m_enable_occlusion = true;
|
||||
@@ -59,7 +59,7 @@ KRAudioSource::~KRAudioSource()
|
||||
{
|
||||
if(m_sourceID) {
|
||||
getContext().getAudioManager()->makeCurrentContext();
|
||||
alDeleteSources(1, &m_sourceID);
|
||||
ALDEBUG(alDeleteSources(1, &m_sourceID));
|
||||
m_sourceID = 0;
|
||||
}
|
||||
while(m_audioBuffers.size()) {
|
||||
@@ -116,9 +116,9 @@ void KRAudioSource::loadXML(tinyxml2::XMLElement *e)
|
||||
}
|
||||
setIs3D(is3d);
|
||||
|
||||
float reference_distance = 20.0f;
|
||||
float reference_distance = 1.0f;
|
||||
if(e->QueryFloatAttribute("reference_distance", &reference_distance) != tinyxml2::XML_SUCCESS) {
|
||||
reference_distance = 20.0f;
|
||||
reference_distance = 1.0f;
|
||||
}
|
||||
setReferenceDistance(reference_distance);
|
||||
|
||||
@@ -158,7 +158,7 @@ void KRAudioSource::prime()
|
||||
|
||||
// Initialize audio source
|
||||
m_sourceID = 0;
|
||||
alGenSources(1, &m_sourceID);
|
||||
ALDEBUG(alGenSources(1, &m_sourceID));
|
||||
|
||||
// Prime the buffer queue
|
||||
m_nextBufferIndex = 0;
|
||||
@@ -167,9 +167,9 @@ void KRAudioSource::prime()
|
||||
}
|
||||
|
||||
//alSourcei(_sourceID, AL_BUFFER, firstBuffer.bufferID);
|
||||
alSourcef(m_sourceID, AL_PITCH, m_pitch);
|
||||
alSourcei(m_sourceID, AL_LOOPING, m_looping && m_audioFile->getBufferCount() == 1);
|
||||
alSourcef(m_sourceID, AL_GAIN, m_gain);
|
||||
ALDEBUG(alSourcef(m_sourceID, AL_PITCH, m_pitch));
|
||||
ALDEBUG(alSourcei(m_sourceID, AL_LOOPING, m_looping && m_audioFile->getBufferCount() == 1));
|
||||
ALDEBUG(alSourcef(m_sourceID, AL_GAIN, m_gain));
|
||||
|
||||
m_isPrimed = true;
|
||||
}
|
||||
@@ -182,7 +182,7 @@ void KRAudioSource::queueBuffer()
|
||||
m_audioBuffers.push(buffer);
|
||||
ALuint buffer_ids[1];
|
||||
buffer_ids[0] = buffer->getBufferID();
|
||||
alSourceQueueBuffers(m_sourceID, 1, buffer_ids);
|
||||
ALDEBUG(alSourceQueueBuffers(m_sourceID, 1, buffer_ids));
|
||||
|
||||
m_nextBufferIndex = (m_nextBufferIndex + 1) % m_audioFile->getBufferCount();
|
||||
}
|
||||
@@ -261,7 +261,7 @@ void KRAudioSource::setReferenceDistance(float reference_distance)
|
||||
m_referenceDistance = reference_distance;
|
||||
if(m_isPrimed && m_is3d) {
|
||||
getContext().getAudioManager()->makeCurrentContext();
|
||||
alSourcef(m_sourceID, AL_REFERENCE_DISTANCE, m_referenceDistance);
|
||||
ALDEBUG(alSourcef(m_sourceID, AL_REFERENCE_DISTANCE, m_referenceDistance));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ void KRAudioSource::setReverb(float reverb)
|
||||
m_reverb = reverb;
|
||||
if(m_isPrimed && m_is3d) {
|
||||
getContext().getAudioManager()->makeCurrentContext();
|
||||
alcASASetSourceProc(ALC_ASA_REVERB_SEND_LEVEL, m_sourceID, &m_reverb, sizeof(m_reverb));
|
||||
ALDEBUG(alcASASetSourceProc(ALC_ASA_REVERB_SEND_LEVEL, m_sourceID, &m_reverb, sizeof(m_reverb)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ void KRAudioSource::setRolloffFactor(float rolloff_factor)
|
||||
m_rolloffFactor = rolloff_factor;
|
||||
if(m_isPrimed && m_is3d) {
|
||||
getContext().getAudioManager()->makeCurrentContext();
|
||||
alSourcef(m_sourceID, AL_ROLLOFF_FACTOR, m_rolloffFactor);
|
||||
ALDEBUG(alSourcef(m_sourceID, AL_ROLLOFF_FACTOR, m_rolloffFactor));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,10 +346,10 @@ void KRAudioSource::physicsUpdate(float deltaTime)
|
||||
getContext().getAudioManager()->makeCurrentContext();
|
||||
updatePosition();
|
||||
ALint processed_count = 0;
|
||||
alGetSourcei(m_sourceID, AL_BUFFERS_PROCESSED, &processed_count);
|
||||
ALDEBUG(alGetSourcei(m_sourceID, AL_BUFFERS_PROCESSED, &processed_count));
|
||||
while(processed_count-- > 0) {
|
||||
ALuint finished_buffer = 0;
|
||||
alSourceUnqueueBuffers(m_sourceID, 1, &finished_buffer);
|
||||
ALDEBUG(alSourceUnqueueBuffers(m_sourceID, 1, &finished_buffer));
|
||||
delete m_audioBuffers.front();
|
||||
m_audioBuffers.pop();
|
||||
queueBuffer();
|
||||
@@ -357,28 +357,28 @@ void KRAudioSource::physicsUpdate(float deltaTime)
|
||||
|
||||
ALint val;
|
||||
// Make sure the source is still playing, and restart it if needed.
|
||||
alGetSourcei(m_sourceID, AL_SOURCE_STATE, &val);
|
||||
if(val != AL_PLAYING) alSourcePlay(m_sourceID);
|
||||
ALDEBUG(alGetSourcei(m_sourceID, AL_SOURCE_STATE, &val));
|
||||
ALDEBUG(if(val != AL_PLAYING) alSourcePlay(m_sourceID));
|
||||
}
|
||||
}
|
||||
|
||||
void KRAudioSource::play()
|
||||
{
|
||||
getContext().getAudioManager()->makeCurrentContext();
|
||||
prime();
|
||||
updatePosition();
|
||||
getContext().getAudioManager()->makeCurrentContext();
|
||||
|
||||
if(m_is3d) {
|
||||
alSource3f(m_sourceID, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
alSourcef(m_sourceID, AL_REFERENCE_DISTANCE, m_referenceDistance);
|
||||
alSourcef(m_sourceID, AL_ROLLOFF_FACTOR, m_rolloffFactor);
|
||||
alSourcef(m_sourceID, AL_REFERENCE_DISTANCE, m_referenceDistance);
|
||||
alcASASetSourceProc(ALC_ASA_REVERB_SEND_LEVEL, m_sourceID, &m_reverb, sizeof(m_reverb));
|
||||
ALDEBUG(alSource3f(m_sourceID, AL_VELOCITY, 0.0f, 0.0f, 0.0f));
|
||||
ALDEBUG(alSourcef(m_sourceID, AL_REFERENCE_DISTANCE, m_referenceDistance));
|
||||
ALDEBUG(alSourcef(m_sourceID, AL_ROLLOFF_FACTOR, m_rolloffFactor));
|
||||
ALDEBUG(alcASASetSourceProc(ALC_ASA_REVERB_SEND_LEVEL, m_sourceID, &m_reverb, sizeof(m_reverb)));
|
||||
ALDEBUG(alSourcei(m_sourceID, AL_SOURCE_RELATIVE, AL_FALSE));
|
||||
} else {
|
||||
alSourcei(m_sourceID, AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
alSource3f(m_sourceID, AL_POSITION, 0.0, 0.0, 0.0);
|
||||
ALDEBUG(alSourcei(m_sourceID, AL_SOURCE_RELATIVE, AL_TRUE));
|
||||
ALDEBUG(alSource3f(m_sourceID, AL_POSITION, 0.0, 0.0, 0.0));
|
||||
}
|
||||
alSourcePlay(m_sourceID);
|
||||
ALDEBUG(alSourcePlay(m_sourceID));
|
||||
m_playing = true;
|
||||
}
|
||||
|
||||
@@ -410,11 +410,11 @@ void KRAudioSource::updatePosition()
|
||||
ALfloat obstruction = 0.0f; // type ALfloat -100.0 db (most obstruction) - 0.0 db (no obstruction, 0.0 default)
|
||||
|
||||
KRVector3 worldPosition = getWorldTranslation();
|
||||
alSource3f(m_sourceID, AL_POSITION, worldPosition.x, worldPosition.y, worldPosition.z);
|
||||
ALDEBUG(alSource3f(m_sourceID, AL_POSITION, worldPosition.x, worldPosition.y, worldPosition.z));
|
||||
|
||||
alcASASetSourceProc(ALC_ASA_OCCLUSION, m_sourceID, &occlusion, sizeof(occlusion));
|
||||
alcASASetSourceProc(ALC_ASA_OBSTRUCTION, m_sourceID, &obstruction, sizeof(obstruction));
|
||||
alcASASetSourceProc(ALC_ASA_REVERB_SEND_LEVEL, m_sourceID, &m_reverb, sizeof(m_reverb));
|
||||
ALDEBUG(alcASASetSourceProc(ALC_ASA_OCCLUSION, m_sourceID, &occlusion, sizeof(occlusion)));
|
||||
ALDEBUG(alcASASetSourceProc(ALC_ASA_OBSTRUCTION, m_sourceID, &obstruction, sizeof(obstruction)));
|
||||
ALDEBUG(alcASASetSourceProc(ALC_ASA_REVERB_SEND_LEVEL, m_sourceID, &m_reverb, sizeof(m_reverb)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -401,6 +401,11 @@ void KRCamera::createBuffers() {
|
||||
GLDEBUG(glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &renderBufferWidth));
|
||||
GLDEBUG(glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &renderBufferHeight));
|
||||
|
||||
if(renderBufferWidth == 0 || renderBufferHeight == 0) {
|
||||
renderBufferWidth = 1024; // FINDME - HACK for OSX
|
||||
renderBufferHeight = 768;
|
||||
}
|
||||
|
||||
if(renderBufferWidth != backingWidth || renderBufferHeight != backingHeight) {
|
||||
backingWidth = renderBufferWidth;
|
||||
backingHeight = renderBufferHeight;
|
||||
|
||||
@@ -103,6 +103,17 @@ fprintf(stderr, "Error at line number %d, in file %s. glGetError() returned %i f
|
||||
} \
|
||||
}
|
||||
|
||||
#define ALDEBUG(x) \
|
||||
x; \
|
||||
{ \
|
||||
GLenum e; \
|
||||
while( (e=alGetError()) != AL_NO_ERROR) \
|
||||
{ \
|
||||
fprintf(stderr, "Error at line number %d, in file %s. alGetError() returned %i for call %s\n",__LINE__, __FILE__, e, #x ); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define KRMIN(x,y) ((x) < (y) ? (x) : (y))
|
||||
#define KRMAX(x,y) ((x) > (y) ? (x) : (y))
|
||||
|
||||
|
||||
@@ -63,8 +63,13 @@ using namespace std;
|
||||
|
||||
- (id)init
|
||||
{
|
||||
#if TARGET_OS_IPHONE
|
||||
BOOL isIpad = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad;
|
||||
BOOL isRetina = [[UIScreen mainScreen] scale] >= 2.0;
|
||||
#else
|
||||
BOOL isIpad = false;
|
||||
BOOL isRetina = false;
|
||||
#endif
|
||||
|
||||
if(isIpad && isRetina) {
|
||||
KRContext::KRENGINE_MAX_VBO_HANDLES = 10000;
|
||||
|
||||
@@ -31,7 +31,6 @@ KRNode::KRNode(KRScene &scene, std::string name) : KRContextObject(scene.getCont
|
||||
m_localTranslation = KRVector3::Zero();
|
||||
m_parentNode = NULL;
|
||||
m_pScene = &scene;
|
||||
getScene().notify_sceneGraphCreate(this);
|
||||
m_modelMatrixValid = false;
|
||||
m_inverseModelMatrixValid = false;
|
||||
m_bindPoseMatrixValid = false;
|
||||
@@ -52,6 +51,7 @@ void KRNode::addChild(KRNode *child) {
|
||||
assert(child->m_parentNode == NULL);
|
||||
child->m_parentNode = this;
|
||||
m_childNodes.push_back(child);
|
||||
getScene().notify_sceneGraphCreate(child);
|
||||
}
|
||||
|
||||
tinyxml2::XMLElement *KRNode::saveXML(tinyxml2::XMLNode *parent) {
|
||||
|
||||
@@ -23,6 +23,7 @@ class KRTextureManager;
|
||||
class KRContext;
|
||||
class KRScene;
|
||||
class KRAABB;
|
||||
class KRNode;
|
||||
|
||||
class KRNode : public KRContextObject
|
||||
{
|
||||
|
||||
@@ -763,6 +763,22 @@ void LoadMaterial(KRContext &context, std::vector<KRResource *> &resources, FbxS
|
||||
// ----====---- Output Material File ----====----
|
||||
KRMaterial *new_material = new KRMaterial(context, pMaterial->GetName());
|
||||
|
||||
std::string name = pMaterial->GetName();
|
||||
if(boost:starts_with(name, "ab_reflect_")) {
|
||||
new_material->setAlphaMode(KRMaterial::KRMATERIAL_ALPHA_MODE_BLENDONESIDE);
|
||||
int underscore_pos = name.find('_', 11);
|
||||
new_material->setReflectionCube(name.substr(11, underscore_pos - 11));
|
||||
} else if(boost::starts_with(name, "reflect_")) {
|
||||
int underscore_pos = name.find('_', 8);
|
||||
new_material->setReflectionCube(name.substr(8, underscore_pos - 8));
|
||||
} else if(boost::starts_with(name, "at_")) {
|
||||
new_material->setAlphaMode(KRMaterial::KRMATERIAL_ALPHA_MODE_TEST);
|
||||
} else if(boost::starts_with(name, "ab_")) {
|
||||
new_material->setAlphaMode(KRMaterial::KRMATERIAL_ALPHA_MODE_BLENDONESIDE);
|
||||
} else if(boost::starts_with(name, "ab2_")) {
|
||||
new_material->setAlphaMode(KRMAterial::KRMATERIAL_ALPHA_MODE_BLENDTWOSIDE);
|
||||
}
|
||||
|
||||
FbxPropertyT<FbxDouble3> lKFbxDouble3;
|
||||
FbxPropertyT<FbxDouble> lKFbxDouble1;
|
||||
|
||||
|
||||
@@ -49,8 +49,9 @@ const long KRENGINE_OCCLUSION_TEST_EXPIRY = 60;
|
||||
KRScene::KRScene(KRContext &context, std::string name) : KRResource(context, name) {
|
||||
m_pFirstLight = NULL;
|
||||
m_pRootNode = new KRNode(*this, "scene_root");
|
||||
notify_sceneGraphCreate(m_pRootNode);
|
||||
|
||||
m_skyBoxName = "";
|
||||
m_skyBoxName = name + "_skybox";
|
||||
}
|
||||
|
||||
KRScene::~KRScene() {
|
||||
@@ -68,6 +69,7 @@ void KRScene::renderFrame(float deltaTime) {
|
||||
}
|
||||
camera->renderFrame(deltaTime);
|
||||
getContext().endFrame(deltaTime);
|
||||
physicsUpdate(deltaTime);
|
||||
}
|
||||
|
||||
void KRScene::render(KRCamera *pCamera, std::map<KRAABB, int> &visibleBounds, const KRViewport &viewport, KRNode::RenderPass renderPass, bool new_frame) {
|
||||
@@ -383,7 +385,7 @@ void KRScene::notify_sceneGraphCreate(KRNode *pNode)
|
||||
{
|
||||
m_nodeTree.add(pNode);
|
||||
if(pNode->hasPhysics()) {
|
||||
m_physicsNodes.erase(pNode);
|
||||
m_physicsNodes.insert(pNode);
|
||||
}
|
||||
// m_newNodes.insert(pNode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user