First real texture support function for glsl.

This commit is contained in:
Bill Currie 2011-12-26 18:34:51 +09:00
parent 42034acc03
commit e2a8de33cc
4 changed files with 71 additions and 35 deletions

View file

@ -31,28 +31,9 @@
#include "QF/qtypes.h"
#define MAX_GLTEXTURES 2048
extern int gl_alpha_format;
extern int gl_solid_format;
extern int gl_lightmap_format;
extern int gl_filter_min;
extern int gl_filter_max;
extern qboolean Anisotropy;
extern float aniso;
extern int part_tex;
/*
extern int part_tex_dot;
extern int part_tex_smoke;
extern int part_tex_spark;
*/
void GL_Upload8 (byte *data, int width, int height, qboolean mipmap, qboolean alpha);
void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboolean alpha);
int GL_LoadQuakeTexture (const char *identifier, int width, int height,
byte *data);
int GL_LoadTexture (const char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha, int bytesperpixel);
int GL_FindTexture (const char *identifier);
void GL_TextureMode_f (void);
void GDT_Init (void);

View file

@ -5,6 +5,9 @@ INCLUDES= -I$(top_srcdir)/include $(GLX_CFLAGS)
shader_src= quake2d.frag quaketxt.vert
shader_gen= quake2d.fc quaketxt.vc
glsl_src = \
glsl_draw.c glsl_main.c glsl_particles.c glsl_screen.c glsl_textures.c
if BUILD_GL
noinst_LTLIBRARIES= libglsl.la
BUILT_SOURCES= $(shader_gen)
@ -19,9 +22,6 @@ SUFFICES=.frag .vert .fc .vc
.vert.vc:
sed -e 's/^/"/' -e 's/$$/\\n"/' $< > $@
glsl_src = \
glsl_draw.c glsl_main.c glsl_particles.c glsl_screen.c
libglsl_la_SOURCES= $(glsl_src)
EXTRA_DIST = $(glsl_src) $(shader_src)

View file

@ -40,6 +40,7 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$";
#include "QF/GLSL/defines.h"
#include "QF/GLSL/funcs.h"
#include "QF/GLSL/qf_textures.h"
#include "QF/GLSL/qf_vid.h"
#include "gl_draw.h"
@ -95,7 +96,6 @@ Draw_TextBox (int x, int y, int width, int lines, byte alpha)
VISIBLE void
Draw_Init (void)
{
GLuint tnum;
int i;
int frag, vert;
@ -114,16 +114,7 @@ Draw_Init (void)
if (draw_chars[i] == 0)
draw_chars[i] = 255; // proper transparent color
qfglGenTextures (1, &tnum);
char_texture = tnum;
qfglBindTexture (GL_TEXTURE_2D, char_texture);
qfglTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE,
128, 128, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, draw_chars);
qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
qfglGenerateMipmap (GL_TEXTURE_2D);
char_texture = GL_LoadQuakeTexture ("conchars", 128, 128, draw_chars);
}
static inline void

View file

@ -0,0 +1,64 @@
/*
glsl_textures.c
Texture format setup.
Copyright (C) 1996-1997 Id Software, Inc.
Copyright (C) 2001 Ragnvald Maartmann-Moe IV
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 <stdio.h>
#include "QF/GLSL/defines.h"
#include "QF/GLSL/funcs.h"
#include "QF/GLSL/qf_textures.h"
int
GL_LoadQuakeTexture (const char *identifier, int width, int height, byte *data)
{
GLuint tnum;
qfglGenTextures (1, &tnum);
qfglBindTexture (GL_TEXTURE_2D, tnum);
qfglTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE,
width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
qfglGenerateMipmap (GL_TEXTURE_2D);
return tnum;
}