PDA

View Full Version : Fullscreen problems



marcus256
06-03-2002, 10:22 PM
I have two problems which I would like to solve for the X11 version of GLFW (they are both related to fullscreen functionality):

1) With pure Xlib (no XF86VidMode), is there a way to determine the physical display size? DisplayWidth/DisplayHeight & WidthOfScreen/HeightOfScreen unfortunately return the virtual size of the display.

2) With XFree86 it is possible to change the display resolution with CTRL+ALT+[keypad +/-]. Is there a way to prevent this behaviour (block these actions), or at least detect them.

zen
06-04-2002, 05:11 PM
Unfortunately I don't know the answer to your first question.Regarding the CTRL+ALT+[+-] though,since xlib uses VidMode to switch resolution at runtime you can use XF86VidModeLockModeSwitch(or something like that,jesus are these names long) to do so.Just remember to unlock before exiting.I'm going to post on the first one if I find anything.

Edit:regarding the display size.There must be a way to find out since most window managers have a max size toggle for their windows.I doubt they rely on VidMode,besides it doesn't make sense for xlib ont to expose something like that.Maybe it can be calculated from the calls you used( and others).

[This message has been edited by zen (edited 06-04-2002).]

marcus256
06-04-2002, 08:35 PM
Thank you zen!

Yes, you're correct about XF86VidModeLockModeSwitch. I'm surprised I didn't see it before, it's exactly what I need. http://www.opengl.org/discussion_boards/ubb/smile.gif

About the other question, I still have not found a solution. Even if there are no clear solutions, there usually is some way to solve these things (in my experience). For instance, there is no way to set the viewport without XF86VidModeSetViewPort(), but you can "fool" the display by using XWarpPointer() to position the cursor in the four corners of the viewport that you want. Heck, on the C=64 you could not access memory address $0001, since it was mapped to a control register in the CPU, but people worked around it by using techniques like sprite collision detection...

Rob Fletcher
06-05-2002, 12:44 AM
Hi Marcus ... C=64 ahh, those were the days!

Using the Zeus assembler, sprites, oh such
fun! And using those raster interrupts to
"apparently" make the screen look wider!

I'll check out the X stuff for you.

R.

marcus256
06-05-2002, 04:19 AM
Hello Rob!

I'm glad my question got your attention http://www.opengl.org/discussion_boards/ubb/smile.gif You're obviously very skilled with the X Window System.

Yes, the C=64 really rocked (and still does, apparently). I'm still amazed by how well balanced the design was - pretty much everything was HW accelerated back then: animated sprites (change animation "frame" by changing a memory pointer, and screen position by setting three bytes), HW collision detection (wouldn't that be nice in OpenGL? http://www.opengl.org/discussion_boards/ubb/wink.gif ), three channel sound with automatic envelope generation (and filters etc), HW graphics scrolling (change only one byte to control display pixel offset), character based graphics display (only need to change 40x25=1000 bytes for a complete screen update, where the screen consists of 32000 or 64000 pixels depending on resolution), etc. etc.

[This message has been edited by marcus256 (edited 06-05-2002).]

06-05-2002, 05:45 PM
One such trick I heard about is to get the viewport size for the root window. This should give you the physical screen size if I understood the trick right. Never tested it myself.

