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
Fast Grid Drawer thingCode: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);
Then we use the vertex arrays to draw a primitive when I click a certain area of the grid and colorfy it...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
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...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!



LinkBack URL
About LinkBacks



