Jump to content
  • Advertisement
Sign in to follow this  
majak

rendering to texture problem

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

	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
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;

Share this post


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

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!