PocketMatrix forums

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

Solve this code segment ...

This code has no error, but it dont display the resource image. Kindly fix it and paste it again. Thankyou.

Code:

CGapiSurface* g_ipaq;

class CMyApplication : public CGapiApplication
{
public:
CMyApplication(const GDAPPCONFIG& config) : CGapiApplication(config)
{}

virtual HRESULT CreateSysMemSurfaces(CGapiDisplay* pDisplay, HINSTANCE hInstance)
{
return GD_OK;
}

virtual HRESULT CreateVidMemSurfaces(CGapiDisplay* pDisplay, HINSTANCE hInstance)
{
return GD_OK;
}

virtual CreateSurfaces(CGapiDisplay* pDisplay, HINSTANCE hInstance)
{
const COLORREF TRANSPARENTCOLOR = RGB(0, 0, 255);
g_ipaq->CreateSurface(GDSURFACE_SYSTEMMEMORY,hInstance,IDR_PNG2, _T("PNG"));
g_ipaq->SetColorKey(TRANSPARENTCOLOR);

}
virtual HRESULT ProcessNextFrame(CGapiSurface* pBackbuffer, DWORD dwFlags)
{

pBackbuffer->FillRect(NULL, RGB(128, 128, 128), 0, NULL);

pBackbuffer->BltFast(0,0,g_ipaq,NULL,NULL,NULL);

return S_OK;
};

virtual HRESULT KeyDown(DWORD dwKey, GDKEYLIST& keylist)
{

Shutdown();
return S_OK;
};

virtual ~CMyApplication() {};
};

int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
LPTSTR pCmdLine, int nCmdShow)
{
GDAPPCONFIG config;
ZeroMemory(&config;, sizeof(GDAPPCONFIG));//zeromemory macro fills a block of memory with zeros, i-e here it is initializing the "config" to zeros
// this macro also works as "::ZeroMemory..."
config.hInstance = hInst;
config.pAppTitle = TEXT("Welcome to GapiDraw!");
config.dwMaxFPS = 20;
config.dwWindowIcon = IDI_APP;

// Create the application
CMyApplication simple(config);

// Start main loop

return simple.Run();
}
InexorableTash · 19 Oct 2004, 06:16 UTC
"Give a man a fish and he can eat for a day. Teach a man to fish and he can eat for the rest of his life."

(1) Try checking the return values of the method calls into the various CGapiSurface objects. Are they returning success or failure? If success, is your code doing what you think it's doing? If failure, why?

(2) Try using breakpoints to determine if values you think are set really are. (Hint: they aren't)

(3) Try using breakpoints, and determing if the code you assume is running really is running. (Hint: it's not)

(These are basic software debugging steps, so it's important to learn them. Otherwise, you might as well just contract someone to write your code for you.)
Hi,
Just a couple of questions:
What size is your image?
What size is the screen you try to display it on?

I see you BltFast your image with this code:
pBackbuffer->BltFast(0,0,g_ipaq,NULL,NULL,NULL);
If the image is bigger than the screen it won't appear.
If it is the case, instead of the NULL pointer (just after the surface pointer in the call to BltFast) use a pointer to a RECT you set smaller than your screen.

It may not help but that just caught my eye.

Vincent.
vince_mad wrote:Hi,

If it is the case, instead of the NULL pointer (just after the surface pointer in the call to BltFast) use a pointer to a RECT you set smaller than your screen.



or set the clipper on the destination surface