Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (612)
Games in Android Showcase (172)
games submitted by our members
Games in WIP (658)
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 1795 times)
0 Members and 1 Guest are viewing this topic.
Offline QuicK

Junior Devvie

« 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: 389
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 Devvie

« 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 Devvie

« 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...
Online Riven
« League of Dukes »

« JGO Overlord »

Medals: 1039
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.

-   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: 389
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 Devvie

« 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.

afikri (9 views)
2015-08-31 09:30:22

afikri (17 views)
2015-08-31 09:30:07

afikri (7 views)
2015-08-31 09:27:24

afikri (11 views)
2015-08-31 09:26:40

Roquen (16 views)
2015-08-29 11:30:54

GamerC4 (29 views)
2015-08-22 20:38:50

GamerC4 (24 views)
2015-08-22 20:37:18

GamerC4 (29 views)
2015-08-22 20:37:01

Kefwar (34 views)
2015-08-22 18:07:24

GamerC4 (26 views)
2015-08-22 01:00:24
HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30 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‑
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!