# glWindowPos2i in C++

This topic is 4390 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
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.

##### Share on other sites

This topic is 4390 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628682
• Total Posts
2984206

• 13
• 13
• 9
• 10
• 10