rayfract
diff 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 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/imtk/imtk.c Mon Jul 31 18:58:56 2023 +0300 1.3 @@ -0,0 +1,70 @@ 1.4 +#include <stdio.h> 1.5 +#include <stdlib.h> 1.6 +#include <string.h> 1.7 +#include <ctype.h> 1.8 +#include <assert.h> 1.9 +#ifndef __APPLE__ 1.10 +#include <GL/glut.h> 1.11 +#else 1.12 +#include <GLUT/glut.h> 1.13 +#endif 1.14 +#include "imtk.h" 1.15 +#include "state.h" 1.16 +#include "draw.h" 1.17 + 1.18 +void imtk_post_redisplay(void) 1.19 +{ 1.20 + glutPostRedisplay(); 1.21 +} 1.22 + 1.23 +void imtk_begin(void) 1.24 +{ 1.25 + int width, height; 1.26 + 1.27 + glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT); 1.28 + 1.29 + glDisable(GL_DEPTH_TEST); 1.30 + glDisable(GL_STENCIL_TEST); 1.31 + glDisable(GL_ALPHA_TEST); 1.32 + glDisable(GL_TEXTURE_1D); 1.33 + glDisable(GL_TEXTURE_2D); 1.34 + glDisable(GL_CULL_FACE); 1.35 + glDisable(GL_SCISSOR_TEST); 1.36 + glDisable(GL_LIGHTING); 1.37 + glEnable(GL_BLEND); 1.38 + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 1.39 + 1.40 + 1.41 + imtk_get_viewport(&width, &height); 1.42 + 1.43 + glMatrixMode(GL_PROJECTION); 1.44 + glPushMatrix(); 1.45 + glLoadIdentity(); 1.46 + glTranslatef(-1, 1, 0); 1.47 + glScalef(2.0 / width, -2.0 / height, 1.0); 1.48 + 1.49 + glMatrixMode(GL_MODELVIEW); 1.50 + glPushMatrix(); 1.51 + glLoadIdentity(); 1.52 +} 1.53 + 1.54 +void imtk_end(void) 1.55 +{ 1.56 + glMatrixMode(GL_PROJECTION); 1.57 + glPopMatrix(); 1.58 + glMatrixMode(GL_MODELVIEW); 1.59 + glPopMatrix(); 1.60 + 1.61 + glPopAttrib(); 1.62 +} 1.63 + 1.64 +void imtk_label(const char *str, int x, int y) 1.65 +{ 1.66 + if(x == IMTK_AUTO || y == IMTK_AUTO) { 1.67 + imtk_layout_get_pos(&x, &y); 1.68 + } 1.69 + 1.70 + glColor4fv(imtk_get_color(IMTK_TEXT_COLOR)); 1.71 + imtk_draw_string(x, y + 14, str); 1.72 + imtk_layout_advance(imtk_string_size(str), 12); 1.73 +}