Sign in to follow this  
majak

rendering to texture problem

Recommended Posts

majak    122
	D3DLOCKED_RECT RC;
	Texture->LockRect(0, &RC, 0, 0);	
	int* Pixels = (int*)RC.pBits;		
	int* DPixels = (int*)Pixels;		

	for(int k=0; k<pixelAntal; k++){					

		*DPixels++ = buffer[k];	
		Pixels += RC.Pitch;	
	}//end for
	Texture->UnlockRect(0);		

This part of my code I just copied from an tutorial, so I don't really undestand it, could someone explain it? Also I think I'm doing something wrong in this part: int* Pixels = (int*)RC.pBits; int* DPixels = (int*)Pixels; My buffer array is an int array, but instead of drawing my picture on the entire screen, it devides it in eight and draw the picture eight times...

Share this post


Link to post
Share on other sites
majak    122
I don't know if it means anything, but I have this:

Present_Parameters.AutoDepthStencilFormat = D3DFMT_D16;

should it be something else, since I operate with 24 bit texture?

HRESULT Result = D3DXCreateTexture(D3D_Device, the_width, the_height, 1, 0, D3DFMT_R8G8B8, D3DPOOL_MANAGED, &Texture);

the_width = 512;
the_height = 512;

Share this post


Link to post
Share on other sites
majak    122
*DPixels++ = buffer[k];
Pixels += RC.Pitch;

the pitch counts the bytes in the texture and since I use ints, it's four times bigger than my width. Anyone who knows how to deal with that?

Also I get like two pictures on top of each other!!
So instead og having one big picture, I have 2*4 small pictures..

Share this post


Link to post
Share on other sites
majak    122

int next = 0;
D3DLOCKED_RECT RC;
Texture->LockRect(0, &RC, 0, 0);
unsigned int *bytePointer =(unsigned int*)RC.pBits;


for (DWORD y=0;y<the_height;y++)
{
for (DWORD x=0;x<the_width;x++)
{
DWORD index=(x*4+(y*(RC.Pitch)));
bytePointer[index]= buffer[next];
next++;
}
}

Texture->UnlockRect(0);





I have no idea if I'm the right track, but as far as I can see I need to deal with the Pitch.. This piece og code does not work, please help me undestand what happends here.

Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this