bmap_fill crashes on- and bmap_save doesnt save huge bitmaps

Posted By: HeelX

bmap_fill crashes on- and bmap_save doesnt save huge bitmaps - 04/08/13 17:08

Hi,

I want to create and save a huge skybox texture, but I noticed that for heights > 1024px bmap_fill crashes and bmap_save doesn't save the bitmap. With the following example code you can reproduce it:

Code:
int main ()
{
	wait(3);
	
	int w = 2048; // works for 1024 and less!
	
	BMAP* b = bmap_createblack(w * 6, w, 8888); // or 24, format doesn't matter here
	if (b != NULL)
	{
		// bmap_fill(b, COLOR_BLUE, 100); // error: "Script crash in main"
		bmap_save(b, "bigblue.tga"); // nothing is saved
	}
}

Posted By: sivan

Re: bmap_fill crashes on- and bmap_save doesnt save huge bitmaps - 04/09/13 07:23

you nedd 3 tricks and it works (I had a lot of problems with where to use waits in image manipulations...):

Code:
#include <acknex.h>

int main ()
{
	level_load(NULL);
	wait(3);
	d3d_texlimit = 2048 * 6;
	
	int w = 2048; 
	BMAP* b = bmap_createblack(w * 6, w, 888); // or 24, format doesn't matter here
	wait(1);
	if (b != NULL)
	{
		bmap_fill(b, COLOR_BLUE, 100); 
		wait_for(bmap_fill);
		bmap_save(b, "bigblue.tga"); 
	}
}



but d3d_texlimit is 3d card dependent...
Posted By: HeelX

Re: bmap_fill crashes on- and bmap_save doesnt save huge bitmaps - 04/09/13 09:28

Sivan, thanks - I didn't thought about the impact of maximum texture size the 3D card. Though, d3d_texlimit is initialized with the highest possible texture resolution anyway. For my card it is 8192. So, when setting it to 6 * 2048 = 12288 it is obvious, that leads to an error, when bmap_save or bmap_fill are executed on such a huge bitmap.

Though, your code doesn't changed the behaviour of the script on my computer; bmap_fill still crashes and bmap_save doesn't produce any output file.

At least bmap_fill should check the bitmap dimensions first, in my opppinion. And the manual should refer to d3d_texlimit as constraint for both functions. At least it is written about bmap_save that the image size must be a multiple of 8.
Posted By: sivan

Re: bmap_fill crashes on- and bmap_save doesnt save huge bitmaps - 04/09/13 09:54

the strange thing is that my card gives also a max value of 8192, but setting it higher in this case works...
Posted By: jcl

Re: bmap_fill crashes on- and bmap_save doesnt save huge bitmaps - 04/09/13 14:16

We'll look into this. If the texture dimensions are exceeded, it should give an error message, but not crash.

- BTW, it's always nice to randomly insert wait(3) calls in the code, especially after level_load(). Your PC certainly appreciates a 3 frame holiday after loading a heavy file. Players of my age will also be glad when the game doesn't start so fast. wink
Posted By: sivan

Re: bmap_fill crashes on- and bmap_save doesnt save huge bitmaps - 04/09/13 14:55

apparently that wait is accidently there after copying and removing some lines
© 2024 lite-C Forums