mirror of
https://github.com/libretro/libretro-tyrquake.git
synced 2024-11-27 02:00:41 +00:00
qpic: pass in a qpic8_t to QPic_8to32
GL_Upload8 also takes the pic8_t directly now. Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
parent
cee4b1e31c
commit
4b95f0de20
@ -216,7 +216,7 @@ Scrap_Flush(GLuint texnum)
|
||||
for (i = 0; i < MAX_SCRAPS; i++, scrap++) {
|
||||
if (scrap->dirty && texnum == scrap->glnum) {
|
||||
GL_Bind(scrap->glnum);
|
||||
GL_Upload8(scrap->texels, BLOCK_WIDTH, BLOCK_HEIGHT, false, true);
|
||||
GL_Upload8(&scrap->pic, false);
|
||||
scrap->dirty = false;
|
||||
return;
|
||||
}
|
||||
@ -1113,18 +1113,17 @@ GL_Upload8
|
||||
===============
|
||||
*/
|
||||
void
|
||||
GL_Upload8(const byte *data, int width, int height, qboolean mipmap,
|
||||
qboolean alpha)
|
||||
GL_Upload8(const qpic8_t *pic, qboolean mipmap)
|
||||
{
|
||||
qpic32_t *pic;
|
||||
qpic32_t *pic32;
|
||||
int mark;
|
||||
|
||||
mark = Hunk_LowMark();
|
||||
|
||||
pic = QPic32_Alloc(width, height);
|
||||
QPic_8to32(data, width, height, width, alpha, pic);
|
||||
pic32 = QPic32_Alloc(pic->width, pic->height);
|
||||
QPic_8to32(pic, pic32);
|
||||
|
||||
GL_Upload32(pic, mipmap, alpha);
|
||||
GL_Upload32(pic32, mipmap, pic->alpha);
|
||||
|
||||
Hunk_FreeToLowMark(mark);
|
||||
}
|
||||
@ -1141,6 +1140,7 @@ GL_LoadTexture(const char *identifier, int width, int height,
|
||||
int i;
|
||||
gltexture_t *glt;
|
||||
unsigned short crc;
|
||||
qpic8_t pic;
|
||||
|
||||
crc = CRC_Block(data, width * height);
|
||||
|
||||
@ -1174,14 +1174,20 @@ GL_LoadTexture(const char *identifier, int width, int height,
|
||||
glt->height = height;
|
||||
glt->mipmap = mipmap;
|
||||
|
||||
pic.width = width;
|
||||
pic.height = height;
|
||||
pic.stride = width;
|
||||
pic.alpha = alpha;
|
||||
pic.pixels = data; /* FIXME - const... */
|
||||
|
||||
#ifdef NQ_HACK
|
||||
if (!isDedicated) {
|
||||
GL_Bind(glt->texnum);
|
||||
GL_Upload8(data, width, height, mipmap, alpha);
|
||||
GL_Upload8(&pic, mipmap);
|
||||
}
|
||||
#else
|
||||
GL_Bind(glt->texnum);
|
||||
GL_Upload8(data, width, height, mipmap, alpha);
|
||||
GL_Upload8(&pic, mipmap);
|
||||
#endif
|
||||
|
||||
return glt->texnum;
|
||||
|
@ -395,30 +395,42 @@ A sky texture is 256*128, with the right side being a masked overlay
|
||||
void
|
||||
R_InitSky(texture_t *mt)
|
||||
{
|
||||
const byte *src = (const byte *)mt + mt->offsets[0];
|
||||
qpic32_t *pic;
|
||||
byte *src = (byte *)mt + mt->offsets[0];
|
||||
qpic8_t pic;
|
||||
qpic32_t *pic32;
|
||||
int mark;
|
||||
|
||||
/* Set up the pic to describe the sky texture */
|
||||
pic.width = 128;
|
||||
pic.height = 128;
|
||||
pic.stride = 256;
|
||||
|
||||
mark = Hunk_LowMark();
|
||||
pic = QPic32_Alloc(128, 128);
|
||||
pic32 = QPic32_Alloc(128, 128);
|
||||
|
||||
/* Create the solid layer */
|
||||
QPic_8to32(src + 128, 128, 128, 256, false, pic);
|
||||
pic.alpha = false;
|
||||
pic.pixels = src + 128;
|
||||
QPic_8to32(&pic, pic32);
|
||||
|
||||
glGenTextures(1, &mt->gl_texturenum);
|
||||
GL_Bind(mt->gl_texturenum);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, gl_solid_format,
|
||||
128, 128, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, pic->pixels);
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, pic32->pixels);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
/* Create the alpha layer */
|
||||
QPic_8to32(src, 128, 128, 256, true, pic);
|
||||
pic.alpha = true;
|
||||
pic.pixels = src;
|
||||
QPic_8to32(&pic, pic32);
|
||||
|
||||
glGenTextures(1, &mt->gl_texturenum_alpha);
|
||||
GL_Bind(mt->gl_texturenum_alpha);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, gl_alpha_format,
|
||||
128, 128, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, pic->pixels);
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, pic32->pixels);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
|
@ -133,25 +133,28 @@ QPic32_AlphaFix(qpic32_t *pic)
|
||||
}
|
||||
|
||||
void
|
||||
QPic_8to32(const byte *in, int width, int height, int stride, qboolean alpha,
|
||||
qpic32_t *out)
|
||||
QPic_8to32(const qpic8_t *in, qpic32_t *out)
|
||||
{
|
||||
qpixel32_t *pixel = out->pixels;
|
||||
const int width = in->width;
|
||||
const int height = in->height;
|
||||
const int stride = in->stride;
|
||||
const byte *in_p = in->pixels;
|
||||
qpixel32_t *out_p = out->pixels;
|
||||
int x, y;
|
||||
|
||||
if (alpha) {
|
||||
/* index 0 is a transparent colour */
|
||||
if (in->alpha) {
|
||||
/* index 255 is transparent */
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++, in++, pixel++)
|
||||
pixel->rgba = (*in) ? d_8to24table[*in] : 0;
|
||||
in += stride - width;
|
||||
for (x = 0; x < width; x++, in_p++, out_p++)
|
||||
out_p->rgba = (*in_p == 255) ? 0 : d_8to24table[*in_p];
|
||||
in_p += stride - width;
|
||||
}
|
||||
QPic32_AlphaFix(out);
|
||||
} else {
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++, in++, pixel++)
|
||||
pixel->rgba = d_8to24table[*in];
|
||||
in += stride - width;
|
||||
for (x = 0; x < width; x++, in_p++, out_p++)
|
||||
out_p->rgba = d_8to24table[*in_p];
|
||||
in_p += stride - width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#include "client.h"
|
||||
#include "model.h"
|
||||
#include "protocol.h"
|
||||
#include "qpic.h"
|
||||
|
||||
#ifndef APIENTRY
|
||||
#define APIENTRY
|
||||
@ -59,8 +60,7 @@ extern unsigned char d_15to8table[65536];
|
||||
|
||||
extern float gldepthmin, gldepthmax;
|
||||
|
||||
void GL_Upload8(const byte *data, int width, int height,
|
||||
qboolean mipmap, qboolean alpha);
|
||||
void GL_Upload8(const qpic8_t *pic, qboolean mipmap);
|
||||
int GL_LoadTexture(const char *identifier, int width, int height,
|
||||
const byte *data, qboolean mipmap, qboolean alpha);
|
||||
int GL_FindTexture(const char *identifier);
|
||||
|
@ -57,8 +57,7 @@ typedef struct {
|
||||
qpic32_t *QPic32_Alloc(int width, int height);
|
||||
|
||||
/* Create 32 bit texture from 8 bit source */
|
||||
void QPic_8to32(const byte *in, int width, int height, int stride,
|
||||
qboolean alpha, qpic32_t *out);
|
||||
void QPic_8to32(const qpic8_t *in, qpic32_t *out);
|
||||
|
||||
/* Stretch from in size to out size */
|
||||
void QPic32_Stretch(const qpic32_t *in, qpic32_t *out);
|
||||
|
Loading…
Reference in New Issue
Block a user