Problem with OpenGl

I just started learning OpenGL and I have a bug with my first project.
I know I installed Freeglut right because I can run some other code that includes freeglut and glew.
So what am I doing wrong ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <GL/freeglut.h>

static void RenderSceneCB()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glutSwapBuffers();
}

static void InitializeGlutCallbacks()
{
    glutDisplayFunc(RenderSceneCB);
}


int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
    glutInitWindowSize(1024, 768);
    glutInitWindowPosition(100, 100);
    glutCreateWindow("Project 1");

    InitializeGlutCallbacks();

    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    glutMainLoop();
    
    return 0;
}
Last edited on
What makes you think something is wrong?

Hard to solve a problem when we don't know what the problem is.
I get the compiler errors

error C2220: warning treated as error - no 'object' file generated

warning C4113: 'void (__cdecl *)()' differs in parameter lists from 'void (__cdecl *)(void)'
what line? and/or what function?
Last edited on
line 11
sorry for the missing informations :)
Are you compiling as C or C++?

In C, empty parenthesis means a function takes any number of parameters (similar to the elipsis (...) in C++), whereas in C++ it means a function takes no parameters.

So what you have there looks like it would work for C++ but would break for C.

To correct:

1
2
3
4
5
static void RenderSceneCB(void)  // <- add the 'void' here
{
    glClear(GL_COLOR_BUFFER_BIT);
    glutSwapBuffers();
}
Okay thanks I found out that my settings was on C for some reason :/
but I got it working now :D
thanks for the quick response
Topic archived. No new replies allowed.