DirectX Error: TXFORM2

Posted By: Caermundh

DirectX Error: TXFORM2 - 06/20/12 20:51

I am getting the error message "DirectX Error: TXFORM2" at runtime when i try to lock a bitmap with bmap_lock.

Heres what im doing:

BMAP* letter_bmap;

function main()
{ letter_bmap = bmap_create("georgia_font2.jpg");
wait(1);
bmap_to_format(letter_bmap,8888);
bmap_lock(letter_bmap,0);
}

Does anyone know what this error means?
Posted By: SchokoKeks

Re: DirectX Error: TXFORM2 - 06/21/12 03:27

I don't know what that error means exactly, but check if bmap_to_format actually worked.
If it returns 0, then the conversion failed.

Also, as you can read in the manual under "file formats", the use of the jpg is discouraged:
Quote:
JPG images should not be used for textures in realtime games. They combine all disadvantages of the other formats, plus the additional disadvantage of slow loading, high video memory consumption, and bad texture quality. Their only advantage is small file size.


Also:
Quote:
Also supported, but not recommended are BMP, PNG and JPG images - they are read through the DirectX library and thus depend on the DirectX version, and have other shortcomings. The selected image format does matter because all formats have their specific advantages and disadvantages:

So maybe DirectX loads them in a way so that you can't use bmap lock and other manipulation functions. You might want to try the same code with another file format.

Quote:
Recommended image formats are TGA, DDS, PCX and WAD.


Hope this helped.
Posted By: Caermundh

Re: DirectX Error: TXFORM2 - 06/21/12 17:03

ok - did some testing. The bmap_to_format is not failing - its converting the bmap successfully. I also converted the file to .tga format - no luck, i still get the DirectX Error: TXFORM2.
Posted By: sivan

Re: DirectX Error: TXFORM2 - 06/21/12 20:07

as it is described in the manual at bmap_lock page, it's not allowed to use bmap_lock before the first frame, and in your code there is no level loaded. put a level_load(NULL); in the beginning and a wait(1); it should work fine.
Posted By: Rei_Ayanami

Re: DirectX Error: TXFORM2 - 06/21/12 20:09

Originally Posted By: sivan
as it is described in the manual at bmap_lock page, it's not allowed to use bmap_lock before the first frame


He put a wait(1) in the code above.

Originally Posted By: sivan
and in your code there is no level loaded. put a level_load(NULL); in the beginning and a wait(1); it should work fine.


That is really not needed as it should not have any effect on the 2D functions.
Posted By: Caermundh

Re: DirectX Error: TXFORM2 - 06/21/12 20:17

Im loading a level, and doing a wait(1); after loading it. I just didnt include that code or the other things im doing in main as they didnt seem pertinent to the problem.
Posted By: Caermundh

Re: DirectX Error: TXFORM2 - 06/21/12 20:35

hummmm....well i found a fix - but its a strange one. I put the bmap_lock in a subroutine with the bmap its locking passed as a parameter and now it works fine.

Heres the code:

function my_bmap_lock_func(BMAP* letter_bmap)
{ bmap_lock(letter_bmap,0);
....
<bitmap manipulation code goes here>
....
return;
}

function main()
{ BMAP* letter_bmap;
level_load("my_level.wmb");
wait(1);
letter_bmap = bmap_create("georgia_font2.tga");
wait(1);
bmap_to_format(letter_bmap,8888);
my_bmap_lock_func(letter_bmap);
}

so very very odd.....
Posted By: Rei_Ayanami

Re: DirectX Error: TXFORM2 - 06/21/12 20:39

are you unlocking it?

Cause: "A bitmap must be unlocked for being visible on the screen."

This could cause the crash.
Posted By: Caermundh

Re: DirectX Error: TXFORM2 - 06/21/12 21:07

yeah, im unlocking it later, at the end of the subroutine - or rather, before i was using a subroutine, i was unlocking it at the end of main, but seeing as how it was crashing on the bmap_lock() command, unlocking it seemed like a moot point.
Posted By: sivan

Re: DirectX Error: TXFORM2 - 06/22/12 07:39

strange. but I never had any reason to lock a bmap in main function laugh
© 2024 lite-C Forums