OpenGL draw colored squares problem
in
Core Library Questions
•
2 years ago
so im trying to draw random colored squares like the image attached. i can draw a random square but am having trouble drawing multiple 1 by 1 pixel squares so that the ooutput is like the image attached
. my code so far :
glPushMatrix();
glTranslatef(xpos, ypos, 0);
glColor3ub( rand()%255, rand()%255, rand()%255 );
glBegin(GL_QUADS);
glVertex2i(0,0);
glVertex2i(1,0);
glVertex2i(1,1);
glVertex2i(0,1);
glEnd();
glPopMatrix();
. my code so far :
glPushMatrix();
glTranslatef(xpos, ypos, 0);
glColor3ub( rand()%255, rand()%255, rand()%255 );
glBegin(GL_QUADS);
glVertex2i(0,0);
glVertex2i(1,0);
glVertex2i(1,1);
glVertex2i(0,1);
glEnd();
glPopMatrix();
1