I am making a simple pong game with a API called freeglut, following along with the instructions provided at http://noobtuts.com/cpp/2d-pong-game. Included in the API are two functions that call for an pointer to a callback that returns void, which I have defined below the main function. At compile time, however, I get error message C2065 stating that the provided callback argument is an undeclared identifier.
Here are the definitions of the functions provided by intellisense when I hover over them.
void__stdcall glutDisplayFunc(void(*callback)())
void__stdcall glutTimerFunc(unsigned int time, void(*callback)(int), int value)
Here is my code:
#include "stdafx.h"
#include "freeglut.h"
#include <string>
#include <windows.h>
#include <iostream>
#include <conio.h>
#include <sstream>
#include <math.h>
#include <gl\GL.h>
#include <gl\GLU.h>
#pragma comment (lib, "OpenGL32.lib")
//window size and update rate (60 fps)
int width = 500;
int height = 200;
int interval = 1000 / 60;
int _tmain(int argc, char** argv)
{
//initialize openg 1 (via glut)
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(width, height);
glutCreateWindow("jackfrye.com Pong");
//Register callback functions
glutDisplayFunc(draw);
glutTimerFunc(interval, update, 0);
glutMainLoop();
return 0;
}
void draw() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
//TODO: draw scene
//swap buffers (has to be done at the end);
glutSwapBuffers();
}
void update(int value) {
//Call update() again in 'interval' milliseconds
glutTimerFunc(interval, update, 0);
//Redisplay frame
glutPostRedisplay();
}
I have tried putting the callbacks inside of the main function, but I do not think this is correct and it still does not compile.