Allow mods to provide raw 8bit paletted image data.
This commit is contained in:
parent
0a7f0cd7d4
commit
39e921624f
3 changed files with 22 additions and 6 deletions
|
@ -2342,9 +2342,12 @@ uploadfmt_t PR_TranslateTextureFormat(int qcformat)
|
|||
case 13: return PTI_RG8;
|
||||
case 14: return PTI_RGB32F;
|
||||
|
||||
case 15: return TF_8PAL24;
|
||||
case 16: return TF_8PAL32;
|
||||
|
||||
default:
|
||||
qcformat = -qcformat;
|
||||
if (qcformat < PTI_MAX)
|
||||
if ((unsigned int)qcformat < PTI_MAX)
|
||||
return qcformat;
|
||||
return PTI_INVALID;
|
||||
}
|
||||
|
@ -2371,6 +2374,9 @@ int PR_UnTranslateTextureFormat(uploadfmt_t pixelformat)
|
|||
case PTI_RG8: return 13;
|
||||
case PTI_RGB32F: return 14;
|
||||
|
||||
case TF_8PAL24: return 15;
|
||||
case TF_8PAL32: return 16;
|
||||
|
||||
default:return -pixelformat;
|
||||
}
|
||||
}
|
||||
|
@ -2615,7 +2621,7 @@ void QCBUILTIN PF_R_SetViewFlag(pubprogfuncs_t *prinst, struct globalvars_s *pr_
|
|||
Q_strncpyz(r_refdef.rt_destcolour[i].texname, PR_GetStringOfs(prinst, OFS_PARM1), sizeof(r_refdef.rt_destcolour[i].texname));
|
||||
if (prinst->callargc >= 4 && *r_refdef.rt_destcolour[i].texname)
|
||||
{
|
||||
float fmt = G_FLOAT(OFS_PARM2);
|
||||
int fmt = G_FLOAT(OFS_PARM2);
|
||||
float *size = G_VECTOR(OFS_PARM3);
|
||||
if (fmt < 0)
|
||||
R2D_RT_Configure(r_refdef.rt_destcolour[i].texname, size[0], size[1], PR_TranslateTextureFormat(-fmt), (RT_IMAGEFLAGS&~IF_LINEAR)|IF_NEAREST);
|
||||
|
@ -2629,7 +2635,7 @@ void QCBUILTIN PF_R_SetViewFlag(pubprogfuncs_t *prinst, struct globalvars_s *pr_
|
|||
Q_strncpyz(r_refdef.rt_sourcecolour.texname, PR_GetStringOfs(prinst, OFS_PARM1), sizeof(r_refdef.rt_sourcecolour));
|
||||
if (prinst->callargc >= 4 && *r_refdef.rt_sourcecolour.texname)
|
||||
{
|
||||
float fmt = G_FLOAT(OFS_PARM2);
|
||||
int fmt = G_FLOAT(OFS_PARM2);
|
||||
float *size = G_VECTOR(OFS_PARM3);
|
||||
if (fmt < 0)
|
||||
R2D_RT_Configure(r_refdef.rt_sourcecolour.texname, size[0], size[1], PR_TranslateTextureFormat(-fmt), (RT_IMAGEFLAGS&~IF_LINEAR)|IF_NEAREST);
|
||||
|
@ -2642,7 +2648,7 @@ void QCBUILTIN PF_R_SetViewFlag(pubprogfuncs_t *prinst, struct globalvars_s *pr_
|
|||
Q_strncpyz(r_refdef.rt_depth.texname, PR_GetStringOfs(prinst, OFS_PARM1), sizeof(r_refdef.rt_depth.texname));
|
||||
if (prinst->callargc >= 4 && *r_refdef.rt_depth.texname)
|
||||
{
|
||||
float fmt = G_FLOAT(OFS_PARM2);
|
||||
int fmt = G_FLOAT(OFS_PARM2);
|
||||
float *size = G_VECTOR(OFS_PARM3);
|
||||
if (fmt < 0)
|
||||
R2D_RT_Configure(r_refdef.rt_depth.texname, size[0], size[1], PR_TranslateTextureFormat(-fmt), (RT_IMAGEFLAGS&~IF_LINEAR)|IF_NEAREST);
|
||||
|
@ -2655,7 +2661,7 @@ void QCBUILTIN PF_R_SetViewFlag(pubprogfuncs_t *prinst, struct globalvars_s *pr_
|
|||
Q_strncpyz(r_refdef.rt_ripplemap.texname, PR_GetStringOfs(prinst, OFS_PARM1), sizeof(r_refdef.rt_ripplemap.texname));
|
||||
if (prinst->callargc >= 4 && *r_refdef.rt_ripplemap.texname)
|
||||
{
|
||||
float fmt = G_FLOAT(OFS_PARM2);
|
||||
int fmt = G_FLOAT(OFS_PARM2);
|
||||
float *size = G_VECTOR(OFS_PARM3);
|
||||
if (fmt < 0)
|
||||
R2D_RT_Configure(r_refdef.rt_ripplemap.texname, size[0], size[1], PR_TranslateTextureFormat(-fmt), (RT_IMAGEFLAGS&~IF_LINEAR)|IF_NEAREST);
|
||||
|
|
|
@ -901,17 +901,25 @@ void QCBUILTIN PF_CL_uploadimage (pubprogfuncs_t *prinst, struct globalvars_s *p
|
|||
}
|
||||
else
|
||||
{
|
||||
void *palette = NULL;
|
||||
unsigned int blockbytes, blockwidth, blockheight, blockdepth;
|
||||
//get format info
|
||||
Image_BlockSizeForEncoding(format, &blockbytes, &blockwidth, &blockheight, &blockdepth);
|
||||
//round up as appropriate
|
||||
blockwidth = ((width+blockwidth-1)/blockwidth)*blockwidth;
|
||||
blockheight = ((height+blockheight-1)/blockheight)*blockheight;
|
||||
|
||||
//we do allow palettes on the end.
|
||||
if (format == TF_8PAL24)
|
||||
size -= 768, palette = (qbyte*)imgptr+size, blockbytes=1;
|
||||
else if (format == TF_8PAL32)
|
||||
size -= 1024, palette = (qbyte*)imgptr+size, blockbytes=1;
|
||||
|
||||
if (size != blockwidth*blockheight*blockbytes)
|
||||
G_INT(OFS_RETURN) = 0; //size isn't right. which means the pointer might be invalid too.
|
||||
else
|
||||
{
|
||||
Image_Upload(tid, format, imgptr, NULL, width, height, 1, RT_IMAGEFLAGS);
|
||||
Image_Upload(tid, format, imgptr, palette, width, height, 1, RT_IMAGEFLAGS);
|
||||
tid->width = width;
|
||||
tid->height = height;
|
||||
G_INT(OFS_RETURN) = 1;
|
||||
|
|
|
@ -14062,6 +14062,8 @@ void PR_DumpPlatform_f(void)
|
|||
{"IMGFMT_R4G4B4A4", "const float", CS|MENU, D("Packed 16-bit colour pixel format, with alpha"), 12},
|
||||
{"IMGFMT_R8G8", "const float", CS|MENU, D("16-bit two-channel pixel format."), 13},
|
||||
{"IMGFMT_R32G32B32F", "const float", CS|MENU, D("A pixel format that matches QC's vector type."), 14},
|
||||
{"IMGFMT_P8_RGB8", "const float", CS|MENU, D("8bit paletted format, with 768 bytes of RGB8 palette directly following the image data. Exclusively for r_uploadimage."), 15},
|
||||
{"IMGFMT_P8_RGBA8", "const float", CS|MENU, D("8bit paletted format, with 1024 bytes of RGBA8 palette directly following the image data. Exclusively for r_uploadimage."), 16},
|
||||
|
||||
{"RF_VIEWMODEL", "const float", CS, D("Specifies that the entity is a view model, and that its origin is relative to the current view position. These entities are also subject to viewweapon bob."), CSQCRF_VIEWMODEL},
|
||||
{"RF_EXTERNALMODEL", "const float", CS, D("Specifies that this entity should be displayed in mirrors (and may still cast shadows), but will not otherwise be visible."), CSQCRF_EXTERNALMODEL},
|
||||
|
|
Loading…
Reference in a new issue