Handle failures to create an OpenGL context better
This commit is contained in:
parent
ca92c51f51
commit
b1edf540d8
10
SDL/main.c
10
SDL/main.c
@ -450,6 +450,16 @@ usage:
|
|||||||
SDL_SetWindowMinimumSize(window, 160, 144);
|
SDL_SetWindowMinimumSize(window, 160, 144);
|
||||||
|
|
||||||
SDL_GLContext gl_context = SDL_GL_CreateContext(window);
|
SDL_GLContext gl_context = SDL_GL_CreateContext(window);
|
||||||
|
|
||||||
|
GLint major, minor;
|
||||||
|
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
||||||
|
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
||||||
|
|
||||||
|
if (major * 0x100 + minor < 0x302) {
|
||||||
|
SDL_GL_DeleteContext(gl_context);
|
||||||
|
gl_context = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (gl_context == NULL) {
|
if (gl_context == NULL) {
|
||||||
renderer = SDL_CreateRenderer(window, -1, 0);
|
renderer = SDL_CreateRenderer(window, -1, 0);
|
||||||
texture = SDL_CreateTexture(renderer, SDL_GetWindowPixelFormat(window), SDL_TEXTUREACCESS_STREAMING, 160, 144);
|
texture = SDL_CreateTexture(renderer, SDL_GetWindowPixelFormat(window), SDL_TEXTUREACCESS_STREAMING, 160, 144);
|
||||||
|
@ -65,6 +65,14 @@ static GLuint create_program(const char *vsh, const char *fsh)
|
|||||||
|
|
||||||
bool init_shader_with_name(shader_t *shader, const char *name)
|
bool init_shader_with_name(shader_t *shader, const char *name)
|
||||||
{
|
{
|
||||||
|
GLint major, minor;
|
||||||
|
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
||||||
|
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
||||||
|
|
||||||
|
if (major * 0x100 + minor < 0x302) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static char master_shader_code[0x801] = {0,};
|
static char master_shader_code[0x801] = {0,};
|
||||||
static char shader_code[0x10001] = {0,};
|
static char shader_code[0x10001] = {0,};
|
||||||
static char final_shader_code[0x10801] = {0,};
|
static char final_shader_code[0x10801] = {0,};
|
||||||
|
Loading…
Reference in New Issue
Block a user