[osg-users] How to write RGB value To the osg::Texture object pixel by pixel?

zhangguilian zhangguilian at ict.ac.cn
Sun Oct 21 00:45:20 PDT 2007


Hi ,I still don't know how to write RGB value to the osg::Texture object pixel by pixel which can be realized in OpenGL as follows:

//in openGL
#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;
}
}
}

//Used here
glTexImage2D(GL_TEXTURE_2D,0,3,TEXTUREWIDTH,
TEXTUREHEIGHT,0,GL_RGB,GL_UNSIGNED_BYTE,
&Texture[0][0][0]);

Could you please give some examples? Thank you very much!

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20071021/a4383969/attachment-0002.htm>


More information about the osg-users mailing list