WaltN's picture

Possible Problem with TexImage2d<byte> with Final Argument of pixels[,,]

I am experimenting with procedural texturing, and I used a pixels[,,] array to hold the [x, y, color] data. The bulk of my code pre-existed, having originated in code that read the texture from a file. The result is depicted in the screenshot below.

Note the band on the left edge of the terrain. The code uses an interleaved VBO to represent vertex position, normal, and texture coordinates for a 256x256 height map. I procedurally generate a 512x512 texture image by blending images as a function of height. The band suggested that my texture coordinates were shifted along the x-coordinate by 4.0/255.0. I checked, and my texture coordinates were 0.0 all along the left edge and 1.0 all along the right edge. I thought I might have to fudge the result, so I did just that. I added 4.0/255.0 to the x-coordinate of each texture coordinate. The result looked perfect.

I decided to give it one more try. Instead of using a byte[,,] approach, I wrote directly (using unsafe code) in a System.Drawing.Bitmap so I could use the IntPtr form of the last argument of TexImage2D. The result, after I remembered to remove my fudge factor, was perfect.

Just this morning, I noticed the "width - Specifies the width of the texture image. All implementations support texture images that are at least 1024 texels wide" in, I think, all of the definitions of TexImage 2D. Could the 1024 proviso be the source of the problem I observed?

Inline Images

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Which version of OpenTK.dll are you using? There used to be a bug where T[,] and T[,,] were loaded using the wrong IL instruction (which worked on Mono but not .Net). This has been resolved in the last release, but I think the NuGet package is slightly out of date and does not contain the fix yet.

I'd suggest downloading the latest release from sourceforge and giving that a try. If the issue persists, please file a bug report at https://github.com/opentk/opentk/issues.

WaltN's picture

It's 1.1. But I did use NuGet, when setting up the project back in June.

I'll give the download from sourceforge a try when I get a chance.

WaltN's picture
the Fiddler wrote:

Which version of OpenTK.dll are you using? There used to be a bug where T[,] and T[,,] were loaded using the wrong IL instruction (which worked on Mono but not .Net). This has been resolved in the last release, but I think the NuGet package is slightly out of date and does not contain the fix yet.

I'd suggest downloading the latest release from sourceforge and giving that a try. If the issue persists, please file a bug report at https://github.com/opentk/opentk/issues.

I've confirmed that the problem goes away if I use the DLL from Sourceforge (dated 6/20/2014) rather than via NuGet.