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:
File diff suppressed because it is too large
Load Diff
@@ -44,6 +44,7 @@ KRAudioManager::KRAudioManager(KRContext &context) : KRContextObject(context)
|
||||
ALDEBUG(alcMakeContextCurrent(m_alContext));
|
||||
|
||||
// ----- Configure listener -----
|
||||
ALDEBUG(alSpeedOfSound(1116.43701f)); // 1116.43701 feet per second
|
||||
ALDEBUG(alDistanceModel(AL_EXPONENT_DISTANCE));
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
@@ -56,7 +57,7 @@ KRAudioManager::KRAudioManager(KRContext &context) : KRContextObject(context)
|
||||
ALfloat global_reverb_level = -5.0f;
|
||||
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)));
|
||||
|
||||
|
||||
@@ -108,6 +109,7 @@ void KRAudioManager::setViewMatrix(const KRMat4 &viewMatrix)
|
||||
vectorForward.normalize();
|
||||
|
||||
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));
|
||||
ALfloat orientation[] = {vectorForward.x, vectorForward.y, vectorForward.z, vectorUp.x, vectorUp.y, vectorUp.z};
|
||||
ALDEBUG(alListenerfv(AL_ORIENTATION, orientation));
|
||||
@@ -373,7 +373,7 @@ void KRAudioSource::play()
|
||||
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));
|
||||
// ALDEBUG(alSourcei(m_sourceID, AL_SOURCE_RELATIVE, AL_FALSE));
|
||||
} else {
|
||||
ALDEBUG(alSourcei(m_sourceID, AL_SOURCE_RELATIVE, AL_TRUE));
|
||||
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)
|
||||
|
||||
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(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_OBSTRUCTION, m_sourceID, &obstruction, sizeof(obstruction)));
|
||||
ALDEBUG(alcASASetSourceProc(ALC_ASA_REVERB_SEND_LEVEL, m_sourceID, &m_reverb, sizeof(m_reverb)));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,13 +398,13 @@ void KRCamera::renderFrame(float deltaTime)
|
||||
void KRCamera::createBuffers() {
|
||||
|
||||
GLint renderBufferWidth = 0, renderBufferHeight = 0;
|
||||
#if TARGET_OS_IPHONE
|
||||
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;
|
||||
}
|
||||
#else
|
||||
renderBufferWidth = 576; // FINDME - HACK for OSX
|
||||
renderBufferHeight = 374;
|
||||
#endif
|
||||
|
||||
if(renderBufferWidth != backingWidth || renderBufferHeight != backingHeight) {
|
||||
backingWidth = renderBufferWidth;
|
||||
@@ -167,12 +167,25 @@ using namespace std;
|
||||
|
||||
- (BOOL)loadShaders
|
||||
{
|
||||
NSFileManager* fileManager = [NSFileManager defaultManager];
|
||||
NSString *bundle_directory = [[NSBundle mainBundle] bundlePath];
|
||||
for (NSString* fileName in [fileManager contentsOfDirectoryAtPath: bundle_directory error:nil]) {
|
||||
if([fileName hasSuffix: @".vsh"] || [fileName hasSuffix: @".fsh"] || [fileName isEqualToString:@"font.pvr"]) {
|
||||
NSString* path = [NSString stringWithFormat:@"%@/%@", bundle_directory, fileName];
|
||||
_context->loadResource([path UTF8String]);
|
||||
#if TARGET_OS_IPHONE
|
||||
NSString *bundleName = @"kraken_standard_assets_ios.bundle";
|
||||
#else
|
||||
NSString *bundleName = @"kraken_standard_assets_osx.bundle";
|
||||
#endif
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,9 +178,19 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
|
||||
stream << "\n";
|
||||
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;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user