HowTo: OpenGL Texture Buffers with Qt?
-
I'd like to make use of OpenGL's Texture Buffers with Qt, as it is shown in this non-Qt example:
https://gist.github.com/roxlu/5090067
Following this command
@glBufferData(GL_TEXTURE_BUFFER, sizeof(tbo_data), tbo_data, GL_STATIC_DRAW);@
it looks like I have to use the QOpenGLBuffer class, but only the QOpenGLTexture has a target for it.
So i tried to create the latter resulting in two errors:
@Buffer textures do not allocate storage
QOpenGLTexture::setData(): Texture target does not support pixel data upload@So my questions are:
Can you point me in the right direction?
Do I have to use QOpenGLBuffer and/or QOpenGLTexture?
If I have to use QOpenGLTexture, how can I "setData" i.e. transfer the data to the texture buffer? -
Hi StridaHD, I think it depends on what you want to do.
If you want to give your texture to the graphics card, you cand do it like this:
@
GLuint texture;texture= bindTexture(QPixmap(QString("URL of your texture")), GL_TEXTURE_2D);
@And that's all... Save that GLuint to refer to your texture whenever you want to draw it.
Now, I said "it depends" because it actually does on the way you want OpenGL to render the frame.
What are you using? VBOs?
-
Hi BlastDV,
I try to use as much OpenGL as provided with Qt. So QOpenGLTexture( QImage( ... ) ) works fine for adding 2D Textures.
I use the textures together with VBOs and Shaders (OpenGL 3.2 CoreProfile). So far I could realize everything with QOpenGLBuffer and QOpenGLShader.I'd like to use texture buffers to pass non-Image data (arbitrary floats) to the shaders and access it e.g. by @myTextureBufferFunctionValue[gl_PrimitiveID]@ (assuming a 1D texture buffer).
If possible I would like to do the same to e.g. pass bitarrays as unsigend integers to the shaders, which I can't do with Qt because of the rescaling issue with strided data: https://qt-project.org/forums/viewthread/38929/