diff --git a/src/eglapp.cpp b/src/eglapp.cpp index 94a3b404..67335295 100644 --- a/src/eglapp.cpp +++ b/src/eglapp.cpp @@ -24,6 +24,7 @@ #endif #include "core.h" +#include "lolgl.h" #include "eglapp.h" /* diff --git a/src/scene.cpp b/src/scene.cpp index 658e1d9d..6f714947 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -154,13 +154,15 @@ void Scene::Render() // XXX: rename to Blit() // XXX: end of debug stuff #if defined HAVE_GL_2X || defined HAVE_GLES_2X - GLuint uni, attr_pos, attr_tex; - uni = stdshader->GetUniformLocation("model_matrix"); + GLuint uni_mat, uni_tex, attr_pos, attr_tex; attr_pos = stdshader->GetAttribLocation("in_Position"); attr_tex = stdshader->GetAttribLocation("in_TexCoord"); stdshader->Bind(); - glUniformMatrix4fv(uni, 1, GL_FALSE, &model_matrix[0][0]); + uni_mat = stdshader->GetUniformLocation("model_matrix"); + glUniformMatrix4fv(uni_mat, 1, GL_FALSE, &model_matrix[0][0]); + uni_tex = stdshader->GetUniformLocation("in_Texture"); + glUniform1i(uni_tex, 0); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); @@ -208,6 +210,12 @@ void Scene::Render() // XXX: rename to Blit() vertex + 18 * (j - i), texture + 12 * (j - i)); } +#if defined HAVE_GL_2X || defined HAVE_GLES_2X + stdshader->Bind(); +#endif + glActiveTexture(GL_TEXTURE0); + Tiler::Bind(data->tiles[i].code); + #if defined HAVE_GL_2X || defined HAVE_GLES_2X # if !defined HAVE_GLES_2X glBindVertexArray(data->vao); @@ -247,11 +255,6 @@ void Scene::Render() // XXX: rename to Blit() glTexCoordPointer(2, GL_FLOAT, 0, texture); #endif -#if defined HAVE_GL_2X || defined HAVE_GLES_2X - stdshader->Bind(); -#endif - - Tiler::Bind(data->tiles[i].code); glDrawArrays(GL_TRIANGLES, 0, (n - i) * 6); #if defined HAVE_GL_2X || defined HAVE_GLES_2X diff --git a/src/video.cpp b/src/video.cpp index e11a56d9..fe4717b4 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -30,13 +30,15 @@ mat4 proj_matrix, view_matrix, model_matrix; #if defined HAVE_GL_2X || defined HAVE_GLES_2X static char const *vertexshader = +#if !defined HAVE_GLES_2X + "#version 130\n" +#endif + "\n" #if defined HAVE_GLES_2X "attribute vec3 in_Position;\n" "attribute vec2 in_TexCoord;\n" "varying vec2 pass_TexCoord;\n" #else - "#version 130\n" - "\n" "in vec3 in_Position;\n" "in vec2 in_TexCoord;\n" #endif @@ -59,7 +61,9 @@ static char const *vertexshader = "}\n"; static char const *fragmentshader = +#if !defined HAVE_GLES_2X "#version 130\n" +#endif "\n" "uniform sampler2D in_Texture;\n" //"in vec3 pass_Color;\n" @@ -70,14 +74,13 @@ static char const *fragmentshader = "\n" "void main()\n" "{\n" - //" gl_FragColor = 0.5 * (texture2D(in_Texture, vec2(gl_TexCoord[0]))\n" - //" + vec4(pass_Color, 1.0));\n" #if defined HAVE_GLES_2X - " gl_FragColor = vec4(0.5, 1.0, 0.0, 0.5);\n" + " gl_FragColor = texture2D(in_Texture, pass_TexCoord);\n" + //" gl_FragColor = vec4(0.5, 1.0, 0.0, 0.5);\n" + //" gl_FragColor = vec4(pass_TexCoord * 4.0, 0.0, 0.25);\n" #else " gl_FragColor = texture2D(in_Texture, vec2(gl_TexCoord[0]));\n" #endif - //" gl_FragColor = texture2D(in_Texture, pass_TexCoord);\n" "}\n"; #endif