EasyGL Tutorial - Transparency
and Animation
#include <iostream.h>
#include "easygl.h"
int x=0, int y=0, xdir=5, ydir=25;
void EasyRender()
{
clearGraph();
//Notice for transparency you draw the back objects
befor the near ones
//And inorder to be see through the Alpha(last)
value must be less than 1.0
print(185, 210, "Hello World!",1.0,1.0,1.0,1.0);
color(0.0, 0.2, 0.5, 0.8);
square(50, 50, 350, 350);
square(200, 200, 500, 500, 0.0, 0.5, 1.0, 0.6);
//When animating we don't need any loops because
EasyRender is in a loop it
//self. it's called about 60 times(frames) a second(given
the Video Card)
circle(x, y, 10);
x+= xdir; //Make
the circle move!
y+= ydir;
//This will cause the circle to bounce off the edges
of the screen!
if(x > 1004) //Screen
width - 20(r*2)
xdir = -25;
else if(x < 20)
xdir = 25;
if(y > 748) //Screen
height - 20
ydir = -25;
else if(y < 20)
ydir = 25;
update();
}
int main()
{
initEasyGL();
return 1;
}