glamtk
changeset 6:9b623dc0f296
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 09 Mar 2011 10:12:31 +0200 |
parents | 86ba127ac2f2 |
children | a115dff39a54 |
files | src/draw.c |
diffstat | 1 files changed, 65 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/draw.c Wed Mar 09 10:12:31 2011 +0200 1.3 @@ -0,0 +1,65 @@ 1.4 +#ifndef __APPLE__ 1.5 +#include <GL/gl.h> 1.6 +#else 1.7 +#include <OpenGL/gl.h> 1.8 +#endif 1.9 + 1.10 +#include "draw.h" 1.11 + 1.12 +struct color { 1.13 + float r, g, b, a; 1.14 +}; 1.15 + 1.16 +static struct color fgcolor = {0, 0, 0, 1}; 1.17 +static struct color bgcolor = {0.4, 0.4, 0.4, 1}; 1.18 + 1.19 +void imtk_draw_color(float r, float g, float b, float a) 1.20 +{ 1.21 + fgcolor.r = r; 1.22 + fgcolor.g = g; 1.23 + fgcolor.b = b; 1.24 + fgcolor.a = a; 1.25 +} 1.26 + 1.27 +void imtk_draw_background(float r, float g, float b, float a) 1.28 +{ 1.29 + bgcolor.r = r; 1.30 + bgcolor.g = g; 1.31 + bgcolor.b = b; 1.32 + bgcolor.a = a; 1.33 +} 1.34 + 1.35 +void imtk_draw_rect(int x, int y, int w, int h, int rad) 1.36 +{ 1.37 + glBegin(GL_LINE_LOOP); 1.38 + linestart(x + rad, y); 1.39 + lineto(x + w - rad, y); 1.40 + arcto(x + w, y + rad); 1.41 + lineto(x + w, y + h - rad); 1.42 + arcto(x + w - rad, y + h); 1.43 + lineto(x + rad, y + h); 1.44 + arcto(x, y + h - rad); 1.45 + lineto(x, y + rad); 1.46 + arcto(x + rad, y); 1.47 + glEnd(); 1.48 +} 1.49 + 1.50 +static int px, py; 1.51 + 1.52 +static void linestart(int x, int y) 1.53 +{ 1.54 + px = x; 1.55 + py = y; 1.56 + glVertex2i(x, y); 1.57 +} 1.58 + 1.59 +static void lineto(int x, int y) 1.60 +{ 1.61 + px = x; 1.62 + py = y; 1.63 + glVertex2i(x, y); 1.64 +} 1.65 + 1.66 +static void arcto(int x, int y, int rad) 1.67 +{ 1.68 +}