I've been working on OpenGL tutorials and now am moving what I'm learning into a class, but I ran into a problem. When I call glutDisplayFunc and glutReshapeFunc they can't find the callback functions (even though they exist). I'm really at a loss here and I either have a syntax error (even though everything works when I take it outside the class) or there is something going on under the hood that I am not aware of? Any help would be greatly appreciated
I'll admit I'm pretty rusty with classes but I can't seem to spot what I am doing wrong. Anyone have any idea?
//HEADER FILE
class OGLAppManager
{
public:
OGLAppManager();
void reshape(int width, int height);
void display(void);
private:
float rotationAngle;
};
//SOURCE FILE
#include "OGLAppManager.h"
OGLAppManager::OGLAppManager()
{
rotationAngle = 0;
//Set display properties
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); //Set up a display buffer, enable double buffering, blending and depth testing
glutInitWindowSize(1000, 1000); //Set the width and height of the window
glutInitWindowPosition(100, 100); //Set window position
glutCreateWindow("GSP 420"); //Set window caption
//Window Control Functions
glutDisplayFunc(display); //Tell glut to draw window based on function
glutReshapeFunc(reshape); //Tell glut to reshape the window when dragged
};
//Function to reshape the window when dragged
void OGLAppManager::reshape(int width, int height)
{
//Set viewport to window size
glViewport(0, 0, (GLsizei)width, (GLsizei)height);
// Switch to projection matrix to manipulate how scene is viewed
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); //Reset projection matrix to avoid artifacts
//Set FOV, + Near and Far clip planes
gluPerspective(60, (GLfloat)width / (GLfloat)height, 1.0, 100.0);
//Switch back to modelview matrix
glMatrixMode(GL_MODELVIEW);
};
//Function to draw the scene
void OGLAppManager::display(void)
{
//Handle drawing
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); //Clear background of window
glClear(GL_COLOR_BUFFER_BIT); //Clear the color buffer
glLoadIdentity(); //Load identity matrix to reset drawing locations
//Translate scene back
glTranslatef(0.0f, 0.0f, -6.0f);
//Draw a pyramid
glPushMatrix();
glRotatef(rotationAngle, 0.0, 1.0, 0.0);
glBegin(GL_TRIANGLES);
//SNIP
glutSwapBuffers(); //Flush buffers to the window
rotationAngle++; //Rotation angle for pyramid
};