Jump to content
  • Advertisement
Sign in to follow this  
GreyHound

[DevIL] Using IL to copy textures together into 1 bigger texture

This topic is 3466 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

If you think this is better placed into the OpenGL forum or so please move it. I didn't really know where to place this thread :P Hi, i want to combine several textures into 1 texture to be able to use texCoordPointers later. My problem is as following: I want to create a picture that contains 2 pictures but i'm having trouble getting the alpha layer properly. Currently i call the shown function with the same file to keep stuff simple and reduce errors. It actually creates a *.tga containing the 2 files but the alpha layer is merged into the file. It is also topdown. Here is a picture to visualize my problem: MyProbleme What i want to get: Desired result And this is the file i use a source Src file i use If anyone can see what i'm doing wrong i'd be hightly pleased. Thanks a lot
void buildTextureAtlas(const char* fileA, const char* fileB){ 
	 
	//the handles for target and 2 sources 
	ILuint target; 
	ILuint src1; 
	ILuint src2; 
	 
	//keep track about errors 
	ILboolean success; 
	 
	//gen 3 tex 
	ilGenImages(1, &target);  
	ilGenImages(1, &src1);  
	ilGenImages(1, &src2);  
	 
	//bind source 1 and load 
	ilBindImage(src1);  
	success = ilLoadImage(fileA); 
	 
	if(!success) 
	return; 
	 
	//save width and height 
	int w1 = ilGetInteger(IL_IMAGE_WIDTH); 
	int h1 = ilGetInteger(IL_IMAGE_HEIGHT); 
	 
	//bind 2nd source and load 
	ilBindImage(src2);  
	success = ilLoadImage(fileB); 
	 
	if(!success){ 
	ilDeleteImages(1, &src1);  
	return; 
	} 
	 
	//save second width 
	int w2 = ilGetInteger(IL_IMAGE_WIDTH); 
	int h2 = ilGetInteger(IL_IMAGE_HEIGHT);  
	 
	//use 2nd texture params for target (for now) 
	ILint bpp = ilGetInteger(IL_IMAGE_BPP); 
	ILint pf = ilGetInteger(IL_IMAGE_FORMAT); 
	ILint depth = ilGetInteger(IL_IMAGE_DEPTH); 
	ILint type = ilGetInteger(IL_IMAGE_TYPE); 
	 
	 
	//extract filename only for test saving 
	std::string identifier = fileA; 
	identifier = identifier.substr(identifier.rfind("/")+1, identifier.rfind(".")-identifier.rfind("/")-1); 
	std::string tar = identifier; 
	tar.append("_Target.tga"); 
	 
	//bind target 
	ilBindImage(target);  
	//create with desired parameters 
	ilTexImage(w1+w2,h1, depth, bpp, pf, type, (void*)NULL);  

       //copy src1 to 0 0 
	ilOverlayImage(src1, 0, 0, 0);
       //copy src2 to w1 0  
	ilOverlayImage(src2, w1, 0, 0);  
	 
	if (!success) 
	return; 
	 
	 
	ilEnable(IL_FILE_OVERWRITE); 
	ilSaveImage(tar.c_str()); 
}
P.S: i also tried ilBlit(src1, 0,0,0,0,0,0,w1,h1,depth); and ilBlit(src2, w1,0,0,0,0,0,w2,h2,depth); [Edited by - GreyHound on December 20, 2008 3:42:42 PM]

Share this post


Link to post
Share on other sites
Advertisement
DevIL (at least in version 1.7.3) doesn't handle the alpha channels correctly, so it's an issue with the library itself, not some kind of wrong usage.

Have a look at the devil forum here if you want to know more and how i solved it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Denton Woods on Sourceforge - 2008-12-23 16:55
I just added in the IL_BLIT_BLEND flag in CVS. By default, the behavior is the same as it was, blending the source image into the destination image. If you use this flag in ilDisable, it uses the code that you need.


I thought i'd post this here so someone can actually find a good solution if he comes across this thread looking for a solution to a similar problem.

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!