Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (ozgur, TipmyPip, AndrewAMD), 1,209 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: How to get 16it floats out of a bmap... pixel_for_vec dont work! [Re: EvilSOB] #384620
10/05/11 12:46
10/05/11 12:46
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
dds is just a container format which can store all kind of texture data, compressed and uncompressed and so on. So this really depends on how you save it. But I guess that there is no basic format for compressed 16bit fp textures, because of that I´d assume that your texture is uncompressed.
On bmap_lock, what format is returned?

Edit: Also, you should probably go with 32bit instead of 16, as otherwize things get quite tricky, because there is no corresponding datatype.

Something like this could then work:
Code:
#include <d3d9.h>

/* DX Lock flags */
#define D3DLOCK_READONLY 0x00000010L
#define D3DLOCK_DISCARD 0x00002000L
#define D3DLOCK_NOOVERWRITE 0x00001000L
#define D3DLOCK_NOSYSLOCK 0x00000800L
#define D3DLOCK_DONOTWAIT 0x00004000L                  
#define D3DLOCK_NO_DIRTY_UPDATE 0x00008000L

void ReadPixels(float **pixels, BMAP* rbmap)
{
	LPDIRECT3DTEXTURE9 dxtex = rbmap->d3dtex;
	D3DLOCKED_RECT dxrect;
	unsigned char *bmp;
	
	bmap_preload(rbmap);
	dxtex->LockRect(0, &dxrect, NULL, D3DLOCK_READONLY);
	bmp = dxrect.pBits;
	
	var width = bmap_width(rbmap);
	var height = bmap_height(rbmap);
	
	*pixels = sys_malloc(width*height*sizeof(float));
	
	var x, y;
	for(y = 0; y < height; y++)
	{
		memcpy(pixels[y*width], bmp[y*dxrect.Pitch], sizeof(float*width));
	}
	
	dxtex->UnlockRect(0);
}



Last edited by Slin; 10/05/11 13:11.
Re: How to get 16it floats out of a bmap... pixel_for_vec dont work! [Re: Slin] #384636
10/05/11 15:56
10/05/11 15:56
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Compile error dude ...pBits is not a member of "VOID"

Im digging for it now, but no luck so far...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: How to get 16it floats out of a bmap... pixel_for_vec dont work! [Re: EvilSOB] #385301
10/16/11 02:56
10/16/11 02:56
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Klaatu ... Verada ... Nictu !!!
Thread Resurrection time!

OK, Ive finally gotten to the pixel data via the BMAP.finalbits pointer.
Luckily the data is actually uncompressed. Purely by luck.

BUT, Im able to pull the RAW 16-bit floats out of the DX-data, but
am having a lot of difficulty converting them to 32-bit lite-c floats.
(my pointer maths is still severely rusty still...)

So, any suggestions on how to convert these 16bit floats to 32bit floats?
And / or ultimately to lite-c (scaled?) 'long's or 'short's?


Thanks again guys.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: How to get 16it floats out of a bmap... pixel_for_vec dont work! [Re: EvilSOB] #385309
10/16/11 13:30
10/16/11 13:30
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
Originally Posted By: EvilSOB
...So, any suggestions on how to convert these 16bit floats to 32bit floats?...

Use D3DXFloat16To32Array and consult the SDK help for more details.


Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Re: How to get 16it floats out of a bmap... pixel_for_vec dont work! [Re: rojart] #385314
10/16/11 14:00
10/16/11 14:00
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Been there, tried that, and failed...

Looks to be another obscure D3D function that conitec didnt bother
to fully implement in their d3d9.h header.

And I dont know D3D well enough to perform a manual override on it.
Tried and failed...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: How to get 16it floats out of a bmap... pixel_for_vec dont work! [Re: EvilSOB] #385348
10/17/11 05:24
10/17/11 05:24
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Ive finally come up with my own converter.

Here it is in case anyone else is interested...


Code:
//-----------------------------------------------
// Convert (D3D) float16 to (acknex) float32
//-----------------------------------------------
float	float16to32(short num)
{	long	z = (num & 0x8000) <<16;
	z = z | (((num & 0x7C00) >>10 ) +0x70) <<23;
	z = z |   (num & 0x03ff) <<13;
	return(*((float*)&z));								}
//-----------------------------------------------




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 2 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1