Skip to content
Permalink
Browse files

hackish static linking mode for GLES3 (webgl; not really good for any…

…thing else)
  • Loading branch information...
Akaricchi committed Sep 9, 2019
1 parent 7d5830a commit c0d0ca97100d5f72148a7ebeeacd656ecd7a684c
@@ -236,13 +236,15 @@ static void gl33_set_viewport(const FloatRect *vp) {
glViewport(vp->x, vp->y, vp->w, vp->h);
}

#ifndef STATIC_GLES3
static void gl41_get_viewport(FloatRect *vp) {
glGetFloati_v(GL_VIEWPORT, 0, &vp->x);
}

static void gl41_set_viewport(const FloatRect *vp) {
glViewportIndexedfv(0, &vp->x);
}
#endif

static void gl33_init_context(SDL_Window *window) {
R.gl_context = SDL_GL_CreateContext(window);
@@ -252,7 +254,7 @@ static void gl33_init_context(SDL_Window *window) {
}

glcommon_load_functions();
glcommon_check_extensions();
glcommon_check_capabilities();

if(glcommon_debug_requested()) {
glcommon_debug_enable();
@@ -262,13 +264,18 @@ static void gl33_init_context(SDL_Window *window) {
gl33_set_clear_depth(1);
gl33_set_clear_color(RGBA(0, 0, 0, 0));

#ifdef STATIC_GLES3
GLVT.get_viewport = gl33_get_viewport;
GLVT.set_viewport = gl33_set_viewport;
#else
if(glext.viewport_array) {
GLVT.get_viewport = gl41_get_viewport;
GLVT.set_viewport = gl41_set_viewport;
} else {
GLVT.get_viewport = gl33_get_viewport;
GLVT.set_viewport = gl33_set_viewport;
}
#endif

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
@@ -941,7 +948,11 @@ static void gl33_draw(VertexArray *varr, Primitive prim, uint firstvert, uint co

if(instances) {
if(base_instance) {
#ifdef STATIC_GLES3
log_fatal("base_instance is not supported");
#else
glDrawArraysInstancedBaseInstance(gl_prim, firstvert, count, instances, base_instance);
#endif
} else {
glDrawArraysInstanced(gl_prim, firstvert, count, instances);
}
@@ -964,7 +975,11 @@ static void gl33_draw_indexed(VertexArray *varr, Primitive prim, uint firstidx,

if(instances) {
if(base_instance) {
#ifdef STATIC_GLES3
log_fatal("base_instance is not supported");
#else
glDrawElementsInstancedBaseInstance(gl_prim, count, GL33_IBO_GL_DATATYPE, (void*)iofs, instances, base_instance);
#endif
} else {
glDrawElementsInstanced(gl_prim, count, GL33_IBO_GL_DATATYPE, (void*)iofs, instances);
}
@@ -79,7 +79,7 @@ ShaderObject* gl33_shader_object_compile(ShaderSource *source) {

glCompileShader(gl_handle);

#ifdef DEBUG
#if defined DEBUG && !defined STATIC_GLES3
if(GLAD_GL_ANGLE_translated_shader_source) {
GLint srclen;
glGetShaderiv(gl_handle, GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE, &srclen);
@@ -363,9 +363,13 @@ void gl33_texture_fill_region(Texture *tex, uint mipmap, uint x, uint y, const P
}

void gl44_texture_clear(Texture *tex, const Color *clr) {
#ifdef STATIC_GLES3
UNREACHABLE;
#else
for(int i = 0; i < tex->params.mipmaps; ++i) {
glClearTexImage(tex->gl_handle, i, GL_RGBA, GL_FLOAT, &clr->r);
}
#endif
}

void gl33_texture_clear(Texture *tex, const Color *clr) {
@@ -12,6 +12,8 @@
#include "util.h"
#include "../api.h"

#ifndef STATIC_GLES3

static void APIENTRY glcommon_debug(
GLenum source,
GLenum type,
@@ -95,6 +97,16 @@ void glcommon_debug_object_label(GLenum identifier, GLuint name, const char *lab
}
}

#else

void glcommon_debug_object_label(GLenum identifier, GLuint name, const char *label) { }

void glcommon_debug_enable(void) {
log_error("OpenGL debugging is not supported on your system");
}

#endif

bool glcommon_debug_requested(void) {
return env_get("TAISEI_GL_DEBUG", DEBUG_GL_DEFAULT);
}
@@ -6,4 +6,8 @@ r_glcommon_src = files(
'texture.c',
)

r_glcommon_libdeps = [dep_glad]
r_glcommon_libdeps = []

if not static_gles30
r_glcommon_libdeps += dep_glad
endif

0 comments on commit c0d0ca9

Please sign in to comment.
You can’t perform that action at this time.