En opengl es 2.0 quand je voulais changer l'attribut "a_degree" dans vertex shader au début j'ai utilisé glVertexAttribPointer et glEnableVertexAttribArray avec de vrais paramètres mais le comportement est totalement différent quand j'ai utilisé glVertexAttrib1f pourquoi?Quelles sont les différences entre glVertexAttribPointer et glVertexAttrib1f
voici mon code shader:
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";
utiliser avec:
glEnableVertexAttribArray (m_shaderData.rotateLoc);
glVertexAttribPointer (m_shaderData.rotateLoc, 1, GL_FLOAT,
GL_FALSE, 0, °ree);
vs
glVertexAttrib1f(m_shaderData.rotateLoc,degree);
En fait glVertexAttrib1f fonctionnent très bien dans cette situation et ma texture tourner correctement, mais avec glVertexAttribPointer juste un point de la rotation de la texture qui n'est pas mon désir.