imtk

view src/imtk.c @ 16:1cf212375db3

textbox cursor handling
author John Tsiombikas <nuclear@siggraph.org>
date Tue, 19 Apr 2011 08:24:39 +0300
parents 6d35e6c7b2ca
children c7a7ddbe7714
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"
16 void imtk_post_redisplay(void)
17 {
18 glutPostRedisplay();
19 }
21 void imtk_begin(void)
22 {
23 int width, height;
25 imtk_get_viewport(&width, &height);
27 glMatrixMode(GL_PROJECTION);
28 glPushMatrix();
29 glLoadIdentity();
30 glTranslatef(-1, 1, 0);
31 glScalef(2.0 / width, -2.0 / height, 1.0);
33 glMatrixMode(GL_MODELVIEW);
34 glPushMatrix();
35 glLoadIdentity();
37 glPushAttrib(GL_ENABLE_BIT);
38 glDisable(GL_DEPTH_TEST);
39 glDisable(GL_CULL_FACE);
40 glDisable(GL_LIGHTING);
41 glEnable(GL_BLEND);
43 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
44 }
46 void imtk_end(void)
47 {
48 glPopAttrib();
50 glMatrixMode(GL_PROJECTION);
51 glPopMatrix();
52 glMatrixMode(GL_MODELVIEW);
53 glPopMatrix();
54 }
56 void imtk_label(const char *str, int x, int y)
57 {
58 glColor4fv(imtk_get_color(IMTK_TEXT_COLOR));
59 imtk_draw_string(x, y, str);
60 }
63 /*
64 int imtk_combobox(int id, char *textbuf, size_t buf_sz, const char *list, int sel, int x, int y)
65 {
66 imtk_textbox(id + 1, textbuf, buf_sz, x, y);
67 imtk_button(id + 3, "V", x + TEXTBOX_SIZE, y);
69 if(prev_active == id + 3) {
70 sel = imtk_listbox(id + 5, list, sel, x, y + 20);
71 }
72 return sel;
73 }
74 */