summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorpixel <pixel>2003-03-14 13:36:40 +0000
committerpixel <pixel>2003-03-14 13:36:40 +0000
commit2ef9753588b02155faf8bc5a176e4fcf7489dae2 (patch)
treeeaa482c393ca29af35350fd033570989f1fcaff8 /lib
parent700cd603a7ceced2fe8b6a064330d6f88d278dce (diff)
glcolor, first episode
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am4
-rw-r--r--lib/glcolor.cc13
-rw-r--r--lib/glfont.cc8
-rw-r--r--lib/glshape.cc24
-rw-r--r--lib/sprite.cc2
5 files changed, 32 insertions, 19 deletions
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();