projects
/
voxscape
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ef75bad
)
fix red/blue order (imago reads BGRA, output expects RGBA)
author
John Tsiombikas
<nuclear@member.fsf.org>
Mon, 17 Oct 2022 21:32:12 +0000
(
00:32
+0300)
committer
John Tsiombikas
<nuclear@member.fsf.org>
Mon, 17 Oct 2022 21:32:12 +0000
(
00:32
+0300)
src/voxscape.c
patch
|
blob
|
history
diff --git
a/src/voxscape.c
b/src/voxscape.c
index
7d39a8b
..
54c0b10
100644
(file)
--- a/
src/voxscape.c
+++ b/
src/voxscape.c
@@
-116,8
+116,10
@@
struct voxscape *vox_open(const char *hfile, const char *cfile)
memcpy(vox->height, hpix, width * height);
memcpy(vox->height, hpix, width * height);
+ /* swap r/b and discard alpha while copying */
for(i=0; i<width*height; i++) {
for(i=0; i<width*height; i++) {
- vox->color[i] = cpix[i] & 0xffffff; /* discard alpha */
+ vox->color[i] = (cpix[i] & 0xff00) | ((cpix[i] & 0xff) << 16) |
+ ((cpix[i] & 0xff0000) >> 16);
}
img_free_pixels(hpix);
}
img_free_pixels(hpix);
@@
-141,9
+143,9
@@
void vox_fog(struct voxscape *vox, int zstart, uint32_t color)
{
vox->zfog = zstart;
{
vox->zfog = zstart;
- vox->fogcolor[0] = color >> 16;
+ vox->fogcolor[2] = color >> 16;
vox->fogcolor[1] = (color >> 8) & 0xff;
vox->fogcolor[1] = (color >> 8) & 0xff;
- vox->fogcolor[2] = color & 0xff;
+ vox->fogcolor[0] = color & 0xff;
}
#define H(x, y) \
}
#define H(x, y) \
@@
-350,12
+352,12
@@
void vox_sky_grad(struct voxscape *vox, uint32_t chor, uint32_t ctop)
grad = alloca(vox->fbheight * sizeof *grad);
grad = alloca(vox->fbheight * sizeof *grad);
- r0 = ctop >> 16;
+ b0 = ctop >> 16;
g0 = (ctop >> 8) & 0xff;
g0 = (ctop >> 8) & 0xff;
- b0 = ctop & 0xff;
- r1 = chor >> 16;
+ r0 = ctop & 0xff;
+ b1 = chor >> 16;
g1 = (chor >> 8) & 0xff;
g1 = (chor >> 8) & 0xff;
- b1 = chor & 0xff;
+ r1 = chor & 0xff;
for(i=0; i<d; i++) {
t = (i << 16) / d;
for(i=0; i<d; i++) {
t = (i << 16) / d;
@@
-380,28
+382,28
@@
static uint32_t lerp_rgb(int r0, int g0, int b0, int r1, int g1, int b1, int32_t
int r = XLERP(r0, r1, t, 16);
int g = XLERP(g0, g1, t, 16);
int b = XLERP(b0, b1, t, 16);
int r = XLERP(r0, r1, t, 16);
int g = XLERP(g0, g1, t, 16);
int b = XLERP(b0, b1, t, 16);
- return (r << 16) | (g << 8) | b;
+ return (b << 16) | (g << 8) | r;
}
static uint32_t lerp_color(uint32_t ca, uint32_t cb, int32_t t)
{
int r0, g0, b0, r1, g1, b1;
}
static uint32_t lerp_color(uint32_t ca, uint32_t cb, int32_t t)
{
int r0, g0, b0, r1, g1, b1;
- r0 = ca >> 16;
+ b0 = ca >> 16;
g0 = (ca >> 8) & 0xff;
g0 = (ca >> 8) & 0xff;
- b0 = ca & 0xff;
- r1 = cb >> 16;
+ r0 = ca & 0xff;
+ b1 = cb >> 16;
g1 = (cb >> 8) & 0xff;
g1 = (cb >> 8) & 0xff;
- b1 = cb & 0xff;
+ r1 = cb & 0xff;
return lerp_rgb(r0, g0, b0, r1, g1, b1, t);
}
static uint32_t lerp_pcol_rgb(uint32_t pcol, int r, int g, int b, int32_t t)
{
return lerp_rgb(r0, g0, b0, r1, g1, b1, t);
}
static uint32_t lerp_pcol_rgb(uint32_t pcol, int r, int g, int b, int32_t t)
{
- int r0 = pcol >> 16;
+ int b0 = pcol >> 16;
int g0 = (pcol >> 8) & 0xff;
int g0 = (pcol >> 8) & 0xff;
- int b0 = pcol & 0xff;
+ int r0 = pcol & 0xff;
return lerp_rgb(r0, g0, b0, r, g, b, t);
}
return lerp_rgb(r0, g0, b0, r, g, b, t);
}