From 1f25ab9ec2994569ad9ebbf9933095fe2ecef026 Mon Sep 17 00:00:00 2001 From: Ragnvald Maartmann-Moe IV Date: Fri, 6 Apr 2001 04:27:39 +0000 Subject: [PATCH] New generated texture for spark particles. --- qw/source/gl_dyn_part.c | 7 ++--- qw/source/gl_dyn_textures.c | 53 +++++++++++++++++++++++++++++-------- qw/source/gl_textures.c | 2 +- 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/qw/source/gl_dyn_part.c b/qw/source/gl_dyn_part.c index e131b7dd1..cc429de6f 100644 --- a/qw/source/gl_dyn_part.c +++ b/qw/source/gl_dyn_part.c @@ -80,8 +80,9 @@ extern qboolean lighthalf; extern cvar_t *cl_max_particles; -extern int part_tex_smoke[8]; extern int part_tex_dot; +extern int part_tex_spark; +extern int part_tex_smoke[8]; int ramp[8] = { 0x6d, 0x6b, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 }; @@ -282,7 +283,7 @@ R_RunSparkEffect (vec3_t org, int count, int ofuzz) (ofuzz / 8) * .75, vec3_origin, cl.time + 99, 12 + (rand () & 3), 96); while (count--) - particle_new_random (pt_fallfadespark, part_tex_dot, org, ofuzz * .75, + particle_new_random (pt_fallfadespark, part_tex_spark, org, ofuzz * .75, 1, 96, cl.time + 5, ramp[rand () % 6], lhrandom (0, 255)); } @@ -444,7 +445,7 @@ R_TeleportSplash (vec3_t org) VectorNormalize (dir); vel = 50 + (rand () & 63); VectorScale (dir, vel, pvel); - particle_new (pt_grav, part_tex_dot, porg, 0.6, pvel, + particle_new (pt_grav, part_tex_spark, porg, 0.6, pvel, (cl.time + 0.2 + (rand () & 7) * 0.02), (7 + (rand () & 7)), 255); } diff --git a/qw/source/gl_dyn_textures.c b/qw/source/gl_dyn_textures.c index c3c1301b7..c8939bc7f 100644 --- a/qw/source/gl_dyn_textures.c +++ b/qw/source/gl_dyn_textures.c @@ -38,15 +38,18 @@ extern void noise_diamondsquare(unsigned char *noise, int size); extern void noise_plasma(unsigned char *noise, int size); static void GDT_InitDotParticleTexture (void); +static void GDT_InitSparkParticleTexture (void); static void GDT_InitSmokeParticleTexture (void); -int part_tex_smoke[8]; int part_tex_dot; +int part_tex_spark; +int part_tex_smoke[8]; void GDT_Init (void) { GDT_InitDotParticleTexture (); + GDT_InitSparkParticleTexture (); GDT_InitSmokeParticleTexture (); } @@ -56,18 +59,12 @@ GDT_InitDotParticleTexture (void) int x, y, dx2, dy, d; byte data[16][16][2]; - // - // particle texture - // - part_tex_dot = texture_extension_number++; - glBindTexture (GL_TEXTURE_2D, part_tex_dot); - for (x = 0; x < 16; x++) { dx2 = x - 8; dx2 *= dx2; for (y = 0; y < 16; y++) { dy = y - 8; - d = 255 - 4 * (dx2 + dy * dy); + d = 255 - 4 * (dx2 + (dy * dy)); if (d<=0) { d = 0; data[y][x][0] = 0; @@ -77,13 +74,47 @@ GDT_InitDotParticleTexture (void) data[y][x][1] = (byte) d; } } - glTexImage2D (GL_TEXTURE_2D, 0, 2, 16, 16, 0, GL_LUMINANCE_ALPHA, - GL_UNSIGNED_BYTE, data); - + part_tex_dot = texture_extension_number++; + glBindTexture (GL_TEXTURE_2D, part_tex_dot); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexImage2D (GL_TEXTURE_2D, 0, 2, 16, 16, 0, GL_LUMINANCE_ALPHA, + GL_UNSIGNED_BYTE, data); } + +static void +GDT_InitSparkParticleTexture (void) +{ + int x, y, dx2, dy, d; + byte data[16][16][2]; + + for (x = 0; x < 16; x++) { + dx2 = 8 - abs(x - 8); + dx2 *= dx2; + for (y = 0; y < 16; y++) { + dy = 8 - abs(y - 8); + d = 3 * (dx2 + dy * dy) - 100; + if (d>255) + d = 255; + if (d<1) { + d = 0; + data[y][x][0] = 0; + } else + data[y][x][0] = 255; + + data[y][x][1] = (byte) d; + } + } + part_tex_spark = texture_extension_number++; + glBindTexture (GL_TEXTURE_2D, part_tex_spark); + glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexImage2D (GL_TEXTURE_2D, 0, 2, 16, 16, 0, GL_LUMINANCE_ALPHA, + GL_UNSIGNED_BYTE, data); +} + + static void GDT_InitSmokeParticleTexture (void) { diff --git a/qw/source/gl_textures.c b/qw/source/gl_textures.c index e7c57e5d4..68e86878b 100644 --- a/qw/source/gl_textures.c +++ b/qw/source/gl_textures.c @@ -73,8 +73,8 @@ static glmode_t modes[] = { {"GL_NEAREST", GL_NEAREST, GL_NEAREST}, {"GL_LINEAR", GL_LINEAR, GL_LINEAR}, {"GL_NEAREST_MIPMAP_NEAREST", GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST}, - {"GL_LINEAR_MIPMAP_NEAREST", GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR}, {"GL_NEAREST_MIPMAP_LINEAR", GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST}, + {"GL_LINEAR_MIPMAP_NEAREST", GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR}, {"GL_LINEAR_MIPMAP_LINEAR", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR} };