Jump to content
  • Advertisement
Sign in to follow this  
MARS_999

OpenGL Wow this is a good one, stumped

This topic is 4639 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

When I render my horizon map that I calculate in my engine all of a sudden its smeared. I don't know what I would have changed to make this happen but it wasn't doing this a few hours ago. So when I save out the data that I send to OpenGL the image is fine and not smeared or zoomed in. I am not sure what would be causing this. Any ideas would be great. As of now I have no idea what I would post for code...

Share this post


Link to post
Share on other sites
Advertisement
how is it "smeared"? Maybe a screenshot of how it's supposed to look, and then how it's smeared and a little more detail on exactly what you're doing.

You say you calculate it in your engine (I imagine you don't load it so there is no file to corrupt) how do you go about doing this?

We need more info. (Well, I do, maybe some other people don't.)

Share this post


Link to post
Share on other sites
Ok, here is the messy image

http://img86.imageshack.us/img86/7921/untitled1copy0fu.jpg

and the one I save out to a file just before I upload it to OpenGL. And no on the repeating the texture coords.

http://img103.imageshack.us/img103/3844/map1296horizonmap8qt.jpg

Share this post


Link to post
Share on other sites
May I suggest checking to make sure it's being attached to the proper verts at the proper texture coords? It looks to me like the texture is loading fine, but that the texture coordinates are wrong.

Maybe make a grid with easy to read numbers on it and try to load that in and see how it's distorted to give you a quick visual before looking at it in code. After checking the code, run the debugger over it, make sure the values are created properly and then if for some reason it looks like the code doesn't match the debug try rebuilding your project (maybe you're running off an old build, it happens sometimes.)

Share this post


Link to post
Share on other sites
Quote:
Original post by M2tM
May I suggest checking to make sure it's being attached to the proper verts at the proper texture coords? It looks to me like the texture is loading fine, but that the texture coordinates are wrong.

Maybe make a grid with easy to read numbers on it and try to load that in and see how it's distorted to give you a quick visual before looking at it in code.


Can't be the thing render just fine a few hours ago, and I haven't changed the texture coordinates for it... Thats why I am stumped... ;(

Share this post


Link to post
Share on other sites
If you're in Visual Studio try cleaning your solution and rebuilding. If truly nothing has changed, that might be the issue. I definitly suggest running the debugger over the values to make sure it is what you think it should be. Obviously something isn't working, don't dwell on the fact that it used to work. Focus on solving the problem through debugging and clear thinking. Try rebooting your computer if all else fails. Who knows what it could be without the project file?

Share this post


Link to post
Share on other sites
Quote:
Original post by M2tM
If you're in Visual Studio try cleaning your solution and rebuilding. If truly nothing has changed, that might be the issue. I definitly suggest running the debugger over the values to make sure it is what you think it should be. Obviously something isn't working, don't dwell on the fact that it used to work. Focus on solving the problem through debugging and clear thinking. Try rebooting your computer if all else fails. Who knows what it could be without the project file?


Thanks for the ideas, but tried most of them so far... One thing I have noticed is that my app is taking 115megs to run in the task manager?? Do I need to tell the compiler to allocate more RAM for the app? Just wondering...

Share this post


Link to post
Share on other sites
Quote:
Original post by MARS_999

Thanks for the ideas, but tried most of them so far... One thing I have noticed is that my app is taking 115megs to run in the task manager?? Do I need to tell the compiler to allocate more RAM for the app? Just wondering...


Tell the compiler to allocate more ram?? What language are you using.

If you use C/C++ check for uninitialized variables and/or buffer overflows. just a thought.

I would sugest you, to start using revision control (svn, cvs,..), so that you can see what you changed in the last couple of versions. Its a good feeling to know you can restore past versions at will :)

Share this post


Link to post
Share on other sites
Odds are your packing alignment (set via glPixelStore) is incorrect. The default for GL_UNPACK_ALIGNMENT is 4.

The "horizon map" image you linked to is 129x129, so if you unpacked it into 24-bit RGB, your row size (or stride) would be 129x3 = 387 bytes, but since OpenGL is expecting a row alignment of 4, glTexImage2D would actually transfer 388 bytes (387 bytes read, 1 byte skipped).

This is why your texture has black pixels on the left-hand side -- OpenGL is skipping parts of your texture data and eventually is reading data from unallocated memory. Power-of-two (and many other) sized textures do not exhibit this problem because the width of the texture times 3 "just happens" to also be aligned to 4.

Either set GL_UNPACK_ALIGNMENT to 1 before calling glTexImage2D, or unpack your texture so each row is aligned to 4 bytes in memory.

Share this post


Link to post
Share on other sites
Quote:
Original post by bpoint
Odds are your packing alignment (set via glPixelStore) is incorrect. The default for GL_UNPACK_ALIGNMENT is 4.

The "horizon map" image you linked to is 129x129, so if you unpacked it into 24-bit RGB, your row size (or stride) would be 129x3 = 387 bytes, but since OpenGL is expecting a row alignment of 4, glTexImage2D would actually transfer 388 bytes (387 bytes read, 1 byte skipped).

This is why your texture has black pixels on the left-hand side -- OpenGL is skipping parts of your texture data and eventually is reading data from unallocated memory. Power-of-two (and many other) sized textures do not exhibit this problem because the width of the texture times 3 "just happens" to also be aligned to 4.

Either set GL_UNPACK_ALIGNMENT to 1 before calling glTexImage2D, or unpack your texture so each row is aligned to 4 bytes in memory.


Ok, that makes sense. I will try it when I get home. I will let you know. Thanks

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!