Remove ES3 Support

This commit is contained in:
TheBrokenRail 2024-06-18 17:31:58 -04:00
parent 3ee682f6f2
commit 4156520e88
11 changed files with 3 additions and 200 deletions

View File

@ -11,20 +11,10 @@ if(GLES_COMPATIBILITY_LAYER_USE_DEFAULT_INCLUDE_PATH)
target_include_directories(gles-compatibility-layer PUBLIC include) target_include_directories(gles-compatibility-layer PUBLIC include)
endif() endif()
# GL Version
option(GLES_COMPATIBILITY_LAYER_USE_ES3 "Use OpenGL ES 3" TRUE)
if(GLES_COMPATIBILITY_LAYER_USE_ES3)
target_compile_definitions(gles-compatibility-layer PUBLIC GLES_COMPATIBILITY_LAYER_USE_ES3)
endif()
# Shaders # Shaders
include(cmake/util.cmake) include(cmake/util.cmake)
set(SHADER_FOLDER "es2") embed_resource(gles-compatibility-layer "src/shaders/main.vsh")
if(GLES_COMPATIBILITY_LAYER_USE_ES3) embed_resource(gles-compatibility-layer "src/shaders/main.fsh")
set(SHADER_FOLDER "es3")
endif()
embed_resource(gles-compatibility-layer "src/shaders/${SHADER_FOLDER}/main.vsh")
embed_resource(gles-compatibility-layer "src/shaders/${SHADER_FOLDER}/main.fsh")
# Warnings # Warnings
target_compile_options(gles-compatibility-layer PRIVATE -Wall -Wextra -Werror -Wpointer-arith -Wshadow -Wnull-dereference) target_compile_options(gles-compatibility-layer PRIVATE -Wall -Wextra -Werror -Wpointer-arith -Wshadow -Wnull-dereference)

View File

@ -172,20 +172,6 @@ void glLightfv(GLenum light, GLenum pname, const GLfloat *params);
void glLightModelfv(GLenum pname, const GLfloat *params); void glLightModelfv(GLenum pname, const GLfloat *params);
void glPixelStorei(GLenum pname, GLint param); void glPixelStorei(GLenum pname, GLint param);
// Not Part Of OpenGL ES 1.1
#ifdef GLES_COMPATIBILITY_LAYER_USE_ES3
#define GL_SAMPLES_PASSED_ARB 0x8c2f // GL_ANY_SAMPLES_PASSED
#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 // GL_QUERY_RESULT_AVAILABLE
#define GL_QUERY_RESULT_ARB 0x8866 // GL_QUERY_RESULT
void glGenQueriesARB(GLsizei n, GLuint *ids);
void glDeleteQueriesARB(GLsizei n, const GLuint *ids);
void glBeginQueryARB(GLenum target, GLuint id);
void glEndQueryARB(GLenum target);
void glGetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params);
#endif
void extra_enable_highlight_mode(float red, float green, float blue, float alpha);
void extra_disable_highlight_mode();
// Init // Init
typedef void *(*getProcAddress_t)(const char *); typedef void *(*getProcAddress_t)(const char *);
void init_gles_compatibility_layer(getProcAddress_t); void init_gles_compatibility_layer(getProcAddress_t);

View File

