Jump to content
  • Advertisement
Sign in to follow this  
MrRage

OpenGL OpenGL and Xwindows

This topic is 4500 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

I want to write a simple OpenGL app in Xwindows and so I haven't been able to find any examples on how to do it. I can do this in windows using just the winapi so I was hoping to find a similar way to do it under X with out using something like GTK+. Any input would be appreciated, thanks

Share this post


Link to post
Share on other sites
Advertisement
There is a nice techpubs article on Sgi.com that is a good way to get started.

OpenGl on SGI

Chapter 3. OpenGL and X: Examples - has some sample code for using xt widgets or just using straight xlib to create an OpenGL Context.

Share this post


Link to post
Share on other sites
Xlib is quite painfull. You might want to consider using SDL or GTK to set up the window. These are crossplatform, so you also avoid platform specific code. If you still want to do it with only Xlib, PM me and I will send you the code I use to set up windows for use with OGL (it isn't ready for public release yet :)

Share this post


Link to post
Share on other sites
Do a google search for a sample app called glxsimple.c. It's from the book OpenGL Programming for the X Window System by Mark J. Kilgard (the green book). It just sets up a simple opengl window using xlib which isn't too bad if you've worked with the winapi, and it's pretty straight forward.

Hope this helps.

Share this post


Link to post
Share on other sites
If you check out NeHe, you might see the NeHeGL GLX basecode on the left side, under the heading 'OpenGL Basecode'. If you want something cross-platform, and you don't mind not being able to do fullscreen toggling in Windows, or changing the current display properties (colour depth, refresh rate, etc.), then you might as well use SDL, but if you're like me, and want a fairly flexible window setup, then that code should help you on your way (I still haven't figured out fullscreen toggling using Xlib, but everything else seems to be working fairly well at the moment).

Share this post


Link to post
Share on other sites
Quote:
Disgruntled Gamer:
It just sets up a simple opengl window using xlib which isn't too bad if you've worked with the winapi, and it's pretty straight forward.


yes, the simple examples are straight forward but things like fullscreen are tricky to get right. Unfortunately the Xlib documentation isn't clear about which functions can be called in which window state, it took me lots of trial and error to find out. Sad thing that good documentation, like the OpenGL one, is rare.

Share this post


Link to post
Share on other sites
Quote:
Original post by Gorax
(I still haven't figured out fullscreen toggling using Xlib, but everything else seems to be working fairly well at the moment).


I think I'm gonna clean up my rewrite of the glx basecode and release it. The fullscreen toggling in the nehe glx code is a dirty hack that leaks memory :-/

But if you are interested here is what I do:
1. unmap the window
2. change screen resolution with the XF86VidMode extention
3. set the viewport and window location/size to match the resolution
4. grab mouse and keybopard
5. set the redirect_override property of the window*
6. map the window

* this is considered bad practice, but I find it ok. The "right way" to do it is window manager hints.

Share this post


Link to post
Share on other sites
Hi nefthy,

I've been wondering myself how you setup a full screen window in xwindows. I would be very interested in seeing your code on how to do it. I have a lot more experience with win32 programming than I do with xwindow programming so the steps you listed aren't that familiar to me. Any further explanation would be greatly appreciated. Also is there an easy way to turn off your mouse pointer in xwindows, like an xwindows version of ShowCursor or something?

DG

[Edited by - Disgruntled Gamer on April 21, 2006 6:20:47 PM]

Share this post


Link to post
Share on other sites
As I said I will clean the code up and upload it. As for hiding the mouse pointer, I havent found it yet, but I will hopefully.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Cool thanks guys, this information is great. Hopfully I can post some progress later tonight.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!