[Interest] How to use QSGSimpleTextureNode?
Nuno Santos
nunosantos at imaginando.pt
Mon Nov 3 17:15:31 CET 2014
Hi,
I’m trying to render text on scene graph. My strategy consists in creating a texture with all the glyphs and then draw a specific subset of the texture for each glyph. I have already done this for iOS and Android native API’s but now, i’m porting my app to Qt/Qml and need to do it on scene graph.
My new node is extending QSGSimpleTextureNode. The code below is just for the most basic test purpose.
unsigned char *data = (unsigned char*) malloc(ts*ts*4);
uint8_t * p = data;
for(int i=0; i<ts*ts; ++i)
{
*p = 0; ++p;
*p = 255; ++p;
*p = 255; ++p;
*p = 0; ++p;
}
glGenTextures(1, &_texture);
glBindTexture(GL_TEXTURE_2D, _texture);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ts, ts, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
// how do I set data to the texture?
setTexture()
free(data);
The essential question right now is how do I set my custom texture data to a texture?
I have a Googled a lot about QSGSimpleTextureNode and QSGTexture but couldn’t find any clear example on how to do this.
Any thoughts?
Thanks,
Nuno Santos
More information about the Interest
mailing list