Pen test reviewed
This commit is contained in:
parent
f3d98e483a
commit
4de39b5a2f
@ -5,7 +5,7 @@
|
|||||||
// James Turk (jpt2433@rit.edu)
|
// James Turk (jpt2433@rit.edu)
|
||||||
//
|
//
|
||||||
// Version:
|
// Version:
|
||||||
// $Id: Pen_test.cpp,v 1.2 2005/07/17 06:19:18 cozman Exp $
|
// $Id: Pen_test.cpp,v 1.3 2005/07/19 20:55:40 cozman Exp $
|
||||||
|
|
||||||
#include "photon.hpp"
|
#include "photon.hpp"
|
||||||
using namespace photon;
|
using namespace photon;
|
||||||
@ -20,11 +20,9 @@ public:
|
|||||||
app(AppCore::getInstance()),
|
app(AppCore::getInstance()),
|
||||||
video(video::VideoCore::getInstance())
|
video(video::VideoCore::getInstance())
|
||||||
{
|
{
|
||||||
LogSinkPtr csp( new ConsoleSink("console") );
|
|
||||||
log.addSink(csp);
|
|
||||||
|
|
||||||
video.setOrthoView(800,600);
|
video.setOrthoView(800,600);
|
||||||
|
|
||||||
|
// initialize three pens, red, blue and green
|
||||||
r.setColor(255, 0, 0);
|
r.setColor(255, 0, 0);
|
||||||
g.setColor(0, 255, 0);
|
g.setColor(0, 255, 0);
|
||||||
b.setColor(0, 0, 255);
|
b.setColor(0, 0, 255);
|
||||||
@ -32,9 +30,8 @@ public:
|
|||||||
|
|
||||||
void update()
|
void update()
|
||||||
{
|
{
|
||||||
|
// used to measure FPS and display it in the title bar
|
||||||
static double t=0;
|
static double t=0;
|
||||||
static const math::Point2 center(400, 300);
|
|
||||||
|
|
||||||
if(app.getTime() - t > 1.0)
|
if(app.getTime() - t > 1.0)
|
||||||
{
|
{
|
||||||
app.setTitle("FPS: " +
|
app.setTitle("FPS: " +
|
||||||
@ -42,38 +39,40 @@ public:
|
|||||||
t = app.getTime();
|
t = app.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const math::Point2 center(400, 300); // used for clock
|
||||||
|
|
||||||
video.clear();
|
video.clear();
|
||||||
|
|
||||||
unsigned int i,j; //used throughout demo
|
unsigned int i,j; //used throughout demo
|
||||||
|
|
||||||
// points
|
// draw points in a traveling sine curve
|
||||||
for(i=0; i < 400; ++i)
|
g.fillRectangle(math::Rect(math::Point2(0,0), 800, 100));
|
||||||
|
for(i=0; i < 800; i += 5)
|
||||||
{
|
{
|
||||||
r.drawPoint(math::Point2(i, 2*i));
|
scalar ang = math::degToRad(i+100*app.getTime());
|
||||||
g.drawPoint(math::Point2(i, 3*i));
|
r.drawPoint(math::Point2(i, 50+50*std::sin(ang) ));
|
||||||
b.drawPoint(math::Point2(i, 4*i));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// lines
|
// draw lines in a fancy pattern
|
||||||
for(i=100; i <= 200; i += 10)
|
for(i=100; i <= 200; i += 20)
|
||||||
{
|
{
|
||||||
for(j=100; j <= 200; j += 10)
|
for(j=100; j <= 200; j += 20)
|
||||||
{
|
{
|
||||||
g.drawLine(math::Point2(100,i), math::Point2(j, 200));
|
g.drawLine(math::Point2(100,i), math::Point2(j, 200));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// circles
|
// draw circles to create a clock
|
||||||
b.fillCircle(math::Circle(center, 60));
|
b.fillCircle(math::Circle(center, 60));
|
||||||
g.drawCircle(math::Circle(center, 60));
|
g.drawCircle(math::Circle(center, 60));
|
||||||
g.drawCircle(math::Circle(center, 50));
|
g.drawCircle(math::Circle(center, 50));
|
||||||
|
|
||||||
// vectors
|
// draw vector as clock hand
|
||||||
math::Vector2 clockHand;
|
math::Vector2 clockHand;
|
||||||
clockHand.resolveDeg(50, 20*app.getTime());
|
clockHand.resolveDeg(50, 20*app.getTime());
|
||||||
r.drawVector(center, clockHand);
|
r.drawVector(center, clockHand);
|
||||||
|
|
||||||
// rectangles
|
// draw rectangles to show Rect::calcIntersection in action
|
||||||
math::Rect rect1(math::Point2(500, 300), 200, 100);
|
math::Rect rect1(math::Point2(500, 300), 200, 100);
|
||||||
math::Rect rect2(math::Point2(550, 375), 100, 200);
|
math::Rect rect2(math::Point2(550, 375), 100, 200);
|
||||||
r.drawRectangle(rect1);
|
r.drawRectangle(rect1);
|
||||||
@ -84,12 +83,11 @@ public:
|
|||||||
private:
|
private:
|
||||||
video::Pen r,g,b;
|
video::Pen r,g,b;
|
||||||
|
|
||||||
|
|
||||||
Log log;
|
|
||||||
AppCore& app;
|
AppCore& app;
|
||||||
video::VideoCore& video;
|
video::VideoCore& video;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// standard application, creates window, registers task and runs
|
||||||
class PenTest : public Application
|
class PenTest : public Application
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user