![]() |
| | #1 |
| Absent Minded Programmer Join Date: May 2005
Posts: 933
| Figured it out 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);
![]() 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 );
}
}
}
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.... instead of Seats Seat[3][14][28].... 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); 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! Last edited by Shamino; 11-06-2005 at 12:39 AM. |
| Shamino is offline | |
| | #2 |
| Crazy Fool Join Date: Jan 2003 Location: Canada
Posts: 2,596
| 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);
__________________ jeff.bagu.org - Terrain rendering and other random stuff |
| Perspective is offline | |
| | #3 |
| Absent Minded Programmer Join Date: May 2005
Posts: 933
| the drawing method isn't really my lag issue, its data management, the 3d array is a destroyer, translating with it = death to processor |
| Shamino is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| figured it out but have one question | romeoz | C++ Programming | 5 | 07-08-2003 07:49 PM |
| I figured out my other problem, but... | hpy_gilmore8 | C++ Programming | 18 | 04-22-2003 10:59 PM |
| Now that I have figured out sound, | Vanished | Game Programming | 2 | 12-09-2002 04:01 PM |
| I have figured out the differences between 95 and XP... | DavidP | A Brief History of Cprogramming.com | 6 | 04-03-2002 03:47 PM |
| I just figured this method out. | knave | C++ Programming | 2 | 09-13-2001 11:39 PM |