mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 15:01:41 +00:00
Make the dynamic textures more readily available.
I want to get QF style particles going in glsl (since id style is currently stuck at one pixel), but I don't want multiple copies of the texture code.
This commit is contained in:
parent
358bbc4439
commit
4955caafe5
9 changed files with 173 additions and 67 deletions
|
@ -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 \
|
||||
\
|
||||
|
|
|
@ -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 \
|
||||
\
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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 <string.h>
|
||||
|
@ -40,13 +39,15 @@ static __attribute__ ((used)) const char rcsid[] =
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#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
|
||||
|
|
146
libs/video/renderer/r_dyn_textures.c
Normal file
146
libs/video/renderer/r_dyn_textures.c
Normal file
|
@ -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 <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#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;
|
||||
}
|
Loading…
Reference in a new issue