mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-09-30 02:48:14 +03:00
Merge pull request #38 from kichikuou/use_gles
Use OpenGL ES directly if `USE_GLES` is defined
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
@@ -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;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/* 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
|
||||
|
||||
#ifdef USE_GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
|
||||
#endif /* SYSTEM4_GFX_GL_H */
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <SDL.h>
|
||||
#include <GL/glew.h>
|
||||
#include "gfx/gl.h"
|
||||
|
||||
struct sdl_private {
|
||||
SDL_Window *window;
|
||||
|
||||
+10
-2
@@ -8,14 +8,22 @@ libm = meson.get_compiler('c').find_library('m', required: false)
|
||||
sdl2 = dependency('sdl2')
|
||||
sdl2ttf = dependency('SDL2_ttf')
|
||||
ffi = dependency('libffi')
|
||||
gl = dependency('GL')
|
||||
glew = dependency('glew')
|
||||
tj = dependency('libturbojpeg')
|
||||
webp = dependency('libwebp')
|
||||
png = dependency('libpng')
|
||||
cglm = dependency('cglm', fallback : ['cglm', 'cglm_dep'])
|
||||
sndfile = dependency('sndfile')
|
||||
|
||||
if get_option('use_gles')
|
||||
gles = dependency('glesv2')
|
||||
gl_deps = [gles]
|
||||
add_project_arguments('-DUSE_GLES', language : 'c')
|
||||
else
|
||||
gl = dependency('GL')
|
||||
glew = dependency('glew')
|
||||
gl_deps = [gl, glew]
|
||||
endif
|
||||
|
||||
chibi = dependency('chibi-scheme', required : get_option('debugger'))
|
||||
|
||||
flex = find_program('flex')
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
option('debugger', type : 'feature', value : 'auto')
|
||||
option('use_gles', type : 'boolean', value : false, description : 'Target OpenGL ES 3.0')
|
||||
|
||||
+1
-1
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <GL/glew.h>
|
||||
#include "gfx/gl.h"
|
||||
#include "system4.h"
|
||||
#include "system4/cg.h"
|
||||
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ xsystem4 = ['audio.c',
|
||||
'hll/VSFile.c',
|
||||
]
|
||||
|
||||
xsystem4_deps = [libm, zlib, sdl2, sdl2ttf, ffi, gl, glew, cglm, sndfile, libsys4_dep]
|
||||
xsystem4_deps = [libm, zlib, sdl2, sdl2ttf, ffi, cglm, sndfile, libsys4_dep] + gl_deps
|
||||
|
||||
if chibi.found()
|
||||
xsystem4_deps += chibi
|
||||
|
||||
+3
-6
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user