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!
Annoying Managed DirectDraw Surface.Lock Bug
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);
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);
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement