2001-05-09 05:41:34 +00:00
|
|
|
/*
|
|
|
|
gl_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
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2001-12-19 04:03:57 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
2001-05-09 05:41:34 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2012-01-21 10:13:01 +00:00
|
|
|
#include "QF/image.h"
|
2001-08-22 11:00:25 +00:00
|
|
|
#include "QF/qtypes.h"
|
2001-06-24 09:25:55 +00:00
|
|
|
#include "QF/GL/defines.h"
|
|
|
|
#include "QF/GL/funcs.h"
|
2003-01-06 18:28:13 +00:00
|
|
|
#include "QF/GL/qf_textures.h"
|
2001-09-04 10:32:51 +00:00
|
|
|
#include "QF/GL/qf_vid.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2012-02-14 08:28:09 +00:00
|
|
|
#include "r_internal.h"
|
2012-01-21 10:13:01 +00:00
|
|
|
|
2022-03-15 04:29:05 +00:00
|
|
|
GLuint gl_part_tex;
|
2012-02-17 09:33:07 +00:00
|
|
|
static GLint part_tex_internal_format = 2;
|
2001-05-09 05:41:34 +00:00
|
|
|
|
|
|
|
|
2001-12-19 04:03:57 +00:00
|
|
|
static void
|
|
|
|
GDT_InitParticleTexture (void)
|
|
|
|
{
|
|
|
|
byte data[64][64][2];
|
|
|
|
|
|
|
|
memset (data, 0, sizeof (data));
|
|
|
|
|
2022-03-15 04:29:05 +00:00
|
|
|
qfglGenTextures (1, &gl_part_tex);
|
2012-02-17 09:33:07 +00:00
|
|
|
qfglBindTexture (GL_TEXTURE_2D, gl_part_tex);
|
2001-12-19 04:03:57 +00:00
|
|
|
qfglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
qfglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
2003-02-06 21:47:33 +00:00
|
|
|
qfglTexImage2D (GL_TEXTURE_2D, 0, part_tex_internal_format, 64, 64, 0, GL_LUMINANCE_ALPHA,
|
2001-12-19 04:03:57 +00:00
|
|
|
GL_UNSIGNED_BYTE, data);
|
|
|
|
}
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
static void
|
|
|
|
GDT_InitDotParticleTexture (void)
|
|
|
|
{
|
2012-01-21 10:13:01 +00:00
|
|
|
tex_t *tex;
|
|
|
|
|
|
|
|
tex = R_DotParticleTexture ();
|
2001-12-19 04:03:57 +00:00
|
|
|
qfglTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 32, 32, GL_LUMINANCE_ALPHA,
|
2012-01-21 10:13:01 +00:00
|
|
|
GL_UNSIGNED_BYTE, tex->data);
|
|
|
|
free (tex);
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
GDT_InitSparkParticleTexture (void)
|
|
|
|
{
|
2012-01-21 10:13:01 +00:00
|
|
|
tex_t *tex;
|
|
|
|
|
|
|
|
tex = R_SparkParticleTexture ();
|
2001-12-19 04:03:57 +00:00
|
|
|
qfglTexSubImage2D (GL_TEXTURE_2D, 0, 32, 0, 32, 32, GL_LUMINANCE_ALPHA,
|
2012-01-21 10:13:01 +00:00
|
|
|
GL_UNSIGNED_BYTE, tex->data);
|
|
|
|
free (tex);
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
GDT_InitSmokeParticleTexture (void)
|
|
|
|
{
|
2012-01-21 10:13:01 +00:00
|
|
|
tex_t *tex;
|
|
|
|
|
|
|
|
tex = R_SmokeParticleTexture ();
|
2001-12-19 04:03:57 +00:00
|
|
|
qfglTexSubImage2D (GL_TEXTURE_2D, 0, 0, 32, 32, 32, GL_LUMINANCE_ALPHA,
|
2012-01-21 10:13:01 +00:00
|
|
|
GL_UNSIGNED_BYTE, tex->data);
|
|
|
|
free (tex);
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
|
|
|
|
2001-09-24 17:52:13 +00:00
|
|
|
void
|
|
|
|
GDT_Init (void)
|
2001-05-09 05:41:34 +00:00
|
|
|
{
|
2003-02-06 21:47:33 +00:00
|
|
|
if (gl_feature_mach64)
|
|
|
|
part_tex_internal_format = 4;
|
2001-12-19 04:03:57 +00:00
|
|
|
GDT_InitParticleTexture ();
|
2001-09-24 17:52:13 +00:00
|
|
|
GDT_InitDotParticleTexture ();
|
|
|
|
GDT_InitSparkParticleTexture ();
|
|
|
|
GDT_InitSmokeParticleTexture ();
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|