sanegl
diff sanegl.c @ 0:00b315b6db1e
sanegl initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 23 Jun 2011 05:19:40 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/sanegl.c Thu Jun 23 05:19:40 2011 +0300 1.3 @@ -0,0 +1,73 @@ 1.4 +#include <stdio.h> 1.5 + 1.6 +#define SANEGL_IMPL_ 1.7 +#include "sanegl.h" 1.8 + 1.9 +struct vertex { 1.10 + float pos[4]; 1.11 + float color[4]; 1.12 + float tex[2]; 1.13 + float norm[3]; 1.14 +}; 1.15 + 1.16 +static const int mode_verts[] = { 1.17 + 1, /* GL_POINTS */ 1.18 + 2, /* GL_LINES */ 1.19 + -1, /* GL_LINE_LOOP TODO */ 1.20 + -1, /* GL_LINE_STRIP TODO */ 1.21 + 3, /* GL_TRIANGLES */ 1.22 + -1, /* GL_TRIANGLE_STRIP TODO */ 1.23 + -1, /* GL_TRIANGLE_FAN TODO */ 1.24 + 6, /* GL_QUADS (two triangles) */ 1.25 + -1, /* GL_QUAD_STRIP TODO */ 1.26 + -1 /* GL_POLYGON TODO */ 1.27 +}; 1.28 + 1.29 +static struct vertex vcur = { 1.30 + {0, 0, 0, 1}, /* position */ 1.31 + {1, 1, 1, 1}, /* color */ 1.32 + {0, 0}, /* tex-coord */ 1.33 + {0, 0, 0} /* normal */ 1.34 +}; 1.35 + 1.36 + 1.37 +void glBegin(GLenum mode) 1.38 +{ 1.39 + printf("glBegin\n"); 1.40 +} 1.41 + 1.42 +void glEnd(void) 1.43 +{ 1.44 + printf("glEnd\n"); 1.45 +} 1.46 + 1.47 +void glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) 1.48 +{ 1.49 + vcur.pos[0] = x; 1.50 + vcur.pos[1] = y; 1.51 + vcur.pos[2] = z; 1.52 + vcur.pos[3] = w; 1.53 + 1.54 + varr[nvert++] = vcur; 1.55 +} 1.56 + 1.57 +void glColor4f(GLfloat r, GLfloat g, GLfloat, b, GLfloat a) 1.58 +{ 1.59 + vcur.color[0] = r; 1.60 + vcur.color[1] = g; 1.61 + vcur.color[2] = b; 1.62 + vcur.color[3] = a; 1.63 +} 1.64 + 1.65 +void glNormal3f(GLfloat x, GLfloat y, GLfloat z) 1.66 +{ 1.67 + vcur.normal[0] = x; 1.68 + vcur.normal[1] = y; 1.69 + vcur.normal[2] = z; 1.70 +} 1.71 + 1.72 +void glTexCoord4f(GLfloat x, GLfloat y) 1.73 +{ 1.74 + vcur.tex[0] = x; 1.75 + vcur.tex[1] = y; 1.76 +}