This site is no longer active and is available for archival purposes only. Registration and login is disabled.

BitBlt to GAPI


BitBlt to GAPI

Postby Avatar » Aug 16, 2001 @ 8:32pm

I'm in the process of making a PPC adventure game. I got it to work using bitblt and was happy and carefree 'till I started reading messages about how much bitblt sucks and how slow it really is compared to GAPI calls ;)<br>So, I decided to convert the rendering proecedures to utilise GAPI. Unfortunately, I have yet to come across clear instructions on the usage of Game API calls. So here's what I have right now:<br>1. Background picture is loaded into memory and is BitBlt-ed using SRCCOPY to destination<br>2. Mask picture is loaded and is Bitblt-ed to destination using MERGEPAINT<br>3. Sprite picture is loaded and Bitblt-ed to destination using SRCAND<br><br>The result is a properly-displayed sprite on a background.<br><br>Now, how exactly do I do this in GAPI? I would appreciate if you could give specific example code, rather than saying, oh just using GAPI OpenSurface() call or whatnot.<br><br>Thanks in advance for your help!
Avatar
pm Member
 
Posts: 59
Joined: Aug 16, 2001 @ 8:32pm


Re: BitBlt to GAPI

Postby Dan East » Aug 16, 2001 @ 8:44pm

Well, I'm giving you exactly the type of answer you didn't want, but Digby or someone will come along and fill you in. ;) GAPI just gives you a raw buffer to the display. There are no GAPI functions to do any type of graphical manipulation at all. You will have to, pixel by pixel, perform the logic you desire.<br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: BitBlt to GAPI

Postby Avatar » Aug 16, 2001 @ 8:55pm

Yeah, I knew that much, but thanks. It's just that there are quite a few developers out there already experienced with making replacment routines for BitBlt logic operations in GAPI...and I was/am hoping to benifit from their wisdom :)
Avatar
pm Member
 
Posts: 59
Joined: Aug 16, 2001 @ 8:32pm


Re: BitBlt to GAPI

Postby Dan East » Aug 16, 2001 @ 9:08pm

Oh yeah, I forgot about some of the 3rd party libraries out there. Jacco's EasyCE is one of them:<br>http://userwww.econ.hvu.nl/~kouwenhs/tech.htm<br><br>However, that website is down, which is most likely a very temporary problem.<br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: BitBlt to GAPI

Postby Avatar » Aug 16, 2001 @ 9:30pm

The whole point of using GAPI is to get rid of some of the overhead that slows down the bitblt operations...so I don't think using EasyCE would be the ideal solution. Thanks, nonetheless...
Avatar
pm Member
 
Posts: 59
Joined: Aug 16, 2001 @ 8:32pm


Re: BitBlt to GAPI

Postby Digby » Aug 16, 2001 @ 9:39pm

GAPI will give you a pointer to the display memory buffer.  GAPI also has a function you can call to get the pixel format of this buffer.  If you know both of those things, you can read and write to this buffer and things will show up on the display.<br><br>What you're doing with those masking ROPs is basically performing a transparent blit.  That is, some pixels in the rect will make it to the display surface and some won't.  You currently determine this with a monochrome mask, and ask GDI to perform a logic operation using this mask during the blit.<br><br>With GAPI, you don't need any of this.  Since you are going to be copying data from your sprite buffer to the display buffer, all you need is a way to tell if a particular pixel in your sprite is transparent or opaque.  If it's opaque, you write the value to the appropriate address in the display buffer.  If it's transparent, you're done and can move to the next pixel in the sprite.<br><br>Marking pixels as transparent can be done in a number of ways.  You could use your monochrome mask that you have now.  You would traverse the mask along with traversing the sprite buffer. If the mask bit is set, then you copy the pixel from the sprite to the display buffer.  You can also use a colorkey scheme where you pick one color that isn't used by your sprite and set all of the transparent pixels in the sprite buffer to that color.  When you're traversing the sprite buffer and come across this color, you skip the pixel.  You could also dedicate a bit in the pixel (an alpha bit) that could flag the pixel as being transparent or opaque.<br><br>Hope that helps.  There's an article on GAPI programming on Microsoft's Pocket PC site, but I think it has errors in the code.  Recently there was a series of articles on GAPI on brighthand.com written by Larry Bank.  You might give that a look.  As always lots of us here have dealt with GAPI and can help you if you get stuck.<br>
Digby
pm Insider
 
Posts: 1011
Joined: Apr 29, 2001 @ 1:53pm


Re: BitBlt to GAPI

Postby Dan East » Aug 16, 2001 @ 10:20pm

