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

Robert Osfield robert.osfield at gmail.com
Sun Oct 21 04:04:11 PDT 2007


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
>
>



More information about the osg-users mailing list