• Advertisement
Sign in to follow this  

Accessing 128-bit texture help plz

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

In 32bit D3DFMT_A8R8G8B8 there's no problem using the code:
if(FAILED(ge_pd3dDevice->CreateTexture(8, 8, 1, 
D3DUSAGE_DYNAMIC, 
D3DFMT_A8R8G8B8, 
D3DPOOL_DEFAULT, 
&pVectorTexture, NULL)))assert(0);
		if(FAILED(pVectorTexture->LockRect(0, &lr, NULL, D3DLOCK_DISCARD)))assert(0);
		for(int y=0; y<8; ++y)
		{
			BYTE* pData = (BYTE*)(((BYTE*)lr.pBits)+(lr.Pitch * y));
			for(int x=0; x<8; ++x){
				if(x % 2 == 0){
					*pData++ = 20;//B
					*pData++;//G
					*pData++;//R
					*pData++;//A
				}
                                   else{
					*pData++;
					*pData++;
					*pData++;
					*pData++;
				}
			}
		}
		pVectorTexture->UnlockRect(0);



Now I modify some lines to do 128 bit texture:
if(FAILED(ge_pd3dDevice->CreateTexture(8, 8, 1, 
D3DUSAGE_DYNAMIC, 
D3DFMT_A32B32G32R32F, 
D3DPOOL_DEFAULT, 
&pVectorTexture, NULL)))assert(0);
		if(FAILED(pVectorTexture->LockRect(0, &lr, NULL, D3DLOCK_DISCARD)))assert(0);
		for(int y=0; y<8; ++y)
		{
			DWORD* pData = (DWORD*)(((DWORD*)lr.pBits)+(lr.Pitch * y / 4));
			for(int x=0; x<8; ++x){
				if(x % 2 == 0){
					*pData++ = 20;//B
					*pData++;//G
					*pData++;//R
					*pData++;//A
				}
				else{
					*pData++;
					*pData++;
					*pData++;
					*pData++;
				}
			}
		}
		pVectorTexture->UnlockRect(0);



But I can get nothing. Is there something wrong? THX

Share this post


Link to post
Share on other sites
Advertisement
Quote:

Is there something wrong?


I've never used 128-bit textures, but my guess would be that the "F" on the end of the format type means each channel is a float, not an integer(or DWORD, same thing).

Share this post


Link to post
Share on other sites
Quote:
Original post by Scet
the "F" on the end of the format type means each channel is a float
This is the case here.

When performing this sort of operation you have access to very low-level implementation details so you need to REALLY understand how it's laid out in memory.

Accessing data incorrectly is effectively a form of casting - you're converting an IEEE754 single precision floating point value to a 32bit unsigned integer [smile]

hth
Jack

Share this post


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

  • Advertisement