X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2F3dgfx.c;h=47b3830ee38fcc190b04a67fbd6c1481e6123b93;hp=d7e2e41704067282c433d3ddbd467c9bc82ea27c;hb=07ce18b114e1e01b2a85a04079128f3eb754de1d;hpb=f7789d3011a5ac2620a2f7732a389963f790fd85 diff --git a/src/3dgfx.c b/src/3dgfx.c index d7e2e41..47b3830 100644 --- a/src/3dgfx.c +++ b/src/3dgfx.c @@ -91,9 +91,9 @@ void g3d_framebuffer(int width, int height, void *pixels) st->height = height; st->pixels = pixels; - pimg_fb.pixels = pixels; - pimg_fb.width = width; - pimg_fb.height = height; + pfill_fb.pixels = pixels; + pfill_fb.width = width; + pfill_fb.height = height; } void g3d_enable(unsigned int opt) @@ -340,6 +340,33 @@ void g3d_mtl_shininess(float shin) st->mtl.shin = shin; } +static INLINE int calc_shift(unsigned int x) +{ + int res = -1; + while(x) { + x >>= 1; + ++res; + } + return res; +} + +static INLINE int calc_mask(unsigned int x) +{ + return x - 1; +} + +void g3d_set_texture(int xsz, int ysz, void *pixels) +{ + pfill_tex.pixels = pixels; + pfill_tex.width = xsz; + pfill_tex.height = ysz; + + pfill_tex.xshift = calc_shift(xsz); + pfill_tex.yshift = calc_shift(ysz); + pfill_tex.xmask = calc_mask(xsz); + pfill_tex.ymask = calc_mask(ysz); +} + void g3d_draw(int prim, const struct g3d_vertex *varr, int varr_size) { g3d_draw_indexed(prim, varr, varr_size, 0, 0);