Hi, I’m hacing trouble with this program that i have. what it should do is create a bunch of different color boxes using the QUAD_STRIP for my polygons:
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
#include <math.h>
void RenderScene()
{
GLfloat x,y;
x = x + 10;
y = y + 10;
int cPivot = 1;
glDisable(GL_CULL_FACE);
if(( cPivot %2) == 0)
glColor3f(1.0f, 0.0f, 0.0f);
else
glColor3f(0.0f, 1.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(.03f, 1.f, 0.0f);
glBegin(GL_QUAD_STRIP);
//First quad
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 10.0f, 0.0f);
glVertex3f(10.0f, 0.0f, 0.0f);
glVertex3f(10.0f, 10.0f, 0.0f);
//Second quad
glVertex2f(x, y);
glVertex2f(x, y);
glEnd();
glFlush();
glutSwapBuffers();
}
void TimerFunc(int value)
{
glutPostRedisplay();
glutTimerFunc(100, TimerFunc, 1);
}
void ChangeSize(int w, int h)
{
GLfloat nRange = 200.0f;
// Prevent a divide by zero
if(h == 0)
h = 1;
// Set Viewport to window dimensions
glViewport(0, 0, w, h);
// Reset projection matrix stack
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Establish clipping volume (left, right, bottom, top, near, far)
if (w <= h)
glOrtho (-nRange, nRange, -nRange*h/w, nRange*h/w, -nRange, nRange);
else
glOrtho (-nRange*w/h, nRange*w/h, -nRange, nRange, -nRange, nRange);
// Reset Model view matrix stack
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void SetupRC()
{
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glColor3f(0.0f, 1.0f, 0.0f);
glFrontFace(GL_CW);
glShadeModel(GL_FLAT);
}
void main(void)
{
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutCreateWindow(“simple ****”);
glutReshapeFunc(ChangeSize);
glutDisplayFunc(RenderScene);
glutTimerFunc(100, TimerFunc, 1);
SetupRC();
glutMainLoop();
}
If you can help that’d be great