Digby, it looks like he wants some source he can Copy / Paste and hit F7. <br><br>The source to EasyCE is available. I don't know how many blit type operations Jacco provides, but I'm sure what you're looking for can be found there. I doubt his library adds much overhead, and again, the source is available.<br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: BitBlt to GAPI

Postby Avatar » Aug 16, 2001 @ 11:25pm

Dan is right: I comprehend the theoretical routines quite well, but I was hoping someone had a piece of actual code handy and didn't mind sharing. Dibgy understood correctly, I am dealing with transperencies and overlays on backgrounds; in bitblt this is done through various ROP codes. I would like to know how to do this w/ GAPI...
Avatar
pm Member
 
Posts: 59
Joined: Aug 16, 2001 @ 8:32pm


Re: BitBlt to GAPI

Postby Digby » Aug 17, 2001 @ 12:29am

Yeah, I see that now.  Oh, well I'd be happy to oblige, but I'm going on vacation for about a week.  I'm sure someone could get him going. <br><br>Avatar, just disregard what I posted.  I won't delete the post as it might help someone else.<br><br>
Digby
pm Insider
 
Posts: 1011
Joined: Apr 29, 2001 @ 1:53pm


Re: BitBlt to GAPI

Postby Dan East » Aug 17, 2001 @ 12:55am

How are you currently loading your bitmaps / what format are they? Or are they resources embedded in the exe?<br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: BitBlt to GAPI

Postby Avatar » Aug 17, 2001 @ 1:17am

The original setup had the images embedded into the EXE, but I am currently moving away from that (ie loading from extenal BMPs). BTW, what's up with LoadImage() not working w/ external files?<br>The sprites are 256c bitmaps, whereas the masks are 16c.
Avatar
pm Member
 
Posts: 59
Joined: Aug 16, 2001 @ 8:32pm


Re: BitBlt to GAPI

Postby RICoder » Aug 17, 2001 @ 6:08pm

Avatar, I have written MUCHO code doing this, and would be willing to share.  Drop me an e-mail and I'll send it along.<br>Blt functions that I wrote support alpha and transparency too.<br>Its not optimized, but it works.
<iframe src="http://gamercard.xbox.com/RICoder.card" scrolling="no" frameBorder="0" height="140" width="204">RICoder</iframe>
User avatar
RICoder
FOX News Correspondent
 
Posts: 3948
Joined: Jul 10, 2001 @ 1:48pm
Location: the matrix has me


Re: BitBlt to GAPI

Postby Avatar » Aug 17, 2001 @ 10:53pm

Here's another, somewhat related question. I am rendering an object in a 3d program (eg 3d Studio Max, Bryce, etc.) and then would like to use it in my application. However, I run into the following problem. When a certain object is rendered, it's edges are made smoother through antialiasing techniques. This poses some problems, such as color bleeding when I try to use it inside my own program. For example, if I have an object of multiple colours rendered against a white background, on the final image there are some near-white pixels outlining the object that make the edges look smooth; however, if I apply a mask (through BitBlt or whatnot) and put it on a non-white background, these near-white pixels are readily visible and produce a visually unappealing effect. Do any of you have any ideas or recommendations as to what I should do to solve this problem? Maybe I should use something else instead of masking (ie alpha blending)?
Avatar
pm Member
 
Posts: 59
Joined: Aug 16, 2001 @ 8:32pm


Re: BitBlt to GAPI

Postby RICoder » Aug 18, 2001 @ 1:17pm

Yeah, that would be a good use for alpha.<br><br>Also, the deal with LoadImage is that the #define for L_FROM_FILE (or whatever it is...) is not in the header for CE.  I think its value is 0x0.  Also, when using the Emu with LoadImage you have to specify an explicit path (i.e. "c:\wince300\emu\..")  As opposed to other API where the emulator dir is the root dir in the emulator.
<iframe src="http://gamercard.xbox.com/RICoder.card" scrolling="no" frameBorder="0" height="140" width="204">RICoder</iframe>
User avatar
RICoder
FOX News Correspondent
 
Posts: 3948
Joined: Jul 10, 2001 @ 1:48pm
Location: the matrix has me


Re: BitBlt to GAPI

Postby Avatar » Aug 18, 2001 @ 10:03pm

Any chance of getting some code for alpha blending routines? I think Fredrik was working on something like that not that long ago...Nothing advanced, just making the outermost sprite pixels ~50% transparent...
Avatar
pm Member
 
Posts: 59
Joined: Aug 16, 2001 @ 8:32pm


Next

Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron