imtk

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