From 0586ddf8db8c487680de18886b9fa16599ecc975 Mon Sep 17 00:00:00 2001 From: XProger Date: Sun, 19 Mar 2017 21:25:09 +0300 Subject: [PATCH] #15 mac build fix --- src/core.h | 16 ++++++++++++-- .../osx/OpenLara.xcodeproj/project.pbxproj | 8 +++---- src/platform/osx/main.cpp | 21 ++++++++++--------- src/shader.h | 3 +-- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/core.h b/src/core.h index 00d0506..0f93e2e 100644 --- a/src/core.h +++ b/src/core.h @@ -49,9 +49,21 @@ #include #include #include + + #define GL_RGBA32F GL_RGBA + #define GL_RGBA16F GL_RGBA + + #define GL_TEXTURE_COMPARE_MODE 0x884C + #define GL_TEXTURE_COMPARE_FUNC 0x884D + #define GL_COMPARE_REF_TO_TEXTURE 0x884E + #define glGenVertexArrays glGenVertexArraysAPPLE #define glDeleteVertexArrays glDeleteVertexArraysAPPLE #define glBindVertexArray glBindVertexArrayAPPLE + + #define GL_PROGRAM_BINARY_LENGTH 0 + #define glGetProgramBinary(...) 0 + #define glProgramBinary(...) 0 #elif __EMSCRIPTEN__ #define MOBILE #include @@ -339,7 +351,7 @@ namespace Core { #endif char *ext = (char*)glGetString(GL_EXTENSIONS); -// LOG("%s\n", ext); + //LOG("%s\n", ext); support.shaderBinary = extSupport(ext, "_program_binary"); support.VAO = extSupport(ext, "_vertex_array_object"); @@ -414,7 +426,7 @@ namespace Core { item.height = height; glBindRenderbuffer(GL_RENDERBUFFER, item.ID); - glRenderbufferStorage(GL_RENDERBUFFER, depth ? GL_RGB565 : GL_DEPTH_COMPONENT16, width, height); + glRenderbufferStorage(GL_RENDERBUFFER, depth ? GL_RGB : GL_DEPTH_COMPONENT16, width, height); glBindRenderbuffer(GL_RENDERBUFFER, 0); return cache.count++; diff --git a/src/platform/osx/OpenLara.xcodeproj/project.pbxproj b/src/platform/osx/OpenLara.xcodeproj/project.pbxproj index c9f67f2..1fbc192 100644 --- a/src/platform/osx/OpenLara.xcodeproj/project.pbxproj +++ b/src/platform/osx/OpenLara.xcodeproj/project.pbxproj @@ -7,8 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 9971B72F1E7C239900F25790 /* LEVEL2.PSX in Resources */ = {isa = PBXBuildFile; fileRef = 9971B72E1E7C239900F25790 /* LEVEL2.PSX */; }; 99BFB6A21DCA7F5300E2E997 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 99BFB6A11DCA7F5300E2E997 /* main.cpp */; }; - 99BFB6A51DCA872D00E2E997 /* LEVEL2_DEMO.PHD in Resources */ = {isa = PBXBuildFile; fileRef = 99BFB6A31DCA872D00E2E997 /* LEVEL2_DEMO.PHD */; }; 99BFB6A61DCA872D00E2E997 /* 05.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 99BFB6A41DCA872D00E2E997 /* 05.ogg */; }; 99BFB6A91DCA87BF00E2E997 /* stb_vorbis.c in Sources */ = {isa = PBXBuildFile; fileRef = 99BFB6A81DCA87BF00E2E997 /* stb_vorbis.c */; }; 99BFB6AB1DCA87C500E2E997 /* minimp3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 99BFB6AA1DCA87C500E2E997 /* minimp3.cpp */; }; @@ -19,6 +19,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 9971B72E1E7C239900F25790 /* LEVEL2.PSX */ = {isa = PBXFileReference; lastKnownFileType = file; name = LEVEL2.PSX; path = ../../../bin/LEVEL2.PSX; sourceTree = SOURCE_ROOT; }; 99BFB68D1DCA7F1700E2E997 /* lara.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lara.h; path = ../../lara.h; sourceTree = ""; }; 99BFB68E1DCA7F1700E2E997 /* format.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = format.h; path = ../../format.h; sourceTree = ""; }; 99BFB68F1DCA7F1700E2E997 /* level.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = level.h; path = ../../level.h; sourceTree = ""; }; @@ -38,7 +39,6 @@ 99BFB69D1DCA7F1700E2E997 /* texture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = texture.h; path = ../../texture.h; sourceTree = ""; }; 99BFB69E1DCA7F1700E2E997 /* libs */ = {isa = PBXFileReference; lastKnownFileType = folder; name = libs; path = ../../libs; sourceTree = ""; }; 99BFB6A11DCA7F5300E2E997 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; - 99BFB6A31DCA872D00E2E997 /* LEVEL2_DEMO.PHD */ = {isa = PBXFileReference; lastKnownFileType = file; name = LEVEL2_DEMO.PHD; path = ../../../bin/LEVEL2_DEMO.PHD; sourceTree = SOURCE_ROOT; }; 99BFB6A41DCA872D00E2E997 /* 05.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; name = 05.ogg; path = ../../../bin/05.ogg; sourceTree = SOURCE_ROOT; }; 99BFB6A81DCA87BF00E2E997 /* stb_vorbis.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = stb_vorbis.c; path = ../../libs/stb_vorbis/stb_vorbis.c; sourceTree = ""; }; 99BFB6AA1DCA87C500E2E997 /* minimp3.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = minimp3.cpp; path = ../../libs/minimp3/minimp3.cpp; sourceTree = ""; }; @@ -121,7 +121,7 @@ 99C4C0A31796AACF0032DE85 /* Supporting Files */ = { isa = PBXGroup; children = ( - 99BFB6A31DCA872D00E2E997 /* LEVEL2_DEMO.PHD */, + 9971B72E1E7C239900F25790 /* LEVEL2.PSX */, 99BFB6A41DCA872D00E2E997 /* 05.ogg */, 99C4C0A41796AACF0032DE85 /* OpenLara-Info.plist */, ); @@ -181,7 +181,7 @@ buildActionMask = 2147483647; files = ( 99BFB6A61DCA872D00E2E997 /* 05.ogg in Resources */, - 99BFB6A51DCA872D00E2E997 /* LEVEL2_DEMO.PHD in Resources */, + 9971B72F1E7C239900F25790 /* LEVEL2.PSX in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/platform/osx/main.cpp b/src/platform/osx/main.cpp index 08b5eb8..535bb4d 100644 --- a/src/platform/osx/main.cpp +++ b/src/platform/osx/main.cpp @@ -144,9 +144,19 @@ int getTime() { return int(t / 1000); } -char *contentPath; +char Stream::contentDir[255]; +char Stream::cacheDir[255]; int main() { + Stream::contentDir[0] = Stream::cacheDir[0] = 0; + + // get path to game content + CFBundleRef bundle = CFBundleGetMainBundle(); + CFURLRef bundleURL = CFBundleCopyBundleURL(bundle); + CFStringRef pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle); + CFStringGetFileSystemRepresentation(pathStr, Stream::contentDir, 230); + strcat(Stream::contentDir, "/Contents/Resources/"); + // init window Rect rect = {0, 0, 720, 1280}; CreateNewWindow(kDocumentWindowClass, kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | kWindowFullZoomAttribute | kWindowResizableAttribute | kWindowStandardHandlerAttribute, &rect, &window); @@ -168,14 +178,6 @@ int main() { aglSetDrawable(context, GetWindowPort(window)); aglSetCurrentContext(context); - // get path to game content - CFBundleRef bundle = CFBundleGetMainBundle(); - CFURLRef bundleURL = CFBundleCopyBundleURL(bundle); - CFStringRef pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle); - contentPath = new char[1024]; - CFStringGetFileSystemRepresentation(pathStr, contentPath, 1024); - strcat(contentPath, "/Contents/Resources/"); - soundInit(); Game::init(); @@ -211,7 +213,6 @@ int main() { } Game::free(); - delete[] contentPath; // TODO: sndFree aglSetCurrentContext(NULL); diff --git a/src/shader.h b/src/shader.h index 60515d1..57ee8e7 100644 --- a/src/shader.h +++ b/src/shader.h @@ -66,7 +66,6 @@ struct Shader { Shader(const char *source, const char *defines = "") { char fileName[255]; - //LOG(hello[0]); // generate shader file path if (Core::support.shaderBinary) { uint32 hash = fnv32(defines, strlen(defines), fnv32(source, strlen(source))); @@ -228,4 +227,4 @@ struct Shader { } }; -#endif \ No newline at end of file +#endif