Changing window size in code.

Anything libgdx related goes here!

Changing window size in code.

Postby mmtbb » Wed Dec 22, 2010 6:18 pm

I notice that while testing my app on the desktop, I can resize the window, and the graphics resize as well. That is pretty nice. I know I can retreive the size of the window, but is there a way to resize the window with code (without dragging the corners)? Say I touch the screen and it resizes the window to 240x320, for instance.
mmtbb
 
Posts: 135
Joined: Thu Nov 11, 2010 6:56 pm

Re: Changing window size in code.

Postby mzechner » Wed Dec 22, 2010 7:55 pm

No, and it's unlikely that we'll add that feature as it is not portable.
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: Changing window size in code.

Postby NateS » Wed Dec 22, 2010 8:16 pm

The feature doesn't apply to Android, but does to the desktop, where we need a way to set the app to fullscreen and to change the resolution (window size in windowed mode).
NateS
 
Posts: 1980
Joined: Fri Nov 12, 2010 11:08 am

Re: Changing window size in code.

Postby mmtbb » Wed Dec 22, 2010 8:27 pm

ok, thanks. I was hoping for an easy solution to scale my game to different size android devices. I'll go on to plan B. :)
mmtbb
 
Posts: 135
Joined: Thu Nov 11, 2010 6:56 pm

Re: Changing window size in code.

Postby BurningHand » Wed Dec 22, 2010 8:57 pm

You want to scale the desktop window to match different Android screen sizes?
IRC: nexsoftware / mobidevelop; GitHub: MobiDevelop;
BurningHand
 
Posts: 2812
Joined: Mon Oct 25, 2010 4:35 am

Re: Changing window size in code.

Postby mmtbb » Wed Dec 22, 2010 9:01 pm

no. The desktop has a feature that I was wondering if it was implimented with the actual android app, which it doesn't.
mmtbb
 
Posts: 135
Joined: Thu Nov 11, 2010 6:56 pm

Re: Changing window size in code.

Postby BurningHand » Wed Dec 22, 2010 9:04 pm

I'm pretty sure that it scales automatically for the screen.
IRC: nexsoftware / mobidevelop; GitHub: MobiDevelop;
BurningHand
 
Posts: 2812
Joined: Mon Oct 25, 2010 4:35 am

Re: Changing window size in code.

Postby mzechner » Wed Dec 22, 2010 10:22 pm

that "feature" is related to how you set your OpenGL ES viewport (glViewport) and how you set your projection matrices. Actually it only has to do with the viewport. No matter your projection matrix your final output image will be scaled to the viewport, which is specified as bottom left corner in pixels and width and height in pixels. In OpenGL ES non-the-less. Has nothing to do with libgdx or desktop/android stuff.
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: Changing window size in code.

Postby mmtbb » Thu Dec 23, 2010 7:03 pm

Mario,

I have a scaling routine that will work for the textures. The only thing I have to work out now are the fonts. spriteBatch.draw() has a nice param that allows you to draw a rectangle smaller or bigger than the original. Would it be possible to add a parameter to the bitmapfont.draw() function to scale the bitmapfont?
mmtbb
 
Posts: 135
Joined: Thu Nov 11, 2010 6:56 pm

Re: Changing window size in code.

Postby NateS » Thu Dec 23, 2010 7:56 pm

BitmapFont has methods for scaling in SVN. However, that isn't the right way to do it. You should change the projection matrix of your SpriteBatch. This allows you to hardcode all your code to use a specific resolution, and that will get automatically scaled by OpenGL to fill the screen, no matter what the real resolution of the screen is.
NateS
 
Posts: 1980
Joined: Fri Nov 12, 2010 11:08 am

Next

Return to Libgdx

Who is online

Users browsing this forum: diazndc, Google [Bot] and 1 guest