From c00cd54ca5ed959cbccff7aa7261fb5025d1832c Mon Sep 17 00:00:00 2001 From: pixel Date: Wed, 26 Mar 2003 14:07:43 +0000 Subject: bleh --- lib/glshape.cc | 187 +++++---------------------------------------------------- 1 file changed, 14 insertions(+), 173 deletions(-) (limited to 'lib/glshape.cc') diff --git a/lib/glshape.cc b/lib/glshape.cc index 6c314fb..7b93dfb 100644 --- a/lib/glshape.cc +++ b/lib/glshape.cc @@ -4,11 +4,11 @@ #include "gltexture.h" #include "glfont.h" -#define ENTER bool was2d = in2D(true) -#define ENTERT bool was2d = in2D(false) -#define LEAVE out2D(was2d) +#define ENTER bool was2d = Enter(true) +#define ENTERT bool was2d = Enter(false) +#define LEAVE Leave(was2d) -void mogltk::shape::box(int x1, int y1, int x2, int y2, ColorP c) { +void mogltk::glshape::box(int x1, int y1, int x2, int y2, glColorP c) { ENTER; c.Bind(); @@ -22,7 +22,7 @@ void mogltk::shape::box(int x1, int y1, int x2, int y2, ColorP c) { LEAVE; } -void mogltk::shape::box(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4) { +void mogltk::glshape::box(int x1, int y1, int x2, int y2, glColorP c1, glColorP c2, glColorP c3, glColorP c4) { ENTER; glBegin(GL_TRIANGLE_STRIP); @@ -35,85 +35,7 @@ void mogltk::shape::box(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, Co LEAVE; } -void mogltk::shape::hline(int x1, int x2, int y, ColorP c) { - box(x1, y, x2, y, c); -} - -void mogltk::shape::hline3d(int x1, int x2, int y, ColorP shade1, ColorP shade2, bool bevel) { - ENTER; - - if (!bevel) { - hline(x1, x2, y, shade2); - hline(x1, x2, y + 1, shade1); - } else { - hline(x1, x2, y, shade1); - hline(x1, x2, y + 1, shade2); - } - - LEAVE; -} - -void mogltk::shape::vline(int x, int y1, int y2, ColorP c) { - box(x, y1, x, y2, c); -} - -void mogltk::shape::vline3d(int x, int y1, int y2, ColorP shade1, ColorP shade2, bool bevel) { - ENTER; - - if (!bevel) { - vline(x, y1, y2, shade2); - vline(x + 1, y1, y2, shade1); - } else { - vline(x, y1, y2, shade1); - vline(x + 1, y1, y2, shade2); - } - - LEAVE; -} - -void mogltk::shape::hline(int x1, int x2, int y, ColorP c1, ColorP c2) { - box(x1, y, x2, y, c1, c2, c1, c2); -} - -void mogltk::shape::vline(int x, int y1, int y2, ColorP c1, ColorP c2) { - box(x, y1, x, y2, c1, c1, c2, c2); -} - -void mogltk::shape::pixel(int x, int y, ColorP c) { - box(x, y, x, y, c); -} - -void mogltk::shape::obox(int x1, int y1, int x2, int y2, ColorP c) { - ENTER; - - hline(x1, x2, y1, c); - hline(x1, x2, y2, c); - vline(x1, y1, y2, c); - vline(x2, y1, y2, c); - - LEAVE; -} - -void mogltk::shape::obox(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4) { - ENTER; - - hline(x1, x2, y1, c1, c2); - hline(x1, x2, y2, c3, c4); - vline(x1, y1, y2, c1, c3); - vline(x2, y1, y2, c2, c4); - - LEAVE; -} - -void mogltk::shape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, int tx, int ty, double f, ColorP c) { - tbox(t, x1, y1, x2, y2, tx, ty, tx + (int) ((x2 - x1) * f), ty + (int) ((y2 - y1) * f), c); -} - -void mogltk::shape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4, int tx, int ty, double f) { - tbox(t, x1, y1, x2, y2, c1, c2, c3, c4, tx, ty, tx + (int) ((x2 - x1) * f), ty + (int) ((y2 - y1) * f)); -} - -void mogltk::shape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, int tx1, int ty1, int tx2, int ty2, ColorP c) { +void mogltk::glshape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, int tx1, int ty1, int tx2, int ty2, glColorP c) { ENTERT; c.Bind(); @@ -128,7 +50,7 @@ void mogltk::shape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, in LEAVE; } -void mogltk::shape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4, int tx1, int ty1, int tx2, int ty2) { +void mogltk::glshape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, glColorP c1, glColorP c2, glColorP c3, glColorP c4, int tx1, int ty1, int tx2, int ty2) { ENTERT; t->Bind(); @@ -142,7 +64,7 @@ void mogltk::shape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, Co LEAVE; } -void mogltk::shape::box3d(int x1, int y1, int x2, int y2, ColorP face, ColorP shade1, ColorP shade2, int depth, bool bevel) { +void mogltk::glshape::box3d(int x1, int y1, int x2, int y2, glColorP face, glColorP shade1, glColorP shade2, int depth, bool bevel) { ENTER; if (!bevel) { @@ -182,92 +104,7 @@ void mogltk::shape::box3d(int x1, int y1, int x2, int y2, ColorP face, ColorP sh LEAVE; } -void mogltk::shape::obox3d(int x1, int y1, int x2, int y2, ColorP shade1, ColorP shade2, bool bevel) { - ENTER; - - if (!bevel) { - obox(x1 + 1, y1 + 1, x2, y2, shade1); - obox(x1, y1, x2 - 1, y2 - 1, shade2); - } else { - obox(x1, y1, x2 - 1, y2 - 1, shade1); - obox(x1 + 1, y1 + 1, x2, y2, shade2); - } - - LEAVE; -} - -void mogltk::shape::window(int x1, int y1, int x2, int y2, const String & title, - ColorP titlecolor, ColorP titlebackcolor, - ColorP front, ColorP shade1, ColorP shade2) { - ENTER; - - box3d(x1, y1, x2, y2, front, shade1, shade2); - hline3d(x1 + 2, x2 - 2, y1 + 19, shade1, shade2, 1); - box(x1 + 2, y1 + 2, x2 - 2, y1 + 18, titlebackcolor); - text((x1 + x2) / 2, y1 + 2, title, titlecolor, CENTER); - - LEAVE; -} - -void mogltk::shape::text(int x, int y, const String & text, ColorP textcolor, align_t align) { - int tsize = SystemFont->singletextsize(text); - switch (align) { - case LEFT: - SystemFont->putcursor(x, y); - break; - case CENTER: - SystemFont->putcursor(x - (tsize / 2), y); - break; - case RIGHT: - SystemFont->putcursor(x - tsize, y); - break; - } - SystemFont->setcolor(textcolor); - SystemFont->setshadow(0); - SystemFont->printf(text); -} - -void mogltk::shape::text3d(int x, int y, const String & atext, ColorP textcolor, - ColorP shade1, ColorP shade2, - align_t align, bool bevel) { - ENTER; - - SystemFont->setwspace(1); - if (!bevel) { - text(x - 1, y - 1, atext, shade2, align); - text(x + 1, y + 1, atext, shade1, align); - } else { - text(x - 1, y - 1, atext, shade1, align); - text(x + 1, y + 1, atext, shade2, align); - } - text(x, y, atext, textcolor, align); - SystemFont->setwspace(0); - - LEAVE; -} - -void mogltk::shape::button(int x1, int y1, int x2, int y2, - const String & atext, bool bevel, - ColorP front, ColorP shade1, ColorP shade2, - ColorP round, ColorP textcolor, - ColorP tshade1, ColorP tshade2) { - ENTER; - - box3d(x1, y1, x2, y2, front, shade1, shade2, 2, bevel); - hline(x1, x2, y1 - 1, round); - hline(x1, x2, y2 + 1, round); - vline(x1 - 1, y1, y2, round); - vline(x2 + 1, y1, y2, round); - pixel(x1, y1, round); - pixel(x1, y2, round); - pixel(x2, y1, round); - pixel(x2, y2, round); - text3d((x1 + x2) / 2, (y1 + y2) / 2 - 8, atext, textcolor, tshade1, tshade2, CENTER, bevel); - - LEAVE; -} - -bool mogltk::shape::in2D(bool unbind) { +bool mogltk::glshape::Enter(bool unbind) { bool was2D = mogltk::glbase::is2D(); if (!was2D) @@ -278,7 +115,11 @@ bool mogltk::shape::in2D(bool unbind) { return was2D; } -void mogltk::shape::out2D(bool was2D) { +bool mogltk::glshape::Enter() { + return Enter(true); +} + +void mogltk::glshape::Leave(bool was2D) { if (!was2D) mogltk::glbase::Leave2DMode(); } -- cgit v1.2.3