LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Arvigeus on April 21, 2010, 14:23:38

Title: XRandR question (noob)
Post by: Arvigeus on April 21, 2010, 14:23:38
I'm trying to write a program that controls the display (changing resolutions, rotating, external monitor and etc). The problem is I have little experience in Java, so I have troubles using LWJGL. I use XRandR.java source file added to my project and trying to make a wrapper for it. What do I need to list displays for example and execute commands (like "xrandr --output ZZZ --scale XXXxYYY"); ?

Sorry for bothering... :(
Title: Re: XRandR question (noob)
Post by: Fool Running on April 21, 2010, 16:55:28
I'm not exactly sure what you're trying to do, but LWJGL has the function Display.getAvailableDisplayModes() that lists the display modes supported and then you can pass them to Display.setDisplayMode() to create a full-screen display in that resolution.

If all you're trying to do is use XRandR to change resolutions, etc. without LWJGL, that is, obviously, outside the scope of LWJGL and you'll probably not get much help here, sorry.

EDIT: You might try a Linux forum for help with XRandR...
Title: Re: XRandR question (noob)
Post by: ryanm on April 21, 2010, 17:21:36
Hello there
If you're using LWJGL I'm not sure you should be using this class directly. If you're not using LWJGL,
find a version of the class that isn't tied into it over here (http://rugl.googlecode.com/svn/Util/src/com/ryanm/util/XRandR.java).

Listing possible resolutions:
for( String name : XRandr.getScreenNames() )
{
for( XRandr.Screen s : XRandr.getResolutions( name ) )
{
System.out.println( s );
}
}


To set a configuration, search through the arrays of possible resolutions as above for the ones you want, and pass them to XRandr.setConfiguration().

The class doesn't support rotation, but it would be easy to add.
Title: Re: XRandR question (noob)
Post by: Arvigeus on April 21, 2010, 18:36:48
 :D
Thanks a lot! Although I don't understand much of it, it simply works! I was struggling with this the whole day.
I never knew about for(String name : XRandR.getScreenNames()) syntax.
Title: Re: XRandR question (noob)
Post by: Fool Running on April 22, 2010, 12:09:58
Wow, I never realized that LWJGL has a utility for access to XRandR.

I guess I've made a fool of myself. :-[
Title: Re: XRandR question (noob)
Post by: Matzon on April 22, 2010, 12:38:49
was added recently :)
Title: Re: XRandR question (noob)
Post by: ryanm on April 22, 2010, 13:17:33
It probably should be made package-private. Having two different ways to change resolution seems like an accident waiting to happen to me, plus it's platform-specific.
Title: Re: XRandR question (noob)
Post by: princec on April 22, 2010, 13:29:23
I think it should probably remain public. Let people who know what they're doing use it, etc. etc. We're not in the restriction game.

Cas :)
Title: Re: XRandR question (noob)
Post by: kappa on April 22, 2010, 13:48:43
I think ryanm has the right idea in this case, all the public methods in XRandr should be made package-private. Last thing you need is an unsigned jar using the lwjgl certificate to pull of some crazy xrandr graphics hack/crash :)

Besides its pretty minimal amount of code, in the extremely rare case you need to use XRander directly, you can just copy and paste the class and use it with your own code.
Title: Re: XRandR question (noob)
Post by: princec on April 22, 2010, 15:10:17
The XRandR code should be privileged, not private ... and if a signed app wants to do a crazy XRandR hack then that's fine, that's what signed apps are for.

Cacs :)
Title: Re: XRandR question (noob)
Post by: kappa on April 22, 2010, 18:36:41
Quote from: princec on April 22, 2010, 15:10:17
The XRandR code should be privileged, not private ... and if a signed app wants to do a crazy XRandR hack then that's fine, that's what signed apps are for.

Cacs :)

you know that actually makes sense, I now agree with you :)