Draw to texture using FBOs - aspect ratio issues - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Draw to texture using FBOs - aspect ratio issues (/thread-7864.html)
Draw to texture using FBOs - aspect ratio issues - Madrayken - Jul 15, 2010 10:36 AM
I'm on my second game using FBOs and have run into some odd problems.
I'm trying to create a background texture procedurally to save some load-time.
Here's my initial setup code for all my frame buffers:
On my first render pass, I set up the texture. Here I'm just drawing a line to check it's all working:
Now, if I comment out that glViewport line (which I did accidentally at one point) then the aspect ratio is correct and the line draws from one corner of the texture at 45 degrees... and then stops about 2/3 of the way across. For some reason the edge is being masked. I presume it's because the viewport isn't big enough.
However if I uncomment the line (and set the nice, square viewport), the line drawn (and any sprites) are drawn squished, indicating that the aspect ratio is wrong.
Anyone have any ideas why my glViewport doesn't seem to be giving me the correct aspect ratio?
Any help appreciated. OGL isn't my strong point. I thought I understood it fairly well, but this has been driving me nuts all day.
RE: Draw to texture using FBOs - aspect ratio issues - Skorche - Jul 15, 2010 11:33 AM
Are you stretching the square FBO texture to a non-square portion of the screen? If you are then, you need to be setting the projection matrix to match the FBO dimensions or the actual viewport dimensions?
RE: Draw to texture using FBOs - aspect ratio issues - Madrayken - Jul 15, 2010 11:47 AM
(Jul 15, 2010 11:33 AM)Skorche Wrote: Are you stretching the square FBO texture to a non-square portion of the screen? If you are then, you need to be setting the projection matrix to match the FBO dimensions or the actual viewport dimensions?
I'm being a bit slow today, so I'm not sure what you mean.
If you mean: are you stretching the texture, thus distorting it, the answer is 'no'.
I test the process out by drawing the texture on screen. The texture shows up as a square of the correct dimensions with a weirdly angled line on it.
If you mean 'are you altering the projection matrix as well as the making the glViewport call' the answer is 'no'. The only consideration I'm making for the size of this texture (it's 256 x 256) is the glViewport call. I've not seen anyone do this this in any of FBO examples, so I didn't think of doing it myself.