rendering to texture problem

Started by
3 comments, last by majak 18 years, 8 months ago

	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...
Advertisement
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;
*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..
If I remove this part: Pixels += RC.Pitch;
it does not change the image! What am I doing wrong?
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

This topic is closed to new replies.

Advertisement