Sign in to follow this  

Display Stretching

This topic is 2337 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've recently started trying to implement a deferred shading model into my program. I've got as far as creating buffers and textures to render to, but it's stretching at the top and right-hand side of the display. I've created a simple scene with two models to demonstrate:
[img]http://img807.imageshack.us/img807/2636/screenshot20110725at201.jpg[/img]
(Image scaled down)

The area which draws properly seems to always be (at least roughly) the same size, regardless of resolution, as if the buffer is generating at a fixed size. I'm generating the buffers and textures like this:

[color="#3f0b80"] [size="2"][color="#3f0b80"][font="Arial"][size="2"] glGenRenderbuffersEXT[color="#000000"]([/color][color="#3900d5"]1[/color][color="#000000"], &[/color][color="#568186"]albedoBuffer[/color][color="#000000"]);[/color][/size][/font][/color]
[/size][/color]
[color="#3f0b80"][size="2"] glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, albedoBuffer);[/size][/color][size="2"]

[color="#3f0b80"] glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, resolution[0], resolution[1]);[/color]

[color="#3f0b80"] glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, albedoBuffer);[/color]

[color="#3f0b80"] glGenTextures(1, &albedoTexture);[/color]

[color="#3f0b80"] glBindTexture(GL_TEXTURE_2D, albedoTexture);[/color]

[color="#3f0b80"] glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, resolution[0], resolution[1], 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);[/color]

[color="#3F0B80"] [font="Arial"]glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, albedoTexture, 0);[/font][/color][/size]

A call to [font="Arial"][color="#3F0B80"][size="2"]glCheckFramebufferStatusEXT[/size][/color][color="#3F0B80"][size="2"][color="#000000"]([/color][/size][/color][color="#3F0B80"][size="2"][color="#74492d"]GL_FRAMEBUFFER_EXT[/color][/size][/color][/font][color="#3F0B80"][size="2"][color="#000000"][font="Arial"]);[/font] [/color][/size][/color] shows the buffer generating properly, so I have no idea what's causing this problem.

Share this post


Link to post
Share on other sites
kinda looks like clamping texture addressing, could you verify this? To narrow down the problem you could use gDEBugger to see where it's going wrong, at the texture generation phase or at rendering it to the screen.

Share this post


Link to post
Share on other sites
That would seem to be the case. Does the texture have any dimension requirements, for example being a power of 2? At the moment I'm just using the screen resolution as the texture size.

Share this post


Link to post
Share on other sites
Could be that you're not setting the viewport to the correct size when you initially draw into the textures, or that the texture coordinates you use when outputting the render textures are wrong. Perhaps try outputting a visualisation of the texture coordinates, or as Murdocki says use gDEBugger to better isolate where the problem is occurring.

Share this post


Link to post
Share on other sites
[color=#1C2837][size=2]Ok, I've been doing some research, and it turns out it could be a hardware limitation on my end. In the absence of a newer machine, I may be limited to power-of-2 texture sizes (seems to be the case), so I now have the fun task of working around this constraint. [/size][/color]

Share this post


Link to post
Share on other sites
If it was a limitation, it wouldn't even work in the first place if you tried a dimension that wasn't allowed. You just don't get another dimension than what you asked for. You get something, even if it's not entirely the correct thing, so if you have a texture of the incorrect size, then ultimately that was what you asked for.

Share this post


Link to post
Share on other sites
Hmm, Ok. I'd assumed OpenGL would have a fallback for something like this. Is there a simple way (a get call, or something) to retrieve the dimensions of a texture after it's been created?

Edit: Nevermind, just found it. Well, I used [color=#3F0B80][font="Arial"][size="2"]glGetTexLevelParameteriv[/size][/font][/color] to get the width and height, it returned 1920 and 1200, as it ought to be doing.

Share this post


Link to post
Share on other sites
Not for the first time, I feel remarkably stupid, it seems I may have had the wrong texture bound during the render. However I'm entirely sure that was the full extent of the problem; binding another texture temporarily and then binding the render texture again seemed to mess up the sizes, but I may have missed something else there.

Edit: Right, fixed it now. I had some dodgy texture handling going on, some old code that I had forgotten to replace. Thank you to those who tried to help, and apologies for wasting your time =P

Share this post


Link to post
Share on other sites

This topic is 2337 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this