Jump to content
  • Advertisement
Sign in to follow this  
OandO

Display Stretching

This topic is 2551 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:
screenshot20110725at201.jpg
(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"] [color="#3f0b80"][font="Arial"] glGenRenderbuffersEXT[color="#000000"]([color="#3900d5"]1[color="#000000"], &[color="#568186"]albedoBuffer[color="#000000"]);[/font]

[color="#3f0b80"] glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, albedoBuffer);

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

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

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

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

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

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

A call to [font="Arial"][color="#3F0B80"]glCheckFramebufferStatusEXT[color="#3F0B80"][color="#000000"]([color="#3F0B80"][color="#74492d"]GL_FRAMEBUFFER_EXT[/font][color="#3F0B80"][color="#000000"][font="Arial"]);[/font] 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
Advertisement
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
Hmm, odd. I just tested with a 1920x1200 resolution (my native resolution) and the area that draws correctly is 1024x1024.

Share this post


Link to post
Share on other sites
Are you sure the size of the texture really is the same as your native screen resolution, and that you're not "rounding" it to nearest lower power of two or something?

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.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!