X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=demo_prior;a=blobdiff_plain;f=src%2Fimtk%2Fimtk.c;fp=src%2Fimtk%2Fimtk.c;h=545c4c57dd2b80d4111279d27ad7819c1b47f3f9;hp=0000000000000000000000000000000000000000;hb=2f14a35e7d557da12f24056267b911f24774aa18;hpb=5eefe7b94c8d6c6caa2c10e3835ab0831a3c42a1 diff --git a/src/imtk/imtk.c b/src/imtk/imtk.c new file mode 100644 index 0000000..545c4c5 --- /dev/null +++ b/src/imtk/imtk.c @@ -0,0 +1,66 @@ +#include +#include +#include +#include +#include +#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); +}