PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Direct Screen access with GapiDraw

Hi!

I have a question about accessing the screen directly. Since im not very familier with GapiDraw or DirectX (I have not coded gfx routines since I last used Watcom C in dos in 1998). And heard it could return a pointer to the screens memorylocation.

So how do I do this?

How would this putpixel look like.

screen[x+(y*screen_wi)]=128;

PS: Is this also possible to do with a surface? :)

Regards,
cPix.
Below is an example on how you access the screen directly using GetBuffer. The code loops through each pixel on the screen setting it to white. Some of the helper functions are found in "GapiDrawExtension.h"

Code:
GDBUFFERDESC bb;
if(FAILED(pBackbuffer->GetBuffer(&bb)))
return;

WORD* pBuffer = bb.pBuffer;
long xPitch = bb.xPitch >> 1;
long yPitch = bb.yPitch >> 1;
long nWidth = bb.dwWidth;
long nHeight = bb.dwHeight;

gdhelper::OptimizePitch(pBuffer, nWidth, nHeight, xPitch, yPitch);

WORD *pTemp, *pDest = pBuffer;
for(int y=0; y < nHeight; ++y)
{
pTemp = pDest;
for(int x=0; x < nWidth; ++x)
{
switch (bb.dwPixelFormat)
{
case GDPIXELFORMAT_555:
*pTemp = (WORD)gd555::RGBToNative(255, 255, 255);
break;
case GDPIXELFORMAT_565:
*pTemp = (WORD)gd565::RGBToNative(255, 255, 255);
break;
}
pTemp += xPitch;
}
pDest += yPitch;
}
pBackbuffer->ReleaseBuffer();


And yes, you can do this on any CGapiSurface.

/scoreman