libpsys
annotate src/psys_gl.c @ 3:133094e2f5a5
reorganizing
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Mon, 26 Sep 2011 18:20:11 +0300 |
parents | 6e5342a2529a |
children | 613d2bf3ea1f |
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@2 | 17 xform[0] = xform[5] = xform[10] = 1.0; |
nuclear@2 | 18 xform[1] = xform[2] = xform[4] = xform[6] = xform[8] = xform[9] = 0.0; |
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@2 | 25 glEnable(GL_BLEND); |
nuclear@3 | 26 glBlendFunc(GL_SRC_ALPHA, GL_ONE); |
nuclear@2 | 27 |
nuclear@2 | 28 if(em->tex) { |
nuclear@2 | 29 glEnable(GL_TEXTURE_2D); |
nuclear@2 | 30 glBindTexture(GL_TEXTURE_2D, em->tex); |
nuclear@2 | 31 } |
nuclear@2 | 32 |
nuclear@0 | 33 glDepthMask(0); |
nuclear@0 | 34 |
nuclear@0 | 35 glBegin(GL_QUADS); |
nuclear@0 | 36 glColor3f(1, 1, 1); |
nuclear@0 | 37 } |
nuclear@0 | 38 |
nuclear@0 | 39 void psys_gl_draw(struct psys_emitter *em, struct psys_particle *p, void *cls) |
nuclear@0 | 40 { |
nuclear@0 | 41 float hsz = p->size / 2.0; |
nuclear@0 | 42 |
nuclear@0 | 43 glTexCoord2f(0, 0); |
nuclear@0 | 44 glVertex3f(p->pos.x - hsz, p->pos.y - hsz, p->pos.z); |
nuclear@0 | 45 |
nuclear@0 | 46 glTexCoord2f(1, 0); |
nuclear@0 | 47 glVertex3f(p->pos.x + hsz, p->pos.y - hsz, p->pos.z); |
nuclear@0 | 48 |
nuclear@0 | 49 glTexCoord2f(1, 1); |
nuclear@0 | 50 glVertex3f(p->pos.x + hsz, p->pos.y + hsz, p->pos.z); |
nuclear@0 | 51 |
nuclear@0 | 52 glTexCoord2f(0, 1); |
nuclear@0 | 53 glVertex3f(p->pos.x - hsz, p->pos.y + hsz, p->pos.z); |
nuclear@0 | 54 } |
nuclear@0 | 55 |
nuclear@0 | 56 void psys_gl_draw_end(struct psys_emitter *em, void *cls) |
nuclear@0 | 57 { |
nuclear@0 | 58 glEnd(); |
nuclear@0 | 59 |
nuclear@0 | 60 glDepthMask(1); |
nuclear@0 | 61 glPopAttrib(); |
nuclear@0 | 62 |
nuclear@0 | 63 glMatrixMode(GL_MODELVIEW); |
nuclear@0 | 64 glPopMatrix(); |
nuclear@0 | 65 } |