PocketMatrix forums

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

help

I'm a beginner and I dont quite understand the use of surfaces and bitmaps.
can anyone give me a simple code - just pasting a picture as the background, and another picture on it.
thanks.
There are some ready-to-run examples included with gapidraw.
Look in the folder "examples" :)

Artax
jeremieweldin · 20 Aug 2002, 15:14 UTC — read lamothe
Read Tricks of the windows game programming gurus (ISBN: 0672323699; 2nd edition) (amazon link below), or go to gamedev.net and look for directdraw tutorials.

http://www.amazon.com/exec/obidos/ASIN/0672323699/qid=1029852030/sr=2-1/102-5754734-4895338
Hello, I used to program with PocketFrog all this while but now trying to look into GapiDraw. The problem is none of this make sense! :evil:

I was a beginner in pocketFrog but thanks to Conan's tutorial and some built in samples I quickly got the hang of whats going on.

But with GAPI I cant see how to even start. Even the built-in samples in the samples/w32 folder dont make sense. Do all functions start with near pascal thingamajig or just the one in reversi? I cant find any samples that blit a picture into the background and another picture onto a surface. Like the originator of this thread, if someone could just make a code of a jpg blit onto the background, a jpg picture on the foreground, and move that picture up 20 pixels, then thats all I need.

Right now, I cant find this information anywhere. Your links dont help me either jeremieweldin but thanks for it.

Searching this forum, this is probably the most relevant thread to my problem.

If you can help, please post here.

Thanks in advance.
Define a surface then load the image into the surface with CreateSurface, depending on what sort of image you have will determine how you use CreateSurface; there are a few different methods. Then in your ProcessFrame method Blit that surface into the backbuffer.

In general:
[some init method]
GapiSurface surface;
surface.CreateSurface(...);

[some ProcessNextFrame method]
backbuffer.Blt(x, y, &surface, ...);

Thats just off the top of my head, some parameters and such may not be correct, and spelling.
Just study the included 'Simple' project for an introduction. It will show you how to execute both simple BltFast and the slightly more complex Blt operations. It also covers basic stylus input. Really, GapiDraw is very easy to use once you understand the basics.
eh, where is this "simple" project you mentioned?

I have looked through \Pocket PC 2002\samples\win32 and I cannot find anything remotely named "simple"

It does sound just like what I need to know to get moving though.

Thanks.

By the way, is it right to say that the way gapidraw works is by drawing on a backbuffer, then flip that to forefront and drawing the next frame on the new backbuffer? so the game will function like the page is continuously flipping where you always draw on the backbuffer? So lets say I want to display a screen indefinitely, does that mean I still flip the page until the user presses an input or I stop flipping the page until the user keys in an input? This concept is really new to me.
I't sounds like you're looking in the wrong place. If you haven't already, download the GapiDraw 2.01b distribution and install it. Then look in ./GapiDraw/samples/simple for the simple project.


By the way, is it right to say that the way gapidraw works is by drawing on a backbuffer, then flip that to forefront and drawing the next frame on the new backbuffer? so the game will function like the page is continuously flipping where you always draw on the backbuffer? So lets say I want to display a screen indefinitely, does that mean I still flip the page until the user presses an input or I stop flipping the page until the user keys in an input?


If you use the included CMyApplication framework, your description of page flipping is correct. Page flipping continues while waiting for user input.
CpuWhiz105 · 18 May 2003, 14:35 UTC — Minimal Sample
The minimal sample is all you need to set up GapiDraw, so just take that and add:
CGapiSurface surface1;
near the top of the file (after the includes.) and add:
surface1.CreateSurface(NULL, filePath);
to CreateSurfaces. It should look like this

Code:
HRESULT CMyApplication::CreateSurfaces(CGapiDisplay& display, HINSTANCE hInstance)
{
surface1.CreateSurface(NULL, "C:\image.bmp")
return S_OK;
}


That should load your image, now you need to blit it. In the ProcessNextFrame add:
backbuffer.BlitFast(0, 0, &surface1, NULL, 0, NULL);
and it should look like this:
Code:
HRESULT CMyApplication::ProcessNextFrame(CGapiSurface& backbuffer, DWORD dwFlags)
{
// Clear the back buffer
backbuffer.FillRect(NULL, RGB(128, 128, 128), 0, NULL);

DWORD dwXCenter = (backbuffer.GetWidth()>>1);
DWORD dwYCenter = (backbuffer.GetHeight()>>1);

// Draw some text
TCHAR str1[] = TEXT("This is a minimal GapiDraw Application");
TCHAR str2[] = TEXT("-Press any key to exit-");
backbuffer.DrawText(dwXCenter, (dwYCenter-10), str1, GDDRAWTEXT_CENTER | GDDRAWTEXT_BORDER, NULL);
backbuffer.DrawText(dwXCenter, (dwYCenter+2), str2, GDDRAWTEXT_CENTER | GDDRAWTEXT_BORDER, NULL);

backbuffer.BlitFast(0, 0, &surface1, NULL, 0, NULL);

return S_OK;
}

That should work. I hope it helps.
masChman wrote:
By the way, is it right to say that the way gapidraw works is by drawing on a backbuffer, then flip that to forefront and drawing the next frame on the new backbuffer?


Yes. The process frame methods are called to update the screen every *frame*. The frame rate depends on your settings and also how much time is spent doing the work. This is all based on using the GapiApplication files that are included with GD, you could of course try a different method and write the base framework in another way.
If you guys were women I'd kiss yah =) Lucky you, you arent =)

This is really good, it helped me understand quite a bit about this library but I cant say I'm equipped sufficiently enough yet to start any programming. Are there any online links that would make a good start for a complete beginner in directdraw/gapidraw?

[quote]I't sounds like you're looking in the wrong place.[/quote]

LOL yeah. I'm glad you said that or I'd still be lost. You see I downloaded both gapidraw and PPC2002sdk at once, and I forgot to install gapidraw yet. That's why I cant find the folder you mentioned. I was browsing through the ppc2002sdk folder! No wonder nothing made sense. I couldnt even find any processnextframe methods in any of the samples! LOL does that qualify me for the dumbest programmer on this board yet?
There's a few tutorials on our website forums (http://www.ppcstudios.com) that might help a bit. The GapiDraw samples are really the key to understanding it all though. You might want to pick up the book Pocket PC Game Programming by Jonathan Harbour. While its not GapiDraw specific, it might be a good starting point for you.