Widescreen Display without skewing (LWJGL)

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)

Wait…that’s not true.

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

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.

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 :slight_smile:

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…

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)

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

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.

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 :P)