diff --git a/include/Makefile.am b/include/Makefile.am index 7d6f0a41e..f6d399bcc 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -8,8 +8,8 @@ EXTRA_DIST = asm_i386.h alsa_funcs_list.h adivtab.h anorm_dots.h anorms.h \ gib_function.h gib_handle.h gib_object.h gib_parse.h gib_process.h \ gib_regex.h gib_semantics.h gib_thread.h gib_tree.h gib_vars.h gl_draw.h \ gl_warp_sin.h in_win.h logos.h net_dgrm.h net_loop.h net_udp.h net_vcr.h \ - net_wins.h netchan.h netmain.h old_keys.h ops.h qstring.h quakeasm.h \ - regex.h r_cvar.h r_dynamic.h r_local.h r_screen.h r_shared.h \ + net_wins.h netchan.h netmain.h noisetextures.h old_keys.h ops.h qstring.h \ + quakeasm.h regex.h r_cvar.h r_dynamic.h r_local.h r_screen.h r_shared.h \ rua_internal.h sbar.h skin_stencil.h snd_internal.h sv_console.h \ varrays.h vgamodes.h vregset.h winquake.h world.h \ \ diff --git a/include/QF/Makefile.am b/include/QF/Makefile.am index 4d68aaec7..09caf2a82 100644 --- a/include/QF/Makefile.am +++ b/include/QF/Makefile.am @@ -12,7 +12,7 @@ nobase_pkginclude_HEADERS = \ wad.h wadfile.h winding.h zone.h \ \ GL/ati.h GL/defines.h GL/extensions.h GL/funcs.h GL/qf_explosions.h \ - GL/qf_funcs_list.h GL/qf_lightmap.h GL/qf_noisetextures.h \ + GL/qf_funcs_list.h GL/qf_lightmap.h \ GL/qf_rlight.h GL/qf_rmain.h GL/qf_rsurf.h GL/qf_sky.h GL/qf_textures.h \ GL/qf_vid.h GL/types.h \ \ diff --git a/include/QF/GL/qf_noisetextures.h b/include/noisetextures.h similarity index 100% rename from include/QF/GL/qf_noisetextures.h rename to include/noisetextures.h diff --git a/include/r_local.h b/include/r_local.h index 9f45507f3..0cab89f24 100644 --- a/include/r_local.h +++ b/include/r_local.h @@ -402,4 +402,8 @@ extern byte crosshair_data[]; struct qpic_s *Draw_CrosshairPic (void); +struct tex_s *R_DotParticleTexture (void); +struct tex_s *R_SparkParticleTexture (void); +struct tex_s *R_SmokeParticleTexture (void); + #endif // _R_LOCAL_H diff --git a/libs/video/renderer/Makefile.am b/libs/video/renderer/Makefile.am index fc0ec0b4f..2ecd9a0e3 100644 --- a/libs/video/renderer/Makefile.am +++ b/libs/video/renderer/Makefile.am @@ -10,8 +10,9 @@ EXTRA_LTLIBRARIES= libQFrenderer_sw.la libQFrenderer_sw32.la \ libQFrenderer_gl.la libQFrenderer_glsl.la common_sources= \ - crosshair.c r_alias.c r_bsp.c r_cvar.c r_efrag.c r_ent.c r_graph.c \ - r_light.c r_main.c r_part.c r_progs.c r_screen.c + crosshair.c noisetextures.c r_alias.c r_bsp.c r_cvar.c r_dyn_textures.c \ + r_efrag.c r_ent.c r_graph.c r_light.c r_main.c r_part.c r_progs.c \ + r_screen.c libQFrenderer_gl_la_LDFLAGS= -version-info $(QUAKE_LIBRARY_VERSION_INFO) -rpath $(libdir) libQFrenderer_gl_la_LIBADD= gl/libgl.la diff --git a/libs/video/renderer/gl/Makefile.am b/libs/video/renderer/gl/Makefile.am index 5d01519d2..82cf583ae 100644 --- a/libs/video/renderer/gl/Makefile.am +++ b/libs/video/renderer/gl/Makefile.am @@ -13,7 +13,7 @@ gl_src = \ gl_draw.c gl_dyn_lights.c gl_dyn_part.c gl_dyn_textures.c \ gl_fog.c gl_graph.c gl_lightmap.c gl_mod_alias.c gl_mod_sprite.c \ gl_rmain.c gl_rmisc.c gl_rsurf.c gl_screen.c gl_skin.c gl_sky.c \ - gl_sky_clip.c gl_textures.c gl_warp.c noisetextures.c + gl_sky_clip.c gl_textures.c gl_warp.c libgl_la_SOURCES= $(gl_src) diff --git a/libs/video/renderer/gl/gl_dyn_textures.c b/libs/video/renderer/gl/gl_dyn_textures.c index ea3b0a01d..714d98760 100644 --- a/libs/video/renderer/gl/gl_dyn_textures.c +++ b/libs/video/renderer/gl/gl_dyn_textures.c @@ -28,8 +28,7 @@ # include "config.h" #endif -static __attribute__ ((used)) const char rcsid[] = - "$Id$"; +static __attribute__ ((used)) const char rcsid[] = "$Id$"; #ifdef HAVE_STRING_H # include @@ -40,13 +39,15 @@ static __attribute__ ((used)) const char rcsid[] = #include +#include "QF/image.h" #include "QF/qtypes.h" #include "QF/GL/defines.h" #include "QF/GL/funcs.h" -#include "QF/GL/qf_noisetextures.h" #include "QF/GL/qf_textures.h" #include "QF/GL/qf_vid.h" +#include "r_local.h" + /* int part_tex_dot; int part_tex_smoke; @@ -75,80 +76,34 @@ GDT_InitParticleTexture (void) static void GDT_InitDotParticleTexture (void) { - byte data[32][32][2]; - int x, y, dx2, dy, d; + tex_t *tex; - for (x = 0; x < 32; x++) { - dx2 = x - 16; - dx2 *= dx2; - for (y = 0; y < 32; y++) { - dy = y - 16; - d = 255 - (dx2 + (dy * dy)); - if (d <= 0) - d = 0; - data[y][x][0] = 255; - data[y][x][1] = (byte) d; - } - } + tex = R_DotParticleTexture (); qfglTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 32, 32, GL_LUMINANCE_ALPHA, - GL_UNSIGNED_BYTE, data); + GL_UNSIGNED_BYTE, tex->data); + free (tex); } static void GDT_InitSparkParticleTexture (void) { - byte data[32][32][2]; - int x, y, dx2, dy, d; + tex_t *tex; - for (x = 0; x < 32; x++) { - dx2 = 16 - abs (x - 16); - dx2 *= dx2; - for (y = 0; y < 32; y++) { - dy = 16 - abs (y - 16); - d = (dx2 + dy * dy) - 200; - if (d > 255) { - d = 255; - } else if (d < 1) { - d = 0; - } - data[y][x][0] = 255; - data[y][x][1] = (byte) d; - } - } + tex = R_SparkParticleTexture (); qfglTexSubImage2D (GL_TEXTURE_2D, 0, 32, 0, 32, 32, GL_LUMINANCE_ALPHA, - GL_UNSIGNED_BYTE, data); + GL_UNSIGNED_BYTE, tex->data); + free (tex); } static void GDT_InitSmokeParticleTexture (void) { - byte d; - byte data[32][32][2], noise1[32][32], noise2[32][32]; - float dx, dy2; - int x, y, c; + tex_t *tex; - memset (noise1, 0, sizeof (noise1)); - noise_plasma (&noise1[0][0], 32); - noise_diamondsquare (&noise2[0][0], 32, 4); - for (y = 0; y < 32; y++) { - dy2 = y - 16; - dy2 *= dy2; - for (x = 0; x < 32; x++) { - dx = x - 16; - c = 255 - (dx * dx + dy2); - if (c < 1) - c = 0; - d = (noise1[y][x] + noise2[y][x]) / 2; - data[y][x][0] = 255; - if (d > 0) { - data[y][x][1] = (d * c) / 255; - } else { - data[y][x][1] = 0; - } - } - } + tex = R_SmokeParticleTexture (); qfglTexSubImage2D (GL_TEXTURE_2D, 0, 0, 32, 32, 32, GL_LUMINANCE_ALPHA, - GL_UNSIGNED_BYTE, data); + GL_UNSIGNED_BYTE, tex->data); + free (tex); } void diff --git a/libs/video/renderer/gl/noisetextures.c b/libs/video/renderer/noisetextures.c similarity index 100% rename from libs/video/renderer/gl/noisetextures.c rename to libs/video/renderer/noisetextures.c diff --git a/libs/video/renderer/r_dyn_textures.c b/libs/video/renderer/r_dyn_textures.c new file mode 100644 index 000000000..2d05a1c0b --- /dev/null +++ b/libs/video/renderer/r_dyn_textures.c @@ -0,0 +1,146 @@ +/* + r_dyn_textures.c + + Dynamic texture generation. + + Copyright (C) 1996-1997 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + + Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307, USA + +*/ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +static __attribute__ ((used)) const char rcsid[] = "$Id$"; + +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif + +#include + +#include "QF/image.h" +#include "QF/qtypes.h" + +#include "noisetextures.h" +#include "r_local.h" + +tex_t * +R_DotParticleTexture (void) +{ + byte (*data)[32][32][2]; + int x, y, dx2, dy, d; + tex_t *tex; + + tex = malloc (field_offset (tex_t, data[sizeof (*data)])); + tex->width = 32; + tex->height = 32; + tex->format = tex_la; + tex->palette = 0; + data = (byte (*)[32][32][2]) tex->data; + + for (x = 0; x < 32; x++) { + dx2 = x - 16; + dx2 *= dx2; + for (y = 0; y < 32; y++) { + dy = y - 16; + d = 255 - (dx2 + (dy * dy)); + if (d <= 0) + d = 0; + (*data)[y][x][0] = 255; + (*data)[y][x][1] = (byte) d; + } + } + return tex; +} + +tex_t * +R_SparkParticleTexture (void) +{ + byte (*data)[32][32][2]; + int x, y, dx2, dy, d; + tex_t *tex; + + tex = malloc (field_offset (tex_t, data[sizeof (*data)])); + tex->width = 32; + tex->height = 32; + tex->format = tex_la; + tex->palette = 0; + data = (byte (*)[32][32][2]) tex->data; + + for (x = 0; x < 32; x++) { + dx2 = 16 - abs (x - 16); + dx2 *= dx2; + for (y = 0; y < 32; y++) { + dy = 16 - abs (y - 16); + d = (dx2 + dy * dy) - 200; + if (d > 255) { + d = 255; + } else if (d < 1) { + d = 0; + } + (*data)[y][x][0] = 255; + (*data)[y][x][1] = (byte) d; + } + } + return tex; +} + +tex_t * +R_SmokeParticleTexture (void) +{ + byte d; + byte (*data)[32][32][2], noise1[32][32], noise2[32][32]; + float dx, dy2; + int x, y, c; + tex_t *tex; + + tex = malloc (field_offset (tex_t, data[sizeof (*data)])); + tex->width = 32; + tex->height = 32; + tex->format = tex_la; + tex->palette = 0; + data = (byte (*)[32][32][2]) tex->data; + + memset (noise1, 0, sizeof (noise1)); + noise_plasma (&noise1[0][0], 32); + noise_diamondsquare (&noise2[0][0], 32, 4); + for (y = 0; y < 32; y++) { + dy2 = y - 16; + dy2 *= dy2; + for (x = 0; x < 32; x++) { + dx = x - 16; + c = 255 - (dx * dx + dy2); + if (c < 1) + c = 0; + d = (noise1[y][x] + noise2[y][x]) / 2; + (*data)[y][x][0] = 255; + if (d > 0) { + (*data)[y][x][1] = (d * c) / 255; + } else { + (*data)[y][x][1] = 0; + } + } + } + return tex; +}