Reputation: 1047
While trying to compile a simple example openGL example to display text, I ran into the problem with 'glWindowPos2i' could not be resolved. glWindowPos2i seemed to compile fine as a C program under GCC, but for a could not be resolved error under eclipse as a c++ program with g++. (solution below)
The environment is eclipse (juno) under ubuntu 13.04 with openGL 3.3.0 (NVIDIA 310.44) GLEW version 1.8.0
Upvotes: 0
Views: 2224
Reputation: 1047
The issue was that glWindowPos2i is an extension and in order compile with c++, glWindowPos2i needed to be defined by its address. At the top of the program, just after the includes glWindowPos2i needs to be defined as a global.
PFNGLWINDOWPOS2IPROC glWindowPos2i;
Then in the body of the program, after the glutInit, a value needs to be assigned to the global variable.
glWindowPos2i = (PFNGLWINDOWPOS2IPROC) glutGetProcAddress("glWindowPos2i");
The glutGetProcAddress is defined by an include for and the definition for PFNGLWINDOWPOS2IPROC comes from
The full list of the includes I'm using are
#include <GL/glew.h>
#include <GL/glext.h>
#include <GL/freeglut.h>
#include <GL/freeglut_ext.h>
The linker includes I'm using are
-lGL -lm -lglut -lGLEW -lGLU
Upvotes: 2