- got sdl2 branch compiling and game loads

This commit is contained in:
SoftCoder
2015-09-28 23:28:11 -07:00
parent 23ea9f6201
commit 8e439a2325
26 changed files with 214 additions and 107 deletions

View File

@@ -45,7 +45,8 @@ namespace Shared{ namespace Platform{
class PlatformContextGl {
protected:
SDL_Surface *icon;
SDL_Window *screen;
SDL_Window *window;
SDL_GLContext glcontext;
public:
// Example values:
@@ -69,7 +70,8 @@ public:
virtual void makeCurrent();
virtual void swapBuffers();
SDL_Window * getScreen() { return screen; }
SDL_Window * getScreenWindow() { return window; }
SDL_Surface * getScreenSurface();
DeviceContextHandle getHandle() const { return 0; }
};

View File

@@ -669,9 +669,9 @@ int mainSetup(int argc, char **argv) {
return 3;
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
SDL_EnableUNICODE(1);
//SDL_EnableUNICODE(1);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
//SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
return 0;

View File

@@ -30,14 +30,13 @@ using Shared::Graphics::Vec2i;
#if SDL_VERSION_ATLEAST(2,0,0)
typedef SDL_Keysym SDL_keysym;
typedef SDL_Keycode SDLKey;
#endif
namespace Shared{ namespace Platform{
class Timer;
class PlatformContextGl;
//class PlatformContextGl;
enum MouseButton {
mbUnknown,
@@ -95,7 +94,7 @@ enum WindowStyle{
class Window {
private:
SDL_Window *sdlWindow;
static SDL_Window *sdlWindow;
Uint32 lastMouseDown[mbCount];
int lastMouseX[mbCount];
int lastMouseY[mbCount];
@@ -130,8 +129,9 @@ protected:
static int lastShowMouseState;
public:
static SDL_Window *getSDLWindow();
static bool handleEvent();
static void revertMousePos(SDL_Window *sdlwindow);
static void revertMousePos();
static Vec2i getOldMousePos();
static bool isKeyDown() { return isKeyPressedDown; }
static void setupGraphicsScreen(int depthBits=-1, int stencilBits=-1, bool hardware_acceleration=false, bool fullscreen_anti_aliasing=false);
@@ -141,6 +141,7 @@ public:
static bool isKeyStateModPressed(int mod);
static wchar_t extractLastKeyPressed();
Window();
Window(SDL_Window *sdlWindow);
virtual ~Window();
@@ -192,6 +193,9 @@ public:
static char getRawKey(SDL_keysym keysym);
protected:
void setSDLWindow(SDL_Window *window);
virtual void eventCreate(){}
virtual void eventMouseDown(int x, int y, MouseButton mouseButton){}
virtual void eventMouseUp(int x, int y, MouseButton mouseButton){}
@@ -218,16 +222,16 @@ private:
static MouseButton getMouseButton(int sdlButton);
//static char getKey(SDL_keysym keysym, bool skipSpecialKeys=false);
//static char getNormalKey(SDL_keysym keysym,bool skipSpecialKeys=false);
static void toggleFullscreen(SDL_Window *sdlwindow);
static void toggleFullscreen();
static wchar_t convertStringtoSDLKey(const string &value);
};
bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input, vector<int> modifiersToCheck);
bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input, bool modifiersAllowed=true);
bool isKeyPressed(SDL_Keycode compareKey, SDL_KeyboardEvent input, vector<int> modifiersToCheck);
bool isKeyPressed(SDL_Keycode compareKey, SDL_KeyboardEvent input, bool modifiersAllowed=true);
SDLKey extractKeyPressed(SDL_KeyboardEvent input);
bool isAllowedInputTextKey(SDLKey key);
SDL_Keycode extractKeyPressed(SDL_KeyboardEvent input);
bool isAllowedInputTextKey(SDL_Keycode key);
wchar_t extractKeyPressedUnicode(SDL_KeyboardEvent input);
vector<int> extractKeyPressedUnicodeLength(string text);

View File

@@ -24,17 +24,25 @@ namespace Shared{ namespace Platform{
// class WindowGl
// =====================================================
class WindowGl: public Window{
class WindowGl: public Window {
private:
ContextGl context;
static void setGamma(SDL_Window *window,float gammaValue);
public:
WindowGl();
WindowGl(SDL_Window *sdlWindow);
virtual ~WindowGl();
void initGl(int colorBits, int depthBits, int stencilBits,
bool hardware_acceleration, bool fullscreen_anti_aliasing,
float gammaValue);
void makeCurrentGl();
void swapBuffersGl();
void setGamma(float gammaValue){context.setGammaValue(gammaValue);}
void setGamma(float gammaValue);
SDL_Window * getScreenWindow();
SDL_Surface * getScreenSurface();
virtual bool ChangeVideoMode(bool preserveContext, int resWidth, int resHeight,
bool fullscreenWindow, int colorBits, int depthBits, int stencilBits,