1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-13 16:44:50 +02:00
This commit is contained in:
XProger
2017-03-24 04:01:52 +03:00
4 changed files with 30 additions and 18 deletions

View File

@@ -49,9 +49,21 @@
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#include <AGL/agl.h>
#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 <emscripten.h>
@@ -381,7 +393,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");
@@ -460,7 +472,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++;

View File

@@ -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 = "<group>"; };
99BFB68E1DCA7F1700E2E997 /* format.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = format.h; path = ../../format.h; sourceTree = "<group>"; };
99BFB68F1DCA7F1700E2E997 /* level.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = level.h; path = ../../level.h; sourceTree = "<group>"; };
@@ -38,7 +39,6 @@
99BFB69D1DCA7F1700E2E997 /* texture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = texture.h; path = ../../texture.h; sourceTree = "<group>"; };
99BFB69E1DCA7F1700E2E997 /* libs */ = {isa = PBXFileReference; lastKnownFileType = folder; name = libs; path = ../../libs; sourceTree = "<group>"; };
99BFB6A11DCA7F5300E2E997 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
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 = "<group>"; };
99BFB6AA1DCA87C500E2E997 /* minimp3.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = minimp3.cpp; path = ../../libs/minimp3/minimp3.cpp; sourceTree = "<group>"; };
@@ -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;
};

View File

@@ -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);

View File

@@ -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
#endif