void CreateBuffers()
{
//Vertex Array
glGenBuffers(1,&BufferID[0]);
glBindBuffer(GL_ARRAY_BUFFER_ARB,BufferID[0]);
glBufferData(GL_ARRAY_BUFFER_ARB,
sizeof(Vector3)*nrverts,
Vertices,
GL_STATIC_DRAW_ARB);
//TexCoord Array
glGenBuffers(1,&BufferID[1]);
glBindBuffer(GL_ARRAY_BUFFER_ARB,BufferID[1]);
glBufferData(GL_ARRAY_BUFFER_ARB,
sizeof(Vector2)*nrverts,
Texels[0],
GL_STATIC_DRAW_ARB);
//Normals
glGenBuffers(1,&BufferID[2]);
glBindBuffer(GL_ARRAY_BUFFER_ARB,BufferID[2]);
glBufferData(GL_ARRAY_BUFFER_ARB,
sizeof(Vector3)*nrverts,
Normals,
GL_STATIC_DRAW_ARB);
glBindBuffer(GL_ARRAY_BUFFER_ARB,0);
}
void SetBufferArrays()
{
glEnableClientState(GL_NORMAL_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER_ARB,BufferID[2]);
glNormalPointer(GL_FLOAT,0,NULL);//Normals);
//TexCoordArray for 3 texturing units
glClientActiveTextureARB(GL_TEXTURE0_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER_ARB,BufferID[1]);
glTexCoordPointer(2,GL_FLOAT,0,NULL);//Texels[0]);
//
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER_ARB,BufferID[1]);
glTexCoordPointer(2,GL_FLOAT,0,NULL);//Texels[0]);
//
glClientActiveTextureARB(GL_TEXTURE2_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER_ARB,BufferID[1]);
glTexCoordPointer(2,GL_FLOAT,0,NULL);
//
glEnableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER_ARB,BufferID[0]);
//glBindBuffer(GL_ARRAY_BUFFER_ARB,0);
glVertexPointer(3,GL_FLOAT,0,NULL);
}
//the rendition is just a glDrawRangeElements(wich is not far from from
glDrawElements, it differs by totally nothing to me)
void RenderObjects(UINT group)
{//A part of some object grouping I`m doing
//Basicly I have a number of objects per group/material
//And this renders all the objects coresponding to material[group]
for(int j=0;j<Group[group].nr;j++)
if (Object[Group[group].Object[j].Index].nrindices>0)
{//use_range is set 1 but doesn`t have any effect either
if (!use_range)
glDrawElements(GL_TRIANGLES,Object[Group[group].Object[j].Index].nrindices,GL_UNSIGNED_INT,
Indices+Object[Group[group].Object[j].Index].offset);
else
glDrawRangeElements(GL_TRIANGLES,
Object[Group[group].Object[j].Index].min_off,
Object[Group[group].Object[j].Index].max_off,
Object[Group[group].Object[j].Index].nrindices,GL_UNSIGNED_INT,
Indices+Object[Group[group].Object[j].Index].offset);
}
}
GL_ARB_vertex_buffer_object
Guess what ? I`m having a 10 frames Decrease :D WTF is going on ? I`m willing to post all of my code to know if I`m wrong. I was having 167 FPS, now it`s down to 155. Ok,here`s some code used->
Relative Games - My apps
Just a shoot into the dark but have you tried to setup a VBO for your indices, too (you know, using glIndexPointer)?
Try an interleaved array, you're now using 3 VBOs (vs normally 1) -> states switching cost ?
Be shure to update your graphics drivers, older drivers can't do VBO's correctly.
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
Quote:
Original post by cippyboy
Guess what ? I`m having a 10 frames Decrease :D
WTF is going on ? I`m willing to post all of my code to know if I`m wrong.
I was having 167 FPS, now it`s down to 155.
Put everything (position, texCoords, normals etz.) in the same VBO, instead of creating separate VBO for every array.
And the 10 fps drop is not as bad as you think. Read:
http://www.mvps.org/directx/articles/fps_versus_frame_time.htm
-Put index buffer in VBO.
-Use unsigned short for index format if you can. Most cards are optimized for this.
darookie: that's not what glIndexPointer is for.
-Use unsigned short for index format if you can. Most cards are optimized for this.
darookie: that's not what glIndexPointer is for.
You should never let your fears become the boundaries of your dreams.
Your stride parameter is also wrong, you currently have.
When you make the changes the other guys recommended it should look like this:
The vertex, I put in there is some generic object, you should create that. the macro is a macro that is recommended to be used by the ARB if you read the paper about VBO's they have it listed. the values generated by the offset macro tell the function where to start looking for the textures, normals, and verts.
Hope this helps, just woke up so it might be a bit incoherient.
glNormalPointer(GL_FLOAT,0,NULL);//Normals);glTexCoordPointer(2,GL_FLOAT,0,NULL);//Texels[0]);glTexCoordPointer(2,GL_FLOAT,0,NULL);//Texels[0]);
When you make the changes the other guys recommended it should look like this:
#define BUFFER_OFFSET(offset) (GLchar*)(NULL + offset))glNormalPointer(GL_FLOAT,sizeof(vertex),BUFFER_OFFSET(0));glTexCoordPointer(2,GL_FLOAT,sizeof(vertex),BUFFER_OFFSET(sizeof(GLfloat)*3);glVertexPointer(3,GL_FLOAT,sizeof(vertex),BUFFER_OFFSET(sizeof(GLfloat)*5);
The vertex, I put in there is some generic object, you should create that. the macro is a macro that is recommended to be used by the ARB if you read the paper about VBO's they have it listed. the values generated by the offset macro tell the function where to start looking for the textures, normals, and verts.
Hope this helps, just woke up so it might be a bit incoherient.
Quote:
Original post by _DarkWIng_
darookie: that's not what glIndexPointer is for.
I always confuse this [smile], thanks for the correction!
Ok, where to put indices anyways ? in a GL_ELEMENT_ARRAY_BUFFER_ARB ?
Oh and by the way, how am I suppose to use the glDrawRangeElements if I don`t send the Index throgh that ? put a glIndexPointer and call glDraw[Range]Arrays ?
Oh and how do I put texcoords in a huge array(intervealed)if I use something like
Meaning that I have a maximum of 3 texture units, and sometimes I only 1 or 2 :D
Oh and by the way, how am I suppose to use the glDrawRangeElements if I don`t send the Index throgh that ? put a glIndexPointer and call glDraw[Range]Arrays ?
Oh and how do I put texcoords in a huge array(intervealed)if I use something like
glClientActiveTextureARB(GL_TEXTURE0_ARB);glEnableClientState(GL_TEXTURE_COORD_ARRAY);glBindBuffer(GL_ARRAY_BUFFER_ARB,BufferID[1]);glTexCoordPointer(2,GL_FLOAT,0,NULL);//Texels[0]);//glClientActiveTextureARB(GL_TEXTURE1_ARB);glEnableClientState(GL_TEXTURE_COORD_ARRAY);glBindBuffer(GL_ARRAY_BUFFER_ARB,BufferID[1]);glTexCoordPointer(2,GL_FLOAT,0,NULL);//Texels[0]);//glClientActiveTextureARB(GL_TEXTURE2_ARB);glEnableClientState(GL_TEXTURE_COORD_ARRAY);glBindBuffer(GL_ARRAY_BUFFER_ARB,BufferID[1]);glTexCoordPointer(2,GL_FLOAT,0,NULL);
Meaning that I have a maximum of 3 texture units, and sometimes I only 1 or 2 :D
Relative Games - My apps
News Flash:GL_UNSIGNED_SHORT instead of GL_UNSIGNED_INT, frame boost of 5 FPS, not too much but I`m gonna switch between at initialisation probably (if I have less than 65 K triangles in a scene)
Relative Games - My apps
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement