preshel
Senior Newbie 
|
 |
«
Posted
2007-02-04 00:43:32 » |
|
What haven't I seen any LWJGL demo app with a resize-window function?...
|
|
|
|
|
darkprophet
Senior Member   
Go Go Gadget Arms
|
 |
«
Reply #1 - Posted
2007-02-04 00: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
|
|
|
|
Matzon
|
 |
«
Reply #2 - Posted
2007-02-04 00:58:16 » |
|
why would you need it for a game, no really
|
|
|
|
Games published by our own members! Check 'em out!
|
|
woogley
|
 |
«
Reply #3 - Posted
2007-02-04 05:09:48 » |
|
just shove AWTGLCanvas in a JFrame if you *really* need window resizing..
|
|
|
|
|
Evil-Devil
|
 |
«
Reply #4 - Posted
2007-02-06 10: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!
|
|
|
|
|
princec
|
 |
«
Reply #5 - Posted
2007-02-06 12:15:01 » |
|
I expect we will make the window resizable in LWJGL1.1 anyway. Cas 
|
|
|
|
Matzon
|
 |
«
Reply #6 - Posted
2007-02-06 14:01:38 » |
|
heh, did you just volunteer ?
|
|
|
|
princec
|
 |
«
Reply #7 - Posted
2007-02-06 16:18:34 » |
|
Bah no, I don't need that feature  I'm sticking to writing games with it now!! Cas 
|
|
|
|
preshel
Senior Newbie 
|
 |
«
Reply #8 - Posted
2007-02-07 08: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...
|
|
|
|
|
Matzon
|
 |
«
Reply #9 - Posted
2007-02-07 10: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!
|
|
Orangy Tang
|
 |
«
Reply #10 - Posted
2007-02-07 10: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.
|
|
|
|
preshel
Senior Newbie 
|
 |
«
Reply #11 - Posted
2007-02-08 17: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)
|
|
|
|
|
Matzon
|
 |
«
Reply #12 - Posted
2007-02-08 18: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
|
|
|
|
preshel
Senior Newbie 
|
 |
«
Reply #13 - Posted
2007-02-08 19:05:43 » |
|
How can i retrieve the max width/height of my screen ?
|
|
|
|
|
Evil-Devil
|
 |
«
Reply #14 - Posted
2007-02-09 09:42:04 » |
|
You can use getAvailableDisplayModes() to fetch every supported mode, or use the AWTToolkit to get the current screen measures.
|
|
|
|
|
Matzon
|
 |
«
Reply #15 - Posted
2007-02-09 09:44:24 » |
|
... or use the AWTToolkit to get the current screen measures.
Display.getDisplayMode() gets you the current display mode (including size). If you havn't created a display yet
|
|
|
|
preshel
Senior Newbie 
|
 |
«
Reply #16 - Posted
2007-02-10 12:01:34 » |
|
Ok, Thanks, I'll try it.
|
|
|
|
|
andrewxios
Junior Newbie
|
 |
«
Reply #17 - Posted
2011-12-16 22: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(); |
|
|
|
|
|
ra4king
|
 |
«
Reply #18 - Posted
2011-12-16 22:55:23 » |
|
..... way to revive this thread from the dead. We don't need zombies roaming around!! 
|
|
|
|
andrewxios
Junior Newbie
|
 |
«
Reply #19 - Posted
2011-12-16 22: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.
|
|
|
|
|
princec
|
 |
«
Reply #20 - Posted
2011-12-16 23:47:30 » |
|
Works every time for me... Cas 
|
|
|
|
theagentd
|
 |
«
Reply #21 - Posted
2011-12-17 07: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.
|
|
|
kappa
|
 |
«
Reply #22 - Posted
2011-12-17 10: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.
|
|
|
|
|
Cero
|
 |
«
Reply #23 - Posted
2011-12-17 18: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
|
|
|
|
theagentd
|
 |
«
Reply #24 - Posted
2011-12-17 19: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.
|
|
|
Cero
|
 |
«
Reply #25 - Posted
2011-12-17 19:54:16 » |
|
yeah like I said, you stretch everything then, which I dont wanna do
|
|
|
|
Riven
|
 |
«
Reply #26 - Posted
2011-12-17 20:28:04 » |
|
then also adjust your projection matrix 
|
|
|
|
|