Also, there is a MUCH faster alternative to dbPoint and dbDot. This alternative is to access the display memory directly to read and write. Here's a summary of how it works:
1. Lock the display memory for the window using dbLockPixels().
2. Obtain a pointer to the base address of the window's display memory using dbGetPixelsPointer(). As you'll see in my code, you have to cast the return value to an integer pointer, because the address is returned as an integer value, which is actually a VERY, VERY poor programming practice (shame, shame TGC). Probably done for compatibility with dbpro or something??? Not sure.
4. Go ahead and do your thing with this pointer, using dbGetPixelsPitch() to obtain the number of bytes per row. To convert this to the number of pixels per row (on a 32 bit OS), simply divide the result by 4, since an int is 32 bit, which is equal to 4 bytes, and each pixel uses 32 bits to store the color value within Dark GDK.
5. To finish, you MUST unlock the display memory. To do this, call dbUnlockPixels().
3. I know that's a lot to digest, so I've included the following two functions for easy reading/writing of pixels using this MUCH faster alternative to dbPoint and dbDot. Enjoy!
void setPixelColor(int x, int y, int color)
{
//**NOTE**: Pixels per row = dbGetPixelsPitch() / 4.
//**NOTE**: Pixel number = ((y - 1) * pixelsPerRow) + x.
dbLockPixels();
int* pixel = (int*)dbGetPixelsPointer();
*(pixel + x + ((y - 1) * (dbGetPixelsPitch() / 4))) = color;
dbUnlockPixels();
}
int getPixelColor(int x, int y)
{
//**NOTE**: Pixels per row = dbGetPixelsPitch() / 4.
//**NOTE**: Pixel number = ((y - 1) * (dbGetPixelsPitch() / 4)) + x.
int color = 0;
dbLockPixels();
int* pixel = (int*)dbGetPixelsPointer();
color = *(pixel + x + ((y - 1) * (dbGetPixelsPitch() / 4)));
dbUnlockPixels();
return color;
}
,Willie