Hey I’m a complete openGL noob. I’m attempting to make a simple slider. I have the following:
void display(){
glClear(GL_COLOR_BUFFER_BIT);
glLineWidth((GLfloat)2);
glColor3f(0, 0, 0);
glBegin(GL_LINES);
glVertex2i(100, (height - 50 - 255));
glVertex2i(100, (height - 50));
glEnd();
glBegin(GL_QUADS);
glColor3f(1, 0, 0);
glVertex2i(90, redY - 5);
glVertex2i(90, redY + 5);
glVertex2i(110, redY + 5);
glVertex2i(110, redY - 5);
glEnd();
glutSwapBuffers();
}
void mouse(int button, int state, int x, int y){
switch (button){
case GLUT_LEFT_BUTTON:
if (state == GLUT_DOWN){
if (x >= 90 && x <= 110 && y >= redY - 5 && y <= redY + 5){
ruberbanding = true;
}
}
else if (state == GLUT_UP){
ruberbanding = false;
}
glutPostRedisplay();
}
}
void motion(int x, int y){
if (ruberbanding && y <= 555 && y >= 255){
redY = y;
glutPostRedisplay();
}
}
the display function is listed as my display callback. Why doesn’t this work? I think I may have misunderstood something along the way.