Can I load OGL_RGB_888, OGL_RGB_555 PVRs with glCompressedTexImage2D on iPhone?

Member
Posts: 249
Joined: 2008.10
Post: #1
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.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #2
Those are not really compressed texture formats, they are simply quantized. You need to load them using vanilla glTexImage2D().

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 249
Joined: 2008.10
Post: #3
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.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #4
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/...mage2D.xml

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 249
Joined: 2008.10
Post: #5
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/...mage2D.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.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #6
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.
Quote this message in a reply
Member
Posts: 249
Joined: 2008.10
Post: #7
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Unable to load textures wademcgillis 15 7,246 Apr 9, 2010 03:37 PM
Last Post: Macmenace
  How do you load PNGs on a C++ program? riruilo 8 5,770 Oct 20, 2009 05:20 PM
Last Post: miketucker
  glCompressedTexImage2D: negative value for level parameter? q2dm1 4 3,533 Dec 15, 2008 12:23 AM
Last Post: q2dm1