diff options
-rw-r--r-- | include/Makefile.am | 2 | ||||
-rw-r--r-- | include/glcolor.h | 18 | ||||
-rw-r--r-- | include/glfont.h | 14 | ||||
-rw-r--r-- | include/glshape.h | 26 | ||||
-rw-r--r-- | include/sprite.h | 4 | ||||
-rw-r--r-- | lib/Makefile.am | 4 | ||||
-rw-r--r-- | lib/glcolor.cc | 13 | ||||
-rw-r--r-- | lib/glfont.cc | 8 | ||||
-rw-r--r-- | lib/glshape.cc | 24 | ||||
-rw-r--r-- | lib/sprite.cc | 2 |
10 files changed, 73 insertions, 42 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index 0aa8482..283156d 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,4 +1,4 @@ pkginclude_HEADERS = \ -engine.h glbase.h glfont.h gltexture.h glshape.h glwidgets.h sprite.h +engine.h glbase.h glcolor.h glfont.h gltexture.h glshape.h glwidgets.h sprite.h noinst_HEADERS = gettext.h diff --git a/include/glcolor.h b/include/glcolor.h new file mode 100644 index 0000000..8296451 --- /dev/null +++ b/include/glcolor.h @@ -0,0 +1,18 @@ +#ifndef __GLCOLOR_H__ +#define __GLCOLOR_H__ + +#include <Exceptions.h> +#include <Color.h> + +namespace mogltk { + class ColorP : public Base { + public: + ColorP(const Color &); + ColorP(Uint8, Uint8, Uint8, Uint8); + void Bind(); + private: + Color c; + }; +}; + +#endif diff --git a/include/glfont.h b/include/glfont.h index 4ace74a..991024e 100644 --- a/include/glfont.h +++ b/include/glfont.h @@ -4,24 +4,24 @@ #include <SDL.h> #include <stdarg.h> #include <BString.h> -#include <Color.h> #include <Handle.h> -#include "gltexture.h" +#include <gltexture.h> +#include <glcolor.h> namespace mogltk { class font : public Base { public: font(Handle *); virtual ~font(); - void drawentry(Uint16, int, int, Color = Color(255, 255, 255, 255)); + void drawentry(Uint16, int, int, ColorP = WHITE); void putcursor(int, int); - void putentry(Uint16, Color = Color(255, 255, 255, 255)); - void putchar(char, Color = Color(255, 255, 255, 255)); + void putentry(Uint16, ColorP = WHITE); + void putchar(char, ColorP = WHITE); void newline(void); int printf(const ugly_string &, ...); int printf(const char *, ...); int printf(const ugly_string &, va_list); - void setcolor(Color); + void setcolor(ColorP); void setshadow(int); int getchar(char) const; int singletextsize(const String &) const; @@ -34,7 +34,7 @@ namespace mogltk { Uint16 * corresp; void Bind(int); int cx, cy, ox; - Color textcolor; + ColorP textcolor; int shadow; }; extern font * SystemFont; diff --git a/include/glshape.h b/include/glshape.h index cd9fef0..a0c7bf2 100644 --- a/include/glshape.h +++ b/include/glshape.h @@ -2,24 +2,24 @@ #define __GLSHAPE_H__ #include <Exceptions.h> -#include <Color.h> +#include <glcolor.h> #include <gltexture.h> namespace mogltk { class shape : public Base { public: - static void box(int x1, int y1, int x2, int y2, Color = WHITE); - static void box(int x1, int y1, int x2, int y2, Color, Color, Color, Color); - static void obox(int x1, int y1, int x2, int y2, Color = WHITE); - static void obox(int x1, int y1, int x2, int y2, Color, Color, Color, Color); - static void tbox(texture *, int x1, int y1, int x2, int y2, int tx = 0, int ty = 0, double = 1.0, Color = WHITE); - static void tbox(texture *, int x1, int y1, int x2, int y2, int tx1, int ty1, int tx2, int ty2, Color = WHITE); - static void tbox(texture *, int x1, int y1, int x2, int y2, Color, Color, Color, Color, int tx = 0, int ty = 0, double = 1.0); - static void tbox(texture *, int x1, int y1, int x2, int y2, Color, Color, Color, Color, int tx1, int ty1, int tx2, int ty2); - static void hline(int x1, int x2, int y, Color = WHITE); - static void hline(int x1, int x2, int y, Color, Color); - static void vline(int x, int y1, int y2, Color = WHITE); - static void vline(int x, int y1, int y2, Color, Color); + static void box(int x1, int y1, int x2, int y2, ColorP = WHITE); + static void box(int x1, int y1, int x2, int y2, ColorP, ColorP, ColorP, ColorP); + static void obox(int x1, int y1, int x2, int y2, ColorP = WHITE); + static void obox(int x1, int y1, int x2, int y2, ColorP, ColorP, ColorP, ColorP); + static void tbox(texture *, int x1, int y1, int x2, int y2, int tx = 0, int ty = 0, double = 1.0, ColorP = WHITE); + static void tbox(texture *, int x1, int y1, int x2, int y2, int tx1, int ty1, int tx2, int ty2, ColorP = WHITE); + static void tbox(texture *, int x1, int y1, int x2, int y2, ColorP, ColorP, ColorP, ColorP, int tx = 0, int ty = 0, double = 1.0); + static void tbox(texture *, int x1, int y1, int x2, int y2, ColorP, ColorP, ColorP, ColorP, int tx1, int ty1, int tx2, int ty2); + static void hline(int x1, int x2, int y, ColorP = WHITE); + static void hline(int x1, int x2, int y, ColorP, ColorP); + static void vline(int x, int y1, int y2, ColorP = WHITE); + static void vline(int x, int y1, int y2, ColorP, ColorP); private: static bool in2D(bool); static void out2D(bool); diff --git a/include/sprite.h b/include/sprite.h index fbc50ff..16565d0 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -4,7 +4,7 @@ #include <vector> #include <Exceptions.h> #include <Handle.h> -#include <Color.h> +#include <glcolor.h> #include "gltexture.h" namespace mogltk { @@ -13,7 +13,7 @@ namespace mogltk { Sprite(Handle *, int, int); Sprite(Uint8 *, int, int); virtual ~Sprite(); - void draw(int, int, Color = WHITE); + void draw(int, int, ColorP = WHITE); private: class TexList : public Base { public: diff --git a/lib/Makefile.am b/lib/Makefile.am index 269a346..a13b4c3 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -5,6 +5,6 @@ LIBS = @SDL_LIBS@ @BALTISOT_LIBS@ INCLUDES = -I.. -I../include -I$(includedir) lib_LTLIBRARIES = libmogltk.la -libmogltk_la_SOURCES = engine.cc glbase.cc glfont.cc gltexture.cc glshape.cc \ -glwidgets.cc sprite.cc +libmogltk_la_SOURCES = engine.cc glbase.cc glcolor.cc glfont.cc gltexture.cc \ +glshape.cc glwidgets.cc sprite.cc diff --git a/lib/glcolor.cc b/lib/glcolor.cc new file mode 100644 index 0000000..23ade75 --- /dev/null +++ b/lib/glcolor.cc @@ -0,0 +1,13 @@ +#include <SDL_opengl.h> +#include "glcolor.h" + +mogltk::ColorP::ColorP(const Color & ac) : c(ac) { +} + +mogltk::ColorP::ColorP(Uint8 ar, Uint8 ag, Uint8 ab, Uint8 aa) : c(ar, ag, ab, aa) { +} + +void mogltk::ColorP::Bind() { + glColor4d((double) c.R / 255, (double) c.G / 255, (double) c.B / 255, (double) c.A / 255); +} + diff --git a/lib/glfont.cc b/lib/glfont.cc index 5cb1646..d8dbb5b 100644 --- a/lib/glfont.cc +++ b/lib/glfont.cc @@ -160,7 +160,7 @@ mogltk::font::~font() { free(sizes); } -void mogltk::font::drawentry(Uint16 entry, int x, int y, Color c) { +void mogltk::font::drawentry(Uint16 entry, int x, int y, ColorP c) { bool was2D; int trueentry, cx, cy, px, py; @@ -208,12 +208,12 @@ void mogltk::font::putcursor(int x, int y) { cy = y; } -void mogltk::font::putentry(Uint16 entry, Color c) { +void mogltk::font::putentry(Uint16 entry, ColorP c) { drawentry(entry, cx, cy, c); cx += sizes[entry]; } -void mogltk::font::putchar(char ch, Color c) { +void mogltk::font::putchar(char ch, ColorP c) { Uint16 * p; int i; @@ -290,7 +290,7 @@ int mogltk::font::printf(const char * p, ...) { return r; } -void mogltk::font::setcolor(Color c) { +void mogltk::font::setcolor(ColorP c) { textcolor = c; } diff --git a/lib/glshape.cc b/lib/glshape.cc index cad1e36..6d88a15 100644 --- a/lib/glshape.cc +++ b/lib/glshape.cc @@ -7,7 +7,7 @@ #define ENTERT bool was2d = in2D(false) #define LEAVE out2D(was2d) -void mogltk::shape::box(int x1, int y1, int x2, int y2, Color c) { +void mogltk::shape::box(int x1, int y1, int x2, int y2, ColorP c) { ENTER; c.Bind(); @@ -21,7 +21,7 @@ void mogltk::shape::box(int x1, int y1, int x2, int y2, Color c) { LEAVE; } -void mogltk::shape::box(int x1, int y1, int x2, int y2, Color c1, Color c2, Color c3, Color c4) { +void mogltk::shape::box(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4) { ENTER; glBegin(GL_TRIANGLE_STRIP); @@ -34,23 +34,23 @@ void mogltk::shape::box(int x1, int y1, int x2, int y2, Color c1, Color c2, Colo LEAVE; } -void mogltk::shape::hline(int x1, int x2, int y, Color c) { +void mogltk::shape::hline(int x1, int x2, int y, ColorP c) { box(x1, y, x2, y, c); } -void mogltk::shape::vline(int x, int y1, int y2, Color c) { +void mogltk::shape::vline(int x, int y1, int y2, ColorP c) { box(x, y1, x, y2, c); } -void mogltk::shape::hline(int x1, int x2, int y, Color c1, Color c2) { +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, Color c1, Color 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::obox(int x1, int y1, int x2, int y2, Color 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); @@ -59,7 +59,7 @@ void mogltk::shape::obox(int x1, int y1, int x2, int y2, Color c) { LEAVE; } -void mogltk::shape::obox(int x1, int y1, int x2, int y2, Color c1, Color c2, Color c3, Color c4) { +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); @@ -68,15 +68,15 @@ void mogltk::shape::obox(int x1, int y1, int x2, int y2, Color c1, Color c2, Col LEAVE; } -void mogltk::shape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, int tx, int ty, double f, Color c) { +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 + (x2 - x1) * f, ty + (y2 - y1) * f, c); } -void mogltk::shape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, Color c1, Color c2, Color c3, Color c4, int tx, int ty, double f) { +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 + (x2 - x1) * f, ty + (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, Color c) { +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) { ENTERT; c.Bind(); @@ -91,7 +91,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, Color c1, Color c2, Color c3, Color c4, int tx1, int ty1, int tx2, int ty2) { +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) { ENTERT; t->Bind(); diff --git a/lib/sprite.cc b/lib/sprite.cc index 68450d3..282eefe 100644 --- a/lib/sprite.cc +++ b/lib/sprite.cc @@ -123,7 +123,7 @@ bool mogltk::Sprite::canfit(int x1, int y1, int x2, int y2) const { return false; } -void mogltk::Sprite::draw(int dx, int dy, Color c) { +void mogltk::Sprite::draw(int dx, int dy, ColorP c) { bool was2D; was2D = mogltk::glbase::is2D(); |