PDA

View Full Version : Open GL errors



hcrogma
04-23-2003, 04:28 AM
I Tried making a class using the exmaple of lesson 2 from NeHe tutorial....but get the following errors...could you please tell how to get around this problem.
Error : function call 'glutDisplayFunc(void)' does not match
'glutDisplayFunc(void (*)())'
myGLObject.cp line 160 glutDisplayFunc(DrawGLScene);
1.
Error : function call 'glutReshapeFunc(void)' does not match
'glutReshapeFunc(void (*)(int, int))'
myGLObject.cp line 161 glutReshapeFunc(ReSizeGLScene);
2.

Error : function call 'glutDisplayFunc(void)' does not match
'glutDisplayFunc(void (*)())'
myGLObject.cp line 160 glutDisplayFunc(DrawGLScene);

Error : function call 'glutReshapeFunc(void)' does not match
'glutReshapeFunc(void (*)(int, int))'
myGLObject.cp line 161 glutReshapeFunc(ReSizeGLScene);

#include"myGLObject.h"

GLvoid myGLObject::InitGL(GLvoid)
{

glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // This Will Clear The Background Color To Black
glClearDepth(1.0); // Enables Clearing Of The Depth Buffer
glDepthFunc(GL_LESS); // The Type Of Depth Test To Do
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading

glMatrixMode(GL_PROJECTION);
glLoadIdentity(); // Reset The Projection Matrix

gluPerspective(45.0f,(GLfloat)kWindowWidth/(GLfloat)kWindowHeight,0.1f,100.0f); // Calculate The Aspect Ratio Of The Window

glMatrixMode(GL_MODELVIEW);

}

// DrawGLScene ---------------------------------------------------------------

GLvoid myGLObject: http://www.opengl.org/discussion_boards/ubb/biggrin.gifrawGLScene(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glLoadIdentity(); // Reset The View

glTranslatef(-1.5f,0.0f,-6.0f);

glBegin(GL_POLYGON);
glVertex3f( 0.0f, 1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glEnd();

glTranslatef(3.0f,0.0f,0.0f);

glBegin(GL_QUADS);
glVertex3f(-1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glEnd();

glFlush();
}

// ReSizeGLScene ------------------------------------------------------------

GLvoid myGLObject::ReSizeGLScene(int Width, int Height)
{
glViewport (0, 0, (GLsizei) Width, (GLsizei) Height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

gluPerspective(45.0, (GLfloat) Width / (GLfloat) Height, 0.1, 100.0);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

// draw object ------------------------------------------------------------
GLvoid myGLObject::showmyobject(GLvoid){
setGraphControl();

InitGL();
glutDisplayFunc(DrawGLScene);
glutReshapeFunc(ReSizeGLScene);

}

Thank you for your assistance..

HalcyonBlaze
04-23-2003, 12:51 PM
I think you need to either declare those methods in the class you pass to GLUT static or just avoid classes and use C stile functions instead.

- Halcyon

sherkan1
04-23-2003, 05:12 PM
Originally posted by hcrogma:
I Tried making a class using the exmaple of lesson 2 from NeHe tutorial....but get the following errors...could you please tell how to get around this problem.
Error : function call 'glutDisplayFunc(void)' does not match
'glutDisplayFunc(void (*)())'
myGLObject.cp line 160 glutDisplayFunc(DrawGLScene);
1.
Error : function call 'glutReshapeFunc(void)' does not match
'glutReshapeFunc(void (*)(int, int))'
myGLObject.cp line 161 glutReshapeFunc(ReSizeGLScene);
2.

Error : function call 'glutDisplayFunc(void)' does not match
'glutDisplayFunc(void (*)())'
myGLObject.cp line 160 glutDisplayFunc(DrawGLScene);

Error : function call 'glutReshapeFunc(void)' does not match
'glutReshapeFunc(void (*)(int, int))'
myGLObject.cp line 161 glutReshapeFunc(ReSizeGLScene);

#include"myGLObject.h"

GLvoid myGLObject::InitGL(GLvoid)
{

glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // This Will Clear The Background Color To Black
glClearDepth(1.0); // Enables Clearing Of The Depth Buffer
glDepthFunc(GL_LESS); // The Type Of Depth Test To Do
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading

glMatrixMode(GL_PROJECTION);
glLoadIdentity(); // Reset The Projection Matrix

gluPerspective(45.0f,(GLfloat)kWindowWidth/(GLfloat)kWindowHeight,0.1f,100.0f); // Calculate The Aspect Ratio Of The Window

glMatrixMode(GL_MODELVIEW);

}

// DrawGLScene