mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 13:35:12 +00:00
check GL version in the GL2.1 backend; check GLEW errors
This commit is contained in:
parent
180db16da8
commit
8d05d2b7e2
2 changed files with 29 additions and 7 deletions
|
@ -479,14 +479,34 @@ static void gfx_opengl_draw_triangles(float buf_vbo[], size_t buf_vbo_len, size_
|
|||
glDrawArrays(GL_TRIANGLES, 0, 3 * buf_vbo_num_tris);
|
||||
}
|
||||
|
||||
static inline bool gl_get_version(int *major, int *minor, bool *is_es) {
|
||||
const char *vstr = (const char *)glGetString(GL_VERSION);
|
||||
if (!vstr || !vstr[0]) return false;
|
||||
|
||||
if (!strncmp(vstr, "OpenGL ES ", 10)) {
|
||||
vstr += 10;
|
||||
*is_es = true;
|
||||
} else if (!strncmp(vstr, "OpenGL ES-CM ", 13)) {
|
||||
vstr += 13;
|
||||
*is_es = true;
|
||||
}
|
||||
|
||||
return (sscanf(vstr, "%d.%d", major, minor) == 2);
|
||||
}
|
||||
|
||||
static void gfx_opengl_init(void) {
|
||||
#if FOR_WINDOWS
|
||||
glewInit();
|
||||
#if FOR_WINDOWS || defined(OSX_BUILD)
|
||||
GLenum err;
|
||||
if ((err = glewInit()) != GLEW_OK)
|
||||
sys_fatal("could not init GLEW:\n%s", glewGetErrorString(err));
|
||||
#endif
|
||||
|
||||
#ifdef OSX_BUILD
|
||||
glewInit();
|
||||
#endif
|
||||
// check GL version
|
||||
int vmajor, vminor;
|
||||
bool is_es = false;
|
||||
gl_get_version(&vmajor, &vminor, &is_es);
|
||||
if (vmajor < 2 && vminor < 1 && !is_es)
|
||||
sys_fatal("OpenGL 2.1+ is required.\nReported version: %s%d.%d", is_es ? "ES" : "", vmajor, vminor);
|
||||
|
||||
glGenBuffers(1, &opengl_vbo);
|
||||
|
||||
|
|
|
@ -510,7 +510,9 @@ static inline bool gl_get_version(int *major, int *minor, bool *is_es) {
|
|||
|
||||
static void gfx_opengl_init(void) {
|
||||
#if FOR_WINDOWS || defined(OSX_BUILD)
|
||||
glewInit();
|
||||
GLenum err;
|
||||
if ((err = glewInit()) != GLEW_OK)
|
||||
sys_fatal("could not init GLEW:\n%s", glewGetErrorString(err));
|
||||
#endif
|
||||
|
||||
// check GL version
|
||||
|
@ -518,7 +520,7 @@ static void gfx_opengl_init(void) {
|
|||
bool is_es = false;
|
||||
gl_get_version(&vmajor, &vminor, &is_es);
|
||||
if (vmajor < 2 && vminor < 2 && !is_es)
|
||||
sys_fatal("OpenGL 1.2+ is required. Reported version: %s%d.%d\n", is_es ? "ES" : "", vmajor, vminor);
|
||||
sys_fatal("OpenGL 1.2+ is required.\nReported version: %s%d.%d", is_es ? "ES" : "", vmajor, vminor);
|
||||
|
||||
// check extensions that we need
|
||||
const bool supported =
|
||||
|
|
Loading…
Reference in a new issue