glamtk

view src/draw.c @ 6:9b623dc0f296

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 09 Mar 2011 10:12:31 +0200
parents
children a115dff39a54
line source
1 #ifndef __APPLE__
2 #include <GL/gl.h>
3 #else
4 #include <OpenGL/gl.h>
5 #endif
7 #include "draw.h"
9 struct color {
10 float r, g, b, a;
11 };
13 static struct color fgcolor = {0, 0, 0, 1};
14 static struct color bgcolor = {0.4, 0.4, 0.4, 1};
16 void imtk_draw_color(float r, float g, float b, float a)
17 {
18 fgcolor.r = r;
19 fgcolor.g = g;
20 fgcolor.b = b;
21 fgcolor.a = a;
22 }
24 void imtk_draw_background(float r, float g, float b, float a)
25 {
26 bgcolor.r = r;
27 bgcolor.g = g;
28 bgcolor.b = b;
29 bgcolor.a = a;
30 }
32 void imtk_draw_rect(int x, int y, int w, int h, int rad)
33 {
34 glBegin(GL_LINE_LOOP);
35 linestart(x + rad, y);
36 lineto(x + w - rad, y);
37 arcto(x + w, y + rad);
38 lineto(x + w, y + h - rad);
39 arcto(x + w - rad, y + h);
40 lineto(x + rad, y + h);
41 arcto(x, y + h - rad);
42 lineto(x, y + rad);
43 arcto(x + rad, y);
44 glEnd();
45 }
47 static int px, py;
49 static void linestart(int x, int y)
50 {
51 px = x;
52 py = y;
53 glVertex2i(x, y);
54 }
56 static void lineto(int x, int y)
57 {
58 px = x;
59 py = y;
60 glVertex2i(x, y);
61 }
63 static void arcto(int x, int y, int rad)
64 {
65 }