- shaders for both lightmapped objects with or without albedo maps
[laserbrain_demo] / src / ui.cc
index 33fbccf..1a18324 100644 (file)
--- a/src/ui.cc
+++ b/src/ui.cc
@@ -14,6 +14,7 @@ static bool init();
 struct Message {
        long start_time, show_until;
        char *str;
+       Vec3 color;
        Message *next;
 };
 static Message *msglist;
@@ -30,13 +31,26 @@ void set_message_timeout(long tm)
 void show_message(const char *fmt, ...)
 {
        va_list ap;
+       va_start(ap, fmt);
+       show_messagev(timeout, Vec3(1, 1, 1), fmt, ap);
+       va_end(ap);
+}
+
+void show_message(long timeout, const Vec3 &color, const char *fmt, ...)
+{
+       va_list ap;
+       va_start(ap, fmt);
+       show_messagev(timeout, color, fmt, ap);
+       va_end(ap);
+}
+
+void show_messagev(long timeout, const Vec3 &color, const char *fmt, va_list ap)
+{
        char buf[512];
 
        init();
 
-       va_start(ap, fmt);
        vsnprintf(buf, sizeof buf, fmt, ap);
-       va_end(ap);
 
        Message *msg = new Message;
        int len = strlen(buf);
@@ -44,6 +58,7 @@ void show_message(const char *fmt, ...)
        memcpy(msg->str, buf, len + 1);
        msg->start_time = time_msec;
        msg->show_until = time_msec + timeout;
+       msg->color = color;
 
        Message dummy;
        dummy.next = msglist;
@@ -90,7 +105,7 @@ void draw_ui()
                long dur = msg->show_until - msg->start_time;
                float alpha = smoothstep(0, trans_time, t) *
                        (1.0 - smoothstep(dur - trans_time, dur, t));
-               glColor4f(1.0, 0.5, 0.1, alpha);
+               glColor4f(msg->color.x, msg->color.y, msg->color.z, alpha);
                glTranslatef(0, -dtx_line_height(), 0);
                dtx_string(msg->str);
                msg = msg->next;