Question about resolutions - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Question about resolutions (/thread-1685.html)
Pages: 1 2
Question about resolutions - NelsonMandella - Mar 3, 2009 01:14 PM
I am working on a 2d isometric engine using opengl(2d textured quads). My engine looks and feels great in and around 800x600 resolution(I'm trying to achieve a particular and very pixelated looks). My desire is to force the user to switch resolutions upon startup, but I have a few concerns. One, am I in any danger of future OS resolution deprecations or anything(perhaps if the day of total resolution independence ever arrive)? Does every machine/monitor have 800x600 capability? Also, might there be a more effective way to achieve this by scaling opengl against the resolution of the machine?
Question about resolutions - NelsonMandella - Mar 3, 2009 11:26 PM
If I may, I'd like to amend my post. It seems that I have not been using 800x600 but 1280x800. This is a screenshot from my engine running in 1280x800:
and this is a screenshot of it running in 800x600:
So in addition to my last question, might anyone have an idea of what's going on here? My quads and textures all have dimensions with power of two.
Question about resolutions - AnotherJake - Mar 4, 2009 12:52 AM
You need to try uploading/linking your images again. Great idea to illustrate the situation!
Question about resolutions - NelsonMandella - Mar 4, 2009 01:25 AM
I can't seem to figure out how to upload a picture.
Question about resolutions - Bachus - Mar 4, 2009 09:57 AM
You need to upload the images to a web-site like Photobucket or whatever and link to them.
Since I can't see them, I'll just guess. Check your gluPerspective and/or glOrtho2D/glOrthof, and glViewport calls. Particularly the aspect ratio part of gluPerspective since 800x600 and 1280x800 have different ratios. If you're hard coding for one the other won't look right.
Question about resolutions - stevejohnson - Mar 4, 2009 10:07 AM
If all you want to do is restrict the viewport to no bigger than 800x600, then just use glScalef() to scale everything up to fill the screen. I can give you sample code if you like, since that's what I did for gw0rp.
Question about resolutions - NelsonMandella - Mar 5, 2009 12:03 PM
Okay here is a screenshot using 1280x800 res:
and here is one in 800x600 res:
The problem seems to be causing my tiles not to line up correctly as you see in the 800x600 photo.
And here is my opengl setup code:
I might also mention that I use png textures with alpha channels.
And yes Diordna, I would love to see your code.
I should also say that I am a very poor programmer and know little about opengl.
Question about resolutions - NelsonMandella - Mar 6, 2009 02:11 PM
Question about resolutions - AnotherJake - Mar 6, 2009 02:29 PM
Beats me. Looks like maybe a floating point issue with your texture coordinates, or possibly your geometry if you're using one quad per tile. You might try subtracting a smidgen off your texture coordinates to see if they stretch to fit a little better. OR you might try using glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); and glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
Question about resolutions - arekkusu - Mar 7, 2009 09:45 AM
It looks exactly like what you'd expect to see from using a texture atlas with linear filtering.
Question about resolutions - NelsonMandella - Mar 7, 2009 01:43 PM
arekkusu Wrote:It looks exactly like what you'd expect to see from using a texture atlas with linear filtering.
Could you elaborate?
Question about resolutions - arekkusu - Mar 7, 2009 06:33 PM
If you put multiple tiles into one texture (that is, dissimilar graphics placed next to each other in one atlas) and draw geometry to the screen, the result will only "look good" if the rasterized pixels sample texels exactly 1:1. If you scale or translate your geometry so that you no longer have a 1:1 mapping, texturing filtering will sample texels from the adjacent tile in the atlas, causing exactly this artifact.
For example, let's say you have one texture which is 8x4 and contains two tiles, one red and one green:
And then you draw a screen aligned 4x4 quad using the red tile:
That will look fine. But draw the same quad scaled (or rotated, or translated by a fractional amount):
Question about resolutions - NelsonMandella - Mar 7, 2009 08:44 PM
arekkusu Wrote:If you put multiple tiles into one texture (that is, dissimilar graphics placed next to each other in one atlas) and draw geometry to the screen, the result will only "look good" if the rasterized pixels sample texels exactly 1:1. If you scale or translate your geometry so that you no longer have a 1:1 mapping, texturing filtering will sample texels from the adjacent tile in the atlas, causing exactly this artifact.
I believe I understand what you are saying. However, I do not scale, rotate, or translate my quads in any way and the geometry to texel thing you mentioned is always 1:1.
Could it be the case that when switching my screen resolution opengl applies scaling transformations to my geometry which creates this effect?.
Question about resolutions - arekkusu - Mar 7, 2009 09:16 PM
If you compare the two pictures you posted, you can see that "before" is 1:1 and "after" is not. Compare the stone tiles on the house-- you can see everything is slightly smudged if you look at it closely.
The 1:1 mapping is a function of your texture, texture coordinates, vertex positions, projection, and viewport. Changing any of those things can affect the scaling.
So, changing either the viewport or the modelview via glScale can introduce this error.
The screen resolution itself is irrelevant, but you typically use glViewport to fill the screen, so that matters.
Question about resolutions - NelsonMandella - Mar 7, 2009 09:41 PM
Turns out I had the wrong view resize setting in Interface Builder- now I really feel dumb