hi i have same problem with custom atributes HELP

hello all !


i try set atributes on vertex


shader:


Code:

uniform mat4 u_mvpMatrix;
attribute vec4 a_position;       
       
      void main()                                 
      {       
        gl_Position = u_mvpMatrix* a_position;
      }

and code init

Code:

loading init shader ....

and
mvpLoc = glGetUniformLocation( prog, "u_mvpMatrix" );
a_position = glGetAttribLocation(prog, "a_position");
glEnableVertexAttribArray(a_position);



draw code

Code:

     glUniformMatrix4fv( mvpLoc, 1, GL_FALSE, (GLfloat*) &mvpMatrix.m[0][0] );
     glVertexAttribPointer(a_position,4,GL_FLOAT,0,0,position);
     glDrawElements(GL_TRIANGLES, 3*numIndicles, GL_UNSIGNED_SHORT, &Indicles);

struct position

Code:

typedef struct
{
   float x,y,z,w;
}positionStruct;
positionStruct*position;
position[0].x = 0;
position[0].y = 0;
position[0].z = 0;
position[0].w = 0;
position[1].x = 1;
position[1].y = 0;
position[1].z = 0;
position[1].w = 0;
position[2].x = 2;
position[2].y = 0;
position[2].z = 0;
position[2].w = 0;
ets ....

The primitive thing not to be displayed

but if i del
Code:
glVertexAttribPointer(a_position,4,GL_FLOAT,0,0,position);
primitive to be displayed normally



how correct set attributes array on vertex ? idarkstranger2009-07-02 19:47:17

aaaaaa GURU help me !!! i try correct my problem Some days ((((((( plz help !

Well there could be different things going on here. Only part of the source code is posted.

In anycase:
   - Do you have proper texture shader?
   - Are your vertices fine? (Looking at them it looks like degenerate triangle)
   - You are talking about triangle, yet you are passing 4 vertices (but only 3 are initialized)
   - Check your CCW/CW culling - or better turn it off for now.