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