Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411430 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 20, 2024, 02:19:57 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Resizing window content [LWJGL]
Pages: [1]
Print
Author Topic: Resizing window content [LWJGL]  (Read 3010 times)
Rion
Level 0
*

Hello!


View Profile
« on: August 15, 2012, 05:41:25 AM »

Hi, I am trying to create "oldschool" look for my game, which is made in OpenGL with framework LWJGL. I need to rescale the pixels in window by given number, but only thing I can set with LWJGL is the size of window.

Here's montage of what I mean:


Thank you for any advice.
« Last Edit: August 15, 2012, 06:04:24 AM by Rion » Logged
DeadPixel
Level 2
**



View Profile WWW
« Reply #1 on: August 15, 2012, 05:44:04 AM »

You want to scale up without resizing the window, correct?  Then just add a scale matrix to the transform matrix you pass into your shader/draw functions.
Logged

Rion
Level 0
*

Hello!


View Profile
« Reply #2 on: August 15, 2012, 05:55:15 AM »

Um, I am not sure, what you mean. I have just started with OpenGL. Could you be more specific?
Logged
zacaj
Level 3
***


void main()


View Profile WWW
« Reply #3 on: August 15, 2012, 06:05:29 AM »

I think what you want to do is render at a different 'internal resolution' and then upscale that to your window size

You need to render to a FBO with the same dimensions as the smaller window, then bind that as a linearly filtered texture and draw it as a full screen quad. Google fbo, framebuffer, render to texture, etc
Logged

My twitter: @zacaj_

Quote from: mcc
Well let's just take a look at this "getting started" page and see--
Quote
Download and install cmake
Noooooooo
Liosan
Level 2
**


View Profile
« Reply #4 on: August 15, 2012, 06:16:52 AM »

In addition to what zacaj wrote about FBOs, you could try one of the fancy scaling algorithms like 2xSal. Things like that are used for instance in DOSBox for upscaling old games. They seem theoretically doable in a post-process shader, I've never tried it myself but always wanted to see how it turns out Smiley

If you have trouble with FBOs with LWJGL, I can try to help you out, I did that recently myself. Pretty straightforward once you get your head around what's actually required Smiley

Liosan
Logged

R.D.
Level 2
**


Making a game about balls. Yepp.


View Profile WWW
« Reply #5 on: August 15, 2012, 08:35:55 AM »

if you using simple fixed function (OpenGL Version < 2.0), just scale the via GL10.glscale(). You should push the current matrix before that and pop after you down rendering your scene (if you want to render some debug in normal size and stuff).
You can push and pop with glPushMatrix and glPopMatrix (bot located in GL10).

That is the most simple solution. Have a quick look at Slick2D. It uses almost only OpenGL 1-2.
Logged

zacaj
Level 3
***


void main()


View Profile WWW
« Reply #6 on: August 15, 2012, 10:14:42 AM »

if you using simple fixed function (OpenGL Version < 2.0), just scale the via GL10.glscale(). You should push the current matrix before that and pop after you down rendering your scene (if you want to render some debug in normal size and stuff).
You can push and pop with glPushMatrix and glPopMatrix (bot located in GL10).

That is the most simple solution. Have a quick look at Slick2D. It uses almost only OpenGL 1-2.
This won't produce the pixelated effect in the image above, which I assumed was intentional.
Logged

My twitter: @zacaj_

Quote from: mcc
Well let's just take a look at this "getting started" page and see--
Quote
Download and install cmake
Noooooooo
R.D.
Level 2
**


Making a game about balls. Yepp.


View Profile WWW
« Reply #7 on: August 15, 2012, 11:37:47 PM »

Of course it does oO You just scale the projection matrix. Maybe you smooth your lines? and load your graphics with a linear filter and no Midmap?
As said, have a peek at Slick2D. There you have the exact effect in teh Graphics class Smiley Also you might want to go to JavaGamingOrg. The creators and Maintainer of LWJGL are lurking around there :D

btw. I don't know how you set up your viewport and all, so I can't tell for sure :D I know Minecraft does something similiar but I haven't looked into the source for ages and it's a hell of a mess too xD

You can still go with a framebuffer tho. Just bind a buffer draw everything and then render the framebuffer quad to the screen with the scale factor you want. But load the framebuffer with a nearst filter Wink
Logged

zacaj
Level 3
***


void main()


View Profile WWW
« Reply #8 on: August 16, 2012, 02:02:41 AM »

Scaling the projection matrix will make everything bigger, but it won't be pixelated any more than the small image is
Logged

My twitter: @zacaj_

Quote from: mcc
Well let's just take a look at this "getting started" page and see--
Quote
Download and install cmake
Noooooooo
R.D.
Level 2
**


Making a game about balls. Yepp.


View Profile WWW
« Reply #9 on: August 16, 2012, 02:08:39 AM »

I understand now, sorry. You probalty want to use a framebuffer here really. Slick2D has to Implementations for this. One works without are framebuffer (PBuffer afair).
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic