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 (568)
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  
  Widescreen Display without skewing (LWJGL)  (Read 1202 times)
0 Members and 1 Guest are viewing this topic.
Offline QuicK

Junior Member





« Posted 2013-02-19 02:58:12 »

When working with LWJGL in a 3d environment using gluPerspective (using HD resolution such as 16x9, or anything larger than 1), there is the same amount of viewable space on the (2d) x and y axes.

Because of this, the screen appears to be stretched on whichever side is larger.

I've read that supposedly, multiplying all of the rendering by the projection matrix will fix this, but cannot find anywhere how I would go about doing so.
sorry, misread that tutorial.

I'm pretty confident most people know what I'm talking about, but I might have worded it weirdly. Let me know if you would like screenshots, or if you would like to test it yourself, make a button binding to toggle between gluPerspective(60, width/height, 0.1f, 1000f), and gluPerspective(60, 1, 0.1f, 1000f)

the latter is what I am trying to achieve while still keeping the same screen size (1600x900)
Offline ra4king

JGO Kernel


Medals: 347
Projects: 3
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2013-02-19 05:36:10 »

When working with LWJGL in a 3d environment using gluPerspective (using HD resolution such as 16x9, or anything larger than 1), there is the same amount of viewable space on the (2d) x and y axes.
Wait....that's not true.

What's wrong with (width/height)? That's how it's supposed to be.

Offline QuicK

Junior Member





« Reply #2 - Posted 2013-02-19 05:57:20 »

The aspect ratio is technically correct, and maybe this is just an issue with OpenGL itself.

When running a game on the source engine (and most other engines), you can look straight down (assuming a 3d environment) and rotate on the y axis extremely fast.

It will produce what appears to be a perfect circle.  With LWJGL using gluPerspective, it creates an oval (unless the aspect ratio is 1).  It's even an issue in one of the most popular titles of our days (Minecraft)

Some might not consider it an issue, but to me, it creates an unrealistic 3d environment.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Danny02
« Reply #3 - Posted 2013-02-19 09:08:45 »

sry, but you are doing something wrong. When you set 1 as the ratio you will get a stretched view and therefor ellipses instead of circles.

ps: HD means high definition, you are looking for the term widescreen.
pps: strange that when people want OpenGL help they are looking for lwjgl, but when there is a problem with the lib it is OpenGLs fault Smiley
Offline QuicK

Junior Member





« Reply #4 - Posted 2013-02-19 10:36:00 »

I'm sorry Danny. I wrote the wrong thing.  I meant when the aspect ratio AND the screen dimensions are a 1:1 ratio.  

ps: I know what HD means, please don't be a jerk.
pps: I am well aware of the difference between OpenGL, and LWJGL.

ppps: Your reply was neither constructive nor informative, please reply with a better response next time. But thank you for at least taking the time to read the post I guess...
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 803
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #5 - Posted 2013-02-19 11:17:30 »

as width and height are ints, width/height is most likely 1, or even 0 on a monitor in portrait mode.

1  
2  
-   gluPerspective(60, width/height, 0.1f, 1000f)
+   gluPerspective(60, (float)width/height, 0.1f, 1000f)

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline ra4king

JGO Kernel


Medals: 347
Projects: 3
Exp: 5 years


I'm the King!


« Reply #6 - Posted 2013-02-20 01:16:00 »

Ha I was actually thinking that might be the problem but I assumed the OP would be smart enough to catch the error.

Offline sproingie

JGO Kernel


Medals: 202



« Reply #7 - Posted 2013-02-20 02:46:27 »

IDEA gives me a warning if I do integer division in float or double context.  FindBugs will do the same for Eclipse.  I recommend installing and using it.
Offline QuicK

Junior Member





« Reply #8 - Posted 2013-02-20 08:35:05 »

Thanks guys.

ra4king: debugging doesn't have much to do with being smart, only with looking in the right places.  I apparently was not.
(you're normally really nice and helpful so I won't hold a grudge Tongue)
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 (40 views)
2014-09-24 16:13:29

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

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

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

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

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

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

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

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

BurntPizza (55 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!