PDA

View Full Version : Drawing grid



xorserq
08-03-2014, 05:09 AM
Hello,

Can anyone explain to me how can one draw a grid with different cells colors. I'm trying to implement Game of Life, and I need to draw a grid with white/black color for each cell.

hlewin
08-03-2014, 10:48 AM
You could simply draw a quad for each cell.
Something like


glBegin(GL_QUADS);
glColor(1,1,1);
glVertex2f( x, y ); glVertex2f( x+cellSize, y );
glVertex2f( x+cellSize, y+cellSize ); glVertex2f( x, y+cellSize );
glEnd();

will draw you a cell in the z=0 plane.
There are quite a few good tutorials on the web showing how to do this.