[osg-users] Equivalent of glTexSubImage2D ?

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Wed Mar 1 01:13:46 PST 2017


Hi Johny,

> Hi,
>
> Thanks for the amazing answers. I'm not trying for sprites, I'm for a repaint over an existing surface. The code below works on another project of mine, but I haven't got it working in my OSG app yet...
>
> What it does, it gives you an BGRA buffer for you to paint your existing surface with.
>
>
> Code:
> void nr::as::Zurface::Paint(unsigned char* src_buffer, int src_row_span, const Awesomium::Rect& src_rect, const Awesomium::Rect& dest_rect) {
> 	auto cid = gGc->getState()->getContextID();
>
> 	texture->getTextureObject( cid )->bind();
>
> 	unsigned char* a = &src_buffer[0];
>
> 	glTexSubImage2D(GL_TEXTURE_2D, 0, dest_rect.x, dest_rect.y, dest_rect.width, dest_rect.height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, a);
>
> 	glBindTexture( GL_TEXTURE_2D, 0 ); // unbind?
> }
>
>
>
>
> Awesomium has its own threads and this one is an arbitrary callback. Should I mutex?

If you don't want to block either threads, you can copy the buffer data 
and apply it in an callback of the scenegraph. You'll need a mutex 
anyways to protect you update-buffer;-)

Cheers
Sebastian
>
> Thank you!
>
> Cheers,
> Johny
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=70367#70367
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



More information about the osg-users mailing list