Archived

This topic is now archived and is closed to further replies.

FabioPal

Beginner SpeedUp

Recommended Posts

FabioPal    122
I'm trying to write an OpenGL 3D Engine using C++... I've read the tutorial about the Display List, (it should be number 6...), my question is simple: How about the speedup? consider that my engine already moves easily about 10000 polygons without using strips or fans on an AthlonXP 1800+ with GeForce2MX using dynamic lights. Consider that I cannot use extensions because my intentions is to port the engine on Linux and I cannot rely on the specific platform or implementation of OGL. Thank you all!!! FabioPal [edited by - FabioPal on April 30, 2003 8:42:04 AM]

Share this post


Link to post
Share on other sites
redragon    122
Display Lists - You might see some improvement, you might see some improvement, but probably not as much as you would hope. I''ve never been a big fan of them. Display lists are also part of OpenGL 1.1 (were they in 1.0 anyone?), so should be supported EVERYWHERE.

Instead of Display Lists...take a look at Vertex Arrays. True, these are "extensions", however they are a built-in as of OpenGL 1.3. Vertex arrays on models as big as you''re talking about, should buy you a lot of performance, because right now you''re probably sending lots of little calls down the OpenGL pipeline, and with vertex arrays, you''ll be sending big chuncks of data, making it faster.

I would also say...most Linux distros have a version of OpenGL that has vertex arrays. Go for it.

- sighuh?

Share this post


Link to post
Share on other sites
mentat    122
just a question; are you sure that vertex arrays come with gl 1.3? IMHO it exists in 1.1, that''s why we can use it without extension mechanism in Windows..

Share this post


Link to post
Share on other sites
redragon    122
Look into the following commands for vertex arrays:


glEnableClientState(GLenum array);
// Available Options:
// GL_COLOR_ARRAY
// GL_EDGE_FLAG_ARRAY
// GL_INDEX_ARRAY
// GL_NORMAL_ARRAY
// GL_TEXTURE_COORD_ARRAY
// GL_VERTEX_ARRAY

// Then you can create/draw/etc. vertex arrays with the following...
void glVertexPointer(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
void glDrawArrays(GLenum mode, GLint first, GLsizei count);
void glArrayElement(GLint index);

It''s not trivial to use, but it''s not that hard either. Worth looking into I''d say.

- sighuh?

Share this post


Link to post
Share on other sites
redragon    122
quote:
Original post by mentat
just a question; are you sure that vertex arrays come with gl 1.3? IMHO it exists in 1.1, that's why we can use it without extension mechanism in Windows..

I'm sorry...It (vertex array) is in 1.2, but not 1.1.

You can use them in 1.1 sure...but they aren't part of the base OGL implementation.

Me not fully awake yet.

- sighuh?

[edited by - redragon on April 30, 2003 9:06:41 AM]

[edited by - redragon on April 30, 2003 9:07:25 AM]

Share this post


Link to post
Share on other sites
FabioPal    122
quote:
Original post by redragon
Look into the following commands for vertex arrays:
...
It''s not trivial to use, but it''s not that hard either. Worth looking into I''d say.
...


thank you... but an example of real code???



FabioPal

Share this post


Link to post
Share on other sites
redragon    122
I''m not saying this is right...and it''s just a quick and dirty example.

GLfloat vert[] = {0.0,0.5, -0.5,-0.5, 0.5,-0.5};
GLfloat color[] = {1.0,0.0,0.0, 0.0,1.0,0.0, 0.0,0.0,1.0};

glEnableClientState(GL_COLOR_ARRAY | GL_VERTEX_ARRAY);

glColorPointer(3, GL_FLOAT, 0, color);
glVertexPointer(2, GL_FLOAT, 0, vert);

glBegin();
glDrawArrays(GL_POLYGON,0,3);
glEnd();

I''m not sure it''s right...kind of managed to confuse myself this morning...but try it.

Share this post


Link to post
Share on other sites
redragon    122
And I'm full of it....

Vertex arrays are in 1.1. Apparently I'm just really asleep at the wheel.

[edited by - redragon on April 30, 2003 9:33:19 AM]

Share this post


Link to post
Share on other sites
FabioPal    122
You''re telling me that all the stuff is about putting ALL the coords, colors and normals into some arrays????

I should rewrite all my engine!!!!

---------------------------------------
There are 10 type of people:
those who knows binary code
and those who doesn''t
---------------------------------------

Share this post


Link to post
Share on other sites
redragon    122
I'm not saying you should...I'm saying you'll get the best performance that way. Vertex arrays will speed up your rendering more than any other mechanism.

And really, many of your points are probably already stored in an array? You can make multiple calls to glVertexPointer, and it's friends.

It's really the difference between making thousands of calls with little pieces of data, or hundreds of calls with big pieces of data.

[edited by - redragon on April 30, 2003 9:37:47 AM]

Share this post


Link to post
Share on other sites
FabioPal    122
You''re right...

---------------------------------------
There are 10 type of people:
those who knows binary code
and those who doesn''t
---------------------------------------

Share this post


Link to post
Share on other sites