From 38b9281ecb4465aaf3e30c55d104cea0a2cdfab9 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 14 May 2014 02:02:51 +0100 Subject: [PATCH] tests with circles --- examples/demo.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/examples/demo.cpp b/examples/demo.cpp index 546b868..dec37f7 100644 --- a/examples/demo.cpp +++ b/examples/demo.cpp @@ -21,11 +21,40 @@ #include "Window.hpp" #include "Widget.hpp" +#include + // ------------------------------------------------------ // use namespace using namespace DGL; +// taken from http://slabode.exofire.net/circle_draw.shtml +template +void drawCircle(const Point& 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(Point(150, 200), 50, 300, false); + + glLineWidth(2.0f); + glColor3f(0.176f/4, 0.212f/4, 0.235f/4); + drawCircle(Point(150, 200), 50, 300, true); } void onReshape(int width, int height) override