Advertisement

OpenGL matrices vs. C-style arrays.

Started by March 30, 2001 10:46 PM
4 comments, last by SWortham 23 years, 10 months ago
I''m used to C-style arrays and matrices. They seem much easier to handle than using OpenGL for handling the matrix. I''ve made a little demo called Terra3D that runs pretty well. But I''d like to make it faster. It uses C-style arrays to hold the vertices. Like this: const int MAX = 500; // LENGTH AND WIDTH OF MATRIX(2D array) struct vertex { GLfloat x, y, z; }; vertex field[MAX+9][MAX+9]; // +9 is for safety. This style of matrix works fine for me, I simply draw the terrain with TRIANGLE_STRIPs. But, is there a faster way? - I program. Do you? www.gldomain.com
- I program. Do you? www.gldomain.com
Ok, I am confused. What does C style ararys have to do with Opengl matrices? What I mean is, it doesn''t matter how you store the data, since you still must pass the data to the API.

You still have to have glVertex3f() [or whatever]...and you are not using openGL matrix until you start doing rotates/translates. All you are doing is passing data.

And triangle strips are usually the fastest, you might want to try display lists also.







Advertisement
Well, there are a lot of functions in the gl.h library that I never use. Some of them seem to relate to matrices. Maybe I''m wrong, maybe there isn''t much else I can do with OpenGL. I saw a VertexPointerEXT function that sounded interesting that is included in OpenGL 1.2. But I''m using OpenGL 1.1. =(

Oh, I have experimented with display lists, but I don''t think they will help in this program.
- I program. Do you? www.gldomain.com
the reason I ask is partly from a quote by Brett Porter regarding MMX, 3dNow, and SSE: "...remember that your OpenGL drivers already use it to do stuff if they are worth their salt. So a lot of Matrix math is probably better off in the OpenGL libraries these days between driver optimisation and hardware T&L."
- I program. Do you? www.gldomain.com
I think he (Brett Porter) means translations, rotations, scaling and the likes. Things that affect the viewing matrix. This that can be done by T&L and would otherwise require hefty CPU usage
ok. hrmm. that makes since. thanks.
- I program. Do you? www.gldomain.com

This topic is closed to new replies.

Advertisement