Search code examples
textures2dopengl-es-2.0marmalade

OpenGL ES 2.0 2D (Marmalade SDK)


Please look at source code it looks like salad of beetroot but maybe one of you will find why it renders glitch textured quad. I spent a lot of time to find mistake without results. I try to render quad (two triangles), texture it and blend with vertex colors. As I understand mistake happens with texture coordinates.

Update:

original picture of texture;

screenshot for gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );

screenshot for gl_FragColor = texColor;

screenshot for gl_FragColor = vec4( v_texCoord.x, v_texCoord.y, 0.0, 0.5 );


Solution

  • When debugging OpenGL shaders by hand, there is a strategy to localize where the problem is. We will use gl_FragColor to dump the results of various calculations within your shaders.

    For example, we change your gl_FragColor = texColor * v_color; to gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 ); to see if the geometry is rendered correctly. If you see a fullscreen red quad, this means your vertex transformations are ok.

    Move on, check your texture coordinates: gl_FragColor = vec4( v_texCoord.x, v_texCoord.y, 0.0, 0.5 ); The result should be a gradual red/green color ramp.

    The wrong color ramp means your UV texture coordinates are wrong. Indeed. You don't setup texture coordinates in void Render(Context* context).