   Speeding Up Obj Loader for OpenGL
  Iv'e just got my latest project up and running, which is an .Obj loader iv'e been working on for the last few days, However it runs very slowly... like .5 fps if the object is mildly complexThis is due because I call glBegin and glEnd for every pollygon, and when there 13,500 pollygons to draw, thats alot of calls to glBegin and glEnd so my main question is this...Is there a way to Draw Multipul Polygons without calling glBegin And glEnd For Every Single One? like some kind of seperator commandAlso I havn't yet but will put in a binarey tree (as soon as i can get the thing to work) How much speed increase can i expect from putting from a linked list.Any other tips or sugestions are VERY welcome.   
  You don't have to call glBegin/glEnd around every triangle. You can just throw your whole list of vertices and it will make a triangle out of every set of three. However this will still be slow as this is not a good way to draw objects.You need to learn about Vertex Buffer Objects (called "VBO"). You'll get an enormous speedup over using immediate mode when you implement your model this way. What you're doing right now is every frame you have to send tens of thousands of calls and megabytes of data to your GPU over the pci bus, which is very slow. When you use VBO you upload all of the model data into the GPU memory once, and then draw it every frame with a single opengl call. You might see a speedup of 10x-100x doing it this way depending on the size of your model.glBegin is miserably slow and depreciated and you shouldn't use it.;  What im using now looks something like this:while(PollyPoint->Next != 0){glBegin(GL_POLYGON);while(PollyPoint->PollyVPoint->Next != 0){GotoVertex(PollyPoint->PollyVPoint->Polly);glVertex3f(VertexPoint->x, VertexPoint->y, VertexPoint->z);PollyPoint->PollyVPoint = PollyPoint->PollyVPoint->Next;}glEnd();PollyPoint = PollyPoint->Next;PollyPoint->PollyVPoint = PollyPoint->PollyVRoot;}I know it's the worst way to go about things but iv'e only been learning openGL for about a week.   ;  Load your data from file into memory first.  Because, I don't see what a obj loader has to do with rendering speed.I hope you're not reading data from file as your render it, because that would be terrible.   ;  First off, you need to make sure you aren't loading it from the hard drive as you render it.  Store it into a data structure first.Second off, I agree with the above posters that you should not be using glBegin/glEnd.  Its deprecated and slow.  Use VBO or at least VA.Third, if you want an IMMEDIATE boost, simply put the glBegin and glEnd calls around that while loop instead of inside it.   ;Quote:Original post by samster581I hope you're not reading data from file as your render it, because that would be terrible.Nuh I have them loaded into a linked list;Quote:Original post by Steve132Use VBO or at least VA.If you want an IMMEDIATE boost, simply put the glBegin and glEnd calls around that while loop instead of inside it.Iv'e herd of VBO but whats VA??I didn't think i'd be able to but if i change to GL_QUADS I can wrap the glBegin And end calls around, however theres not much change in speed   ;  The glBegin/glEnd should be inside the outer while since he is rendering polygons, but as said before, if this model is static you would gain a lot of speed improvement by storing your model in a VBO. That way you won't have to upload it to the graphics card each frame.   ;Quote:Iv'e herd of VBO but whats VA??I didn't think i'd be able to but if i change to GL_QUADS I can wrap the glBegin And end calls around, however theres not much change in speedA vertex array (VA) is syntactically similar to a VBO but it leaves vertex data stored CPU side and transfers it to GPU every frame. It is slower than a VBO and depreciated, so I wouldn't bother trying to implement it.Also I don't think you're understanding what is being said about glBegin. You don't need to change to GL_QUADS. If you have 1000 triangles then you have 3000 vertices. In this case you can call glBegin, call glVertex 3000 times, then call glEnd. There is no requirement that you "glEnd" after every primitive. Every three vertices is automatically treated as a triangle, so you don't have to tell opengl to start and end each triangle.   ;Original post by karwostsQuote:Also I don't think you're understanding what is being said about glBegin. You don't need to change to GL_QUADS. If you have 1000 triangles then you have 3000 vertices. In this case you can call glBegin, call glVertex 3000 times, then call glEnd. There is no requirement that you "glEnd" after every primitive. Every three vertices is automatically treated as a triangle, so you don't have to tell opengl to start and end each triangle.If i used GL_POLYGON wraped around the outside of the whiles like this:glBegin()whilewhileglEnd()it draws the entire image as one huge polygon and the picture comes out distorted and streched. if it's inside the loops the polygons get broken up; however i can wrap it like that if i use glQuads because it breaks off after every 4 verticies