TINYGL: Move texture resampling from create time to render time

Thanks to pixel repacking using cpu data cache, this has a low runtime
cost even for TGL_LINEAR.
Adds support for TGL_NEAREST.
Adds support for TGL_MIRRORED_REPEAT, TGL_CLAMP_TO_EDGE and TGL_REPEAT.
Also, add support for more texture clamping and resampling options.

Mipmaps are not supported, although their sampling modes will be
applied - but to the full-size texture instead of selected mipmap.

Note: Texture sampler is still chosen at texture creation time.
This commit is contained in:
Vincent Pelletier 2017-05-06 14:17:35 +00:00 committed by Paweł Kołodziejski
parent bd37cd3012
commit f8c72b5967
12 changed files with 404 additions and 73 deletions

View file

@ -411,7 +411,7 @@ void gl_draw_triangle_fill(GLContext *c, GLVertex *p0, GLVertex *p1, GLVertex *p
#ifdef TINYGL_PROFILE
count_triangles_textured++;
#endif
c->fb->setTexture(c->current_texture->images[0].pixmap);
c->fb->setTexture(c->current_texture->images[0].pixmap, c->texture_wrap_s, c->texture_wrap_t);
if (c->current_shade_model == TGL_SMOOTH) {
c->fb->fillTriangleTextureMappingPerspectiveSmooth(&p0->zp, &p1->zp, &p2->zp);
} else {