summaryrefslogtreecommitdiff
path: root/src/tex.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-10-10 20:13:14 -0700
committerVito Caputo <vcaputo@pengaru.com>2022-11-29 13:16:47 -0800
commita18c8c422d25fa96d3df96758a38e44f47514acb (patch)
tree95436a5f2afed05c566ec874cd0b337e0d90aac9 /src/tex.c
parente8a92941b0bf045fa7c330e759712968bd0c334e (diff)
*: pivot everything to OpenGL ES 2.0
In the interests of keeping things bisectable this is one big commit of everything necessary to go from OpenGL 2.1 to OpenGL ES 2.0 in one fell swoop. There's a handful of annoying mechanical changes necessary in shaders like removing the 'f' suffix on float constants e.g. 1.f becomes 1.0 etc. This is primarily happening to enable emscripten builds
Diffstat (limited to 'src/tex.c')
-rw-r--r--src/tex.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/tex.c b/src/tex.c
index af110f0..56750d5 100644
--- a/src/tex.c
+++ b/src/tex.c
@@ -51,7 +51,7 @@ static const float texcoords[] = {
static const char *tex_vs = ""
- "#version 120\n"
+ "#version 100\n"
"uniform mat4 model_x;"
"uniform mat4 projection_x;"
@@ -59,23 +59,28 @@ static const char *tex_vs = ""
"attribute vec3 vertex;"
"attribute vec2 texcoord;"
+ "varying vec2 UV;"
+
"void main()"
"{"
- " gl_TexCoord[0].xy = texcoord;"
- " gl_Position = projection_x * model_x * vec4(vertex, 1.f);"
+ " UV = texcoord;"
+ " gl_Position = projection_x * model_x * vec4(vertex, 1.0);"
"}"
"";
static const char *tex_fs = ""
- "#version 120\n"
+ "#version 100\n"
+ "precision mediump float;"
"uniform sampler2D tex0;"
"uniform float alpha;"
+ "varying vec2 UV;"
+
"void main()"
"{"
- " gl_FragColor = texture2D(tex0, gl_TexCoord[0].st);"
+ " gl_FragColor = texture2D(tex0, UV);"
" gl_FragColor.a *= alpha;"
"}"
"";
@@ -159,11 +164,10 @@ tex_t * tex_new(int width, int height, const unsigned char *buf)
/* transparent border pixels outside of the texture boundaries, this
* eliminates the spurious fringing on some sprites/positions */
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
- glTexParameterfv(GL_TEXTURE_3D, GL_TEXTURE_BORDER_COLOR, (float[4]){});
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
glBindTexture(GL_TEXTURE_2D, 0);
tex->refcnt = 1;
© All Rights Reserved