libpsys
view src/psys_gl.c @ 2:6e5342a2529a
more stuff done
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Sun, 25 Sep 2011 04:26:51 +0300 |
parents | 874a942853ad |
children | 133094e2f5a5 |
line source
1 #ifndef __APPLE__
2 #include <GL/gl.h>
3 #else
4 #include <OpenGL/gl.h>
5 #endif
7 #include "psys_impl.h"
9 void psys_gl_draw_start(struct psys_emitter *em, void *cls)
10 {
11 float xform[16];
13 glMatrixMode(GL_MODELVIEW);
14 glPushMatrix();
16 glGetFloatv(GL_MODELVIEW_MATRIX, xform);
17 xform[0] = xform[5] = xform[10] = 1.0;
18 xform[1] = xform[2] = xform[4] = xform[6] = xform[8] = xform[9] = 0.0;
20 glLoadMatrixf(xform);
22 glPushAttrib(GL_ENABLE_BIT);
23 glDisable(GL_LIGHTING);
25 glEnable(GL_BLEND);
26 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
28 if(em->tex) {
29 glEnable(GL_TEXTURE_2D);
30 glBindTexture(GL_TEXTURE_2D, em->tex);
31 }
33 glDepthMask(0);
35 glBegin(GL_QUADS);
36 glColor3f(1, 1, 1);
37 }
39 void psys_gl_draw(struct psys_emitter *em, struct psys_particle *p, void *cls)
40 {
41 float hsz = p->size / 2.0;
43 glTexCoord2f(0, 0);
44 glVertex3f(p->pos.x - hsz, p->pos.y - hsz, p->pos.z);
46 glTexCoord2f(1, 0);
47 glVertex3f(p->pos.x + hsz, p->pos.y - hsz, p->pos.z);
49 glTexCoord2f(1, 1);
50 glVertex3f(p->pos.x + hsz, p->pos.y + hsz, p->pos.z);
52 glTexCoord2f(0, 1);
53 glVertex3f(p->pos.x - hsz, p->pos.y + hsz, p->pos.z);
54 }
56 void psys_gl_draw_end(struct psys_emitter *em, void *cls)
57 {
58 glEnd();
60 glDepthMask(1);
61 glPopAttrib();
63 glMatrixMode(GL_MODELVIEW);
64 glPopMatrix();
65 }