Alex Carbo Meseguer
Alex Carbo Meseguer

Reputation: 3

QOpenGL: Color Index mode

I am working in Unix using QT and I am trying to create a bitmap (either QGLWidget or QGLPixelBuffer classes) to render with OpenGL. I need to use color index mode so when I am creating the bitmap I declare this qglformat:

qglformat.setDirectRendering(true);
qglformat.setRgba(false); // COLOR INDEX MODE
qglformat.setDepth(true);
qglformat.setOverlay(false);
qglformat.setDepthBufferSize(16);

And then I create the bitmap:

QGLWidget:

m_qglwiget = new QGLWidget(qglformat);
m_qglwiget->setGeometry(0,0,m_iW,m_iH);

QGLPixelBuffer:

m_pB = new QGLPixelBuffer(m_iW,m_iH,qglformat);

In the first case the Widget is created but if I see if it is valid, the function isValid() returns 'false'. And the execution aborts with that error: QGLContext::makeCurrent(): Cannot make invalid context current. Because the context is also invalid.

Otherwise in the second case, the PixelBuffer is created correctly but it has changed automaticaly the index color mode to the RGB mode.

The same program runs in the same computer using Windows so it is not problem of the graphic card.

Would you told me how could I define correctly the bitmap in order to be able to render in color index mode?

Upvotes: 0

Views: 685

Answers (1)

datenwolf
datenwolf

Reputation: 162317

I need to use color index mode

Why? Honestly why?

Color index mode is horrible to work with and NO(!) GPU built after 1998 actually supports it! Also color index mode has been removed from modern versions of OpenGL.

Just. Don't. Use. It!

For OpenGL-1.4 and earlier just pretend it's not there.

If you want to create a color indexed pixmap, render it in RGB, and after that turn it into indexed mode.

he same program runs in the same computer using Windows so it is not problem of the graphic card.

The reason is not the GPU, but that the software emulation shipping with Windows since 1996 also implements color index mode. If the GPU doesn't support a requested pixelformat, but the software emulation does, it will silently drop into software emulation mode.

PixelBuffer is created correctly but it has changed automaticaly the index color mode to the RGB mode.

PBuffers are supported by most (today all) GPUs, but not by the software emulation of Windows. So by requesting a PBuffer the only pixel formats that can satisfy this request will be RGB.

Upvotes: 1

Related Questions