PDA

View Full Version : [OpenGL 1.1] glColor3f not working...



yj1214
08-28-2015, 09:42 AM
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f, 1.0f, 1.0f);
//glOrtho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);

glBegin(GL_POLYGON);
glVertex3f(0.25f, 0.25f, 0.0f);
glVertex3f(0.75f, 0.75f, 0.0f);
glVertex3f(0.75f, 0.75f, 0.0f);
glVertex3f(0.25f, 0.25f, 0.0f);
glEnd();
glFlush();


Shouldn't my rectangle white? but why is it showing nothing?


This isn't working either.



glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f(0.25f, 0.25f, 0.0f);
glColor3f(1.0f, 1.0f, 0.0f);
glVertex3f(0.75f, 0.75f, 0.0f);
glColor3f(1.0f, 1.0f, 0.0f);
glVertex3f(0.75f, 0.75f, 0.0f);
glColor3f(1.0f, 1.0f, 0.0f);
glVertex3f(0.25f, 0.25f, 0.0f);




Also, Windows' opengl32.dll is OpenGL 1.1, right? So when I include gl.h, i'm using OpenGL 1.1, am I correct?

sam_thedancer
08-28-2015, 10:11 AM
The vertices you have are not the 4 corners of a square. They are the ends of a line segment.
Try:

glBegin(GL_POLYGON);
glVertex3f(0.25f, 0.25f, 0.0f);
glVertex3f(0.75f, 0.25f, 0.0f);
glVertex3f(0.75f, 0.75f, 0.0f);
glVertex3f(0.25f, 0.75f, 0.0f);
glEnd();