Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  No window resize in LWJGL?  (Read 9539 times)
0 Members and 1 Guest are viewing this topic.
Offline preshel

Senior Newbie





« Posted 2007-02-03 23:43:32 »

What haven't I seen any LWJGL demo app with a resize-window function?...
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #1 - Posted 2007-02-03 23:56:35 »

For native window displays, you would need to recreate the window, the context stays the same so no need to re-init your code/textures/display lists and all that jazz

For AWT, you can use the resize icon and add a WindowListener and use glViewport(position.x, position.y, dimension.x, dimension.y); to change the renderable area of the canvas.

Note that the position isn't the position of the window in terms of the desktop, its mostly 0,0 which means bottom left.

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #2 - Posted 2007-02-03 23:58:16 »

why would you need it for a game, no really

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline woogley
« Reply #3 - Posted 2007-02-04 04:09:48 »

just shove AWTGLCanvas in a JFrame if you *really* need window resizing..
Offline Evil-Devil

Senior Member


Medals: 2


Fir Tree Master


« Reply #4 - Posted 2007-02-06 09:27:19 »

just shove AWTGLCanvas in a JFrame if you *really* need window resizing..
But resizing the AWTGLCanvas is simple as you only have to resize the viewport if you not create a canvas that have the size of a fullscreen window. Else dump the old and create a new one. Of course they have to be shared ones!
Offline princec

JGO Kernel


Medals: 386
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #5 - Posted 2007-02-06 11:15:01 »

I expect we will make the window resizable in LWJGL1.1 anyway.

Cas Smiley

Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #6 - Posted 2007-02-06 13:01:38 »

heh, did you just volunteer ?

Offline princec

JGO Kernel


Medals: 386
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #7 - Posted 2007-02-06 15:18:34 »

Bah no, I don't need that feature Wink I'm sticking to writing games with it now!!

Cas Smiley

Offline preshel

Senior Newbie





« Reply #8 - Posted 2007-02-07 07:41:10 »

Hi all, thanks for the answers, but unfortunatelly i dont understand any.. im way too novice for that stuff.... does anyone have a pre-mayde code for resizing?

Matzon : I Need it cuz my screen size (14" laptop) is not the same as my friends desktop, and I would like to offer
an options to view it all over the screen, but not in fullscreen mode...

Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #9 - Posted 2007-02-07 09:11:44 »

When we talk about resizing the screen, we're talking about live resize - drag with mouse stuff.
If you need to create a window in another size, just pass another DiplayMode to the create method

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #10 - Posted 2007-02-07 09:38:03 »

Hi all, thanks for the answers, but unfortunatelly i dont understand any.. im way too novice for that stuff.... does anyone have a pre-mayde code for resizing?

Matzon : I Need it cuz my screen size (14" laptop) is not the same as my friends desktop, and I would like to offer
an options to view it all over the screen, but not in fullscreen mode...


Display.getDisplayMode() gets you the current display mode (including size). If you havn't created a display yet, this will be the size of the desktop. So just use the current display mode and create a windowed display with it.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline preshel

Senior Newbie





« Reply #11 - Posted 2007-02-08 16:59:48 »

Im talking about an option for real-time resizing... how can that be preformed? no code examples available anywhere? (btw - thanks for the tips on the displaysize)
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #12 - Posted 2007-02-08 17:50:45 »

real time resizing with mouse isn't possible.
The only resizing you can do is destroying the display and create a new one with the requested size

Offline preshel

Senior Newbie





« Reply #13 - Posted 2007-02-08 18:05:43 »

How  can i retrieve the max width/height of my screen ?
Offline Evil-Devil

Senior Member


Medals: 2


Fir Tree Master


« Reply #14 - Posted 2007-02-09 08:42:04 »

You can use getAvailableDisplayModes() to fetch every supported mode, or use the AWTToolkit to get the current screen measures.
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #15 - Posted 2007-02-09 08:44:24 »

... or use the AWTToolkit to get the current screen measures.

Quote
Display.getDisplayMode() gets you the current display mode (including size). If you havn't created a display yet

Offline preshel

Senior Newbie





« Reply #16 - Posted 2007-02-10 11:01:34 »

Ok, Thanks, I'll try it.
Offline andrewxios

Junior Newbie





« Reply #17 - Posted 2011-12-16 21:40:58 »

of course it is possible, although this post is very old, setting the viewport does change the dimensions but it does this only every second time.
this is what i did:

1  
2  
3  
4  
5  
6  
7  
public static void onResize()
   {
      GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight());
   }
...
if(Display.wasResized())
            onResize();
Offline ra4king

JGO Kernel


Medals: 347
Projects: 3
Exp: 5 years


I'm the King!


« Reply #18 - Posted 2011-12-16 21:55:23 »

..... way to revive this thread from the dead. We don't need zombies roaming around!! Tongue

Offline andrewxios

Junior Newbie





« Reply #19 - Posted 2011-12-16 21:58:20 »

i found this thread on google because of the problem 'does this only every second time' and i couldnt find any other threads about that specific problem xD.
Offline princec

JGO Kernel


Medals: 386
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #20 - Posted 2011-12-16 22:47:30 »

Works every time for me...

Cas Smiley

Offline theagentd
« Reply #21 - Posted 2011-12-17 06:31:12 »

Or create a JFrame, add a Canvas, set the Canvas to the Display's parent (Display.setParent(Canvas)), and resize the JFrame in any way you like. AWTGLCanvas is deprecated.

Myomyomyo.
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 77
Projects: 15


★★★★★


« Reply #22 - Posted 2011-12-17 09:48:08 »

Most of information in this thread is now out of date. So just by way of update, as of LWJGL 2.8 the native Display has the ability to be resized.

Its disabled by default but to enable it you call the following method Display.setResizable(true);

Then you can call Display.isResized() which will return a boolean to let you know if the Display has been resized, allowing you to resize your content accordingly. The Display.getWidth() and Display.getHeight() are also new, giving you further information of the window size.
Offline Cero
« Reply #23 - Posted 2011-12-17 17:33:51 »

you know its still doesn't work

just use Display.setResizable(true);
make the background color like red

not draw a line or something which is as long as the width

if you resize it so thats smaller, its all fine, but bigger, that new space is not drawn to

this is just Display.setResizable(true); and not changing the glViewport, because that would just shrink/stretch everything

Offline theagentd
« Reply #24 - Posted 2011-12-17 18:46:23 »

you know its still doesn't work

just use Display.setResizable(true);
make the background color like red

not draw a line or something which is as long as the width

if you resize it so thats smaller, its all fine, but bigger, that new space is not drawn to

this is just Display.setResizable(true); and not changing the glViewport, because that would just shrink/stretch everything
If you don't update the glViewport, you can't draw outside the old boundaries. Try to add GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight()); to the beginning of your game loop inside an if-statement checking Display.isResized(), just like Kappa said.

Myomyomyo.
Offline Cero
« Reply #25 - Posted 2011-12-17 18:54:16 »

yeah like I said, you stretch everything then, which I dont wanna do

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 801
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #26 - Posted 2011-12-17 19:28:04 »

then also adjust your projection matrix Clueless

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (44 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (62 views)
2014-09-21 02:42:18

BurntPizza (32 views)
2014-09-21 01:30:30

moogie (39 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!