@ -115,10 +115,6 @@ static GLuint get_shader() {
} }
// Init // Init
#ifdef GLES_COMPATIBILITY_LAYER_USE_ES3
GL_FUNC(glGenVertexArrays, void, (GLsizei n, GLuint *arrays));
GL_FUNC(glBindVertexArray, void, (GLuint array));
#endif
void init_gles_compatibility_layer(getProcAddress_t new_getProcAddress) { void init_gles_compatibility_layer(getProcAddress_t new_getProcAddress) {
// Setup Passthrough // Setup Passthrough
getProcAddress = new_getProcAddress; getProcAddress = new_getProcAddress;
@ -129,13 +125,6 @@ void init_gles_compatibility_layer(getProcAddress_t new_getProcAddress) {
// Reset Static Variables // Reset Static Variables
reset_variables(); reset_variables();
// Setup VAO
#ifdef GLES_COMPATIBILITY_LAYER_USE_ES3
GLuint vao;
real_glGenVertexArrays()(1, &vao);
real_glBindVertexArray()(vao);
#endif
// Load Shader // Load Shader
GLuint program = get_shader(); GLuint program = get_shader();
real_glUseProgram()(program); real_glUseProgram()(program);
@ -220,14 +209,6 @@ void glDrawArrays(GLenum mode, GLint first, GLsizei count) {
real_glVertexAttrib4f()(a_color_handle, gl_state.color.red, gl_state.color.green, gl_state.color.blue, gl_state.color.alpha); real_glVertexAttrib4f()(a_color_handle, gl_state.color.red, gl_state.color.green, gl_state.color.blue, gl_state.color.alpha);
} }
// Highlight Mode
lazy_uniform(u_highlight_mode);
real_glUniform1i()(u_highlight_mode_handle, gl_state.highlight_mode.enabled);
if (gl_state.highlight_mode.enabled) {
lazy_uniform(u_highlight_mode_color);
real_glUniform4f()(u_highlight_mode_color_handle, gl_state.highlight_mode.color.red, gl_state.highlight_mode.color.green, gl_state.highlight_mode.color.blue, gl_state.highlight_mode.color.alpha);
}
// Lighting // Lighting
lazy_uniform(u_lighting); lazy_uniform(u_lighting);
real_glUniform1i()(u_lighting_handle, gl_state.lighting.enabled); real_glUniform1i()(u_lighting_handle, gl_state.lighting.enabled);

View File

@ -121,28 +121,6 @@ GL_FUNC(glBufferSubData, void, (GLenum target, GLintptr offset, GLsizeiptr size,
void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void *data) { void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void *data) {
real_glBufferSubData()(target, offset, size, data); real_glBufferSubData()(target, offset, size, data);
} }
#ifdef GLES_COMPATIBILITY_LAYER_USE_ES3
GL_FUNC(glGenQueries, void, (GLsizei n, GLuint *ids));
void glGenQueriesARB(GLsizei n, GLuint *ids) {
real_glGenQueries()(n, ids);
}
GL_FUNC(glDeleteQueries, void, (GLsizei n, const GLuint *ids));
void glDeleteQueriesARB(GLsizei n, const GLuint *ids) {
real_glDeleteQueries()(n, ids);
}
GL_FUNC(glBeginQuery, void, (GLenum target, GLuint id));
void glBeginQueryARB(GLenum target, GLuint id) {
real_glBeginQuery()(target, id);
}
GL_FUNC(glEndQuery, void, (GLenum target));
void glEndQueryARB(GLenum target) {
real_glEndQuery()(target);
}
GL_FUNC(glGetQueryObjectuiv, void, (GLuint id, GLenum pname, GLuint *params));
void glGetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params) {
real_glGetQueryObjectuiv()(id, pname, params);
}
#endif
GL_FUNC(glPixelStorei, void, (GLenum pname, GLint param)); GL_FUNC(glPixelStorei, void, (GLenum pname, GLint param));
void glPixelStorei(GLenum pname, GLint param) { void glPixelStorei(GLenum pname, GLint param) {
real_glPixelStorei()(pname, param); real_glPixelStorei()(pname, param);

View File

@ -1,52 +0,0 @@
#version 300 es
precision highp float;
// Result
out vec4 frag_color;
// Texture
uniform bool u_has_texture;
uniform sampler2D u_texture_unit;
// Color
in vec4 v_color;
in vec4 v_texture_pos;
// Highlight Mode
uniform bool u_highlight_mode;
uniform vec4 u_highlight_mode_color;
// Alpha Test
uniform bool u_alpha_test;
// Fog
uniform bool u_fog;
uniform vec4 u_fog_color;
uniform bool u_fog_is_linear;
uniform float u_fog_start;
uniform float u_fog_end;
in vec4 v_fog_eye_position;
// Main
void main(void) {
frag_color = v_color;
// Texture
if (u_has_texture) {
vec4 texture_color = texture(u_texture_unit, v_texture_pos.xy);
if (u_highlight_mode) {
texture_color.rgb = u_highlight_mode_color.rgb;
texture_color.a *= u_highlight_mode_color.a;
frag_color = texture_color;
} else {
frag_color *= texture_color;
}
}
// Fog
if (u_fog) {
float fog_factor;
if (u_fog_is_linear) {
fog_factor = (u_fog_end - length(v_fog_eye_position)) / (u_fog_end - u_fog_start);
} else {
fog_factor = exp(-u_fog_start * length(v_fog_eye_position));
}
fog_factor = clamp(fog_factor, 0.0, 1.0);
frag_color.rgb = mix(frag_color, u_fog_color, 1.0 - fog_factor).rgb;
}
// Alpha Test
if (u_alpha_test && frag_color.a <= 0.1) {
discard;
}
}

View File

@ -1,48 +0,0 @@
#version 300 es
precision highp float;
// Matrices
uniform mat4 u_projection;
uniform mat4 u_model_view;
uniform mat4 u_texture;
// Texture
in vec3 a_vertex_coords;
in vec2 a_texture_coords;
out vec4 v_texture_pos;
// Color
in vec4 a_color;
out vec4 v_color;
// Normal
in vec3 a_normal;
uniform float u_normal_rescale_factor;
// Lighting
uniform bool u_lighting;
uniform vec4 u_lighting_ambient;
uniform bool u_lighting_light_source_0;
uniform vec3 u_lighting_light_source_0_position;
uniform vec4 u_lighting_light_source_0_diffuse;
uniform bool u_lighting_light_source_1;
uniform vec3 u_lighting_light_source_1_position;
uniform vec4 u_lighting_light_source_1_diffuse;
// Fog
out vec4 v_fog_eye_position;
// Main
void main(void) {
v_texture_pos = u_texture * vec4(a_texture_coords.xy, 0.0, 1.0);
gl_Position = u_projection * u_model_view * vec4(a_vertex_coords.xyz, 1.0);
v_color = a_color;
v_fog_eye_position = u_model_view * vec4(a_vertex_coords.xyz, 1.0);
// Lighting
if (u_lighting) {
vec4 transformed_normal = u_model_view * vec4(a_normal, 0.0) * u_normal_rescale_factor;
vec4 total_light = u_lighting_ambient;
if (u_lighting_light_source_0) {
total_light += max(0.0, dot(transformed_normal.xyz, u_lighting_light_source_0_position)) * u_lighting_light_source_0_diffuse;
}
if (u_lighting_light_source_1) {
total_light += max(0.0, dot(transformed_normal.xyz, u_lighting_light_source_1_position)) * u_lighting_light_source_1_diffuse;
}
total_light = clamp(total_light, 0.0, 1.0);
v_color *= total_light;
}
}

View File

@ -6,9 +6,6 @@ uniform sampler2D u_texture_unit;
// Color // Color
varying vec4 v_color; varying vec4 v_color;
varying vec4 v_texture_pos; varying vec4 v_texture_pos;
// Highlight Mode
uniform bool u_highlight_mode;
uniform vec4 u_highlight_mode_color;
// Alpha Test // Alpha Test
uniform bool u_alpha_test; uniform bool u_alpha_test;
// Fog // Fog
@ -24,14 +21,8 @@ void main(void) {
// Texture // Texture
if (u_has_texture) { if (u_has_texture) {
vec4 texture_color = texture2D(u_texture_unit, v_texture_pos.xy); vec4 texture_color = texture2D(u_texture_unit, v_texture_pos.xy);
if (u_highlight_mode) {
texture_color.rgb = u_highlight_mode_color.rgb;
texture_color.a *= u_highlight_mode_color.a;
gl_FragColor = texture_color;
} else {
gl_FragColor *= texture_color; gl_FragColor *= texture_color;
} }
}
// Fog // Fog
if (u_fog) { if (u_fog) {
float fog_factor; float fog_factor;

View File

@ -81,9 +81,6 @@ static gl_state_t init_gl_state = {
.blue = 0.2f, .blue = 0.2f,
.alpha = 0.2f .alpha = 0.2f
} }
},
.highlight_mode = {
.enabled = 0
} }
}; };
gl_state_t gl_state; gl_state_t gl_state;
@ -322,15 +319,3 @@ void glLightModelfv(GLenum pname, const GLfloat *params) {
gl_state.lighting.ambient.alpha = params[3]; gl_state.lighting.ambient.alpha = params[3];
} }
} }
// Highlight Mode
void extra_enable_highlight_mode(float red, float green, float blue, float alpha) {
gl_state.highlight_mode.enabled = 1;
gl_state.highlight_mode.color.red = red;
gl_state.highlight_mode.color.green = green;
gl_state.highlight_mode.color.blue = blue;
gl_state.highlight_mode.color.alpha = alpha;
}
void extra_disable_highlight_mode() {
gl_state.highlight_mode.enabled = 0;
}

View File

@ -71,10 +71,6 @@ typedef struct {
light_source_t light_sources[2]; light_source_t light_sources[2];
color_t ambient; color_t ambient;
} lighting; } lighting;
struct {
GLboolean enabled;
color_t color;
} highlight_mode;
} gl_state_t; } gl_state_t;
extern gl_state_t gl_state; extern gl_state_t gl_state;
void _init_gles_compatibility_layer_state(); void _init_gles_compatibility_layer_state();

View File

@ -50,11 +50,7 @@ static void load_header(std::string filename) {
} }
static void load_headers() { static void load_headers() {
header_lines.clear(); header_lines.clear();
#ifdef GLES_COMPATIBILITY_LAYER_USE_ES3
load_header("/usr/include/GLES3/gl3.h");
#else
load_header("/usr/include/GLES2/gl2.h"); load_header("/usr/include/GLES2/gl2.h");
#endif
} }
// Run Test // Run Test