looks sweet, good luck with it dude
you are using dbDot to draw? if so, well whatever you are using, i
think this way would be faster:
IDirect3DDevice9* device = dbGetDirect3DDevice ( );
IDirect3DSurface9* surface;
D3DLOCKED_RECT Rect;
RECT lockRect;
//rect to lock dimensions
lockRect.left = x;
lockRect.top = y;
lockRect.right = x2;
lockRect.bottom = y2;
device->GetBackBuffer ( 0, 0, D3DBACKBUFFER_TYPE_MONO, &surface );
if ( FAILED ( surface->LockRect ( &Rect, &lockRect, 0 ) ) )
{
surface->Release ( );
return;
}
unsigned int *c = (unsigned int*)Rect.pBits;
//now c is the screen pixels array, you can use it to color anything over there, e.g.
//to color 1024x768 with red, do this:
//note that the locked rect's dimensions above should be 1024x768
for ( int x = 0; x < 1024; x++ )
{
for ( int y = 0; y < 768; y++ )
{
c[x+y*(Rect.Pitch/4)] = D3DCOLOR_XRGB ( 255, 0, 0 );
}
}
surface->UnlockRect ( );
surface->Release ( );
So let me explain what's going there, you get the darkGDK's device and store it in device variable:
IDirect3DDevice9* device = dbGetDirect3DDevice ( );
then you declare a variable that we will store the GDK's backbuffer in it
IDirect3DSurface9* surface;
now declare the variable that will hold the locked screen rectangle
D3DLOCKED_RECT Rect;
now the rectangle of the screen to lock
RECT lockRect;
//rect to lock dimensions
lockRect.left = x;
lockRect.top = y;
lockRect.right = x2;
lockRect.bottom = y2;
Now get the backbuffer, and store it in surface variable
device->GetBackBuffer ( 0, 0, D3DBACKBUFFER_TYPE_MONO, &surface );
now lock the backbuffer's (surface) rect, using the dimensions defined above
if ( FAILED ( surface->LockRect ( &Rect, &lockRect, 0 ) ) )
{
surface->Release ( );
return;
}
get a pointer to the screen's pixels
unsigned int *c = (unsigned int*)Rect.pBits;
now we're done, and ready for coloring, you can access an x,y point of the locked rect by using
c[x+y*(Rect.Pitch/4)], you can assign it to a D3DXCOLOR_XRGB ( r, g, b ) value.
note that x and y are the x and y of the
LOCKED RECTANGLE not the screen
for ( int x = 0; x < 1024; x++ )
{
for ( int y = 0; y < 768; y++ )
{
c[x+y*(Rect.Pitch/4)] = D3DCOLOR_XRGB ( 255, 0, 0 );
}
}
unlock the rectangle
surface->UnlockRect ( );
surface is a COM object, and thus needs to be released to free memory
surface->Release ( );
You can try it out, hope it makes any difference, it's worth a try anyway