crash in glVertexAttribIPointer (integer version!)

[solved]

hi

i am using generic vertex attributes to transfer all my vertex data to the vertex shader. one of the attributes is of type integer which i need as integer in the shader, so i use glVertexAttribIPointer. unfortunately, this call crashes. it works fine when i use a float attribute and glVertexAttribPointer.

here’s the relevant code:


struct MyVertex
{
  float x, y, z;    // 12 bytes
  float nx, ny, nz; // 12 bytes
  float tx, ty, tz; // 12 bytes
  float u, v;       // 8 bytes
  float dx, dy;     // 8 bytes
  int r;	    // 4 bytes
  float pad[2];     // to make it 64bytes
};


void render() {
  glBindBuffer(GL_ARRAY_BUFFER, mVBO);
 
  glEnableVertexAttribArray(mAttribLocs[0]);
  glEnableVertexAttribArray(mAttribLocs[1]);
  glEnableVertexAttribArray(mAttribLocs[2]);
  glEnableVertexAttribArray(mAttribLocs[3]);   
  glEnableVertexAttribArray(mAttribLocs[4]);
  glEnableVertexAttribArray(mAttribLocs[5]);

  glVertexAttribPointer(mAttribLocs[0], 3, GL_FLOAT, GL_FALSE, sizeof(MyVertex), (GLvoid*)offsetof(MyVertex, x));
  glVertexAttribPointer(mAttribLocs[1], 3, GL_FLOAT, GL_FALSE, sizeof(MyVertex), (GLvoid*)offsetof(MyVertex, nx));
  glVertexAttribPointer(mAttribLocs[2], 3, GL_FLOAT, GL_FALSE, sizeof(MyVertex), (GLvoid*)offsetof(MyVertex, tx));
  glVertexAttribPointer(mAttribLocs[3], 2, GL_FLOAT, GL_FALSE, sizeof(MyVertex), (GLvoid*)offsetof(MyVertex, u));
  glVertexAttribPointer(mAttribLocs[4], 2, GL_FLOAT, GL_FALSE, sizeof(MyVertex), (GLvoid*)offsetof(MyVertex, dx));
  // next line CRASHES
  glVertexAttribIPointer(mAttribLocs[5], 1, GL_INT, sizeof(MyVertex), (GLvoid*)offsetof(MyVertex, r)); 
  // works fine: glVertexAttribPointer(mAttribLocs[5], 1, GL_FLOAT, GL_FALSE, sizeof(MyVertex), (GLvoid*)offsetof(MyVertex, r)); 

  glCullFace(GL_BACK);
  glDisable(GL_STENCIL_TEST);
  glDisable(GL_ALPHA_TEST);
  glDisable(GL_BLEND);
  glEnable(GL_DEPTH_TEST);
  glDisable(GL_LIGHTING);
  glDepthFunc(GL_LESS); 
  glDisable(GL_TEXTURE_2D);

  glMultiDrawArrays(GL_POLYGON, (GLint*)&mStartIndices[0], (GLsizei*)&mFaceCounts[0], (GLsizei)mStartIndices.size());

  for (size_t i = 0; i < 6; ++i)
    glDisableVertexAttribArray(mAttribLocs[i]);

  glBindBuffer(GL_ARRAY_BUFFER, 0);
}

edit: here’s part of the vertex shader


#version 130
#extension GL_EXT_gpu_shader4 : enable

in vec3 InVertex;
in vec3 InNormal;
in vec3 InTangent;
in vec2 InTexCoord0;
in vec2 InFacDim;
in int InRule; // <-- attribute in question

flat out int startRule;
...

void main(void) 
{
   ...
   startRule = InRule; // transmit non-interpolated to fragment
   ...


i use a macbookpro with nvidia 9600M and drivers 197.13 on vista64

thanks in advance,
simon

Does the glVertexAttribIPointer function point to NULL?

Regards
elFarto

hi

thanks for bringing me on the right track… i was looking at the wrong places.

indeed the function pointer was zero, using the EXT version works.

cheers,
simon