Init: Check for OpenGL 2.0 and destroy context on error
This commit is contained in:
parent
26bc4842c0
commit
bf5e80dd6a
32
src/main.cpp
32
src/main.cpp
|
@ -50,6 +50,14 @@ static const char *reqExt[] =
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
rgssThreadError(RGSSThreadData *rtData, const QByteArray &msg)
|
||||||
|
{
|
||||||
|
rtData->rgssErrorMsg = msg;
|
||||||
|
rtData->ethread->requestTerminate();
|
||||||
|
rtData->rqTermAck = true;
|
||||||
|
}
|
||||||
|
|
||||||
int rgssThreadFun(void *userdata)
|
int rgssThreadFun(void *userdata)
|
||||||
{
|
{
|
||||||
RGSSThreadData *threadData = static_cast<RGSSThreadData*>(userdata);
|
RGSSThreadData *threadData = static_cast<RGSSThreadData*>(userdata);
|
||||||
|
@ -67,19 +75,14 @@ int rgssThreadFun(void *userdata)
|
||||||
|
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
{
|
{
|
||||||
threadData->rgssErrorMsg =
|
rgssThreadError(threadData, QByteArray("Error creating context: ") + SDL_GetError());
|
||||||
QByteArray("Error creating context: ") + SDL_GetError();
|
|
||||||
threadData->ethread->requestTerminate();
|
|
||||||
threadData->rqTermAck = true;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glewInit() != GLEW_OK)
|
if (glewInit() != GLEW_OK)
|
||||||
{
|
{
|
||||||
threadData->rgssErrorMsg = "Error initializing glew";
|
rgssThreadError(threadData, "Error initializing glew");
|
||||||
SDL_GL_DeleteContext(ctx);
|
SDL_GL_DeleteContext(ctx);
|
||||||
threadData->ethread->requestTerminate();
|
|
||||||
threadData->rqTermAck = true;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,15 +90,22 @@ int rgssThreadFun(void *userdata)
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
SDL_GL_SwapWindow(win);
|
SDL_GL_SwapWindow(win);
|
||||||
|
|
||||||
|
/* Check for required GL version */
|
||||||
|
if (!GLEW_VERSION_2_0)
|
||||||
|
{
|
||||||
|
rgssThreadError(threadData, "At least OpenGL 2.0 is required");
|
||||||
|
SDL_GL_DeleteContext(ctx);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check for required GL extensions */
|
/* Check for required GL extensions */
|
||||||
for (int i = 0; reqExt[i]; ++i)
|
for (int i = 0; reqExt[i]; ++i)
|
||||||
{
|
{
|
||||||
if (!glewIsSupported(reqExt[i]))
|
if (!glewIsSupported(reqExt[i]))
|
||||||
{
|
{
|
||||||
threadData->rgssErrorMsg =
|
rgssThreadError(threadData, QByteArray("Required GL extension \"")
|
||||||
QByteArray("Required GL extension \"") + reqExt[i] + "\" not present";
|
+ reqExt[i] + "\" not present");
|
||||||
threadData->ethread->requestTerminate();
|
SDL_GL_DeleteContext(ctx);
|
||||||
threadData->rqTermAck = true;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue