[osg-users] How to write RGB value of the osg::Texture2D

Mike Weiblen mike.weiblen at gmail.com
Mon Oct 22 09:36:47 PDT 2007


There are several plugins in core that write image data to a file.  Here is
another from osgToy that writes an image as C++ code:
http://osgtoy.svn.sourceforge.net/viewvc/osgtoy/osgtoy/trunk/src/osgPlugins/cpp/

-- mew



On 10/21/07, Robert Osfield <robert.osfield at gmail.com> wrote:
>
> Hi Zahnggulian,
>
> You set up the texture imagery using osg::Image.  There is a range of
> OSG plugins that set up osg::Image such as the rgb, jpeg, gif etc
> plugins, have a look at these.
>
> Robert.
>
> On 10/20/07, zhangguilian <zhangguilian at ict.ac.cn> wrote:
> >
> >
> > Hi, I have an question and eagerly to know the answer.
> > How can I directly write the RGB value of the osg::Texture2D?
> > As a matter of fact,I can write the RGB value of Texture in OpenGL,such
> as :
> > #define TEXTUREWIDTH 64
> > #define TEXTUREHEIGHT 64
> > GLubyte Texture[TEXTUREWIDTH][TEXTUREHEIGHT][3];
> > void makeTexture(void)
> > void makeTexture(void)
> > {
> > int i,j,r,g,b;
> > for(i=0;i<TEXTUREWIDTH;i++)
> > {
> > for(j=0;j<TEXTUREHEIGHT;j++)
> > {
> > r=(i*j)%255;
> > g=(4*i)%255;
> > b=(4*j)%255;
> > Texture[i][j][0 =(GLubyte)r;
> > Texture[i][j][1 =(GLubyte)g;
> > Texture[i][j][2 =(GLubyte)b;
> > }
> > }
> > }
> >
> >
> > void myinit(void)
> > {
> > auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);
> > auxInitPosition(0,0,500,500);
> > auxInitWindow("sample1");
> > auxInitWindow("sample1");
> > glClearColor(0.0,0.0,0.0,0.0);
> > glClear(GL_COLOR_BUFFER_BIT);
> >
> > //The data used for creating texture image is saved in Texture[][][]
> > makeTexture();
> > glPixelStorei(GL_UNPACK_ALIGNMENT,1);
> >
> > //Used here
> > glTexImage2D(GL_TEXTURE_2D,0,3,TEXTUREWIDTH,
> > TEXTUREHEIGHT,0,GL_RGB,GL_UNSIGNED_BYTE,
> > &Texture[0][0][0]);
> >
> > glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
> > glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
> > glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
> > glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
> >
> > glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);
> >
> > glEnable(GL_TEXTURE_2D);
> > glEnable(GL_TEXTURE_2D);
> > // glShadeModel(GL_FLAT);
> > }
> >
> > But I really don't know how to use this mathod in OSG,Could you please
> give
> > me an advice,Thanks a lot!
> >  ________________________________
> >
> > zhangguilian
> > 2007-10-20
> > _______________________________________________
> > osg-users mailing list
> > osg-users at lists.openscenegraph.org
> >
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >
> >
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
Mike Weiblen -- Austin Texas USA -- http://mew.cx/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20071022/963b8837/attachment-0003.htm>


More information about the osg-users mailing list