Er.... 256, not 512, or it will core dump.

On 9/5/06, Don Burns <[EMAIL PROTECTED]> wrote:
osg::image::setImage() is the ticket:


    unsigned char  *data = "" unsigned char[256*256*3];
    unsigned char *ptr = data;

    bool flag = true;
    for( int i = 0; i < 512; i++ )
    {
        if( !(i%32) ) flag = !flag;
        for( int j = 0; j < 512; j++ )
        {
            if( !(j%32) ) flag = !flag;

            if( flag )
            {
                *(ptr++) = 0xFF;
                *(ptr++) = 0xFF;
                *(ptr++) = 0xFF;
            }
            else
            {
                *(ptr++) = 0xFF;
                *(ptr++) = 0x00;
                *(ptr++) = 0x00;
            }
        }
    }

    osg::ref_ptr<osg::Image> image = new osg::Image;
    image->setImage( 256, 256, 1, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, data, osg::Image::USE_NEW_DELETE );

    osg::ref_ptr<osg::Texture2D> tex = new osg::Texture2D;
    tex->setImage( image.get() );

-don

On 9/5/06, Mike Greene < [EMAIL PROTECTED]> wrote:
I have an example snippet that reads a jpeg image from a file and
uses it as a texture:

osg::Image* klnFace  = osgDB::readImageFile("image2.jpg");

KLN89FaceTexture->setImage(klnFace);

How can I use an existing memory image of a jpeg (i.e., not have to
access the hardrive) to accomplish the same task?

i.e., something like:

osg::Image* klnFace  = osgDB::readImageMemory(buffer);

KLN89FaceTexture->setImage(klnFace);

Mike Greene

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to