Re: Alphablending
- From: "Evenbit" <nbaker2328@xxxxxxxxxxx>
- Date: 29 Apr 2006 01:11:06 -0700
jukka@xxxxxxxxxxxx wrote:
FYI, added keys to change the blending factors.
1234567890 - source blending factor
QWERTYUIOPL - dest blending factor
www.liimatta.org/misc/alpha2.zip
COOL!!! That's some really neat "bit-bang'n da hardware" you've done
there! But I am having a little trouble reading the code. Is this
some new-fangled Ultra High Level Assembly (UHLA) someone has invented
to compete with Randy? How are you referencing the CPU registers?
What item of the syntax tells me which flags are being checked and for
what state?
alpha.cpp
---------
/*
*/
#define FUSIONCORE_IMPLEMENT_MAIN
#include <fusion/core/timer.hpp>
#include <fusion/core/surface.hpp>
#include <fusion/plugin/framebuffer.hpp>
#include <fusion/plugin/alphablend.hpp>
using namespace fusion::core;
// ------------------------------------------------------------
// myapp
// ------------------------------------------------------------
class myapp : public message, public framebuffer
{
protected:
timer* xtimer;
surface* screen;
surface* sprite;
public:
myapp()
{
xtimer = timer::create();
screen = surface::create("../screen.jpg",pixelformat::argb8888);
sprite = surface::create("../leaf.tga",pixelformat::argb8888);
open(400,300,"TestWindow");
show(true);
}
~myapp()
{
close();
screen->release();
sprite->release();
xtimer->release();
}
void draw()
{
blit(0,0,screen);
alphablend::setAlphaFunc(alphablend::srcalpha,alphablend::srcinvalpha);
alphablend::setAlphaConstant(255,255);
float time = xtimer->time();
int x0 = static_cast<int>(sin(time*1.0) * 60 + 80);
int x1 = static_cast<int>(sin(time*1.4) * 60 + 80);
int x2 = static_cast<int>(sin(time*1.6) * 60 + 80);
int x3 = static_cast<int>(sin(time*1.2) * 60 + 80);
int y0 = static_cast<int>(cos(time*1.0) * 60 + 80);
int y1 = static_cast<int>(cos(time*1.4) * 60 + 80);
int y2 = static_cast<int>(cos(time*1.6) * 60 + 80);
int y3 = static_cast<int>(cos(time*1.2) * 60 + 80);
alphablend::blend(x0,y0,buffer,sprite);
alphablend::blend(x1,y1,buffer,sprite);
alphablend::blend(x2,y2,buffer,sprite);
alphablend::blend(x3,y3,buffer,sprite);
alphablend::blend(x3+x0,y0,buffer,sprite);
alphablend::blend(x2+x1,y1,buffer,sprite);
alphablend::blend(x1+x2,y2,buffer,sprite);
alphablend::blend(x0+x3,y3,buffer,sprite);
pageflip();
}
void keyboard(int keycode, char charcode, bool press)
{
if ( keycode == message::keycode_esc && press )
mainbreak();
}
};
// ------------------------------------------------------------
// fusionmain()
// ------------------------------------------------------------
int fusionmain(int argc, char** argv)
{
myapp app;
return app.mainloop();
}
Nathan. ;-)
.
- Follow-Ups:
- Re: Alphablending
- From: jukka@xxxxxxxxxxxx
- Re: Alphablending
- References:
- Alphablending
- From: //\\\\o//\\\\annabee <Free
- Re: Alphablending
- From: hutch--
- Re: Alphablending
- From: //\\\\o//\\\\annabee <Free
- Re: Alphablending
- From: Chewy509
- Re: Alphablending
- From: Dunny
- Re: Alphablending
- From: //\\\\o//\\\\annabee <Free
- Re: Alphablending
- From: silk.odyssey
- Re: Alphablending
- From: //\\\\o//\\\\annabee <Free
- Re: Alphablending
- From: Dunny
- Re: Alphablending
- From: //\\\\o//\\\\annabee <Free
- Re: Alphablending
- From: Dunny
- Re: Alphablending
- From: //\\\\o//\\\\annabee <Free
- Re: Alphablending
- From: //\\\\o//\\\\annabee <Free
- Re: Alphablending
- From: jukka@xxxxxxxxxxxx
- Re: Alphablending
- From: jukka@xxxxxxxxxxxx
- Re: Alphablending
- From: //\\\\o//\\\\annabee <Free
- Re: Alphablending
- From: jukka@xxxxxxxxxxxx
- Re: Alphablending
- From: jukka@xxxxxxxxxxxx
- Re: Alphablending
- From: //\\\\o//\\\\annabee <Free
- Re: Alphablending
- From: jukka@xxxxxxxxxxxx
- Alphablending
- Prev by Date: Re: Doubts about Segmentation
- Next by Date: Re: Alphablending
- Previous by thread: Re: Alphablending
- Next by thread: Re: Alphablending
- Index(es):