libpsys

annotate src/psys_gl.c @ 0:1c8eb90a6989

initial commit
author John Tsiombikas <nuclear@mutantstargoat.com>
date Sat, 24 Sep 2011 07:22:07 +0300
parents
children 874a942853ad
rev   line source
nuclear@0 1 #ifndef __APPLE__
nuclear@0 2 #include <GL/gl.h>
nuclear@0 3 #else
nuclear@0 4 #include <OpenGL/gl.h>
nuclear@0 5 #endif
nuclear@0 6
nuclear@0 7 #include "psys_impl.h"
nuclear@0 8
nuclear@0 9 void psys_gl_draw_start(struct psys_emitter *em, void *cls)
nuclear@0 10 {
nuclear@0 11 float xform[16];
nuclear@0 12
nuclear@0 13 glMatrixMode(GL_MODELVIEW);
nuclear@0 14 glPushMatrix();
nuclear@0 15
nuclear@0 16 glGetFloatv(GL_MODELVIEW_MATRIX, xform);
nuclear@0 17 xform[3] = xform[7] = xform[11] = xform[12] = xform[13] = xform[14] = 0.0f;
nuclear@0 18 xform[15] = 1.0f;
nuclear@0 19
nuclear@0 20 glLoadMatrixf(xform);
nuclear@0 21
nuclear@0 22 glPushAttrib(GL_ENABLE_BIT);
nuclear@0 23 glDisable(GL_LIGHTING);
nuclear@0 24
nuclear@0 25 glDepthMask(0);
nuclear@0 26
nuclear@0 27 glBegin(GL_QUADS);
nuclear@0 28 glColor3f(1, 1, 1);
nuclear@0 29 }
nuclear@0 30
nuclear@0 31 void psys_gl_draw(struct psys_emitter *em, struct psys_particle *p, void *cls)
nuclear@0 32 {
nuclear@0 33 float hsz = p->size / 2.0;
nuclear@0 34
nuclear@0 35 glTexCoord2f(0, 0);
nuclear@0 36 glVertex3f(p->pos.x - hsz, p->pos.y - hsz, p->pos.z);
nuclear@0 37
nuclear@0 38 glTexCoord2f(1, 0);
nuclear@0 39 glVertex3f(p->pos.x + hsz, p->pos.y - hsz, p->pos.z);
nuclear@0 40
nuclear@0 41 glTexCoord2f(1, 1);
nuclear@0 42 glVertex3f(p->pos.x + hsz, p->pos.y + hsz, p->pos.z);
nuclear@0 43
nuclear@0 44 glTexCoord2f(0, 1);
nuclear@0 45 glVertex3f(p->pos.x - hsz, p->pos.y + hsz, p->pos.z);
nuclear@0 46 }
nuclear@0 47
nuclear@0 48 void psys_gl_draw_end(struct psys_emitter *em, void *cls)
nuclear@0 49 {
nuclear@0 50 glEnd();
nuclear@0 51
nuclear@0 52 glDepthMask(1);
nuclear@0 53 glPopAttrib();
nuclear@0 54
nuclear@0 55 glMatrixMode(GL_MODELVIEW);
nuclear@0 56 glPopMatrix();
nuclear@0 57 }