Archives for October 2011 (2)
October 6, 2011

OpenGL weirdness

Try this:

        dispList = glGenLists(1);

        glNewList(dispList, GL_COMPILE);

        for(int x=-768; x<768; x++)
        for(int y=-768; y<768; y++)
        {
            glBegin(GL_QUADS);
                glColor3f((double)(rand() % 100) / 500,
			(double)(rand() % 100) / 100, 0);
                glVertex3i((x)  * 1, (y)  * 1, 0);
                glVertex3i((x+1)* 1, (y)  * 1, 0);
                glVertex3i((x+1)* 1, (y+1)* 1, 0);
                glVertex3i((x)  * 1, (y+1)* 1, 0);
            glEnd();
        }

        glEndList();

and render your display list. Then, try this:

        dispList = glGenLists(1);

        glNewList(dispList, GL_COMPILE);
        glBegin(GL_QUADS);	// <- the subtle difference is here

        for(int x=-768; x<768; x++)
        for(int y=-768; y<768; y++)
        {
                glColor3f((double)(rand() % 100) / 500,
			(double)(rand() % 100) / 100, 0);
                glVertex3i((x)  * 1, (y)  * 1, 0);
                glVertex3i((x+1)* 1, (y)  * 1, 0);
                glVertex3i((x+1)* 1, (y+1)* 1, 0);
                glVertex3i((x)  * 1, (y+1)* 1, 0);
        }
        glEnd();		// <- and here

        glEndList();

I don’t know if its my graphics drivers, or graphics card or perhaps just me, but the top code maxed out at 60 fps while the bottom code ran at ~10 fps.

Oh, and don’t ask me why I’m using display lists.

October 6, 2011

Help! GLEW compiles but doesn’t link!

When you compile the glew_static project from glew on Visual Studio and link it with your program, you may get something like this:

app_init.obj : error LNK2001: unresolved external symbol __imp__glewInit
worldscene.obj : error LNK2001: unresolved external symbol __imp____glewBufferSubData
worldscene.obj : error LNK2001: unresolved external symbol __imp____glewBufferData
worldscene.obj : error LNK2001: unresolved external symbol __imp____glewBindBuffer
worldscene.obj : error LNK2001: unresolved external symbol __imp____glewGenBuffers

It’s easy to fix. Just add GLEW_STATIC to the preprocessor definitions and you’re done. This is because without it the header specifies dllimport instead of just extern, which is needed for static linkage.

page 1 of 1