marcus256
06-05-2002, 08:51 PM
Zico, do you have any idea of how that is done? I stumbled upon something called _NET_DESKTOP_VIEWPORT, is that it? (but I think it's the viewport position, not size)

Rob Fletcher
06-06-2002, 03:41 AM
Here's some code which might help ... possibly

rob.


#include <stdio.h>
#include <X11/Xlib.h>
main (int argc, char **argv )
{
Display *dpy;
unsigned int width, height, border_width, depth;
int x,y;
Drawable rootwin ,root;
Screen * screen;
XWindowAttributes windowattr;

dpy = XOpenDisplay(NULL);
screen = DefaultScreenOfDisplay(dpy);
rootwin = RootWindowOfScreen(screen);
width = WidthOfScreen(screen);
height = HeightOfScreen(screen);
printf("Height %d Width %d\n",height, width);

XGetWindowAttributes(dpy, rootwin,&windowattr);
width = windowattr.width;
height = windowattr.height;
printf("Height %d Width %d\n",height, width);

XGetGeometry(dpy, rootwin, &root, &x,
&y, &width, &height, &border_width, &depth);
printf("Height %d Width %d\n",height, width);
}

zen
06-06-2002, 07:48 AM
Pretty clever that.Should work.Btw rob since you seem to know stuff about X,what's the best way of getting the contents of a window(in 8bpp,16bpp,24bpp whatever) in order to save them to a file?I've tried XGetImage with 0x0L for plane_mask and ZPixMap but I get a blank image.May be a packing problem.Sorry for hijacking your thread marcus.

marcus256
06-06-2002, 11:26 PM
Thanks a million, Rob!

I will try it as soon as I boot up Linux http://www.opengl.org/discussion_boards/ubb/smile.gif

Rob Fletcher
06-06-2002, 11:59 PM
Hi ... not really an X *expert*, just not really afraid to program the *beast*.

Check
http://web.mit.edu/afs/athena.mit.edu/contrib/graphics/src/xgrabsc/xgrabsc.c

for source code which should have all you
need ... you *were* on exactly the right track.


rob.

marcus256
06-07-2002, 03:30 AM
Hello again... I tried your source, but the three versions all gave the same result (I'm using a 1024x768 virtual display on a 800x600 screen to test this). I think you need to get some sort of viewport information (the size of the root window seems to always be the size of the virtual display - which seems logical). I suspect that it is a non-standard thing (perhaps there is a window manager protocol or something similar that can give this sort of information?).

Rob Fletcher
06-07-2002, 05:32 AM
Hi Marcus ... I suspect I was thinking along different lines ...

Check in Xatom.h for the XA_WM_<blah> stuff to see if you can do an XGetWindowProperty() call get the Window Manager property.

You might find

#define XA_WM_SIZE_HINTS ((Atom) 41)

or other *friends* which may be of assistance.

Off for a week now ... graphics Conference to run (EGUK, I'm Chairman)

Post here code if you get it to work!

Rob.

06-09-2002, 11:53 PM
No, I do not know how to do it or even if it is possible. Perhaps could you get the graphic context and check if the clip area is set to the physical screen size?
Other unices than linux is often used on more expensive system with big monitors perhaps is virtual desktops not so common on them anyway?

marcus256
06-11-2002, 10:19 PM
Perhaps could you get the graphic context and check if the clip area is set to the physical screen size?

I suppose you're refering to the GL context? I think it is set to the window size, which in turn is set to the (virtual) desktop size.


Other unices than linux is often used on more expensive system with big monitors perhaps is virtual desktops not so common on them anyway?

I guess you're right. Personally I'm not very concerned, but the thing is that when a virtual desktop is used, the fullscreen functionality of GLFW becomes pretty useless (the mouse cursor is hidden and always centered, so it's impossible to 'pan' the view with the mouse). I will release GLFW as it is anyway, but it would be a very nice bonus if I could solve this.

06-12-2002, 12:18 AM
I was thinking about the context for xlib graphics that the root window is using. I have not checked but it seems possible that it is set to the actual screen size.

06-12-2002, 12:36 AM
If you can not get the actual screen size is an alternative to export a fullscreen function that takes width and height as argument. I have not checked your library yet but if it can be mixed with X code could the extra function be good. I assume most unices has X extensions that could be used to get/set the width and height.

zen
06-12-2002, 11:20 AM
One point I don't understand is why you don't want to use VidMode(or don't want ot rely on it anyway).I think everybody who has XFree86 has it.Do you know of any reasons why someone would tell X not to load it?I'm asking because I rely on the fact that it will be there.

PS:As I said in my first post windowmanagers (at leat enlightnenment) seem to know the actual size of the screen.Just take a peek at the code of a simple one in the part that maximizes windows and see how the width,height is calculated.It's not a very attractive solution I know but it might work

[This message has been edited by zen (edited 06-12-2002).]

marcus256
06-15-2002, 10:54 PM
Zen,

Yes. For XFree86 this is not a problem. The solution is for non-XFree86 servers (GLFW is not limited to run only on Linux).

I may have a look at some source codes for window managers (dirty work).

scriptlord
06-27-2002, 08:26 PM
#include <GL/glut.h>
then make sure you have
int main(int argc, char **argv){
then just type GlutInit(&argc, argv);
then you need glutGameModeString("640x480:16@16");
then use
glutEnterGameMode();
and that should do it

zen
06-28-2002, 11:10 AM
I think that marcus is working on some sort of GLUT-like library(GLFW) so using GLUT shouldn't be an option.Besides this propably uses the vidmode extension.If it doesn't it might be worth taking a look at the source.