[osg-users] Trouble loading an OpenGL texture into an osg::Image

90 views
Skip to first unread message

Cody Hanika

unread,
Jul 13, 2013, 5:10:31 PM7/13/13
to osg-...@lists.openscenegraph.org
Hello everyone, 

I am trying to load an OpenGL texture into an osg::Image. I know the OpenGL textureId and I have attempted using both Image::readImageFromCurrentTexture after using glBindTexture() in a Drawable subclass as well as manually using glGetTex* calls to retrieve information about the texture from the texId and then using Image::setImage.  I am doing all of this in a Drawable subclass and then returning the image to a class that draws a Geometry quad. I am calling Image::dirty() and have the dataVariance as DYNAMIC. 

I am just getting the previosuly bound texture mapped to the quad. I have just loaded a random texture using osgDB::readImageFile and that works so I know I am mapping the texture correctly. 

Any idea if I am trying to set the osg::Image data incorrectly or if I am missing something that I need to do? 

Thanks!

Cody

Robert Osfield

unread,
Jul 18, 2013, 11:15:24 AM7/18/13
to OpenSceneGraph Users
Hi Cody,

I'm a bit confused about what you might be trying to do.  Could you take a step back and try to explain what you are trying to do at a higher level, then others should be better able to suggest how to tackle this type of task.

Cheers,
Robert.

_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Cody Hanika

unread,
Jul 18, 2013, 8:19:18 PM7/18/13
to OpenSceneGraph Users
Thanks for the response Robert. So what is going on is I am trying to incorporate CEGUI into OpenSceneGraph. So CEGUI is a GUI system that is meant to be used as a menu system that is always displayed 2d on the screen and not embedded in 3d space.  What I am trying to do is utilize CEGUI's tools for quickly creating a functional GUI. The original example I found was in the OSG 3 cookbook, and for my application I want to be able to embed it in 3d space and have the user be able to interact with it.

So what I have accomplished so far is used an osg::Drawable to give CEGUI a context to render and then CEGUI provides a function to return its OpenGL textureId which I then was able to just use glBindTexture with that and do basic texture mapping to a quad using OpenGL calls.  I was then able to setup the GUI to dymically update as well as follow me through the scene.  But, I would now like to be able to actually use OpenSceneGraph's osg::Geometry to draw this quad. To do this texture mapping, I am just following the example in the OSG 3.0 beginner's guide, with the image coming from the Drawable that is holding all the CEGUI stuff. 

So what I have is an OpenGL texture Id to work with, and I need use that to map that texture to a quad. I know my texture mapping is correct as I have just tried loading an image with osgDB and mapping that, and that works. But when I am trying to grab the image from my drawable, what gets mapped to the quad is the last texture that was used. I have tried using Image::setImage as well as Image::readImageFromCurrentTexture after calling glBindTexture, but neither have worked for me.

tl;dr, given an OpenGL texture ID, how can I map the texture associated with that ID to a quad using osg::Geometry?

Thanks!

Cody

Cody Hanika

unread,
Jul 19, 2013, 1:45:17 AM7/19/13
to OpenSceneGraph Users
I just figured out my problem that I was having. I had a small bug in my code that was preventing the Drawable from updating its image data. Using glBindTexture and then using osg::Image::readImageFromCurrentTexture worked out for me.

Thanks,

Cody
Reply all
Reply to author
Forward
0 new messages