Texture wrap/filter API issues
tromero opened this issue · comments
When a texture is used, such as when drawing a Bitmap
, the texture.filter
and texture.wrap
values on that texture get overwritten by values from the Drawable
's smooth
and tileWrap
properties. This was unexpected and put me in situations where I was assigning texture sampler settings that did nothing, and were instead being overwritten every frame by a prior unrelated Bitmap's draw. This is because the texture was assigned as a secondary texture on a shader used by SpriteBatch
, meaning the SpriteBatch
's tileWrap
setting was only stomping the wrap property of the SpriteBatch
's assigned texture, and not the extra texture used by the shader.
This splat happens in RenderContext.hx in beforeDraw
.
texture.filter = (currentObj.smooth == null ? defaultSmooth : (currentObj.smooth:Bool)) ? Linear : Nearest;
texture.wrap = currentObj.tileWrap && (currentObj.filter == null || inFilter != null) ? Repeat : Clamp;
I think the existence of these settings on the Drawable
is unconventional and unexpected and would prefer to set them once on texture load and never again. The inconsistent naming scheme also bothers me.
Some possible adjustments:
- eliminating the
Drawable
'ssmooth
andtileWrap
properties, so there is always one clear thing to assign - restoring the settings on the texture to what they were before they were squashed, to prevent situations where a
Bitmap
changes what a laterSpriteBatch
does.