Sign in to follow this  
Xadja

[.net] From C++

Recommended Posts

Hi! How this will be look in MDX C#: D3DLOCKED_RECT rect; unsigned short *data; int tempdata[size]; for(int t=0; t<2; t++) { int offset = size*t; texture[t]->LockRect( 0, &rect, NULL, D3DLOCK_DISCARD ); data = (unsigned short*)rect.pBits; for(int i=0; i<size; i++) data[i] = 32768+mass[i+offset]; texture[t]->UnlockRect( 0 ); } Thanks for help!

Share this post


Link to post
Share on other sites
I can't help with the MDX part, but this snippet is prone to crash.

There is a pitch in the D3DLOCKED_RECT struct, also in the MDX version. Use it.
Only copy the image data per line. The drivers are allowed to add optimising data in between.

Share this post


Link to post
Share on other sites
I made it! :)))
Rectangle rect=new Rectangle();
int* data;
int[] tempData=new int[size];
for(int t=0;t<2;t++)
{
int offset = size*t;

GraphicsBuffer buffer = Texture[t].Lock(0, rect, LockFlags.Discard);
data = (int*) buffer.DataBufferPointer;
for(int i=0;i<size;i++)
{
data[i] = 32768 + mass[i + offset];
}
Texture[t].Unlock(0);


Thanks for reading this post :)))

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