Browse Source

Use new circle class in demo code

pull/1/head
falkTX 11 years ago
parent
commit
d5e4107d1a
2 changed files with 7 additions and 30 deletions
  1. +1
    -1
      dpf
  2. +6
    -29
      examples/demo.cpp

+ 1
- 1
dpf

@@ -1 +1 @@
Subproject commit 4c0161dab66c05d20d4629222c89e5a662fc09bd
Subproject commit 9e618371d7ac1f3d6984b0b96102d3bfe56c68d5

+ 6
- 29
examples/demo.cpp View File

@@ -28,33 +28,6 @@


using namespace DGL; using namespace DGL;


// taken from http://slabode.exofire.net/circle_draw.shtml
template<typename T>
void drawCircle(const Point<T>& fPos, const T& fSize, const int fNumSegments, const bool isOutline)
{
// precalculate the sine and cosine
const float fTheta = 2.0f * 3.1415926f / float(fNumSegments);
const float fCos = std::cos(fTheta);
const float fSin = std::sin(fTheta);

// paint
float t, x = fSize, y = 0;

glBegin(isOutline ? GL_LINE_LOOP : GL_POLYGON);

for (int i=0; i<fNumSegments; ++i)
{
// output vertex
glVertex2f(x + fPos.getX(), y + fPos.getY());

// apply the rotation matrix
t = x;
x = fCos * x - fSin * y;
y = fSin * t + fCos * y;
}

glEnd();
}
// ------------------------------------------------------ // ------------------------------------------------------
// our widget // our widget


@@ -96,11 +69,11 @@ protected:
tri.drawOutline(); tri.drawOutline();


glColor3f(0.235f, 0.271f, 0.294f); glColor3f(0.235f, 0.271f, 0.294f);
drawCircle<int>(Point<int>(150, 200), 50, 300, false);
cir.draw();


glLineWidth(2.0f); glLineWidth(2.0f);
glColor3f(0.176f/4, 0.212f/4, 0.235f/4); glColor3f(0.176f/4, 0.212f/4, 0.235f/4);
drawCircle<int>(Point<int>(150, 200), 50, 300, true);
cir.drawOutline();
} }


void onReshape(int width, int height) override void onReshape(int width, int height) override
@@ -114,6 +87,9 @@ protected:
// center triangle // center triangle
tri = Triangle<int>(width*0.5, height*0.1, width*0.1, height*0.9, width*0.9, height*0.9); tri = Triangle<int>(width*0.5, height*0.1, width*0.1, height*0.9, width*0.9, height*0.9);


// circle
cir = Circle<int>(width/2, height*2/3, height/6, 300);

// make widget same size as window // make widget same size as window
setSize(width, height); setSize(width, height);


@@ -124,6 +100,7 @@ protected:
private: private:
Rectangle<int> bgFull, bgSmall; Rectangle<int> bgFull, bgSmall;
Triangle<int> tri; Triangle<int> tri;
Circle<int> cir;
}; };


// ------------------------------------------------------ // ------------------------------------------------------


Loading…
Cancel
Save