0
0
Fork 0
mirror of https://github.com/nzp-team/dquakeplus.git synced 2025-03-02 23:12:08 +00:00

Convert Quake Palette assets to RGBA

This commit is contained in:
Ian 2023-08-27 15:16:51 -04:00
parent 519dccf106
commit 2c84da2295
3 changed files with 34 additions and 16 deletions

View file

@ -25,6 +25,8 @@ extern "C"
#include "../quakedef.h" #include "../quakedef.h"
} }
#include <pspgu.h>
cvar_t jpeg_compression_level = {"jpeg_compression_level", "75"}; cvar_t jpeg_compression_level = {"jpeg_compression_level", "75"};
int image_width; int image_width;
@ -1085,3 +1087,28 @@ int loadtextureimage (char* filename, int matchwidth, int matchheight, qboolean
return texture_index; return texture_index;
} }
/*
=============
loadrgbafrompal
=============
*/
int loadrgbafrompal (char* name, int width, int height, byte* data)
{
int pixels = width * height;
byte* rgbadata = (byte*)Q_malloc(pixels * 4);
for(int i = 0; i < pixels; i++) {
byte palette_index = data[i];
rgbadata[i * 4] = host_basepal[palette_index * 3 + 0];
rgbadata[i * 4 + 1] = host_basepal[palette_index * 3 + 1];
rgbadata[i * 4 + 2] = host_basepal[palette_index * 3 + 2];
rgbadata[i * 4 + 3] = 255; // Set alpha to opaque
}
int ret = GL_LoadImages(name, width, height, rgbadata, qtrue, GU_LINEAR, 0, 4);
free(rgbadata);
return ret;
}

View file

@ -29,3 +29,4 @@ int Image_WritePNGPLTE (char *filename, int compression, byte *pixels, int width
int Image_WriteJPEG (char *filename, int compression, byte *pixels, int width, int height); int Image_WriteJPEG (char *filename, int compression, byte *pixels, int width, int height);
int Image_WritePCX (char *filename, byte *data, int width, int height, byte *palette); int Image_WritePCX (char *filename, byte *data, int width, int height, byte *palette);
int loadrgbafrompal (char* name, int width, int height, byte* data);

View file

@ -34,6 +34,7 @@ extern "C"
#include "video_hardware_fullbright.h" #include "video_hardware_fullbright.h"
#include "video_hardware_hlmdl.h" #include "video_hardware_hlmdl.h"
#include "video_hardware_images.h"
#include <list> #include <list>
@ -2304,22 +2305,11 @@ void *Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype)
{ {
sprintf (name, "%s_%i", loadmodel->name, i); sprintf (name, "%s_%i", loadmodel->name, i);
if(mod_h2)
{ pheader->gl_texturenum[i][0] =
pheader->gl_texturenum[i][0] = pheader->gl_texturenum[i][1] =
pheader->gl_texturenum[i][1] = pheader->gl_texturenum[i][2] =
pheader->gl_texturenum[i][2] = pheader->gl_texturenum[i][3] = loadrgbafrompal(name, pheader->skinwidth, pheader->skinheight, (byte*)(pskintype+1));
pheader->gl_texturenum[i][3] =
GL_LoadPalTex (name, pheader->skinwidth, pheader->skinheight, (byte *)(pskintype + 1) , qtrue, GU_LINEAR, 0, NULL, PAL_H2);
}
else
{
pheader->gl_texturenum[i][0] =
pheader->gl_texturenum[i][1] =
pheader->gl_texturenum[i][2] =
pheader->gl_texturenum[i][3] =
GL_LoadTexture (name, pheader->skinwidth, pheader->skinheight, (byte *)(pskintype + 1) , qtrue, GU_LINEAR, 0);
}
} }
pskintype = (daliasskintype_t *)((byte *)(pskintype+1) + s); pskintype = (daliasskintype_t *)((byte *)(pskintype+1) + s);
/* Crow_bar Memory Leak Fixed One Work not used */ /* Crow_bar Memory Leak Fixed One Work not used */