Organized project to be more portable and require fewer steps to integrate into application projects in Xcode.

Moved standard assets into bundles
This commit is contained in:
2013-01-31 02:16:47 -08:00
parent 291461d912
commit ff63061722
199 changed files with 937 additions and 457 deletions

View File

@@ -44,6 +44,7 @@ KRAudioManager::KRAudioManager(KRContext &context) : KRContextObject(context)
ALDEBUG(alcMakeContextCurrent(m_alContext)); ALDEBUG(alcMakeContextCurrent(m_alContext));
// ----- Configure listener ----- // ----- Configure listener -----
ALDEBUG(alSpeedOfSound(1116.43701f)); // 1116.43701 feet per second
ALDEBUG(alDistanceModel(AL_EXPONENT_DISTANCE)); ALDEBUG(alDistanceModel(AL_EXPONENT_DISTANCE));
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
@@ -56,7 +57,7 @@ KRAudioManager::KRAudioManager(KRContext &context) : KRContextObject(context)
ALfloat global_reverb_level = -5.0f; ALfloat global_reverb_level = -5.0f;
ALDEBUG(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; setting = ALC_ASA_REVERB_ROOM_TYPE_SmallRoom; // ALC_ASA_REVERB_ROOM_TYPE_MediumHall2;
ALDEBUG(alcASASetListenerProc(ALC_ASA_REVERB_ROOM_TYPE, &setting, sizeof(setting))); ALDEBUG(alcASASetListenerProc(ALC_ASA_REVERB_ROOM_TYPE, &setting, sizeof(setting)));
@@ -108,6 +109,7 @@ void KRAudioManager::setViewMatrix(const KRMat4 &viewMatrix)
vectorForward.normalize(); vectorForward.normalize();
makeCurrentContext(); makeCurrentContext();
player_position = KRVector3(1.0, 0.0, 0.0); // FINDME - HACK - TEST CODE
ALDEBUG(alListener3f(AL_POSITION, player_position.x, player_position.y, player_position.z)); 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}; ALfloat orientation[] = {vectorForward.x, vectorForward.y, vectorForward.z, vectorUp.x, vectorUp.y, vectorUp.z};
ALDEBUG(alListenerfv(AL_ORIENTATION, orientation)); ALDEBUG(alListenerfv(AL_ORIENTATION, orientation));

View File

@@ -373,7 +373,7 @@ void KRAudioSource::play()
ALDEBUG(alSourcef(m_sourceID, AL_REFERENCE_DISTANCE, m_referenceDistance)); ALDEBUG(alSourcef(m_sourceID, AL_REFERENCE_DISTANCE, m_referenceDistance));
ALDEBUG(alSourcef(m_sourceID, AL_ROLLOFF_FACTOR, m_rolloffFactor)); ALDEBUG(alSourcef(m_sourceID, AL_ROLLOFF_FACTOR, m_rolloffFactor));
ALDEBUG(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)));
ALDEBUG(alSourcei(m_sourceID, AL_SOURCE_RELATIVE, AL_FALSE)); // ALDEBUG(alSourcei(m_sourceID, AL_SOURCE_RELATIVE, AL_FALSE));
} else { } else {
ALDEBUG(alSourcei(m_sourceID, AL_SOURCE_RELATIVE, AL_TRUE)); ALDEBUG(alSourcei(m_sourceID, AL_SOURCE_RELATIVE, AL_TRUE));
ALDEBUG(alSource3f(m_sourceID, AL_POSITION, 0.0, 0.0, 0.0)); ALDEBUG(alSource3f(m_sourceID, AL_POSITION, 0.0, 0.0, 0.0));
@@ -410,11 +410,17 @@ void KRAudioSource::updatePosition()
ALfloat obstruction = 0.0f; // type ALfloat -100.0 db (most obstruction) - 0.0 db (no obstruction, 0.0 default) ALfloat obstruction = 0.0f; // type ALfloat -100.0 db (most obstruction) - 0.0 db (no obstruction, 0.0 default)
KRVector3 worldPosition = getWorldTranslation(); KRVector3 worldPosition = getWorldTranslation();
worldPosition = KRVector3(0.0, 0.0, 0.0); // FINDME - HACK - TEST CODE
ALDEBUG(alSource3f(m_sourceID, AL_POSITION, worldPosition.x, worldPosition.y, worldPosition.z)); ALDEBUG(alSource3f(m_sourceID, AL_POSITION, worldPosition.x, worldPosition.y, worldPosition.z));
ALDEBUG(alSourcef(m_sourceID, AL_GAIN, m_gain));
ALDEBUG(alSourcef(m_sourceID, AL_MIN_GAIN, 0.0));
ALDEBUG(alSourcef(m_sourceID, AL_MAX_GAIN, 1.0));
ALDEBUG(alcASASetSourceProc(ALC_ASA_OCCLUSION, m_sourceID, &occlusion, sizeof(occlusion))); ALDEBUG(alcASASetSourceProc(ALC_ASA_OCCLUSION, m_sourceID, &occlusion, sizeof(occlusion)));
ALDEBUG(alcASASetSourceProc(ALC_ASA_OBSTRUCTION, m_sourceID, &obstruction, sizeof(obstruction))); ALDEBUG(alcASASetSourceProc(ALC_ASA_OBSTRUCTION, m_sourceID, &obstruction, sizeof(obstruction)));
ALDEBUG(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)));
} }
} }

