Do not use GLEW if USE_GLES is defined

GLEW does not support OpenGL ES so it shouldn't be used when targetting
OpenGL ES.
This commit is contained in:
kichikuou
2021-12-21 13:11:34 +09:00
parent cd34311c62
commit 2f64ee4d21
10 changed files with 42 additions and 14 deletions
+1 -1
View File
@@ -20,7 +20,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <GL/glew.h>
#include "gfx/gl.h"
struct page;
struct dgn;
+1 -1
View File
@@ -18,7 +18,7 @@
#define SYSTEM4_DUNGEON_RENDERER_H
#include <cglm/cglm.h>
#include <GL/glew.h>
#include "gfx/gl.h"
struct dgn_cell;
struct dtx;
+1 -1
View File
@@ -20,7 +20,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <SDL.h>
#include <GL/glew.h>
#include "gfx/gl.h"
#include "gfx/types.h"
struct cg;
+31
View File
@@ -0,0 +1,31 @@
/* Copyright (C) 2021 kichikuou <KichikuouChrome@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://gnu.org/licenses/>.
*/
#ifndef SYSTEM4_GFX_GL_H
#define SYSTEM4_GFX_GL_H
/*
* Define this to target OpenGL ES 3.0.
*/
//#define USE_GLES
#ifdef USE_GLES
#include <GLES3/gl3.h>
#else
#include <GL/glew.h>
#endif
#endif /* SYSTEM4_GFX_GL_H */
+1 -1
View File
@@ -22,7 +22,7 @@
#include <stdbool.h>
#include <SDL.h>
#include <GL/glew.h>
#include "gfx/gl.h"
struct sdl_private {
SDL_Window *window;
+1 -1
View File
@@ -16,7 +16,7 @@
#include <math.h>
#include <SDL.h>
#include <GL/glew.h>
#include "gfx/gl.h"
#include <cglm/cglm.h>
#include "gfx/gfx.h"
+1 -1
View File
@@ -19,7 +19,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <cglm/cglm.h>
#include <GL/glew.h>
#include "gfx/gl.h"
#include "system4.h"
#include "system4/alk.h"
#include "system4/archive.h"
+1 -1
View File
@@ -18,7 +18,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <cglm/cglm.h>
#include <GL/glew.h>
#include "gfx/gl.h"
#include "system4.h"
#include "system4/buffer.h"
#include "system4/cg.h"
+1 -1
View File
@@ -15,7 +15,7 @@
*/
#include <stdlib.h>
#include <GL/glew.h>
#include "gfx/gl.h"
#include "system4.h"
#include "system4/cg.h"
+3 -6
View File
@@ -16,7 +16,7 @@
*/
#include <SDL.h>
#include <GL/glew.h>
#include "gfx/gl.h"
#include <cglm/cglm.h>
#include <string.h>
#include <errno.h>
@@ -33,11 +33,6 @@
struct sdl_private sdl;
/*
* Define this to target OpenGL ES 3.0.
*/
//#define USE_GLES
static const GLchar glsl_preamble[] =
#ifdef USE_GLES
"#version 300 es\n"
@@ -218,10 +213,12 @@ int gfx_init(void)
if (!sdl.gl.context)
ERROR("SDL_GL_CreateContext failed: %s", SDL_GetError());
#ifndef USE_GLES
glewExperimental = GL_TRUE;
GLenum err = glewInit();
if (err != GLEW_OK && err != GLEW_ERROR_NO_GLX_DISPLAY)
ERROR("glewInit failed");
#endif
SDL_GL_SetSwapInterval(0);
gl_initialize();