Figured it out

• 11-05-2005
Shamino
Figured it out
There it is, vertex array, my simple primitive, if I were to use this, in conjunction with a high speed grid drawing function, we'd have a beautifully smooth program

Code:

```float array[9] = {1.0, -1.0, 0.0,                                                                // 3 coordinates per vertex                     0.0, 1.0, 0.0,                                                                // Using GLFloat as the data type                     -1.0, -1.0, 0.0};                                                        // Assume that there is no padding between coordinate values         glVertexPointer(3, GL_FLOAT, 0, array);                                                // Pointer to the first element in the array         glEnableClientState(GL_VERTEX_ARRAY);                 glDrawArrays(GL_TRIANGLES, 0, 3);         glDisableClientState(GL_VERTEX_ARRAY);```
Fast Grid Drawer thing :D

Code:

```void DrawSquare(int left, int top, int right, int bottom) {         glBegin(GL_LINES);         glColor4f(1, 1, 1, 1);         glVertex2d(left, top);         glVertex2d(right, top);         glVertex2d(right, top);         glVertex2d(right, bottom);         glVertex2d(right, bottom);         glVertex2d(left, bottom);         glVertex2d(left, bottom);         glVertex2d(left, top);         glEnd(); } void DrawGrid(int left, int top, int right, int bottom, int w, int h) {         for(int i=left; i<right; i+= w)         {                 for(int o=top; o<bottom; o+= h)                 {                         DrawSquare(i,o,i+w,o+h );                 }         } }```
Then we use the vertex arrays to draw a primitive when I click a certain area of the grid and colorfy it...

remove all those stupid unecessary loops.... yeah... smooth program, thanks all who have helped

I can do this
Seats Seat[392]

because element=row*width+column, I can get to a certain section very easily....

and then translatef with a much better algorithm

definately not

Code:

```                                s[0][k][j].x=k*19.0f;                                        s[0][k][j].y=j*19.0f;                                                                        glTranslatef(s[0][k][j].x,s[0][k][j].y,0.0f);```
instead of doing that, i'll make an algorithm to detect mouse detection, and create a quad on demand with a mouse click to make the color changes and the seat will be sold...

that is the program killer right there, its making everything slow, if edited out, program runs beautifully....

something is making me think, why do i need to fudge with s[][][].x at all? why do i have the x/y in the structure? I don't need to store that information, i don't need that info at all, because i'm drawing the grid with lines, and then im creating the quads at a mouse click with vertex arrays, which are uber fast and dynamic, therefore I can change the stuff in them, and draw different things, thats uber!
• 11-05-2005
Perspective
For something static like that you might get better performance using pre-compiled display lists.

Code:

```GLuint list = glGenLists((GLuint) 1); glNewList(list, GL_COMPILE); /* all your draw commands go here */ glEndList(); /* call it with */ glTranslate( /* object coords */ ); glCallList(list);```
• 11-05-2005
Shamino
the drawing method isn't really my lag issue, its data management, the 3d array is a destroyer, translating with it = death to processor