Commit 7b325f1c authored by Richard Gobeille's avatar Richard Gobeille
Browse files

engine: add SAMPLER_NEAREST_NEAREST_CLAMP and SAMPLER_NEAREST_NEAREST_WRAP,...

engine: add SAMPLER_NEAREST_NEAREST_CLAMP and SAMPLER_NEAREST_NEAREST_WRAP, samplers which use GL_NEAREST_MIPMAP_NEAREST for the minification filter

It looks like mipmapping actually works with the indexed color texture shader in Polymost as-is, but it doesn't work with Polymer art mapping so we're disabling it there.
parent b3a831c6
......@@ -35,6 +35,8 @@ enum glsamplertype
SAMPLER_NEAREST_WRAP,
SAMPLER_LINEAR_CLAMP,
SAMPLER_LINEAR_WRAP,
SAMPLER_NEAREST_NEAREST_CLAMP,
SAMPLER_NEAREST_NEAREST_WRAP,
SAMPLER_CLAMP,
SAMPLER_WRAP_T,
SAMPLER_WRAP_S,
......
......@@ -228,6 +228,18 @@ void buildgl_resetSamplerObjects(void)
glSamplerParameteri(s, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glSamplerParameteri(s, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
s = samplerObjectIDs[SAMPLER_NEAREST_NEAREST_CLAMP];
glSamplerParameteri(s, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glSamplerParameteri(s, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glSamplerParameteri(s, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glSamplerParameteri(s, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glSamplerParameteri(s, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1);
s = samplerObjectIDs[SAMPLER_NEAREST_NEAREST_WRAP];
glSamplerParameteri(s, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glSamplerParameteri(s, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glSamplerParameteri(s, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1);
s = samplerObjectIDs[SAMPLER_DEPTH];
glSamplerParameteri(s, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
glSamplerParameteri(s, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
......@@ -253,11 +265,11 @@ void buildgl_bindSamplerObject(int texunit, int32_t pth_method)
samplerid = SAMPLER_WRAP_T;
break;
case PTH_INDEXED:
samplerid = SAMPLER_NEAREST_WRAP;
samplerid = videoGetRenderMode() == REND_POLYMER ? SAMPLER_NEAREST_WRAP : SAMPLER_NEAREST_NEAREST_WRAP;
break;
case PTH_INDEXED|PTH_CLAMPED:
case PTH_CLAMPED:
samplerid = SAMPLER_NEAREST_CLAMP;
samplerid = videoGetRenderMode() == REND_POLYMER ? SAMPLER_NEAREST_CLAMP : SAMPLER_NEAREST_NEAREST_CLAMP;
break;
case PTH_HIGHTILE:
samplerid = SAMPLER_WRAP_BOTH;
......
......@@ -1858,7 +1858,7 @@ void uploadtextureindexed(int32_t doalloc, vec2_t offset, vec2_t siz, intptr_t t
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, siz.y, siz.x, 0, GL_RED, GL_UNSIGNED_BYTE, (void*) tile);
......@@ -9651,7 +9651,7 @@ int32_t polymost_printtext256(int32_t xpos, int32_t ypos, int16_t col, int16_t b
polymostSet2dView(); // disables blending, texturing, and depth testing
buildgl_bindSamplerObject(0, PTH_INDEXED|PTH_CLAMPED);
buildgl_bindSamplerObject(0, 0);
buildgl_setDisabled(GL_ALPHA_TEST);
glDepthMask(GL_FALSE); // disable writing to the z-buffer
......@@ -9825,7 +9825,7 @@ static int osdcmd_cvar_set_polymost(osdcmdptr_t parm)
r_downsizevar = r_downsize;
}
else if (!Bstrcasecmp(parm->name, "r_anisotropy"))
else if (!Bstrcasecmp(parm->name, "r_anisotropy") || !Bstrcasecmp(parm->name, "r_usesamplerobjects"))
gltexapplyprops();
else if (!Bstrcasecmp(parm->name, "r_texfilter"))
gltexturemode(parm);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment