Jump to content
  • Advertisement
Sign in to follow this  

OpenGL One channel textures not working for ES 2.0?

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

Okay, I've been trying to figure out what is wrong with this code to create a 1024x1024x8 texture with OpenGL ES.  I'm trying to get this working with an iPad2, and it keeps giving me GL_INVALID_OPERATION.  Not sure why as GL_EXT_texture_rg claims to be supported by my device.  I use the same code with core OpenGL 3+ and it works just fine.  I haven't tried ES 3.0 directly because I want this to work on ES 2.0 devices too.

glTexImage2D( GL_TEXTURE_2D, 0, GL_R8_EXT, 1024, 1024, 0, GL_RED_EXT, GL_UNSIGNED_BYTE, pixels );

So I can't seem to figure out why this isn't working.  Any ideas?  Thanks.





EDIT: Thanks to slicer4ever, I got it working (minus a slight bit of texture corruption) using GL_LUMINANCE instead.  If I may ask in addition, what's the big difference between the two since they are both 8-bit texture formats?

Edited by blueshogun96

Share this post

Link to post
Share on other sites

GL_LUMINANCE stores a single value, but when sampled in a shader, it fetches vec4(value, value, value, 1.0). I'm not sure what happens when you try to render to one of these textures (via a FBO).

From the texture_rg extension it seems to be an attempt to modernize the API:

Historically one- and two-component textures have been specified in OpenGL
ES using the luminance or luminance-alpha (L/LA) formats. With the advent
of programmable shaders and render-to-texture capabilities these legacy
formats carry some historical artifacts which are no longer useful.

For example, when sampling from such textures, the luminance values are
replicated across the color components. This is no longer necessary with
programmable shaders.

It is also desirable to be able to render to one- and two-component format
textures using capabilities such as framebuffer objects (FBO), but
rendering to L/LA formats is under-specified (specifically how to map
R/G/B/A values to L/A texture channels).

This extension adds new base internal formats for one-component RED and
two-component RG (red green) textures as well as sized RED and RG internal
formats for renderbuffers. The RED and RG texture formats can be used for
both texturing and rendering into with framebuffer objects

Edited by Hodgman

Share this post

Link to post
Share on other sites

Okay, now I get it.  I personally don't see the need for two different formats, but I'm not on the ARB, so it doesn't matter what I think.


Bottom line is that it works, so I'm satisfied.





Share this post

Link to post
Share on other sites

According to the specification the value you are specifying for the format internal format GL_R8_EXT is for the renderbuffers. Also be aware that for OpenGLES 2.0 at least, from the spec:

GL_INVALID_OPERATION is generated if format does  not match internalformat.


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!