Annoying Managed DirectDraw Surface.Lock Bug

Started by
12 comments, last by Muzlack 20 years ago
SOLVED!

temp = surfaceSecondary.Lock(LockFlags.SurfaceMemoryPointer);

for(int x=0;x<1024;x++)
for(int y=0;y<768;y++)
temp.SetValue((int)rnd.Next(16773378),x,y);
surfaceSecondary.Unlock(temp);
// surfaceSecondary.ColorFill(Color.Yellow);

Plug that into the main display routine, and poof, your getting one hell of a show.

You should try it at full screen

Unfornantly its not very fast, but its more of a proof of concept. In fact, I am only using half the colors as, for some stupid reason, it uses int, instead of unsigned int.

Anyway, I am off to figure out how to emulate an Apple 1!
Advertisement
Hi,

I have been having the same problem for ages what is rnd in the code you suggested

temp.SetValue((int)rnd.Next(16773378),x,y);
This is a known issue that will be addressed in an upcoming release later this year.
http://www.amazon.com/exec/obidos/tg/detail/-/0672325969- Tom Miller, Managed DirectXThis posting is provided "AS IS" with no warranties, and confers no rights.
i''ve also encountered this problem, and to me it seems to be a realy annoying bug. i''ve tried using the array as pointer, while taking into accont the pitch; it didn''t seem to help, but here is the important part:

int stride = back.SurfaceDescription.Pitch;
byte[,] barr = back.LockMicrosoft.DirectX.DirectDraw.LockFlags.SurfaceMemoryPointer );
unsafe
{
fixed (byte* pbdata = barr)
{
for (int j=0; j<100; j++)
{
for (int i=0; i<100; i++)
{
*(pbdata+j*stride+2*i+1) = 0xF8;
}
}
}
}
back.Unlock(barr);

i''m using a 16bit rgb device and this code should paint the surface red (its a 100X100 backbuffer surface called back).

however, it paints half the surface. i''ll be happy to know if this code works for u, and what am i doing wrong
it tolls for thee

This topic is closed to new replies.

Advertisement