- added libdrawtext
[demo_prior] / src / imtk / imtk.c
diff --git a/src/imtk/imtk.c b/src/imtk/imtk.c
new file mode 100644 (file)
index 0000000..545c4c5
--- /dev/null
@@ -0,0 +1,66 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+#include "opengl.h"
+#include "imtk.h"
+#include "state.h"
+#include "draw.h"
+
+void imtk_post_redisplay(void)
+{
+       glutPostRedisplay();
+}
+
+void imtk_begin(void)
+{
+       int width, height;
+
+       glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
+
+       glDisable(GL_DEPTH_TEST);
+       glDisable(GL_STENCIL_TEST);
+       glDisable(GL_ALPHA_TEST);
+       glDisable(GL_TEXTURE_1D);
+       glDisable(GL_TEXTURE_2D);
+       glDisable(GL_CULL_FACE);
+       glDisable(GL_SCISSOR_TEST);
+       glDisable(GL_LIGHTING);
+       glEnable(GL_BLEND);
+       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+
+       imtk_get_viewport(&width, &height);
+
+       glMatrixMode(GL_PROJECTION);
+       glPushMatrix();
+       glLoadIdentity();
+       glTranslatef(-1, 1, 0);
+       glScalef(2.0 / width, -2.0 / height, 1.0);
+
+       glMatrixMode(GL_MODELVIEW);
+       glPushMatrix();
+       glLoadIdentity();
+}
+
+void imtk_end(void)
+{
+       glMatrixMode(GL_PROJECTION);
+       glPopMatrix();
+       glMatrixMode(GL_MODELVIEW);
+       glPopMatrix();
+
+       glPopAttrib();
+}
+
+void imtk_label(const char *str, int x, int y)
+{
+       if(x == IMTK_AUTO || y == IMTK_AUTO) {
+               imtk_layout_get_pos(&x, &y);
+       }
+
+       glColor4fv(imtk_get_color(IMTK_TEXT_COLOR));
+       imtk_draw_string(x, y + 14, str);
+       imtk_layout_advance(imtk_string_size(str), 12);
+}