1 /*
2 OpenUniverse 1.0
3 Copyright (C) 2000 Raul Alonso <amil@las.es>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include "ou.h"
21
22 #ifdef WIN32
23 typedef void (APIENTRY * PFNGLPOINTPARAMETERFEXTPROC)
24 (GLenum pname, GLfloat param);
25 typedef void (APIENTRY * PFNGLPOINTPARAMETERFVEXTPROC)
26 (GLenum pname, const GLfloat * params);
27 static PFNGLPOINTPARAMETERFEXTPROC wglPointParameterfEXT;
28 static PFNGLPOINTPARAMETERFVEXTPROC wglPointParameterfvEXT;
29
InitPointEXT(void)30 void InitPointEXT(void)
31 {
32 wglPointParameterfEXT = (PFNGLPOINTPARAMETERFEXTPROC)
33 wglGetProcAddress("glPointParameterfEXT");
34 wglPointParameterfvEXT = (PFNGLPOINTPARAMETERFVEXTPROC)
35 wglGetProcAddress("glPointParameterfvEXT");
36 }
37 #endif
38
39 int hasPointEXT;
40
CometTail(int body)41 void CometTail(int body)
42 {
43 int i;
44 float a;
45 static GLfloat quad[3] = { 0.25, 0.0, 1 / 60.0 };
46
47 if (!hasPointEXT)
48 return;
49
50 glEnable(GL_POINT_SMOOTH);
51 glPointSize(5.0);
52 #ifdef WIN32
53 wglPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, quad);
54 #else
55 #if 0
56 glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, quad);
57 #endif
58 #endif
59 glDisable(GL_TEXTURE_2D);
60 glDisable(GL_LIGHTING);
61 glEnable(GL_BLEND);
62 glBegin(GL_POINTS);
63
64 for (i = 0; i < planets[body].num_particles; i++) {
65 a =
66 sqrt(1.0 -
67 planets[body].tail[i].dist / planets[body].tail_lenght);
68 glColor4f(0.2 + a / 2.0, 0.2 + a / 2.0, 0.2 + a / 2.0, a);
69 glVertex3f(planets[body].tail[i].origin[0] +
70 planets[body].tail[i].dir[0] *
71 planets[body].tail[i].dist,
72 planets[body].tail[i].origin[1] +
73 planets[body].tail[i].dir[1] *
74 planets[body].tail[i].dist,
75 planets[body].tail[i].origin[2] +
76 planets[body].tail[i].dir[2] *
77 planets[body].tail[i].dist);
78 planets[body].tail[i].dist += 0.01;
79 if (planets[body].tail[i].dist > planets[body].tail_lenght)
80 planets[body].tail[i].dist = 0.0;
81 }
82 glEnd();
83 glDisable(GL_BLEND);
84 if (lighting)
85 glEnable(GL_LIGHTING);
86 glEnable(GL_TEXTURE_2D);
87 glPointSize(1.0);
88 }
89