summaryrefslogtreecommitdiff
path: root/src/graphics/OpenGLDrawMethods.inl
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-05-17 16:44:25 (GMT)
committer jacob1 <jfu614@gmail.com>2013-05-17 16:44:25 (GMT)
commit981f6984c2c0f87d54a9c90f4518c69c9ef02ae0 (patch)
tree757bd699a23c1fad61e60700265a25feb1a3042c /src/graphics/OpenGLDrawMethods.inl
parentcbd402d8cb6aa699ffde83a1b5b3c2f4fc51baaf (diff)
parent77bf649fb4482c86ac1fd9b3233f062b53226007 (diff)
downloadpowder-981f6984c2c0f87d54a9c90f4518c69c9ef02ae0.zip
powder-981f6984c2c0f87d54a9c90f4518c69c9ef02ae0.tar.gz
Merge branch 'HEAD' of git@github.com:FacialTurd/The-Powder-Toy.git
Diffstat (limited to 'src/graphics/OpenGLDrawMethods.inl')
-rw-r--r--src/graphics/OpenGLDrawMethods.inl56
1 files changed, 55 insertions, 1 deletions
diff --git a/src/graphics/OpenGLDrawMethods.inl b/src/graphics/OpenGLDrawMethods.inl
index bfc338a..52d09da 100644
--- a/src/graphics/OpenGLDrawMethods.inl
+++ b/src/graphics/OpenGLDrawMethods.inl
@@ -1,4 +1,5 @@
-#include "../data/font.h"
+#include "../data/font.h"
+#include <math.h>
int PIXELMETHODS_CLASS::drawtext_outline(int x, int y, const char *s, int r, int g, int b, int a)
{
@@ -314,6 +315,59 @@ void PIXELMETHODS_CLASS::fillrect(int x, int y, int width, int height, int r, in
glEnd();
}
+void PIXELMETHODS_CLASS::drawcircle(int x, int y, int rx, int ry, int r, int g, int b, int a)
+{
+ int yTop = ry, yBottom, i, j;
+ if (!rx)
+ {
+ for (j = -ry; j <= ry; j++)
+ blendpixel(x, y+j, r, g, b, a);
+ return;
+ }
+ for (i = 0; i <= rx; i++) {
+ yBottom = yTop;
+ while (pow(i-rx,2.0)*pow(ry,2.0) + pow(yTop-ry,2.0)*pow(rx,2.0) <= pow(rx,2.0)*pow(ry,2.0))
+ yTop++;
+ if (yBottom != yTop)
+ yTop--;
+ for (int j = yBottom; j <= yTop; j++)
+ {
+ blendpixel(x+i-rx, y+j-ry, r, g, b, a);
+ if (i != rx)
+ blendpixel(x-i+rx, y+j-ry, r, g, b, a);
+ if (j != ry)
+ {
+ blendpixel(x+i-rx, y-j+ry, r, g, b, a);
+ if (i != rx)
+ blendpixel(x-i+rx, y-j+ry, r, g, b, a);
+ }
+ }
+ }
+}
+
+void PIXELMETHODS_CLASS::fillcircle(int x, int y, int rx, int ry, int r, int g, int b, int a)
+{
+ int yTop = ry+1, yBottom, i, j;
+ if (!rx)
+ {
+ for (j = -ry; j <= ry; j++)
+ blendpixel(x, y+j, r, g, b, a);
+ return;
+ }
+ for (i = 0; i <= rx; i++)
+ {
+ while (pow(i-rx,2.0)*pow(ry,2.0) + pow(yTop-ry,2.0)*pow(rx,2.0) <= pow(rx,2.0)*pow(ry,2.0))
+ yTop++;
+ yBottom = 2*ry - yTop;
+ for (int j = yBottom+1; j < yTop; j++)
+ {
+ blendpixel(x+i-rx, y+j-ry, r, g, b, a);
+ if (i != rx)
+ blendpixel(x-i+rx, y+j-ry, r, g, b, a);
+ }
+ }
+}
+
void PIXELMETHODS_CLASS::gradientrect(int x, int y, int width, int height, int r, int g, int b, int a, int r2, int g2, int b2, int a2)
{
glBegin(GL_QUADS);