1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-02-25 07:52:43 +01:00

#15 fix RPI build

This commit is contained in:
XProger 2018-02-28 08:19:54 +03:00
parent 7b88afaaae
commit dc2666e437
5 changed files with 128 additions and 21 deletions

View File

@ -75,6 +75,8 @@
#define GL_PROGRAM_BINARY_LENGTH GL_PROGRAM_BINARY_LENGTH_OES
#define glGetProgramBinary(...)
#define glProgramBinary(...)
extern EGLDisplay display;
#elif __linux__
#define LINUX 1
#include <GL/gl.h>
@ -1095,6 +1097,7 @@ namespace Core {
#ifdef __RPI__
settings.detail.setShadows(Core::Settings::LOW);
settings.detail.setLighting(Core::Settings::MEDIUM);
#endif
#ifdef FFP
@ -1464,6 +1467,8 @@ namespace Core {
if (wglSwapIntervalEXT) wglSwapIntervalEXT(1);
#elif LINUX
if (glXSwapIntervalSGI) glXSwapIntervalSGI(1);
#elif __RPI__
eglSwapInterval(display, 1);
#elif _PSP
sceDisplayWaitVblankStart();
#endif
@ -1472,6 +1477,8 @@ namespace Core {
if (wglSwapIntervalEXT) wglSwapIntervalEXT(0);
#elif LINUX
if (glXSwapIntervalSGI) glXSwapIntervalSGI(0);
#elif __RPI__
eglSwapInterval(display, 0);
#endif
}
}

View File

@ -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_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 ),
#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 ),
#endif
#ifndef _PSP
@ -1395,4 +1395,4 @@ struct Inventory {
#undef SETTINGS
#undef LINE_HEIGHT
#endif
#endif

View File

@ -68,14 +68,55 @@ int osGetTime() {
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");
if (!f) return false;
fwrite(data, size, 1, f);
fclose(f);
return true;
// storage
void osCacheWrite(Stream *stream) {
char path[255];
strcpy(path, Stream::cacheDir);
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
#define SND_FRAME_SIZE 4
#define SND_DATA_SIZE (1024 * SND_FRAME_SIZE)
@ -152,6 +193,14 @@ InputKey mouseToInputKey(int btn) {
return ikNone;
}
bool osJoyReady(int index) {
return false;
}
void osJoyVibrate(int index, float L, float R) {
// TODO
}
void toggle_fullscreen(Display* dpy, Window win) {
const size_t _NET_WM_STATE_TOGGLE=2;

View File

@ -72,14 +72,55 @@ int osGetTime() {
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");
if (!f) return false;
fwrite(data, size, 1, f);
fclose(f);
return true;
// storage
void osCacheWrite(Stream *stream) {
char path[255];
strcpy(path, Stream::cacheDir);
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
snd_pcm_uframes_t SND_FRAMES = 512;
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)
return false;
//eglSwapInterval(display, 0); // turn off vsync
return true;
}
@ -257,6 +296,14 @@ int udevMon_fd;
vec2 joyL, joyR;
bool osJoyReady(int index) {
return true; // TODO
}
void osJoyVibrate(int index, float L, float R) {
// TODO
}
InputKey codeToInputKey(int code) {
switch (code) {
// keyboard
@ -482,6 +529,8 @@ void inputUpdate() {
char Stream::cacheDir[255];
char Stream::contentDir[255];
EGLDisplay display;
int main(int argc, char **argv) {
bcm_host_init();
@ -492,7 +541,6 @@ int main(int argc, char **argv) {
Core::width = dmWindow.width;
Core::height = dmWindow.height;
EGLDisplay display;
EGLSurface surface;
EGLContext context;
if (!eglInit(dmWindow, display, context, surface)) {
@ -527,10 +575,11 @@ int main(int argc, char **argv) {
while (!Core::isQuit) {
inputUpdate();
if (Game::update()) {
Game::render();
eglSwapBuffers(display, surface);
}
if (Game::update()) {
Game::render();
Core::waitVBlank();
eglSwapBuffers(display, surface);
}
};
sndFree();

View File

@ -112,6 +112,8 @@ int osGetTime() {
#endif
}
// storage
void osCacheWrite(Stream *stream) {
char path[255];
strcpy(path, Stream::cacheDir);