glWindowPos2i in C++

Started by
0 comments, last by LilBudyWizer 18 years, 4 months ago
Not too long ago I've been suggested here to use glWindowPos to locate texts, because they needed to be displayed even when they were partly out of the screen. It worked fine. However now, on a new project, I'm using C++ instead of C. But now I can't get it to work. I use the following code to test it: #include <GL/gl.h> #include <GL/glu.h> #include <GL/glx.h> #include <SDL/SDL.h> int main() { glWindowPos2i(800, 600); } (I know this wouldn't work if it compiled) But my problem is, it doesn't even compile. Here's what I tried: $ gcc -l m -l GL -l GLU test.c $ (Works fine with gcc) However with g++: $ g++ -l m -l GL -l GLU test.c test.c: In function `int main()': test.c:9: error: `glWindowPos2i' undeclared (first use this function) test.c:9: error: (Each undeclared identifier is reported only once for each function it appears in.) $ Even when I prototype it manually: $ g++ -l m -l GL -l GLU test.c /tmp/ccKzzuv0.o: In function `main': test.c:(.text+0xf): undefined reference to `glWindowPos2i(int, int)' collect2: ld returned 1 exit status $ Any idea on how I can use glWindowPos2i anyway? Thanks in advance
Advertisement
It's an extension. So glWindowPos2i is actually a function pointer rather than an external referance resolved by the linker. The FAQ on here lists a couple of libraries that will declare the pointers and set them for you. glext.h defines the data types for the function pointers, i.e. the parameters. As an example for glWindowPos2i it is PFNGLWINDOWPOS2IPROC. Under windows you would call wglGetProcAddress to set the pointer and I assume under X Windows it would be glxGetProcAddress. Easiest is to just use one of the libraries above.
Keys to success: Ability, ambition and opportunity.

This topic is closed to new replies.

Advertisement