iDevGames Forums
Can I load OGL_RGB_888, OGL_RGB_555 PVRs with glCompressedTexImage2D on iPhone? - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: Can I load OGL_RGB_888, OGL_RGB_555 PVRs with glCompressedTexImage2D on iPhone? (/thread-657.html)



Can I load OGL_RGB_888, OGL_RGB_555 PVRs with glCompressedTexImage2D on iPhone? - riruilo - Oct 21, 2009 11:40 AM

Hi friends!


I can load perfectly PVRTC2 and PVRTC4 files. I modified my code to accept
OGL_RGB_888,OGL_RGB_555,OGL_RGB_565 and OGL_RGBA_8888 but it does not work. (I only see a white rectangle)
Am I doing something wrong or is this not possible on the iPhone.

I created 6 textures with PVRTexToolGUI and I cannot load the last four.
What do you think?
Is anyone loading OGL_RGB_565 PVR files on his code? (for example)


Thanks a lot for your time.


Can I load OGL_RGB_888, OGL_RGB_555 PVRs with glCompressedTexImage2D on iPhone? - Skorche - Oct 21, 2009 12:53 PM

Those are not really compressed texture formats, they are simply quantized. You need to load them using vanilla glTexImage2D().


Can I load OGL_RGB_888, OGL_RGB_555 PVRs with glCompressedTexImage2D on iPhone? - riruilo - Oct 21, 2009 01:27 PM

Skorche Wrote:Those are not really compressed texture formats, they are simply quantized. You need to load them using vanilla glTexImage2D().

Thanks for help. It makes sense what you said.
I tried now but it does not work:
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA4_OES,header.width,header.height,0,GL_RGBA, GL_UNSIGNED_BYTE, data);

2 questions:
Have I to use GL_UNSIGNED_BYTE? And GL_RGBA?

By the way Skorche, did you get them working?

Thanks a lot.


Can I load OGL_RGB_888, OGL_RGB_555 PVRs with glCompressedTexImage2D on iPhone? - Skorche - Oct 21, 2009 02:19 PM

Are you calling glError() to see if it's complaining? I would guess it's giving you an invalid enum error.

While not on the iPhone, I have loaded non-32bit textures before. I'm pretty sure that you just need to find out what parameters to use. It's important to note that there is an internal format (how it's stored in video memory) and the format you are supplying it in. I think in GL ES, they must match as it won't convert it for you.

You probably just need to use GL_UNSIGNED_SHORT_4_4_4_4 or similar:
http://www.khronos.org/opengles/sdk/1.1/docs/man/glTexImage2D.xml


Can I load OGL_RGB_888, OGL_RGB_555 PVRs with glCompressedTexImage2D on iPhone? - riruilo - Oct 21, 2009 03:18 PM

Skorche Wrote:Are you calling glError() to see if it's complaining? I would guess it's giving you an invalid enum error.

While not on the iPhone, I have loaded non-32bit textures before. I'm pretty sure that you just need to find out what parameters to use. It's important to note that there is an internal format (how it's stored in video memory) and the format you are supplying it in. I think in GL ES, they must match as it won't convert it for you.

You probably just need to use GL_UNSIGNED_SHORT_4_4_4_4 or similar:
http://www.khronos.org/opengles/sdk/1.1/docs/man/glTexImage2D.xml

Thanks for reply.

I added that code and after glTexImage2D, glError is 1282, which seems is GL_INVALID_OPERATIO.
I also added what you said about types GL_UNSIGNED_SHORT_4_4_4_4 (It seems I didn't read that part, I was pretty sure it was strange use only GL_UNSIGNED_BYTE)

Thanks a lot for your suggestions.

I read on docs about GL_INVALID_OPERATION:

1) GL_INVALID_OPERATION is generated if internalformat and format are not the same.
2) GL_INVALID_OPERATION is generated if type is GL_UNSIGNED_SHORT_5_6_5 and format is not GL_RGB.
3) GL_INVALID_OPERATION is generated if typeis one of GL_UNSIGNED_SHORT_4_4_4_4, or GL_UNSIGNED_SHORT_5_5_5_1 and formatis not GL_RGBA.


Well, loading:
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA4_OES,header.w idth,header.height,0,GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4 , data);
The only option is 1. I¡m going to see if data holds proper data.


(I remember in glut I had a function to retreive string error, is there anything similar over here?)


Thanks Skorche, you are very helpful.


Can I load OGL_RGB_888, OGL_RGB_555 PVRs with glCompressedTexImage2D on iPhone? - arekkusu - Oct 21, 2009 03:39 PM

You're still violating rule 1).

This is clearly spelled out in the spec, see "3.7.1 Texture Image Specification".

internalformat must be a base format, not a sized format. format must match the base format.

So, try:
Code:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data);

In ES, the sized formats like GL_RGBA4_OES are only valid for glRenderBufferStorage. Those sized format enums are defined by OES_framebuffer_object, and are not part of core ES1.1. Yes, this means the internalformat argument to TexImage is basically useless in ES.

In desktop OpenGL, sized formats are also valid for TexImage.


Can I load OGL_RGB_888, OGL_RGB_555 PVRs with glCompressedTexImage2D on iPhone? - riruilo - Oct 22, 2009 02:38 AM

arekkusu Wrote:You're still violating rule 1).

This is clearly spelled out in the spec, see "3.7.1 Texture Image Specification".

internalformat must be a base format, not a sized format. format must match the base format.

So, try:
Code:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data);

In ES, the sized formats like GL_RGBA4_OES are only valid for glRenderBufferStorage. Those sized format enums are defined by OES_framebuffer_object, and are not part of core ES1.1. Yes, this means the internalformat argument to TexImage is basically useless in ES.

In desktop OpenGL, sized formats are also valid for TexImage.

It worked! You made my day!

Thanks a lot arekkusu and Skorche for your help.