This is my vertex shader:
attribute vec4 a_position;
uniform mat4 u_projection;
uniform vec4 u_origin_translation;
uniform vec4 u_translation;
attribute vec2 a_texCoord;
varying vec2 v_texCoord;
uniform vec4 u_color;
varying vec4 v_color;
attribute vec4 a_color;
void main()
{
vec4 pos = a_position + u_origin_translation + u_translation;
gl_Position = u_projection * pos;
v_texCoord = a_texCoord;
v_color = a_color * u_color;
}
And the pixel shader:
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D s_texture;
varying vec4 v_color;
void main()
{
vec4 texColor = texture2D(s_texture, v_texCoord);
gl_FragColor = texColor * v_color;
}
I am trying to make a textured square in the context of OpenGL ES 2.0 on the Marmalade 7.1 platform;
Source code for sending matrix data (projection form " u_projection ") to the shader:
GLint projectionUniformLocation = glGetUniformLocation(m_ShaderProgram->GetHandle(), m_ShaderProgram->GetProjectionUniformName().c_str());
glUniformMatrix4fv(projectionUniformLocation, 1, 0, &m_Ortho[0]);
My tracking code:
glGetActiveUniform(m_ShaderProgram->GetHandle(), projectionUniformLocation, maxUniformLength, 0, &size, &type, &buffer[0]);
TRACE_OUT("Context::ApplyOrtho: type is matrix " << (type == GL_FLOAT_MAT4));
TRACE_OUT("Context::ApplyOrtho: type is " << type);
TRACE_OUT("Context::ApplyOrtho: buffer is " << &buffer[0]);
TRACE_OUT("Context::ApplyOrtho: projectionUniformLocation is " << projectionUniformLocation);
The whole program works well in a simulator in Windows. It shows a textured square and from a trace of my projection. Multiplication is a type of GL_FLOAT_MAT4 , therefore it is right.
!!! ipad 3, -.
, GL_FLOAT_MAT4, GL_SAMPLER_2D, " s_texture"!!! - .
: Windows projectionUniformLocation 3, ipad 2;
2: :
Context::PrintActiveUniforms: active is s_texture and it location is 0
Context::PrintActiveUniforms: active is u_color and it location is 1
Context::PrintActiveUniforms: active is u_origin_translation and it location is 2
Context::PrintActiveUniforms: active is u_projection and it location is 3
Context::PrintActiveUniforms: active is u_translation and it location is 4
ipad:
Context::PrintActiveUniforms: active is u_origin_translation and it location is 0
Context::PrintActiveUniforms: active is u_color and it location is 1
Context::PrintActiveUniforms: active is s_texture and it location is 7
Context::PrintActiveUniforms: active is u_projection and it location is 2
Context::PrintActiveUniforms: active is u_translation and it location is 6
Update3: ipad 3 (Andon M. Coleman ):
eTB_GLSL__print_uniforms: (loc=0) type=vec4 name=u_origin_translation size=1
eTB_GLSL__print_uniforms: (loc=1) type=vec4 name=u_color size=1
eTB_GLSL__print_uniforms: (loc=7) type=sampler2D name=s_texture size=1
eTB_GLSL__print_uniforms: (loc=2) type=mat4 name=u_projection size=1
eTB_GLSL__print_uniforms: (loc=6) type=vec4 name=u_translation size=1
glGetActiveUniform , u_projection mat4 ?
?