Detecting RGB format support


I am starting to develop a game using augmented reallity using the qcar library (qualcom augmented reallity) and jme3. Qcar initializes the camera by itself and I pass the data through a bytebuffer from native code to java.

By default qcar camera data is formatted in RGB565, but if I try to use it as is, in some devices the image is not renderered (it renders black) and I need to “translate” it to RGB888. I’d like to avoid the translation step when unneeded (it lasts too long, 9ms native code in my SGS).

Is there any way in jme3 to check if RGB565 is supported?


[java]renderer.getCaps() ?[/java]

You may want to check the JavaDoc about this method :

@ozonegrif, Thanks for your answer. I’ve checked your link, but Caps class doesn’t have information about RGB formats related with my problem, only floating point… Any other ideas?

RGB565 support is required by the OpenGL ES 2.0 specification, it must be supported by all vendors otherwise they break the spec.

Perhaps the issue is elsewhere?

I’ve made a test case to check the RGB565 vs RGB888 problem I’m facing and ran it on some android devices. The test just creates two images (one RGB565 and other RGB888) with different colors and renders both images half the screen…

Here is the code for the main class:


package mygame;


import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.renderer.RenderManager;

import com.jme3.scene.Geometry;

import com.jme3.scene.shape.Box;

import com.jme3.texture.Image;

import com.jme3.texture.Texture2D;

import com.jme3.ui.Picture;

import java.nio.ByteBuffer;

public class Main extends SimpleApplication


// Left stands for RGB565

private ByteBuffer leftBuffer=null;

private Image leftImage=null;

private Texture2D leftTexture=null;

private Picture leftPic;

// Right stands for RGB888

private ByteBuffer rightBuffer=null;

private Image rightImage=null;

private Texture2D rightTexture=null;

private Picture rightPic;

public static void main(String[] args)


Main app = new Main();




public void simpleInitApp()


//Create two images of different formats (565 and 888)

//Each image will be covering half the screen

int width=settings.getWidth();

int halfWidth=width/2;

int height=settings.getHeight();

int pxSize=halfWidthheight;

2);//Size2 because of RGB565 format

//White image (each pixel is FFFF (16bit)


for(int i=0; i<pxSize;++i)





leftImage=new Image(Image.Format.RGB565, halfWidth, height, leftBuffer);

leftTexture=new Texture2D();


leftPic=new Picture(“left”);

leftPic.setTexture(assetManager, leftTexture, false);



leftPic.setPosition(0, 0 );


3);//Size*3 because of RGB888 format

//Green image (each pixel is 00FF00 (24bit)


for(int i=0; i<pxSize;++i)


rightBuffer.put((byte)0); //r

rightBuffer.put((byte)255); //g

rightBuffer.put((byte)0); //b


rightImage=new Image(Image.Format.RGB8, halfWidth, height, rightBuffer);

rightTexture=new Texture2D();


rightPic=new Picture(“right”);

rightPic.setTexture(assetManager, rightTexture, false);



rightPic.setPosition(halfWidth, 0);






public void simpleUpdate(float tpf) {

//TODO: add update code



public void simpleRender(RenderManager rm) {

//TODO: add render code




The Activity class is the default one created automatically when added the mobile configuration to the project.

I’ve run the program in some devices having the following results (Bad stands for rendered black):

Galaxy S → 565 OK, 888 OK

HTC desire → 565 Bad, 888 OK

Galaxy Tab - 565 OK, 888 OK

Sony tablet S - 565 Bad, 888 OK

Galaxy S2 - 565 Bad, 888 OK

It seems that all tested devices render correctly RGB888 but only some of them are capable to render RGB565 (just the powerVR based devices). There is no related output in the logcat when running the test.

Also I tried to run this code on the PC getting the following exception:

GRAVE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.UnsupportedOperationException: Unrecognized format: RGB565
at com.jme3.renderer.lwjgl.TextureUtil.uploadTexture(
at com.jme3.renderer.lwjgl.LwjglRenderer.updateTexImageData(
at com.jme3.renderer.lwjgl.LwjglRenderer.setTexture(
at com.jme3.material.MatParamTexture.apply(
at com.jme3.material.Material.render(
at com.jme3.renderer.RenderManager.renderGeometry(
at com.jme3.renderer.queue.RenderQueue.renderGeometryList(
at com.jme3.renderer.queue.RenderQueue.renderQueue(
at com.jme3.renderer.RenderManager.renderViewPortQueues(
at com.jme3.renderer.RenderManager.flushQueue(
at com.jme3.renderer.RenderManager.renderViewPort(
at com.jme3.renderer.RenderManager.render(
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(

This link should give you more of an insight of what some phones are actually capable of doing


@techsonic thanks for the link. I’ve read it, but I can’t find any GL extension or information regarding which hardware supports RGB565 correctly or not there… :? Any other ideas?

The RGB565 natively shows that it uses FrameBuffer Objects. You might want to ask @Momoko_Fan about the FrameBuffer part.

Looking at the OpenGL 2.0 specification, it seems that the RGB565 format is not supported, thus the correct behavior is exhibited on the PC.

@techsonic was referring to the OpenGL ES 2.0 specification, which does indeed support RGB565, although some mobile GPU vendors fail to support it thus breaking the spec.

@Momoko_Fan said:
...was referring to the OpenGL ES 2.0 specification, which does indeed support RGB565, although some mobile GPU vendors fail to support it thus breaking the spec.

Acording to my tests, the only GPUs correctly following the spec are powerVR... So finally, and until I get a better way to do it, I'm just checking the renderer name and if it's PowerVR hardware I use RGB565 otherwise I use RGB888. This way my app works on all hardware I've been able to try. :P