PocketMatrix forums

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

Newbie CGapiRGBASurface question

Hello,

I'm new in GapiDraw and Game Development, and although I've looked in the forum, I was unable to fins a way to find the problem in my code.

I'm trying to display an alpha blended PNG without success...

code:

Code:

...
private
CGapiRGBASurface* m_RotateLeft;
...

m_RotateLeft = new CGapiRGBASurface(m_pGapiDraw);

...


void ClassGame::OnCreateSysMemSurfaces(CGapiDisplay* pDisplay, HINSTANCE hInstance)
{
m_RotateLeft->CreateSurface(GDRGBASURFACE_CLEAR, hInstance, IDR_ROTATELEFT, _T("PNG"));
//...
::SetRect(&m;_btnRotateLeft, m_btnRotateRight.left - m_RotateLeft->GetWidth(), 0, m_btnRotateRight.left, m_RotateLeft->GetHeight());
, NULL);
}

void ClassGame::OnProcessNextFrame(CGapiSurface* pBackBuffer, DWORD dwFlags)
{
pBackBuffer->FillRect(NULL, /*RGB(128, 128, 128)*/0x00AE00, 0, NULL);

pBackBuffer->AlphaBltFast(m_btnRotateLeft.left, m_btnRotateLeft.top, m_RotateLeft, NULL, GDALPHABLTFAST_OPACITY, NULL);
}



However, nothing is displayed.

What am I doing wrong?


Thanks

Joao
From what I can see from the code you have shown it suggests that the rect is more than likely off the screen.

Try altering line 23:
Code:

pBackBuffer->AlphaBltFast(0, 0, m_RotateLeft, NULL, GDALPHABLTFAST_OPACITY, NULL);


That should show the graphic in the top left of the screen.

BTW you don't need to pass any flags if you are not passing a GDALPHABLTFASTFX struct. i.e. GDALPHABLTFAST_OPACITY seems redundant in this example

If you step through your code you will see what values you have for your rect. That should help you sort out any discrepencies there.

Hope this helps
Hello Antony,

First of all, thanks for your reply.

Your changes didn't work, because the rect structure was correct. I already knew that because before trying the CGapiRGBASurface object I was using the CGapiSurface with the same code and the image was appearing just fine.

However, your other comment gave me the light and by trying something a little different it worked :

Code:

pBackBuffer->AlphaBltFast(m_btnRotateLeft.left, m_btnRotateLeft.top, m_RotateLeft, NULL, NULL, NULL);


Therefore, many thanks on helping me solve the problem.


Best regards,

Joao
Nice to know you have sorted it. My intention was to remove the flag and replace with NULL but I guess it is just another of those cut-and-paste errors ;)

The flag ought to be completely ignored in the underlying code if a NULL pointer to the GDALPHABLTFASTFX struct is passed. It seems from your experience that it isn't :o