PocketMatrix forums

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

alpha blending

PringlesOriginal · 18 Aug 2004, 00:59 UTC
how can i do alpha blending with pocketfrog(0.8)? I want to use the .raw files for masking....

anybody got any suggestion?
Give me an example. Blend what with what. You can blend any percentage of a sprite with it's background or with a color etc
Code:
display->SetBlending(140);//140 of 255
//draw something here
display->SetBlending(0xFF);//no blend
I've got code for frog 0.7 that uses two surfaces per blit... one surface as a per-pixel alpha source, the other for the image source.

You'd have to save your alpha layer as a separate image.

Works well, but requires modifying several frog files - which I still haven't done for the new version.
fast_rx wrote:I've got code for frog 0.7 that uses two surfaces per blit... one surface as a per-pixel alpha source, the other for the image source.

You'd have to save your alpha layer as a separate image.

Works well, but requires modifying several frog files - which I still haven't done for the new version.


Would you please share this one since I'm also want to use alpha blending in my current game? Just archive it and upload somewhere, no need for detailed sollution. Anyway, I'm still on PF7 :).

PS: Anyone to tell anything about my recent game "Turbo Reaction"? (http://more-games.tk) It's not and advert, just want to know your oppinion :-).
Made of PocketFrog 7.0, spent a dirty lot of time :)
I'll zip up the modified files and post them tonight.

Maybe Thierry or somebody can look at it and see if I did anything stupid.
Maybe I can integrate them in the next release?
Do you feel that using a whole 16 byte per pixel surface as an alpha mask is acceptable? My code only uses the green value as the alpha...

It seemed the easiest to get what I wanted at the time.

I just came across an article at codeproject that is using the ARGB formatted images to have full alpha ( http://www.codeproject.com/useritems/Tr ... onDemo.asp ).
That would be nice to have, but since all of pocketfrog is 565 format surfaces, I assume it would be a lot of coding to support something like that.
I want to add multiple formats to surfaces. At this point I am toying between adding them to PocketHAL or only to PocketFrog. I will probably do so only for PF first.

One issue is that GetPixels() won't return a Pixel* anymore, but a void*. There is no other way if I am to support multiple pixel formats. Probably not an issue unless you use direct access anyways.
Ok... Since I needed to make the move to PF0.8 anyway, I went ahead and made the modifications. Here's a zip with the modified files, plus a demo app of how it can be used.

The one thing I probably could have done was to figure out how to write this in the algo2d.h file instead of repeating a lot of code. Also, there is just an empty function for the cases involving GenericRaster2D, since I don't know exactly what you'd do with that.

I also notice that the 'assert()' parts are missing. I assume they aren't needed and removed them from the additions as well.

Note: The img source and alpha source MUST be the same width, or you'll get strange things.

I also have written Additive and Subtractive blit functions as well that are good for explosions and things - and you don't have the slowdown of using a custom shader. I can also 'donate' these as well, but I thought I'd wait and hear what comments are made - especially with reguards to putting the stuff in algo2d.h


Maybe my name will be forever remembered in the pocketfrog source code like Frank Z's... :D
Attachments:
AlphaMods.zip (64 KB)
Yes, it's my legacy... some comments in some source code... Oh yeah, and my children :) PocketFrog and my kids. It's all that'll remain once I'm dead. :)
Re: Turbo Reaction, clickgamer does not have a 'try' button just the buy one ? Also the link to your product just links to click gamer not the product page.
Conan wrote:Re: Turbo Reaction, clickgamer does not have a 'try' button just the buy one ? Also the link to your product just links to click gamer not the product page.


Oops, I forgot i've just removed the trial :). Use this link:
http://www.pocketgear.com/software_detail.asp?id=14781

And thank you for discovering a broken link!
fast_rx wrote:Ok... Since I needed to make the move to PF0.8 anyway, I went ahead and made the modifications.


Ooops :). But I am not moving to PF8 yet :). Is it hard to make it back?
Conan · 19 Aug 2004, 13:06 UTC — Feedback on Turbo Reaction
1. The red text is vey hard to read on my Dell Axim.
2. Fatal Application Error on exiting the game 2 times
3. The big icon is just 4 corners with not much else?
Plays nice & fast. Have not tried with sound/music yet as I'm at work.
jaguard wrote:
Ooops :). But I am not moving to PF8 yet :). Is it hard to make it back?


Not too hard... You could do it yourself in 15 minutes probably. Just look for the code that starts with a "//J Elmore" comment.

The only change you should have to do is revert back to the old surface variable types. i.e. "PHAL::Surface&" goes back to "GraphicBuffer&"
Conan · 20 Aug 2004, 09:05 UTC — what does this give over the existing blending functions
Can someone explain what this new alpha blending blending method does that the existing one does not? (I'm being thick obviously)
It's per pixel instead of per image...

There is an ARM demo compiled/included with that zip file.
understood. Have looked at the demo. I will definitely add this feature to my PF for my next game (which is an isometric one)
Thierry,

Have you had a look at the modifications? I was wondering if the approach I took was good or bad. I'd like to see these stay a part of PF, but I also want it to be done correctly.

The reason is that I'd also like to submit an additive and subtractive blit as well, but I'm holding off until I know if the other stuff should have been done differently.

Jason
fast_rx, I haven't look at your code yet. I am currently busy preparing the next release of PocketHAL. I should be able to look at it this week though.

Feel free to submit your code anyways. I will use it as-is or adapt it depending on what I find. It can still be useful to others until it is "officialy" integrated.