imtk

view src/imtk.c @ 24:f416d8def7ef

can't remember
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 05 Sep 2011 03:43:30 +0300
parents 17f5ff624da3
children
line source
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <ctype.h>
5 #include <assert.h>
6 #ifndef __APPLE__
7 #include <GL/glut.h>
8 #else
9 #include <GLUT/glut.h>
10 #endif
11 #include "imtk.h"
12 #include "state.h"
13 #include "draw.h"
15 void imtk_post_redisplay(void)
16 {
17 glutPostRedisplay();
18 }
20 void imtk_begin(void)
21 {
22 int width, height;
24 glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
26 glDisable(GL_DEPTH_TEST);
27 glDisable(GL_STENCIL_TEST);
28 glDisable(GL_ALPHA_TEST);
29 glDisable(GL_TEXTURE_1D);
30 glDisable(GL_TEXTURE_2D);
31 glDisable(GL_CULL_FACE);
32 glDisable(GL_SCISSOR_TEST);
33 glDisable(GL_LIGHTING);
34 glEnable(GL_BLEND);
35 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
38 imtk_get_viewport(&width, &height);
40 glMatrixMode(GL_PROJECTION);
41 glPushMatrix();
42 glLoadIdentity();
43 glTranslatef(-1, 1, 0);
44 glScalef(2.0 / width, -2.0 / height, 1.0);
46 glMatrixMode(GL_MODELVIEW);
47 glPushMatrix();
48 glLoadIdentity();
49 }
51 void imtk_end(void)
52 {
53 glMatrixMode(GL_PROJECTION);
54 glPopMatrix();
55 glMatrixMode(GL_MODELVIEW);
56 glPopMatrix();
58 glPopAttrib();
59 }
61 void imtk_label(const char *str, int x, int y)
62 {
63 if(x == IMTK_AUTO || y == IMTK_AUTO) {
64 imtk_layout_get_pos(&x, &y);
65 }
67 glColor4fv(imtk_get_color(IMTK_TEXT_COLOR));
68 imtk_draw_string(x, y + 14, str);
69 imtk_layout_advance(imtk_string_size(str), 12);
70 }