diff --git a/include/gfx/private.h b/include/gfx/private.h index b25e81c..ccf166b 100644 --- a/include/gfx/private.h +++ b/include/gfx/private.h @@ -29,6 +29,7 @@ struct sdl_private { SDL_PixelFormat *format; struct { SDL_GLContext context; + GLuint vao; GLuint vbo; GLuint ibo; } gl; diff --git a/shaders/blend_amap_alpha.f.glsl b/shaders/blend_amap_alpha.f.glsl index 960ceeb..6adb70b 100644 --- a/shaders/blend_amap_alpha.f.glsl +++ b/shaders/blend_amap_alpha.f.glsl @@ -16,14 +16,14 @@ #version 140 -uniform sampler2D texture; +uniform sampler2D tex; uniform float threshold; in vec2 tex_coord; out vec4 frag_color; void main() { - vec4 texel = texture2D(texture, tex_coord); + vec4 texel = texture(tex, tex_coord); texel.a *= threshold; frag_color = texel; } diff --git a/shaders/copy.f.glsl b/shaders/copy.f.glsl index 993521b..6363711 100644 --- a/shaders/copy.f.glsl +++ b/shaders/copy.f.glsl @@ -16,11 +16,11 @@ #version 140 -uniform sampler2D texture; +uniform sampler2D tex; in vec2 tex_coord; out vec4 frag_color; void main() { - frag_color = texture2D(texture, tex_coord); + frag_color = texture(tex, tex_coord); } diff --git a/shaders/copy_key.f.glsl b/shaders/copy_key.f.glsl index 6880e1e..4ab69e4 100644 --- a/shaders/copy_key.f.glsl +++ b/shaders/copy_key.f.glsl @@ -16,14 +16,14 @@ #version 140 -uniform sampler2D texture; +uniform sampler2D tex; uniform vec4 color; in vec2 tex_coord; out vec4 frag_color; void main() { - vec4 texel = texture2D(texture, tex_coord); + vec4 texel = texture(tex, tex_coord); if (texel.rgb == color.rgb) discard; frag_color = texel; diff --git a/shaders/copy_use_amap_border.f.glsl b/shaders/copy_use_amap_border.f.glsl index 3e1c72c..ef1f4da 100644 --- a/shaders/copy_use_amap_border.f.glsl +++ b/shaders/copy_use_amap_border.f.glsl @@ -16,14 +16,14 @@ #version 140 -uniform sampler2D texture; +uniform sampler2D tex; uniform float threshold; in vec2 tex_coord; out vec4 frag_color; void main() { - vec4 texel = texture2D(texture, tex_coord); + vec4 texel = texture(tex, tex_coord); if (texel.a < threshold) discard; frag_color = texel; diff --git a/shaders/copy_use_amap_under.f.glsl b/shaders/copy_use_amap_under.f.glsl index c9d0ab6..342713c 100644 --- a/shaders/copy_use_amap_under.f.glsl +++ b/shaders/copy_use_amap_under.f.glsl @@ -16,14 +16,14 @@ #version 140 -uniform sampler2D texture; +uniform sampler2D tex; uniform float threshold; in vec2 tex_coord; out vec4 frag_color; void main() { - vec4 texel = texture2D(texture, tex_coord); + vec4 texel = texture(tex, tex_coord); if (texel.w > threshold) discard; frag_color = texel; diff --git a/shaders/hitbox.f.glsl b/shaders/hitbox.f.glsl index 71e75ad..d0602b6 100644 --- a/shaders/hitbox.f.glsl +++ b/shaders/hitbox.f.glsl @@ -16,7 +16,7 @@ #version 140 -uniform sampler2D texture; +uniform sampler2D tex; uniform vec2 bot_left; uniform vec2 top_right; @@ -29,11 +29,11 @@ float point_in_rect(vec2 p, vec2 bot_left, vec2 top_right) { } void main() { - ivec2 size = textureSize(texture, 0); + ivec2 size = textureSize(tex, 0); vec2 tex_bot_left = bot_left / size; vec2 tex_top_right = top_right / size; - vec4 texel = texture2D(texture, tex_coord); + vec4 texel = texture(tex, tex_coord); float t = point_in_rect(tex_coord, tex_bot_left, tex_top_right); frag_color = t * texel + (1 - t) * vec4(0, 0, 0, 0); } diff --git a/shaders/hitbox_noblend.f.glsl b/shaders/hitbox_noblend.f.glsl index 768fb04..9c13e00 100644 --- a/shaders/hitbox_noblend.f.glsl +++ b/shaders/hitbox_noblend.f.glsl @@ -16,7 +16,7 @@ #version 140 -uniform sampler2D texture; +uniform sampler2D tex; uniform vec2 bot_left; uniform vec2 top_right; @@ -29,11 +29,11 @@ float point_in_rect(vec2 p, vec2 bot_left, vec2 top_right) { } void main() { - ivec2 size = textureSize(texture, 0); + ivec2 size = textureSize(tex, 0); vec2 tex_bot_left = bot_left / size; vec2 tex_top_right = top_right / size; - vec4 texel = texture2D(texture, tex_coord); + vec4 texel = texture(tex, tex_coord); texel.a = 1; float t = point_in_rect(tex_coord, tex_bot_left, tex_top_right); frag_color = t * texel + (1 - t) * vec4(0, 0, 0, 0); diff --git a/shaders/render.f.glsl b/shaders/render.f.glsl index a022ea4..d3f73ae 100644 --- a/shaders/render.f.glsl +++ b/shaders/render.f.glsl @@ -16,13 +16,13 @@ #version 140 -uniform sampler2D texture; +uniform sampler2D tex; uniform float alpha_mod; in vec2 tex_coord; out vec4 frag_color; void main() { - frag_color = texture2D(texture, tex_coord); + frag_color = texture(tex, tex_coord); frag_color.a *= alpha_mod; } diff --git a/src/video.c b/src/video.c index 2678c5a..7e73791 100644 --- a/src/video.c +++ b/src/video.c @@ -105,7 +105,7 @@ void gfx_load_shader(struct shader *dst, const char *vertex_shader_path, const c dst->program = program; dst->world_transform = glGetUniformLocation(program, "world_transform"); dst->view_transform = glGetUniformLocation(program, "view_transform"); - dst->texture = glGetUniformLocation(program, "texture"); + dst->texture = glGetUniformLocation(program, "tex"); dst->vertex = glGetAttribLocation(program, "vertex_pos"); dst->alpha_mod = glGetAttribLocation(program, "alpha_mod"); dst->prepare = NULL; @@ -128,6 +128,9 @@ static int gl_initialize(void) GLuint index_data[] = { 0, 1, 2, 3 }; + glGenVertexArrays(1, &sdl.gl.vao); + glBindVertexArray(sdl.gl.vao); + glGenBuffers(1, &sdl.gl.vbo); glBindBuffer(GL_ARRAY_BUFFER, sdl.gl.vbo); glBufferData(GL_ARRAY_BUFFER, 4 * 4 * sizeof(GLfloat), vertex_data, GL_STATIC_DRAW); diff --git a/subprojects/libsys4 b/subprojects/libsys4 index 605d782..b4bd43e 160000 --- a/subprojects/libsys4 +++ b/subprojects/libsys4 @@ -1 +1 @@ -Subproject commit 605d7823d38d529305a7a0a7ffdc5f1b636fd0dc +Subproject commit b4bd43e519771f3af3ac6ec656dfd2a0bb23e865