Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
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 441 times)
0 Members and 1 Guest are viewing this topic.
Offline QuicK

Senior Newbie





« Posted 2013-02-19 03: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)
Online ra4king

JGO Kernel


Medals: 264
Projects: 2


I'm the King!


« Reply #1 - Posted 2013-02-19 06: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

Senior Newbie





« Reply #2 - Posted 2013-02-19 06: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!
Try the Free Demo of Droid Assault
Offline Danny02

JGO Knight


Medals: 36



« Reply #3 - Posted 2013-02-19 10: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

Senior Newbie





« Reply #4 - Posted 2013-02-19 11: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: 438
Projects: 4


Hand over your head.


« Reply #5 - Posted 2013-02-19 12: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
Projects: Revenge of the Titans, Titan Attacks, Droid Assault, and Ultratron
Online ra4king

JGO Kernel


Medals: 264
Projects: 2


I'm the King!


« Reply #6 - Posted 2013-02-20 02: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
« Reply #7 - Posted 2013-02-20 03: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

Senior Newbie





« Reply #8 - Posted 2013-02-20 09: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  
 
 

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (76 views)
2013-05-17 21:29:12

alaslipknot (87 views)
2013-05-16 21:24:48

gouessej (117 views)
2013-05-16 00:53:38

gouessej (112 views)
2013-05-16 00:17:58

theagentd (123 views)
2013-05-15 15:01:13

theagentd (112 views)
2013-05-15 15:00:54

StreetDoggy (156 views)
2013-05-14 15:56:26

kutucuk (178 views)
2013-05-12 17:10:36

kutucuk (177 views)
2013-05-12 15:36:09

UnluckyDevil (185 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.117 seconds with 20 queries.