In OpenGLES 2.0 wenn ich das Attribut "a_degree" im Vertex-Shader ändern wollte, habe ich zuerst glVertexAttribPointer und glEnableVertexAttribArray mit echten Parametern verwendet, aber das Verhalten ist völlig anders, wenn ich glVertexAttrib1f verwende warum?Was ist der Unterschied zwischen glVertexAttribPointer und glVertexAttrib1f?
hier ist mein Shadern Code:
const char* CGraphic::VERTEX_SHADER_SOURCE =
"attribute vec4 a_position; \n"
"attribute vec2 a_texCoord; \n"
"attribute vec4 a_color; \n"
"attribute float a_degree; \n"
"varying lowp vec4 v_color; \n"
"varying vec2 v_texCoord; \n"
"void main() \n"
"{ \n"
" float radianS = a_degree* "
" (3.14159265/180.0); \n"
" float s = sin(radianS); \n"
" float c = cos(radianS); \n"
" mat4 mvpMatrix=mat4( \n"
" c,-s,0,0, "
" s,c,0,0, "
" 0,0,1,0, "
" 0,0,0,1); \n"
" v_color = a_color; \n"
" gl_Position = a_position*mvpMatrix; \n"
" v_texCoord = a_texCoord; \n"
"} \n";
const char* CGraphic::FRAGMENT_SHADER_SOURCE =
"precision mediump float; \n"
" \n"
"varying vec4 vColor; \n"
"varying vec2 v_texCoord; \n"
"uniform sampler2D s_texture; \n"
" \n"
"void main() \n"
"{ \n"
" gl_FragColor = texture2D(s_texture, v_texCoord);\n"
"} \n";
Verwendung mit:
glEnableVertexAttribArray (m_shaderData.rotateLoc);
glVertexAttribPointer (m_shaderData.rotateLoc, 1, GL_FLOAT,
GL_FALSE, 0, °ree);
vs
glVertexAttrib1f(m_shaderData.rotateLoc,degree);
In der Tat glVertexAttrib1f in dieser Situation und meine Textur funktionieren drehen richtig, aber mit glVertexAttribPointer nur ein Punkt der Textur drehen, das ist nicht mein Wunsch.