Creating a fullscreen openGL window in X

Started by
10 comments, last by marijnh 20 years, 8 months ago
Problem is this: I''ve made my own wrapper for fullscreen openGL windows for microsoft windows, keeping the outside more or less platform independant. Now i''ve been trying to port it to X windows, since it would be really neat to be able to compile my applications for linux. Note that, unless proven impossible, i''d like to do this without using the STL library, just Xlib. Don''t ask why. I like to do things completely on my own, and it can''t be THAT hard. I''ve managed to create a window and render opengl stuff to it. The problem is making my window fullscreen and supporting multiple resolutions. I''m quite new to X windows programming, and i have found it hard to find good information about these things online. If anyone has succeeded in creating a fullscreen window in X with just Xlib, i''d really appreciate any advice and/or source code you could throw my way. Marijn
Advertisement
To set your expectations properly there is not really a platform-independent way to change resolutions in X windows.

Most opengl apps just create a window that is the size of the current resolution of the X server and turn off window decorations (borders, title bar, etc...).

You might want to dig through the glut source code and see how it's done there. http://www.opengl.org/developers/documentation/glut/

Sorry. several people have come by my office this morning. More info later.

[edited by - mauman on July 28, 2003 12:05:45 PM]
---CyberbrineDreamsSuspected implementation of the Windows idle loop: void idle_loop() { *((char*)rand()) = 0; }
Ah, that''s too bad. On lower-end computers the desktop is usually of a resolution that you do NOT want to use for rendering 3d graphics (don''t need a big computer to do windowing in 1024 resolution, but for rendering in that resolution you''ll need a serious video card). I guess i''ll end up using STL in the end. How about svgalib, is that still a decent alternative?

Marijn
I suggest you use SDL. It does a lot more fine tuning that you own Xlib code would probably do because it has had a lot of time to mature. But, if you still don''t want to use SDL, take a look at its code for ideas of what functions to use where and such. No direct copying and pasting unless you''re going to respect its license, of course .

glX is sometimes faster but never slower than SDL. i sugest you look into the sourcecodes of some open-source linux games if you are looking for X11''s fullscreen function. you might also want to look into the SDL source.
our new version has many new and good features. sadly, the good ones are not new and the new ones are not good
I implemented my wrapper with SDL now, but it still does not change resolutions when working with X. I use the SDL_SetDisplayMode function, which DOES change resolutions when working in win32, but it just gives me my desktop resolution and only uses a 640x480 (for example) part of that for drawing. Is this normal? If it is, i DEFINITELY have to find a better way to do this.

Marijn
extrange thing. I've coded some thinguies with SDL and it DOES change the resolution in X (linux)... I'll see if I find those sources.

EDIT: One of the sites hosted here have tutorials about SDL and I took the video initialization from there.

[edited by - xaxa on July 29, 2003 6:33:57 AM]
[size="2"]I like the Walrus best.
Dont you need to have the resolutions set up in XF86Config. On My X I have theses modes setup, 320x240, 640x480, 800x600, 1024x768.

You have to select one of theese modes in SDL for it to work right:

//Will work if F/S
SDL_SetVideoMode( 320, 240, 16, SDL_FULLSCREEN | SDL_OPENGL );

//Will not work in F/S
SDL_SetVideoMode( 512, 384, 16, SDL_FULLSCREEN | SDL_OPENGL );

I just make sure any fullscreen mode I want is defined in the config files and only use ones on that list.

Sorry if this doesn''t help or I''m being naive.
that makes a lot of sense
[size="2"]I like the Walrus best.
Oh yeah, those modes, i''ve been screwing around with my X config file so it is quite likely i commented out all other video modes, will have a look at that!

Marijn

This topic is closed to new replies.

Advertisement