View File

@@ -398,13 +398,13 @@ void KRCamera::renderFrame(float deltaTime)
void KRCamera::createBuffers() { void KRCamera::createBuffers() {
GLint renderBufferWidth = 0, renderBufferHeight = 0; GLint renderBufferWidth = 0, renderBufferHeight = 0;
#if TARGET_OS_IPHONE
GLDEBUG(glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &renderBufferWidth)); GLDEBUG(glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &renderBufferWidth));
GLDEBUG(glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &renderBufferHeight)); GLDEBUG(glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &renderBufferHeight));
#else
if(renderBufferWidth == 0 || renderBufferHeight == 0) { renderBufferWidth = 576; // FINDME - HACK for OSX
renderBufferWidth = 1024; // FINDME - HACK for OSX renderBufferHeight = 374;
renderBufferHeight = 768; #endif
}
if(renderBufferWidth != backingWidth || renderBufferHeight != backingHeight) { if(renderBufferWidth != backingWidth || renderBufferHeight != backingHeight) {
backingWidth = renderBufferWidth; backingWidth = renderBufferWidth;

View File

@@ -167,12 +167,25 @@ using namespace std;
- (BOOL)loadShaders - (BOOL)loadShaders
{ {
NSFileManager* fileManager = [NSFileManager defaultManager]; #if TARGET_OS_IPHONE
NSString *bundle_directory = [[NSBundle mainBundle] bundlePath]; NSString *bundleName = @"kraken_standard_assets_ios.bundle";
for (NSString* fileName in [fileManager contentsOfDirectoryAtPath: bundle_directory error:nil]) { #else
if([fileName hasSuffix: @".vsh"] || [fileName hasSuffix: @".fsh"] || [fileName isEqualToString:@"font.pvr"]) { NSString *bundleName = @"kraken_standard_assets_osx.bundle";
NSString* path = [NSString stringWithFormat:@"%@/%@", bundle_directory, fileName]; #endif
_context->loadResource([path UTF8String]);
NSString *bundlePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:bundleName];
NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
if(bundle == nil) {
NSLog(@"ERROR - Standard asset bundle could not be found.");
} else {
NSEnumerator *bundleEnumerator = [[bundle pathsForResourcesOfType: nil inDirectory: nil] objectEnumerator];
NSString * p = nil;
while (p = [bundleEnumerator nextObject]) {
NSString *file_name = [p lastPathComponent];
if([file_name hasSuffix: @".vsh"] || [file_name hasSuffix: @".fsh"] || [file_name hasPrefix:@"font."]) {
NSLog(@" %@\n", file_name);
[self loadResource:p];
}
} }
} }

View File

@@ -178,9 +178,19 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
stream << "\n"; stream << "\n";
std::string options = stream.str(); std::string options = stream.str();
pShader = new KRShader(getContext(), szKey, options, m_vertShaderSource[platform_shader_name], m_fragShaderSource[platform_shader_name]); std::string vertShaderSource = m_vertShaderSource[platform_shader_name];
std::string fragShaderSource = m_fragShaderSource[platform_shader_name];
m_shaders[szKey] = pShader; if(vertShaderSource.length() == 0) {
fprintf(stderr, "ERROR: Vertex Shader Missing: %s\n", platform_shader_name.c_str());
}
if(fragShaderSource.length() == 0) {
fprintf(stderr, "ERROR: Fragment Shader Missing: %s\n", platform_shader_name.c_str());
}
pShader = new KRShader(getContext(), szKey, options, vertShaderSource, fragShaderSource);
m_shaders[szKey] = pShader;\
} }
return pShader; return pShader;
} }

Some files were not shown because too many files have changed in this diff Show More