I tried to use glVertexAttribPointer to send array of tangent data to shader but it hangup my computer (The screen go black and wont recovery,I have to reboot it).
So I rewrite my code using old glBegin()/glEnd() and
glVertexAttrib3fv() and it work fine.
this is the code that dont work.
bumpShader.activateShader();
glDisable(GL_BLEND);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER,vertexBufferID);
glVertexPointer(3,GL_FLOAT,0,0);
glBindBufferARB(GL_ARRAY_BUFFER,normalBufferID);
glNormalPointer(GL_FLOAT,0,0);
glVertexAttribPointer(bumpShader.tangentLoc,3,GL_FLOAT,GL_FALSE,0,&tangentArray[0]);
glEnableVertexAttribArray(bumpShader.tangentLoc);
for(int i=0;i<sceneGroupList.size();i++){
if(this->enableMaterial == true){
glMaterialfv( GL_FRONT, GL_AMBIENT, sceneGroupList[i].ambient );
glMaterialfv( GL_FRONT, GL_DIFFUSE, sceneGroupList[i].diffuse );
glMaterialfv( GL_FRONT, GL_SPECULAR, sceneGroupList[i].specular );
glMaterialfv( GL_FRONT, GL_EMISSION, sceneGroupList[i].emissive );
glMaterialf( GL_FRONT, GL_SHININESS, sceneGroupList[i].shininess );
}
if(sceneGroupList[i].useTexture){
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,sceneGroupList[i].textureID);
glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,sceneGroupList[i].bumpID);
glClientActiveTextureARB(GL_TEXTURE0);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER,texCoordBufferID);
glTexCoordPointer(2,GL_FLOAT,0,0);
}
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER,sceneGroupList[i].indexBufferID);
glDrawElements(GL_TRIANGLES,sceneGroupList[i].elementIndex.size(),GL_UNSIGNED_SHORT,
0);
if(sceneGroupList[i].useTexture){
glActiveTexture(GL_TEXTURE0);
glClientActiveTexture(GL_TEXTURE0);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableVertexAttribArray(bumpShader.tangentLoc);
glBindBufferARB(GL_ARRAY_BUFFER,0);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER,0);
bumpShader.deactivateShader();
-
My gfx card is Geforce 7600GT with latest NVIDIA driver (163.75)
-
tangentArray is an array of float and had a size of 60515*3
-
OS is windows XP
Can someone tell me what might causing the problem ?