mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-15 09:34:18 +02:00
#15 fix RPI build
This commit is contained in:
@@ -75,6 +75,8 @@
|
|||||||
#define GL_PROGRAM_BINARY_LENGTH GL_PROGRAM_BINARY_LENGTH_OES
|
#define GL_PROGRAM_BINARY_LENGTH GL_PROGRAM_BINARY_LENGTH_OES
|
||||||
#define glGetProgramBinary(...)
|
#define glGetProgramBinary(...)
|
||||||
#define glProgramBinary(...)
|
#define glProgramBinary(...)
|
||||||
|
|
||||||
|
extern EGLDisplay display;
|
||||||
#elif __linux__
|
#elif __linux__
|
||||||
#define LINUX 1
|
#define LINUX 1
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
@@ -1095,6 +1097,7 @@ namespace Core {
|
|||||||
|
|
||||||
#ifdef __RPI__
|
#ifdef __RPI__
|
||||||
settings.detail.setShadows(Core::Settings::LOW);
|
settings.detail.setShadows(Core::Settings::LOW);
|
||||||
|
settings.detail.setLighting(Core::Settings::MEDIUM);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FFP
|
#ifdef FFP
|
||||||
@@ -1464,6 +1467,8 @@ namespace Core {
|
|||||||
if (wglSwapIntervalEXT) wglSwapIntervalEXT(1);
|
if (wglSwapIntervalEXT) wglSwapIntervalEXT(1);
|
||||||
#elif LINUX
|
#elif LINUX
|
||||||
if (glXSwapIntervalSGI) glXSwapIntervalSGI(1);
|
if (glXSwapIntervalSGI) glXSwapIntervalSGI(1);
|
||||||
|
#elif __RPI__
|
||||||
|
eglSwapInterval(display, 1);
|
||||||
#elif _PSP
|
#elif _PSP
|
||||||
sceDisplayWaitVblankStart();
|
sceDisplayWaitVblankStart();
|
||||||
#endif
|
#endif
|
||||||
@@ -1472,6 +1477,8 @@ namespace Core {
|
|||||||
if (wglSwapIntervalEXT) wglSwapIntervalEXT(0);
|
if (wglSwapIntervalEXT) wglSwapIntervalEXT(0);
|
||||||
#elif LINUX
|
#elif LINUX
|
||||||
if (glXSwapIntervalSGI) glXSwapIntervalSGI(0);
|
if (glXSwapIntervalSGI) glXSwapIntervalSGI(0);
|
||||||
|
#elif __RPI__
|
||||||
|
eglSwapInterval(display, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -113,7 +113,7 @@ static const OptionItem optDetail[] = {
|
|||||||
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_LIGHTING, SETTINGS( detail.lighting ), STR_QUALITY_LOW, 0, 2 ),
|
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_LIGHTING, SETTINGS( detail.lighting ), STR_QUALITY_LOW, 0, 2 ),
|
||||||
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_SHADOWS, SETTINGS( detail.shadows ), STR_QUALITY_LOW, 0, 2 ),
|
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_SHADOWS, SETTINGS( detail.shadows ), STR_QUALITY_LOW, 0, 2 ),
|
||||||
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_WATER, SETTINGS( detail.water ), STR_QUALITY_LOW, 0, 2 ),
|
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_WATER, SETTINGS( detail.water ), STR_QUALITY_LOW, 0, 2 ),
|
||||||
#if defined(WIN32) || defined(LINUX) || defined(_PSP)
|
#if defined(WIN32) || defined(LINUX) || defined(_PSP) || defined(__RPI__)
|
||||||
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_VSYNC, SETTINGS( detail.vsync ), STR_OFF, 0, 1 ),
|
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_VSYNC, SETTINGS( detail.vsync ), STR_OFF, 0, 1 ),
|
||||||
#endif
|
#endif
|
||||||
#ifndef _PSP
|
#ifndef _PSP
|
||||||
@@ -1395,4 +1395,4 @@ struct Inventory {
|
|||||||
#undef SETTINGS
|
#undef SETTINGS
|
||||||
#undef LINE_HEIGHT
|
#undef LINE_HEIGHT
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -68,14 +68,55 @@ int osGetTime() {
|
|||||||
return int((t.tv_sec - startTime) * 1000 + t.tv_usec / 1000);
|
return int((t.tv_sec - startTime) * 1000 + t.tv_usec / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool osSave(const char *name, const void *data, int size) {
|
|
||||||
FILE *f = fopen(name, "wb");
|
// storage
|
||||||
if (!f) return false;
|
void osCacheWrite(Stream *stream) {
|
||||||
fwrite(data, size, 1, f);
|
char path[255];
|
||||||
fclose(f);
|
strcpy(path, Stream::cacheDir);
|
||||||
return true;
|
strcat(path, stream->name);
|
||||||
|
FILE *f = fopen(path, "wb");
|
||||||
|
if (f) {
|
||||||
|
fwrite(stream->data, 1, stream->size, f);
|
||||||
|
fclose(f);
|
||||||
|
if (stream->callback)
|
||||||
|
stream->callback(new Stream(stream->name, NULL, 0), stream->userData);
|
||||||
|
} else
|
||||||
|
if (stream->callback)
|
||||||
|
stream->callback(NULL, stream->userData);
|
||||||
|
|
||||||
|
delete stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void osCacheRead(Stream *stream) {
|
||||||
|
char path[255];
|
||||||
|
strcpy(path, Stream::cacheDir);
|
||||||
|
strcat(path, stream->name);
|
||||||
|
FILE *f = fopen(path, "rb");
|
||||||
|
if (f) {
|
||||||
|
fseek(f, 0, SEEK_END);
|
||||||
|
int size = ftell(f);
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
char *data = new char[size];
|
||||||
|
fread(data, 1, size, f);
|
||||||
|
fclose(f);
|
||||||
|
if (stream->callback)
|
||||||
|
stream->callback(new Stream(stream->name, data, size), stream->userData);
|
||||||
|
delete[] data;
|
||||||
|
} else
|
||||||
|
if (stream->callback)
|
||||||
|
stream->callback(NULL, stream->userData);
|
||||||
|
delete stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
void osSaveGame(Stream *stream) {
|
||||||
|
return osCacheWrite(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
void osLoadGame(Stream *stream) {
|
||||||
|
return osCacheRead(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Sound
|
// Sound
|
||||||
#define SND_FRAME_SIZE 4
|
#define SND_FRAME_SIZE 4
|
||||||
#define SND_DATA_SIZE (1024 * SND_FRAME_SIZE)
|
#define SND_DATA_SIZE (1024 * SND_FRAME_SIZE)
|
||||||
@@ -152,6 +193,14 @@ InputKey mouseToInputKey(int btn) {
|
|||||||
return ikNone;
|
return ikNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool osJoyReady(int index) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void osJoyVibrate(int index, float L, float R) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
void toggle_fullscreen(Display* dpy, Window win) {
|
void toggle_fullscreen(Display* dpy, Window win) {
|
||||||
const size_t _NET_WM_STATE_TOGGLE=2;
|
const size_t _NET_WM_STATE_TOGGLE=2;
|
||||||
|
|
||||||
|
@@ -72,14 +72,55 @@ int osGetTime() {
|
|||||||
return int((t.tv_sec - startTime) * 1000 + t.tv_usec / 1000);
|
return int((t.tv_sec - startTime) * 1000 + t.tv_usec / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool osSave(const char *name, const void *data, int size) {
|
|
||||||
FILE *f = fopen(name, "wb");
|
// storage
|
||||||
if (!f) return false;
|
void osCacheWrite(Stream *stream) {
|
||||||
fwrite(data, size, 1, f);
|
char path[255];
|
||||||
fclose(f);
|
strcpy(path, Stream::cacheDir);
|
||||||
return true;
|
strcat(path, stream->name);
|
||||||
|
FILE *f = fopen(path, "wb");
|
||||||
|
if (f) {
|
||||||
|
fwrite(stream->data, 1, stream->size, f);
|
||||||
|
fclose(f);
|
||||||
|
if (stream->callback)
|
||||||
|
stream->callback(new Stream(stream->name, NULL, 0), stream->userData);
|
||||||
|
} else
|
||||||
|
if (stream->callback)
|
||||||
|
stream->callback(NULL, stream->userData);
|
||||||
|
|
||||||
|
delete stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void osCacheRead(Stream *stream) {
|
||||||
|
char path[255];
|
||||||
|
strcpy(path, Stream::cacheDir);
|
||||||
|
strcat(path, stream->name);
|
||||||
|
FILE *f = fopen(path, "rb");
|
||||||
|
if (f) {
|
||||||
|
fseek(f, 0, SEEK_END);
|
||||||
|
int size = ftell(f);
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
char *data = new char[size];
|
||||||
|
fread(data, 1, size, f);
|
||||||
|
fclose(f);
|
||||||
|
if (stream->callback)
|
||||||
|
stream->callback(new Stream(stream->name, data, size), stream->userData);
|
||||||
|
delete[] data;
|
||||||
|
} else
|
||||||
|
if (stream->callback)
|
||||||
|
stream->callback(NULL, stream->userData);
|
||||||
|
delete stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
void osSaveGame(Stream *stream) {
|
||||||
|
return osCacheWrite(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
void osLoadGame(Stream *stream) {
|
||||||
|
return osCacheRead(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Sound
|
// Sound
|
||||||
snd_pcm_uframes_t SND_FRAMES = 512;
|
snd_pcm_uframes_t SND_FRAMES = 512;
|
||||||
snd_pcm_t *sndOut;
|
snd_pcm_t *sndOut;
|
||||||
@@ -235,8 +276,6 @@ bool eglInit(EGL_DISPMANX_WINDOW_T &window, EGLDisplay &display, EGLSurface &sur
|
|||||||
if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE)
|
if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//eglSwapInterval(display, 0); // turn off vsync
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,6 +296,14 @@ int udevMon_fd;
|
|||||||
|
|
||||||
vec2 joyL, joyR;
|
vec2 joyL, joyR;
|
||||||
|
|
||||||
|
bool osJoyReady(int index) {
|
||||||
|
return true; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
void osJoyVibrate(int index, float L, float R) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
InputKey codeToInputKey(int code) {
|
InputKey codeToInputKey(int code) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
// keyboard
|
// keyboard
|
||||||
@@ -482,6 +529,8 @@ void inputUpdate() {
|
|||||||
char Stream::cacheDir[255];
|
char Stream::cacheDir[255];
|
||||||
char Stream::contentDir[255];
|
char Stream::contentDir[255];
|
||||||
|
|
||||||
|
EGLDisplay display;
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
bcm_host_init();
|
bcm_host_init();
|
||||||
|
|
||||||
@@ -492,7 +541,6 @@ int main(int argc, char **argv) {
|
|||||||
Core::width = dmWindow.width;
|
Core::width = dmWindow.width;
|
||||||
Core::height = dmWindow.height;
|
Core::height = dmWindow.height;
|
||||||
|
|
||||||
EGLDisplay display;
|
|
||||||
EGLSurface surface;
|
EGLSurface surface;
|
||||||
EGLContext context;
|
EGLContext context;
|
||||||
if (!eglInit(dmWindow, display, context, surface)) {
|
if (!eglInit(dmWindow, display, context, surface)) {
|
||||||
@@ -527,10 +575,11 @@ int main(int argc, char **argv) {
|
|||||||
while (!Core::isQuit) {
|
while (!Core::isQuit) {
|
||||||
inputUpdate();
|
inputUpdate();
|
||||||
|
|
||||||
if (Game::update()) {
|
if (Game::update()) {
|
||||||
Game::render();
|
Game::render();
|
||||||
eglSwapBuffers(display, surface);
|
Core::waitVBlank();
|
||||||
}
|
eglSwapBuffers(display, surface);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
sndFree();
|
sndFree();
|
||||||
|
@@ -112,6 +112,8 @@ int osGetTime() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// storage
|
||||||
void osCacheWrite(Stream *stream) {
|
void osCacheWrite(Stream *stream) {
|
||||||
char path[255];
|
char path[255];
|
||||||
strcpy(path, Stream::cacheDir);
|
strcpy(path, Stream::cacheDir);
|
||||||
|
Reference in New Issue
Block a user