[osg-users] Texturing with GLBeginEndAdapter

tianzjyh tianzjyh at 126.com
Thu Dec 29 01:12:51 PST 2016


Hi, Andersen,
Let's say you have three images, then you can wrap them using osg::Texture2D, something like this:
    >
>osg::Image* image0 = osgDB::readImageFile("filename0.xxx");
>osg::Texture2D* tex0 = new osg::Texture2D(image0);
>tex1->setWrap(..., ...);
>tex1->setFilter(..., ...);
>


And then you can apply them in the drawImplementation() of your drawable like this :
>
>osg::State& state = *renderInfo.getState();
>state.setActiveTextureUnit(0);        //set texture unit 0 as current texture
>tex0->apply(state);                        //apply texture paras to current texture
>...drawQuad0...
>
>...deal with other two quads...
>


--

Cheers, 
---
TianZJ



At 2016-12-29 07:32:01, "Aaron Andersen" <aaron at fosslib.net> wrote:
>Hello,
>
>There is some code in a library which I want to adapt for OSG. The  
>code is pretty old and uses the old style OpenGL. I don't have the  
>time it would take to rewrite this code so I would like to use the  
>GLBeginEndAdapter to make this code work with OSG.
>
>Looking at the GLBeginEndAdapter there isn't much documentation so I  
>was hoping someone could help me out. Please keep in mind my OpenGL  
>skills are lacking (which I why enjoy using a rendering engine like  
>OSG :-).
>
>I've created a subclass to the Drawable class called "MyDrawable". In  
>the drawImplementation function I'm have a couple  
>gl.Begin(GL_QUADS)/gl.End() calls to draw 3 simple rectangles. I'm  
>unsure of how to apply 3 separate textures to these 3 rectangles. From  
>reading the ShapeDrawable class it looks like the state of the  
>Drawable applies the texture to everything you draw.
>
>So how can I apply many different textures to my drawing, with 1  
>texture per shape I draw with GL_QUADS?
>
>Thank you for any insight you can provide.
>Aaron
>
>
>_______________________________________________
>osg-users mailing list
>osg-users at lists.openscenegraph.org
>http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20161229/ee5ac308/attachment-0003.htm>


More information about the osg-users mailing list