Jump to content
  • Advertisement
Sign in to follow this  
Xadja

[.net] From C++

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

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 = 32768+mass[i+offset]; texture[t]->UnlockRect( 0 ); } Thanks for help!

Share this post


Link to post
Share on other sites
Advertisement
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
rect.pBits is a pointer to the image data, more exact, the top left corner of it.

I think in that case you can either use unsafe code and use the pointer or point a byte[] to that address (not sure if that works easily).

Share this post


Link to post
Share on other sites
Can you tell me please what this code do? May be i can do this in MDX.
"data" What do this pointer change?

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 = 32768 + mass[i + offset];
}
Texture[t].Unlock(0);


Thanks for reading this post :)))

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!