Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

fullscreen OpenGL on X/Linux

0 views
Skip to first unread message

Johannes Behr

unread,
Aug 29, 2002, 11:50:09 AM8/29/02
to
Hi,

I would like to open my OpenSG-XWindow fullscreen.
Pure X, no glut/qt window.

Do I have to resize my window manually to the screen size ?
Do I have to set some window-manager hints ?
I have seen games that even change the screen/display resolution.
How can that be done in X ?

Thanks
johannes

Torsten Mohr

unread,
Aug 29, 2002, 1:51:17 PM8/29/02
to
Hi,

you need the DGA (direct graphics access) functions of X,
take a look at the library "xf86dga" and its functions.

I also tried that before but then went to use "SDL".


Regards,
Torsten.

JB West

unread,
Aug 29, 2002, 9:39:46 PM8/29/02
to
> Do I have to resize my window manually to the screen size ?
You need to query the screen size and create a window of that size, located
at (0,0).

> Do I have to set some window-manager hints ?

Yes. OVERRIDE_REDIRECT in the XWindowAttributes.

> I have seen games that even change the screen/display resolution.
> How can that be done in X ?

Not directly with X.

>

--
JB West | jbw...@acm.org
"Johannes Behr" <jb...@zgdv.de> wrote in message
news:pan.2002.08.29.15...@zgdv.de...

Joerg Seebohn

unread,
Aug 30, 2002, 4:38:01 AM8/30/02
to
> I would like to open my OpenSG-XWindow fullscreen.
> Pure X, no glut/qt window. Do I have to resize my window manually to the screen size ?
> Do I have to set some window-manager hints ?

1. Determine the screen size with
int WIDTH = DisplayWidth (display, DefaultScreen(display)) ;
int HEIGHT = DisplayHeight (display, DefaultScreen(display)) ;

2. Create a window that is as big as the screen and overwrites the
window manager so the window manager does not decorate your full
screen window

int opengl_attribs = { ..., 0 } ;
int scrNr = DefaultScreen(display) ;
Visual* visual = glxChooseVisual (display, scrNr,
opengl_attribs) ;
XSetWindowAttributes attr ;
int attr_mask = CWOverrideRedirect ;
attr.override_redirect = true ;
// needs own colormap cause of non default visual which supports
opengl
attr_mask |= CWColormap ;
attr.colormap = XCreateColormap (display,
RootWindow(display,scrNr), visual, AllocNone) ;
Window win_handle = XCreateWindow (display,
RootWindow(display,scrNr), // parent
0, 0, WIDTH, HEIGH,
0, // border_width
// depth (XFree86 supports only one depth => Opengl visual
must have same depth)
CopyFromParent,
InputOutput,
visual,
attr_mask,
&attr
) ;

> I have seen games that even change the screen/display resolution.
> How can that be done in X ?

0. The following solution runs only on XFree86 X server,
plain X does not support different video modes out of the box
1. Determine all possible video modes (width,height)
2. Switch to the one with the correct (width,height) values
(Do not forget to switch back to original WIDTH, HEIGHT at end of
program)

// need special video mode extension
#include <X11/extensions/xf86vmode.h>

int modecount = 0 ;
XF86VidModeModeInfo** ppModeInfos = 0 ;
bool hasModeChanged = false ;
if (XF86VidModeGetAllModeLines (display, scrNr, &modecount,
&ppModeInfos))
{
for(int i = 0; i < modecount; ++i)
{
XF86VidModeModeInfo* pMode = ppModeInfos[i] ;
if ( SEARCH_FOR_WIDTH == pMode->hdisplay
&& SEARCH_FOR_HEIGHT == pMode->vdisplay
)
{
// found video mode => change it
// and reset viewport in case virtual screens are in use
if (XF86VidModeSwitchToMode (display, scrNr, pMode))
{
XF86VidModeSetViewPort (display, scrNr, 0, 0) ;
hasModeChanged = true ;
break ;
}
}
}
}
if (ppModeInfos) XFree (ppModeInfos) ;

Joerg
www.s.netic.de/jseebohn

Ruud van Gaal

unread,
Aug 30, 2002, 5:19:19 AM8/30/02
to
On 30 Aug 2002 01:38:01 -0700, jsee...@s.netic.de (Joerg Seebohn)
wrote:

>> I would like to open my OpenSG-XWindow fullscreen.

...


>> I have seen games that even change the screen/display resolution.
>> How can that be done in X ?
>
>0. The following solution runs only on XFree86 X server,
> plain X does not support different video modes out of the box

See also 'man XF86VidMode' (case matters, not too sure about the
search them though ;-) )

> // need special video mode extension
> #include <X11/extensions/xf86vmode.h>

Brilliant, I'll try that myself too, thanks.


Ruud van Gaal
Free car sim: http://www.racer.nl/
Pencil art : http://www.marketgraph.nl/gallery/

Ruud van Gaal

unread,
Aug 31, 2002, 8:44:04 AM8/31/02
to
On 30 Aug 2002 01:38:01 -0700, jsee...@s.netic.de (Joerg Seebohn)
wrote:

>> I would like to open my OpenSG-XWindow fullscreen.
...


>> I have seen games that even change the screen/display resolution.
>> How can that be done in X ?

...


> // need special video mode extension
> #include <X11/extensions/xf86vmode.h>

I've tried your code and it works for switching resolution.
I did have some trouble with the virtual screen size being bigger (so
the desktop scrolled around as you moved the mouse) but managed to
solve that using XGrabPointer().

However, can I also somehow switch the depth of the screen? Or is it
like on SGI's, where a desktop can handle multiple different visuals
at the same time (whereas on Windows for example you need to
explicitly request a 16- or 32-bit color depth).

Thanks,

Joerg Seebohn

unread,
Aug 31, 2002, 5:49:37 PM8/31/02
to
> However, can I also somehow switch the depth of the screen? Or is it
> like on SGI's, where a desktop can handle multiple different visuals
> at the same time (whereas on Windows for example you need to
> explicitly request a 16- or 32-bit color depth).

No, both is not possible with XFree86.
If you run the following test program,
you'll see that "nvisuals= 0" for
all supported depths (1,4,8,15,16,24,32)
not equal to your actual screen depth,
i.e. XFree86 supports only visuals
for the current depth.

Screen* sp = ScreenOfDisplay (display, 0) ;
std::cout << "sp->ndepths= " << sp->ndepths << "\n" ;
Depth* dp = sp->depths ;
for(int i = 0; i < sp->ndepths; ++i)
{
std::cout << "depth= " << dp[i].depth << "\n" ;
std::cout << "nvisuals= " << dp[i].nvisuals << "\n" ;
}

Joerg
www.s.netic.de/jseebohn

0 new messages