mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-23 05:13:53 +02:00
Update build.sh on the SDL2 platform so it builds the GLES version by default (it was building both!) (#168)
* Add SDL2 platform * add desktopGL support to the SDL2 platform, and add SDL2 context shutdown calls * fixed: now GL and GLES modes work on SDL2, use SDL2GLES define to use one or the other * Add comentary to build.sh with instructions to build GLES or OpenGL version of the SDL2 platform port * Update SDL init code to hide mouse and start in fullscreen mode * Set build.sh on the SDL2 platform so it builds the GLES version by default * Basic keyboard and joystick controls implemented in the SDL2 platform using SDL2 instead of udev * SDL2 platform: input code cleaunp * SDL2 input fix so Lara can do certain movements involving directions and buttons
This commit is contained in:
@@ -4,6 +4,4 @@ set -e
|
|||||||
g++ -DSDL2_GLES -std=c++11 `sdl2-config --cflags` -O3 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -DNDEBUG -D__SDL2__ main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c -I../../ -o OpenLara `sdl2-config --libs` -lGLESv2 -lEGL -lm -lrt -lpthread -lasound -ludev
|
g++ -DSDL2_GLES -std=c++11 `sdl2-config --cflags` -O3 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -DNDEBUG -D__SDL2__ main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c -I../../ -o OpenLara `sdl2-config --libs` -lGLESv2 -lEGL -lm -lrt -lpthread -lasound -ludev
|
||||||
|
|
||||||
# Use this compilation line to build SDL2/OpenGL version
|
# Use this compilation line to build SDL2/OpenGL version
|
||||||
g++ -std=c++11 `sdl2-config --cflags` -O3 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -DNDEBUG -D__SDL2__ main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c -I../../ -o OpenLara `sdl2-config --libs` -lGL -lm -lrt -lpthread -lasound -ludev
|
#g++ -std=c++11 `sdl2-config --cflags` -O3 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -DNDEBUG -D__SDL2__ main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c -I../../ -o OpenLara `sdl2-config --libs` -lGL -lm -lrt -lpthread -lasound -ludev
|
||||||
|
|
||||||
#strip ../../../bin/OpenLara --strip-all --remove-section=.comment --remove-section=.note
|
|
@@ -1,14 +1,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <linux/input.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
//#include <EGL/egl.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <linux/input.h>
|
|
||||||
#include <libudev.h>
|
|
||||||
#include <alsa/asoundlib.h>
|
#include <alsa/asoundlib.h>
|
||||||
|
|
||||||
// SDL2 include stuff
|
// SDL2 include stuff
|
||||||
@@ -106,12 +100,9 @@ void sndFree() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
#define MAX_INPUT_DEVICES 16
|
SDL_GameController *sdl_gamecontroller;
|
||||||
int inputDevices[MAX_INPUT_DEVICES];
|
SDL_Joystick *sdl_joystick;
|
||||||
|
bool using_old_joystick_interface;
|
||||||
udev *udevObj;
|
|
||||||
udev_monitor *udevMon;
|
|
||||||
int udevMon_fd;
|
|
||||||
|
|
||||||
vec2 joyL, joyR;
|
vec2 joyL, joyR;
|
||||||
|
|
||||||
@@ -126,61 +117,57 @@ void osJoyVibrate(int index, float L, float R) {
|
|||||||
InputKey codeToInputKey(int code) {
|
InputKey codeToInputKey(int code) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
// keyboard
|
// keyboard
|
||||||
case KEY_LEFT : return ikLeft;
|
case SDL_SCANCODE_LEFT : return ikLeft;
|
||||||
case KEY_RIGHT : return ikRight;
|
case SDL_SCANCODE_RIGHT : return ikRight;
|
||||||
case KEY_UP : return ikUp;
|
case SDL_SCANCODE_UP : return ikUp;
|
||||||
case KEY_DOWN : return ikDown;
|
case SDL_SCANCODE_DOWN : return ikDown;
|
||||||
case KEY_SPACE : return ikSpace;
|
case SDL_SCANCODE_SPACE : return ikSpace;
|
||||||
case KEY_TAB : return ikTab;
|
case SDL_SCANCODE_TAB : return ikTab;
|
||||||
case KEY_ENTER : return ikEnter;
|
case SDL_SCANCODE_RETURN : return ikEnter;
|
||||||
case KEY_ESC : return ikEscape;
|
case SDL_SCANCODE_ESCAPE : return ikEscape;
|
||||||
case KEY_LEFTSHIFT :
|
case SDL_SCANCODE_LSHIFT :
|
||||||
case KEY_RIGHTSHIFT : return ikShift;
|
case SDL_SCANCODE_RSHIFT : return ikShift;
|
||||||
case KEY_LEFTCTRL :
|
case SDL_SCANCODE_LCTRL :
|
||||||
case KEY_RIGHTCTRL : return ikCtrl;
|
case SDL_SCANCODE_RCTRL : return ikCtrl;
|
||||||
case KEY_LEFTALT :
|
case SDL_SCANCODE_LALT :
|
||||||
case KEY_RIGHTALT : return ikAlt;
|
case SDL_SCANCODE_RALT : return ikAlt;
|
||||||
case KEY_0 : return ik0;
|
case SDL_SCANCODE_0 : return ik0;
|
||||||
case KEY_1 : return ik1;
|
case SDL_SCANCODE_1 : return ik1;
|
||||||
case KEY_2 : return ik2;
|
case SDL_SCANCODE_2 : return ik2;
|
||||||
case KEY_3 : return ik3;
|
case SDL_SCANCODE_3 : return ik3;
|
||||||
case KEY_4 : return ik4;
|
case SDL_SCANCODE_4 : return ik4;
|
||||||
case KEY_5 : return ik5;
|
case SDL_SCANCODE_5 : return ik5;
|
||||||
case KEY_6 : return ik6;
|
case SDL_SCANCODE_6 : return ik6;
|
||||||
case KEY_7 : return ik7;
|
case SDL_SCANCODE_7 : return ik7;
|
||||||
case KEY_8 : return ik8;
|
case SDL_SCANCODE_8 : return ik8;
|
||||||
case KEY_9 : return ik9;
|
case SDL_SCANCODE_9 : return ik9;
|
||||||
case KEY_A : return ikA;
|
case SDL_SCANCODE_A : return ikA;
|
||||||
case KEY_B : return ikB;
|
case SDL_SCANCODE_B : return ikB;
|
||||||
case KEY_C : return ikC;
|
case SDL_SCANCODE_C : return ikC;
|
||||||
case KEY_D : return ikD;
|
case SDL_SCANCODE_D : return ikD;
|
||||||
case KEY_E : return ikE;
|
case SDL_SCANCODE_E : return ikE;
|
||||||
case KEY_F : return ikF;
|
case SDL_SCANCODE_F : return ikF;
|
||||||
case KEY_G : return ikG;
|
case SDL_SCANCODE_G : return ikG;
|
||||||
case KEY_H : return ikH;
|
case SDL_SCANCODE_H : return ikH;
|
||||||
case KEY_I : return ikI;
|
case SDL_SCANCODE_I : return ikI;
|
||||||
case KEY_J : return ikJ;
|
case SDL_SCANCODE_J : return ikJ;
|
||||||
case KEY_K : return ikK;
|
case SDL_SCANCODE_K : return ikK;
|
||||||
case KEY_L : return ikL;
|
case SDL_SCANCODE_L : return ikL;
|
||||||
case KEY_M : return ikM;
|
case SDL_SCANCODE_M : return ikM;
|
||||||
case KEY_N : return ikN;
|
case SDL_SCANCODE_N : return ikN;
|
||||||
case KEY_O : return ikO;
|
case SDL_SCANCODE_O : return ikO;
|
||||||
case KEY_P : return ikP;
|
case SDL_SCANCODE_P : return ikP;
|
||||||
case KEY_Q : return ikQ;
|
case SDL_SCANCODE_Q : return ikQ;
|
||||||
case KEY_R : return ikR;
|
case SDL_SCANCODE_R : return ikR;
|
||||||
case KEY_S : return ikS;
|
case SDL_SCANCODE_S : return ikS;
|
||||||
case KEY_T : return ikT;
|
case SDL_SCANCODE_T : return ikT;
|
||||||
case KEY_U : return ikU;
|
case SDL_SCANCODE_U : return ikU;
|
||||||
case KEY_V : return ikV;
|
case SDL_SCANCODE_V : return ikV;
|
||||||
case KEY_W : return ikW;
|
case SDL_SCANCODE_W : return ikW;
|
||||||
case KEY_X : return ikX;
|
case SDL_SCANCODE_X : return ikX;
|
||||||
case KEY_Y : return ikY;
|
case SDL_SCANCODE_Y : return ikY;
|
||||||
case KEY_Z : return ikZ;
|
case SDL_SCANCODE_Z : return ikZ;
|
||||||
case KEY_HOMEPAGE : return ikEscape;
|
case SDL_SCANCODE_AC_HOME : return ikEscape;
|
||||||
// mouse
|
|
||||||
case BTN_LEFT : return ikMouseL;
|
|
||||||
case BTN_RIGHT : return ikMouseR;
|
|
||||||
case BTN_MIDDLE : return ikMouseM;
|
|
||||||
}
|
}
|
||||||
return ikNone;
|
return ikNone;
|
||||||
}
|
}
|
||||||
@@ -188,89 +175,44 @@ InputKey codeToInputKey(int code) {
|
|||||||
JoyKey codeToJoyKey(int code) {
|
JoyKey codeToJoyKey(int code) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
// gamepad
|
// gamepad
|
||||||
case BTN_A : return jkA;
|
case SDL_CONTROLLER_BUTTON_A : return jkA;
|
||||||
case BTN_B : return jkB;
|
case SDL_CONTROLLER_BUTTON_B : return jkB;
|
||||||
case BTN_X : return jkX;
|
case SDL_CONTROLLER_BUTTON_X : return jkX;
|
||||||
case BTN_Y : return jkY;
|
case SDL_CONTROLLER_BUTTON_Y : return jkY;
|
||||||
case BTN_TL : return jkLB;
|
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER : return jkLB;
|
||||||
case BTN_TR : return jkRB;
|
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER : return jkRB;
|
||||||
case BTN_SELECT : return jkSelect;
|
case SDL_CONTROLLER_BUTTON_BACK : return jkSelect;
|
||||||
case BTN_START : return jkStart;
|
case SDL_CONTROLLER_BUTTON_START : return jkStart;
|
||||||
case BTN_THUMBL : return jkL;
|
case SDL_CONTROLLER_BUTTON_LEFTSTICK : return jkL;
|
||||||
case BTN_THUMBR : return jkR;
|
case SDL_CONTROLLER_BUTTON_RIGHTSTICK : return jkR;
|
||||||
case BTN_TL2 : return jkLT;
|
|
||||||
case BTN_TR2 : return jkRT;
|
|
||||||
}
|
}
|
||||||
return jkNone;
|
return jkNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
int inputDevIndex(const char *node) {
|
|
||||||
const char *str = strstr(node, "/event");
|
|
||||||
if (str)
|
|
||||||
return atoi(str + 6);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void inputDevAdd(const char *node) {
|
|
||||||
int index = inputDevIndex(node);
|
|
||||||
if (index != -1) {
|
|
||||||
inputDevices[index] = open(node, O_RDONLY | O_NONBLOCK);
|
|
||||||
ioctl(inputDevices[index], EVIOCGRAB, 1);
|
|
||||||
//LOG("input: add %s\n", node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void inputDevRemove(const char *node) {
|
|
||||||
int index = inputDevIndex(node);
|
|
||||||
if (index != -1 && inputDevices[index] != -1) {
|
|
||||||
close(inputDevices[index]);
|
|
||||||
//LOG("input: remove %s\n", node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool inputInit() {
|
bool inputInit() {
|
||||||
joyL = joyR = vec2(0);
|
sdl_gamecontroller = NULL;
|
||||||
|
sdl_joystick = NULL;
|
||||||
for (int i = 0; i < MAX_INPUT_DEVICES; i++)
|
if (SDL_NumJoysticks() > 0) {
|
||||||
inputDevices[i] = -1;
|
if(SDL_IsGameController(0)) {
|
||||||
|
sdl_gamecontroller = SDL_GameControllerOpen(0);
|
||||||
udevObj = udev_new();
|
}
|
||||||
if (!udevObj)
|
else {
|
||||||
return false;
|
sdl_joystick = SDL_JoystickOpen(0);
|
||||||
|
using_old_joystick_interface = true;
|
||||||
udevMon = udev_monitor_new_from_netlink(udevObj, "udev");
|
}
|
||||||
udev_monitor_filter_add_match_subsystem_devtype(udevMon, "input", NULL);
|
|
||||||
udev_monitor_enable_receiving(udevMon);
|
|
||||||
udevMon_fd = udev_monitor_get_fd(udevMon);
|
|
||||||
|
|
||||||
udev_enumerate *e = udev_enumerate_new(udevObj);
|
|
||||||
udev_enumerate_add_match_subsystem(e, "input");
|
|
||||||
udev_enumerate_scan_devices(e);
|
|
||||||
udev_list_entry *devices = udev_enumerate_get_list_entry(e);
|
|
||||||
|
|
||||||
udev_list_entry *entry;
|
|
||||||
udev_list_entry_foreach(entry, devices) {
|
|
||||||
const char *path, *node;
|
|
||||||
udev_device *device;
|
|
||||||
|
|
||||||
path = udev_list_entry_get_name(entry);
|
|
||||||
device = udev_device_new_from_syspath(udevObj, path);
|
|
||||||
node = udev_device_get_devnode(device);
|
|
||||||
|
|
||||||
if (node)
|
|
||||||
inputDevAdd(node);
|
|
||||||
}
|
}
|
||||||
udev_enumerate_unref(e);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void inputFree() {
|
void inputFree() {
|
||||||
for (int i = 0; i < MAX_INPUT_DEVICES; i++)
|
if (sdl_gamecontroller != NULL) {
|
||||||
if (inputDevices[i] != -1)
|
SDL_GameControllerClose(sdl_gamecontroller);
|
||||||
close(inputDevices[i]);
|
sdl_gamecontroller = NULL;
|
||||||
udev_monitor_unref(udevMon);
|
}
|
||||||
udev_unref(udevObj);
|
if (sdl_joystick != NULL) {
|
||||||
|
SDL_JoystickClose(sdl_joystick);
|
||||||
|
sdl_joystick = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define JOY_DEAD_ZONE_STICK 8192
|
#define JOY_DEAD_ZONE_STICK 8192
|
||||||
@@ -292,94 +234,76 @@ vec2 joyDir(const vec2 &value) {
|
|||||||
|
|
||||||
void inputUpdate() {
|
void inputUpdate() {
|
||||||
// get input events
|
// get input events
|
||||||
input_event events[16];
|
|
||||||
|
|
||||||
for (int i = 0; i < MAX_INPUT_DEVICES; i++) {
|
int joyIndex = 0; // TODO: joy index
|
||||||
if (inputDevices[i] == -1) continue;
|
|
||||||
int rb = read(inputDevices[i], events, sizeof(events));
|
|
||||||
|
|
||||||
int joyIndex = 0; // TODO: joy index
|
SDL_Event event;
|
||||||
|
while (SDL_PollEvent(&event) == 1) { // while there are still events to be processed
|
||||||
input_event *e = events;
|
switch (event.type) {
|
||||||
while (rb > 0) {
|
case SDL_KEYDOWN: {
|
||||||
switch (e->type) {
|
int scancode = event.key.keysym.scancode;
|
||||||
case EV_KEY : {
|
InputKey key = codeToInputKey(scancode);
|
||||||
InputKey key = codeToInputKey(e->code);
|
if (key != ikNone) {
|
||||||
if (key != ikNone) {
|
Input::setDown(key, 1);
|
||||||
if (key == ikMouseL || key == ikMouseR || key == ikMouseM)
|
}
|
||||||
Input::setPos(key, Input::mouse.pos);
|
break;
|
||||||
Input::setDown(key, e->value != 0);
|
}
|
||||||
} else {
|
case SDL_KEYUP: {
|
||||||
JoyKey key = codeToJoyKey(e->code);
|
int scancode = event.key.keysym.scancode;
|
||||||
Input::setJoyDown(joyIndex, key, e->value != 0);
|
InputKey key = codeToInputKey(scancode);
|
||||||
}
|
if (key != ikNone) {
|
||||||
break;
|
Input::setDown(key, 0);
|
||||||
}
|
}
|
||||||
case EV_REL : {
|
break;
|
||||||
vec2 delta(0);
|
}
|
||||||
delta[e->code] = float(e->value);
|
case SDL_CONTROLLERBUTTONDOWN: {
|
||||||
Input::setPos(ikMouseL, Input::mouse.pos + delta);
|
JoyKey key = codeToJoyKey(event.cbutton.button);
|
||||||
break;
|
Input::setJoyDown(joyIndex, key, 1);
|
||||||
}
|
break;
|
||||||
case EV_ABS : {
|
}
|
||||||
switch (e->code) {
|
case SDL_CONTROLLERBUTTONUP: {
|
||||||
// Left stick
|
JoyKey key = codeToJoyKey(event.cbutton.button);
|
||||||
case ABS_X : joyL.x = joyAxisValue(e->value); break;
|
Input::setJoyDown(joyIndex, key, 0);
|
||||||
case ABS_Y : joyL.y = joyAxisValue(e->value); break;
|
break;
|
||||||
// Right stick
|
}
|
||||||
case ABS_RX : joyR.x = joyAxisValue(e->value); break;
|
case SDL_CONTROLLERAXISMOTION: {
|
||||||
case ABS_RY : joyR.y = joyAxisValue(e->value); break;
|
switch (event.caxis.axis) {
|
||||||
// Left trigger
|
case SDL_CONTROLLER_AXIS_LEFTX:
|
||||||
case ABS_Z : Input::setJoyPos(joyIndex, jkLT, joyTrigger(e->value)); break;
|
if (event.caxis.value < 0) {
|
||||||
// Right trigger
|
Input::setJoyDown(joyIndex, jkLeft, 1);
|
||||||
case ABS_RZ : Input::setJoyPos(joyIndex, jkRT, joyTrigger(e->value)); break;
|
Input::setJoyDown(joyIndex, jkRight, 0);
|
||||||
// D-PAD
|
}
|
||||||
case ABS_HAT0X :
|
if (event.caxis.value > 0) {
|
||||||
case ABS_THROTTLE :
|
Input::setJoyDown(joyIndex, jkRight, 1);
|
||||||
Input::setJoyDown(joyIndex, jkLeft, e->value < 0);
|
Input::setJoyDown(joyIndex, jkLeft, 0);
|
||||||
Input::setJoyDown(joyIndex, jkRight, e->value > 0);
|
}
|
||||||
break;
|
if (event.caxis.value == 0) {
|
||||||
case ABS_HAT0Y :
|
Input::setJoyDown(joyIndex, jkRight, 0);
|
||||||
case ABS_RUDDER :
|
Input::setJoyDown(joyIndex, jkLeft, 0);
|
||||||
Input::setJoyDown(joyIndex, jkUp, e->value < 0);
|
}
|
||||||
Input::setJoyDown(joyIndex, jkDown, e->value > 0);
|
break;
|
||||||
break;
|
case SDL_CONTROLLER_AXIS_LEFTY:
|
||||||
}
|
if (event.caxis.value < 0) {
|
||||||
|
Input::setJoyDown(joyIndex, jkUp, 1);
|
||||||
Input::setJoyPos(joyIndex, jkL, joyDir(joyL));
|
Input::setJoyDown(joyIndex, jkDown, 0);
|
||||||
Input::setJoyPos(joyIndex, jkR, joyDir(joyR));
|
}
|
||||||
}
|
if (event.caxis.value > 0) {
|
||||||
}
|
Input::setJoyDown(joyIndex, jkUp, 0);
|
||||||
//LOG("input: type = %d, code = %d, value = %d\n", int(e->type), int(e->code), int(e->value));
|
Input::setJoyDown(joyIndex, jkDown, 1);
|
||||||
e++;
|
}
|
||||||
rb -= sizeof(events[0]);
|
if (event.caxis.value == 0) {
|
||||||
|
Input::setJoyDown(joyIndex, jkUp, 0);
|
||||||
|
Input::setJoyDown(joyIndex, jkDown, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// monitoring plug and unplug input devices
|
Input::setJoyPos(joyIndex, jkL, joyDir(joyL));
|
||||||
fd_set fds;
|
Input::setJoyPos(joyIndex, jkR, joyDir(joyR));
|
||||||
FD_ZERO(&fds);
|
}
|
||||||
FD_SET(udevMon_fd, &fds);
|
|
||||||
|
|
||||||
timeval tv;
|
|
||||||
tv.tv_sec = 0;
|
|
||||||
tv.tv_usec = 0;
|
|
||||||
|
|
||||||
if (select(udevMon_fd + 1, &fds, NULL, NULL, &tv) > 0 && FD_ISSET(udevMon_fd, &fds)) {
|
|
||||||
udev_device *device = udev_monitor_receive_device(udevMon);
|
|
||||||
if (device) {
|
|
||||||
const char *node = udev_device_get_devnode(device);
|
|
||||||
if (node) {
|
|
||||||
const char *action = udev_device_get_action(device);
|
|
||||||
if (!strcmp(action, "add"))
|
|
||||||
inputDevAdd(node);
|
|
||||||
if (!strcmp(action, "remove"))
|
|
||||||
inputDevRemove(node);
|
|
||||||
}
|
|
||||||
udev_device_unref(device);
|
|
||||||
} else
|
|
||||||
LOG("! input: receive_device\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
@@ -387,7 +311,8 @@ int main(int argc, char **argv) {
|
|||||||
int w, h;
|
int w, h;
|
||||||
SDL_DisplayMode current;
|
SDL_DisplayMode current;
|
||||||
|
|
||||||
SDL_Init(SDL_INIT_VIDEO);
|
|
||||||
|
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_EVENTS|SDL_INIT_GAMECONTROLLER);
|
||||||
|
|
||||||
SDL_GetCurrentDisplayMode(0, ¤t);
|
SDL_GetCurrentDisplayMode(0, ¤t);
|
||||||
|
|
||||||
@@ -397,7 +322,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
// We start in fullscreen mode using the vide mode currently in use, to avoid video mode changes.
|
// We start in fullscreen mode using the vide mode currently in use, to avoid video mode changes.
|
||||||
SDL_Window *window = SDL_CreateWindow(WND_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
SDL_Window *window = SDL_CreateWindow(WND_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
||||||
current.w, current.h, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN_DESKTOP);
|
//current.w, current.h, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||||
|
640, 480, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
|
||||||
|
|
||||||
// We try to use the current video mode, but we inform the core of whatever mode SDL2 gave us in the end.
|
// We try to use the current video mode, but we inform the core of whatever mode SDL2 gave us in the end.
|
||||||
SDL_GetWindowSize(window, &w, &h);
|
SDL_GetWindowSize(window, &w, &h);
|
||||||
@@ -432,12 +358,12 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
sndInit();
|
sndInit();
|
||||||
|
|
||||||
|
inputInit();
|
||||||
|
|
||||||
char *lvlName = argc > 1 ? argv[1] : NULL;
|
char *lvlName = argc > 1 ? argv[1] : NULL;
|
||||||
|
|
||||||
Game::init(lvlName);
|
Game::init(lvlName);
|
||||||
|
|
||||||
inputInit(); // initialize and grab input devices
|
|
||||||
|
|
||||||
while (!Core::isQuit) {
|
while (!Core::isQuit) {
|
||||||
inputUpdate();
|
inputUpdate();
|
||||||
|
|
||||||
@@ -448,8 +374,6 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inputFree();
|
|
||||||
|
|
||||||
sndFree();
|
sndFree();
|
||||||
Game::deinit();
|
Game::deinit();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user