Selaa lähdekoodia

Try to fix GLES 2 rendering. No luck so far.

legacy
Sam Hocevar sam 13 vuotta sitten
vanhempi
commit
cc7dd5f4f6
3 muutettua tiedostoa jossa 21 lisäystä ja 14 poistoa
  1. +1
    -0
      src/eglapp.cpp
  2. +11
    -8
      src/scene.cpp
  3. +9
    -6
      src/video.cpp

+ 1
- 0
src/eglapp.cpp Näytä tiedosto

@@ -24,6 +24,7 @@
#endif

#include "core.h"
#include "lolgl.h"
#include "eglapp.h"

/*


+ 11
- 8
src/scene.cpp Näytä tiedosto

@@ -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


+ 9
- 6
src/video.cpp Näytä tiedosto

@@ -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



Ladataan…
Peruuta
Tallenna