Created
August 3, 2012 08:30
-
-
Save aybabtme/3245860 to your computer and use it in GitHub Desktop.
Error passing pointer to a member functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# clang++ output | |
./src/GlutController.cpp:26:21: error: reference to non-static member function must be called | |
glutSpecialFunc( OnSpecialKeys ); | |
^~~~~~~~~~~~~ | |
./src/GlutController.cpp:27:21: error: reference to non-static member function must be called | |
glutReshapeFunc( OnChangeSize ); | |
^~~~~~~~~~~~ | |
./src/GlutController.cpp:28:21: error: reference to non-static member function must be called; did you mean to call it with no arguments? | |
glutDisplayFunc( OnRenderScene ); | |
^~~~~~~~~~~~~ | |
() | |
./src/GlutController.cpp:28:4: error: no matching function for call to 'glutDisplayFunc' | |
glutDisplayFunc( OnRenderScene ); | |
^~~~~~~~~~~~~~~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* GlutController.cpp | |
* | |
* Created on: Aug 3, 2012 | |
* Author: antoine | |
*/ | |
#include <string> | |
#include "GlutController.h" | |
//////////////////////////////////////////////////////////////////////// | |
// Boilerplate | |
//////////////////////////////////////////////////////////////////////// | |
GlutController::GlutController (int argc, char **argv) { | |
// Setup window | |
gltSetWorkingDirectory( argv[0] ); | |
glutInit(&argc, argv); | |
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH ); | |
glutInitWindowSize( APP_WIDTH, APP_HEIGHT ); | |
glutCreateWindow( APP_NAME ); | |
// Register callbacks | |
glutSpecialFunc( OnSpecialKeys ); | |
glutReshapeFunc( OnChangeSize ); | |
glutDisplayFunc( OnRenderScene ); | |
// Initialize GLEW | |
GLenum anError = glewInit(); | |
if( anError != 0 ){ | |
fprintf( stderr, "GLEW Error: %s\n", | |
glewGetErrorString( anError )); | |
char *aMessage = (char*) glewGetErrorString( anError ); | |
throw std::runtime_error( aMessage ); | |
} | |
} | |
GlutController::~GlutController() { | |
} | |
//////////////////////////////////////////////////////////////////////// | |
// Interface | |
//////////////////////////////////////////////////////////////////////// | |
void GlutController::Start(){ | |
SetupRenderContext(); | |
glutMainLoop(); | |
} | |
//////////////////////////////////////////////////////////////////////// | |
// Callbacks | |
//////////////////////////////////////////////////////////////////////// | |
void GlutController::SetupRenderContext(){ | |
mShaderManager.InitializeStockShaders(); | |
glEnable( GL_DEPTH_TEST ); | |
glClearColor( 0.8f, 0.8f, 0.8f, 1.0f ); | |
} | |
void GlutController::OnChangeSize(int aNewWidth, int aNewHeight){ | |
glViewport(0,0,aNewWidth, aNewHeight); | |
mViewFrustrum.SetPerspective( APP_CAMERA_FOV, | |
float( aNewWidth ) / float( aNewHeight ), | |
APP_CAMERA_NEAR, | |
APP_CAMERA_FAR ); | |
mProjectionMatrixStack.LoadMatrix( | |
mViewFrustrum.GetProjectionMatrix() ); | |
mTransformPipeline.SetMatrixStacks(mModelViewMatrixStack, | |
mProjectionMatrixStack); | |
} | |
void GlutController::OnRenderScene(void){ | |
// Render the scene | |
} | |
void GlutController::OnSpecialKeys(int key, int x, int y){ | |
// Update the model's positions | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* GlutController.h | |
* | |
* Created on: Aug 3, 2012 | |
* Author: antoine | |
*/ | |
#ifndef GLUTCONTROLLER_H_ | |
#define GLUTCONTROLLER_H_ | |
#include <stdexcept> | |
#include <GLTools.h> | |
#include <GLShaderManager.h> | |
#include <GLFrustum.h> | |
#include <GLMatrixStack.h> | |
#include <GLGeometryTransform.h> | |
#include <GL/freeglut.h> | |
#include "Constants.h" | |
#include "models/IDrawableModel.h" | |
class GlutController { | |
public: | |
// Constructor/Destructor | |
GlutController(int argc, char **argv); | |
virtual ~GlutController(); | |
// Interface | |
void Start(void); | |
private: | |
// Fields | |
GLShaderManager mShaderManager; | |
GLFrustum mViewFrustrum; | |
GLMatrixStack mProjectionMatrixStack; | |
GLMatrixStack mModelViewMatrixStack; | |
GLGeometryTransform mTransformPipeline; | |
// Callbacks | |
void OnSpecialKeys(int key, int x, int y); | |
void OnChangeSize(int aNewWidth, int aNewHeight); | |
void OnRenderScene(void); | |
// Methods | |
void SetupRenderContext(void); | |
}; | |
#endif /* GLUTCONTROLLER_H_ */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment