01-29-2013 04:03 AM
Hi,
I submitted my app for BlackBerry World approval. Unfortunately, when going through the QA process, it failed because it failed to load its OpenGL textures on to the Dev Alpha device. They successfuly load on the Gold (and every other version) of the simulator. I don't have access to a Dev Alpha device, so I'm not sure how to go about fixing this issue.
My textures are 2048x1024 (a nice even power of 2 on either side). I see in the help http://developer.blackberry.com/native/documentati
I pay special care to make sure that the textures are loaded on the same thread as the rest of the OpenGL operations.
Mipmapping is enabled. Perhaps the 2048 size textures don't work with mipmaps? To try this, I tried commenting out my call to glGenerateMipmap(GL_TEXTURE_2D) and my calls to glTexParameteri(). When I did that, all of my textures come out black on the simulator. Why would that be? My texture loading code basically looks like this (I'm using OpenGL ES 2.0):
if (*tex == 0) {
glGenTextures(1, tex);
}
glBindTexture(GL_TEXTURE_2D, (*tex));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, format, texWidth, texHeight, 0, format, GL_UNSIGNED_BYTE, NULL);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, imageWidth, imageHeight, format, GL_UNSIGNED_BYTE, pImageData);
glGenerateMipmap(GL_TEXTURE_2D);
Any help would be appreciated.
Thanks,
Mark
01-29-2013 08:02 AM
The Graphics Platform used in Blackberry Dev Alpha device is PowerVR SGX540.
See this http://developer.blackberry.com/native/documentati
PowerVR SGX540 are known not to support non square textures. So may be you may have to reorganize the textures so that they are in powers of 2, as well as square.
See the downsides of PowerVR SGX540 mentioned here :
http://stackoverflow.com/questions/6771331/whats-t
- Dishooom
--------------------------------------------------
Hope this helps... ![]()
01-29-2013 10:40 AM
Thanks! I hadn't seen that limitation in my readings. I'll try it tonight and resubmit. When I get confirmation from BlackBerry World that I'm accepted, I'll respond with a final verdict.
01-29-2013 11:18 AM
02-08-2013 04:07 AM
Unfortunately I haven't heard whether or not I've been accepted yet. But I DO have a device now! So I was able to test my app on it. And it still has errors, even after changing the width and height of my textures. But with the device, I can debug. Here is what I found:
In my texture loading code, I was calling glGetError() at the end of it to see if loading the textures into the hardware worked. I was getting back GL_INVALID_OPERATION. After sprinkling more glGetError() calls, I got confused, especially after I was getting back GL_INVALID_OPERATION after a call to glGenTextures(). The docs don't give any indication that GL_INVALID_OPERATION would be returned from glGenTextures(). Then it hit me -- I wasn't resetting glGetError() before performing my texture operations. When you call glGetError(), it has the side-effect of resetting the error code. So I call glGetError() before I perform my texture operations and all is well.
I was able to trace down the error to a call to glReadPixels I was making. The simulator allows for you to call glReadPixels with GL_RGB as the format. The device doesn't allow this. The format must be GL_RGBA. Which makes sense because that is what the docs state here: http://www.khronos.org/opengles/sdk/docs/man/xhtml
So in summary, setting the texture sizes to be an even power of two probably helped -- but I can't say that doing so fixed my problem. My problem was actually with glReadPixels and because of the fact I didn't properly call glGetError to clear the error state.
02-08-2013 04:08 PM
Just one minor correction. Square texture limitation is for PVRTC compressed textures. This is not a requirement for non compressed textures. Also, glGenerateMipmaps will fail for compressed textures. Mipmaps should be generated offline and loaded using glTexImage2D(mipLevel).
Looking at the code above, there is no need for glTexSubImage2D. The texel data can be passed directly to glTexImage2D.
Lastly, the SGX 540 support Non-Power of 2 textures. However these cannot be mipmapped.