Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
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.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this