ref: 45bdbbcb16c1c95b8c7450fd6700c0a32418c98d
parent: 714038d0bce05c734d4e45289ec2bf1174463e4a
author: rodri <rgl@antares-labs.eu>
date: Tue Jul 9 16:56:27 EDT 2024
texture nomenclature changes. fb format RGBA → XRGB. we are still doing alpha blending, so we use the X chan internally, but we don't care about it when (mem)drawing to the screen.
--- a/camera.c
+++ b/camera.c
@@ -34,7 +34,7 @@
Color c;
va = getvattr(&sp->v, "dir");
- c = cubemaptexture(sp->su->camera->scene->skybox, va->p, neartexsampler);
+ c = samplecubemap(sp->su->camera->scene->skybox, va->p, neartexsampler);
return c;
}
--- a/graphics.h
+++ b/graphics.h
@@ -18,7 +18,7 @@
};
enum {
- RAWTexture,
+ RAWTexture, /* unmanaged */
sRGBTexture,
};
@@ -341,10 +341,10 @@
void freetexture(Texture*);
Color neartexsampler(Texture*, Point2);
Color bilitexsampler(Texture*, Point2);
-Color texture(Texture*, Point2, Color(*)(Texture*, Point2));
+Color sampletexture(Texture*, Point2, Color(*)(Texture*, Point2));
Cubemap *readcubemap(char*[6]);
void freecubemap(Cubemap*);
-Color cubemaptexture(Cubemap*, Point3, Color(*)(Texture*, Point2));
+Color samplecubemap(Cubemap*, Point3, Color(*)(Texture*, Point2));
/* util */
double fmin(double, double);
--- a/render.c
+++ b/render.c
@@ -15,10 +15,10 @@
{
uchar cbuf[4];
- cbuf[0] = fclamp(c.a, 0, 1)*0xFF;
- cbuf[1] = fclamp(c.b, 0, 1)*0xFF;
- cbuf[2] = fclamp(c.g, 0, 1)*0xFF;
- cbuf[3] = fclamp(c.r, 0, 1)*0xFF;
+ cbuf[0] = fclamp(c.b, 0, 1)*0xFF;
+ cbuf[1] = fclamp(c.g, 0, 1)*0xFF;
+ cbuf[2] = fclamp(c.r, 0, 1)*0xFF;
+ cbuf[3] = fclamp(c.a, 0, 1)*0xFF;
return cbuf[3]<<24 | cbuf[2]<<16 | cbuf[1]<<8 | cbuf[0];
}
@@ -27,10 +27,10 @@
{
Color c;
- c.a = (l & 0xff)/255.0;
- c.b = (l>>8 & 0xff)/255.0;
- c.g = (l>>16 & 0xff)/255.0;
- c.r = (l>>24 & 0xff)/255.0;
+ c.b = (l & 0xff)/255.0;
+ c.g = (l>>8 & 0xff)/255.0;
+ c.r = (l>>16 & 0xff)/255.0;
+ c.a = (l>>24 & 0xff)/255.0;
return c;
}
@@ -52,6 +52,7 @@
ulong *dst;
dst = fb->nb;
+ c.a = 1;
dst[Dx(fb->r)*p.y + p.x] = col2ul(c);
}
@@ -222,7 +223,6 @@
fsp.p = p;
c = params->fshader(&fsp);
pixel(params->fb, p, c);
- fsp.v.n.w = 1;
pixeln(params->fb, p, fsp.v.n);
delvattrs(&fsp.v);
}
--- a/texture.c
+++ b/texture.c
@@ -106,7 +106,7 @@
}
Color
-texture(Texture *t, Point2 uv, Color(*sampler)(Texture*,Point2))
+sampletexture(Texture *t, Point2 uv, Color(*sampler)(Texture*,Point2))
{
return sampler(t, uv);
}
@@ -173,7 +173,7 @@
* - “Cubemap Texture Selection”, OpenGL ES 2.0 § 3.7.5, November 2010
*/
Color
-cubemaptexture(Cubemap *cm, Point3 d, Color(*sampler)(Texture*,Point2))
+samplecubemap(Cubemap *cm, Point3 d, Color(*sampler)(Texture*,Point2))
{
Point2 uv;
double ax, ay, az, ma, sc, tc;