gnumster's picture

Starting with Texturing

Hi,
I have tried to Google it and I did spend some reasonable time reading around and looking for an answer to my question.
I am doing the following:

byte[] pixels = new byte[51200] {....}

GL.TexImage2D
(
TextureTarget.Texture2D
, 0
, PixelInternalFormat.Rgba
, 128, 100
, 0
, PixelFormat.Rgba
, PixelType.UnsignedByte
,pixels
);

And I keep receiving "Invalid value" no matter how hard I try...

Could anyone give any ideas on what can I possible be doing wrong?

Thanks!


Comments

Comment viewing options

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

Debugging tip: check the reference pages to see what could cause the error you are getting. In this case:

  • GL_INVALID_VALUE is generated if level is less than 0.
  • GL_INVALID_VALUE may be generated if level is greater than
    log max, where max is the returned value of
    GL_MAX_TEXTURE_SIZE.
  • GL_INVALID_VALUE is generated if internalformat is not 1, 2,
    3, 4, or one of the accepted resolution and format symbolic
    constants.
  • GL_INVALID_VALUE is generated if width or height is less
    than 0 or greater than 2 + GL_MAX_TEXTURE_SIZE, or if either
    cannot be represented as 2k+2(border) for some integer value
    of k.
  • GL_INVALID_VALUE is generated if border is not 0 or 1.

Only the second to last issue looks applicable here: you are using non-power-of-two (NPOT) dimensions. Check whether your video card supports NPOT textures (it needs to advertize OpenGL 2.0 or higher). Most Intel cards and older hardware by Ati/Nvidia does not support NPOT textures well.

According to the OpenGL wiki, "While modern hardware no longer has the power-of-two limitation on texture dimensions, it is generally not a good idea to use it unless you specifically need it."

iliak's picture

You can have a look at my Texture class. If you have question feel free to ask.

zahirtezcan's picture

Do you call BindTexture before TexImage? It seems you call for bind only before parameter set operations.

iliak's picture

You have to bind first the texture and then AFTER modify the parameters

Display.Texture = ... binds the texture