- Updated SDL dependency to SDL2

- fixed compilation issues with cmake and visual studio 2015
This commit is contained in:
xawotihs
2015-10-04 23:10:45 +02:00
parent 4272e2e2b2
commit 22d14b2a4f
25 changed files with 119 additions and 89 deletions

View File

@@ -101,7 +101,7 @@ class SdlApp
public: /* For easy interfacing with JGE static functions */
bool Running;
SDL_Window* window;
SDL_Surface* Surf_Display;
SDL_GLContext gl_context;
SDL_Rect viewPort;
Uint32 lastMouseUpTime;
Uint32 lastFingerDownTime;
@@ -114,7 +114,7 @@ public: /* For easy interfacing with JGE static functions */
int mMouseDownY;
public:
SdlApp() : Surf_Display(NULL), window(NULL), lastMouseUpTime(0), lastFingerDownTime(0), Running(true), mMouseDownX(0), mMouseDownY(0)
SdlApp() : Running(true), window(NULL), gl_context(NULL), lastMouseUpTime(0), lastFingerDownTime(0), mMouseDownX(0), mMouseDownY(0)
{
}
@@ -144,7 +144,7 @@ public:
OnCleanup();
return 0;
};
}
public:
bool OnInit();
@@ -276,7 +276,7 @@ public:
void OnCleanup()
{
SDL_FreeSurface(Surf_Display);
SDL_GL_DeleteContext(gl_context);
SDL_Quit();
}
};
@@ -403,7 +403,11 @@ bool InitGame(void)
void DestroyGame(void)
{
g_engine->SetApp(NULL);
if (g_engine != NULL)
{
g_engine->SetApp(NULL);
}
if (g_app)
{
g_app->Destroy();
@@ -443,7 +447,7 @@ void SdlApp::OnUpdate()
if(g_engine)
g_engine->Render();
SDL_GL_SwapBuffers();
SDL_GL_SwapWindow(window);
}
void SdlApp::OnKeyPressed(const SDL_KeyboardEvent& event)
@@ -637,8 +641,9 @@ bool SdlApp::OnInit()
return false;
}
const SDL_VideoInfo *pVideoInfo = SDL_GetVideoInfo();
DebugTrace("Video Display : h " << pVideoInfo->current_h << ", w " << pVideoInfo->current_w);
SDL_DisplayMode currentDisplayMode;
SDL_GetCurrentDisplayMode(0, &currentDisplayMode);
DebugTrace("Video Display : h " << currentDisplayMode.h << ", w " << currentDisplayMode.w);
#if (defined ANDROID) || (defined IOS)
window_w = pVideoInfo->current_w;
@@ -662,22 +667,37 @@ bool SdlApp::OnInit()
SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 2);
int buffers, samples;
SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &buffers);
SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &samples);
if (buffers == 0 || samples == 0)
{ //no multisampling available
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
}
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
if((Surf_Display = SDL_SetVideoMode(window_w, window_h, 32,
#ifdef ANDROID
SDL_OPENGL | SDL_FULLSCREEN | SDL_WINDOW_BORDERLESS)) == NULL)
{
Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS;
#else
SDL_OPENGL | SDL_RESIZABLE )) == NULL)
{
Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE;
#endif
window = SDL_CreateWindow(
g_launcher->GetName(),
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
window_w, windowed_h, flags);
if (window == NULL)
{
DebugTrace(SDL_GetError());
return false;
}
SDL_WM_SetCaption(g_launcher->GetName(), "");
gl_context = SDL_GL_CreateContext(window);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background (yes that's the way fuckers)
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)