Jump to content
  • Advertisement
Sign in to follow this  

using devil to copy part of one texture to a second texture

This topic is 2546 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all
I need to pre process some textures before I use them. Basically I'm using devil to load the the source texture, then create a second texture on the fly and copy a section of the source texture using ilBlit, to test I output the image as a bitmap. The problem is the bitmap comes out as the right shape and size but is blank, no copied image. I'm really unsure what I'm doing wrong. I should add iloverlayimage dose not work but ilCopy does, though obviouslky wrong , that is it copies the whole image over.
Can anyone tell me what I'm doing wrong with ilBlit in my code? Thanks!

void LoadAnimationImages( VIDEO_ANIMATION *anim, string filename )
ILuint image,blankimage;

/*generate buffer*/
ilGenImages( 1, &image );
/*bind image to buffer*/
ilBindImage( image );
/*load the texture*/
if( !ilLoadImage( filename.c_str() ) )
printf( "\n falied to load texture \n ");

/*get height and with of pixels*/
int pixels_width = ( ilGetInteger( IL_IMAGE_WIDTH ) / GetNumberOfAnimations( anim ) ) * GetFramesUsed( anim ) ;
int pixels_hight = ilGetInteger( IL_IMAGE_HEIGHT );
int bpp = ilGetInteger(IL_IMAGE_BPP);
ILint format = ilGetInteger(IL_IMAGE_FORMAT);
ILint depth = ilGetInteger(IL_IMAGE_DEPTH);
ILint type = ilGetInteger(IL_IMAGE_TYPE);

printf( "\n width %d height %d depth %d \n",pixels_width,pixels_hight, depth );

/**********************create a blank image*********************/
/*generate buffer*/
ilGenImages( 1, &blankimage );
/*bind image to buffer*/
ilBindImage( blankimage );
/* create a new image */
ilTexImage( pixels_width, pixels_hight, depth, bpp, format, type, (void*)NULL );

/*copy some data from main image to reel vector data*/
ilBlit( blankimage, 0,0,depth, 0,0,depth, 128,128,depth ); //to dest x,y,z, from source x,y,z, width height depilth,

//ilOverlayImage( image, 100,100,depth ); does not work
//ilCopy( image ) will work

/*test to maked sure image is copied*/
ilSaveImage("test.bmp"); //test image comes out right size etc but with no image eg just black?



Share this post

Link to post
Share on other sites
(FYI OpenIL isn't part of OpenGL, so not really the right forum section).

The problem you are having is that you are binding the blank image but also passing it as the source parameter to ilBlit. ilBlit blits from the source image provided by the first parameter, to the currently bound image. OpenIL is highly stateful in the same way OpenGL is. When you bind an object as a target, all calls relating to that target apply to the object bound. So ilBindImage(image) means that all OpenIL operations that target an image from that point (until you bind another image) will effect the specified image. That is why ilBlit only takes a single image parameter (source) although you might expect it to take two (source and destination). The destination is the currently bound image.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!