summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-10-28 22:48:57 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-10-28 22:48:57 (GMT)
commite46f26684bfbe82734ad4716e45ebb1a94075a69 (patch)
tree29c0f6f38916ff94f026ac7c18dbd54d67fcbd24 /src
parent7413654b9f1d6c0cde622d1b3129378a8e6c30d2 (diff)
downloadpowder-e46f26684bfbe82734ad4716e45ebb1a94075a69.zip
powder-e46f26684bfbe82734ad4716e45ebb1a94075a69.tar.gz
Fix Life and heat display, implement alpha, blend and add, fix FILT, INVS and BRAY + others
Diffstat (limited to 'src')
-rw-r--r--src/elements/newgraphics.c6
-rw-r--r--src/elements/pipe.c4
-rw-r--r--src/graphics.c146
3 files changed, 104 insertions, 52 deletions
diff --git a/src/elements/newgraphics.c b/src/elements/newgraphics.c
index c3ff414..23c660f 100644
--- a/src/elements/newgraphics.c
+++ b/src/elements/newgraphics.c
@@ -218,6 +218,7 @@ int graphics_INVS(GRAPHICS_FUNC_ARGS)
{
if(pv[ny/CELL][nx/CELL]>4.0f || pv[ny/CELL][nx/CELL]<-4.0f)
{
+ *cola = 100;
*colr = 15;
*colg = 0;
*colb = 150;
@@ -253,9 +254,12 @@ int graphics_FILT(GRAPHICS_FUNC_ARGS)
for (x=0; x<12; x++)
*colg += (cpart->ctype >> (x+9)) & 1;
x = 624/(*colr+*colg+*colb+1);
+ *cola = 127;
*colr *= x;
*colg *= x;
*colb *= x;
+ *pixel_mode &= ~PMODE;
+ *pixel_mode |= PMODE_BLEND;
return 0;
}
int graphics_BRAY(GRAPHICS_FUNC_ARGS)
@@ -309,7 +313,7 @@ int graphics_BRAY(GRAPHICS_FUNC_ARGS)
*colr = 150;
*colr = 50;
}
- //*cola = trans;
+ *cola = trans;
*pixel_mode &= ~PMODE;
*pixel_mode |= PMODE_BLEND;
return 0;
diff --git a/src/elements/pipe.c b/src/elements/pipe.c
index 7014536..3ee5262 100644
--- a/src/elements/pipe.c
+++ b/src/elements/pipe.c
@@ -304,11 +304,11 @@ int graphics_PIPE(GRAPHICS_FUNC_ARGS)
{
if (ptypes[t].graphics_func)
{
- (*(ptypes[t].graphics_func))(&tpart, nx, ny, pixel_mode, colr, colg, colb, firea, firer, fireg, fireb);
+ (*(ptypes[t].graphics_func))(&tpart, nx, ny, pixel_mode, cola, colr, colg, colb, firea, firer, fireg, fireb);
}
else
{
- graphics_DEFAULT(&tpart, nx, ny, pixel_mode, colr, colg, colb, firea, firer, fireg, fireb);
+ graphics_DEFAULT(&tpart, nx, ny, pixel_mode, cola, colr, colg, colb, firea, firer, fireg, fireb);
}
}
//*colr = PIXR(ptypes[cpart->tmp&0xFF].pcolors);
diff --git a/src/graphics.c b/src/graphics.c
index f4e1e50..7dcf130 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -1626,7 +1626,7 @@ GLfloat lineC[(((YRES*XRES)*2)*6)];
void render_parts(pixel *vid)
{
//TODO: Replace cmode with a set of flags
- int deca, decr, decg, decb, colr, colg, colb, firea, firer, fireg, fireb, pixel_mode, i, t, nx, ny, x, y, caddress;
+ int deca, decr, decg, decb, cola, colr, colg, colb, firea, firer, fireg, fireb, pixel_mode, q, i, t, nx, ny, x, y, caddress;
float gradv, flicker, fnx, fny;
#ifdef OGLR
int cfireV = 0, cfireC = 0, cfire = 0;
@@ -1660,6 +1660,7 @@ void render_parts(pixel *vid)
//Defaults
pixel_mode = 0 | PMODE_FLAT;
+ cola = 255;
colr = PIXR(ptypes[t].pcolors);
colg = PIXG(ptypes[t].pcolors);
colb = PIXB(ptypes[t].pcolors);
@@ -1673,6 +1674,7 @@ void render_parts(pixel *vid)
if (graphicscache[t].isready)
{
pixel_mode = graphicscache[t].pixel_mode;
+ cola = graphicscache[t].cola;
colr = graphicscache[t].colr;
colg = graphicscache[t].colg;
colb = graphicscache[t].colb;
@@ -1685,10 +1687,11 @@ void render_parts(pixel *vid)
{
if (ptypes[t].graphics_func)
{
- if ((*(ptypes[t].graphics_func))(&(parts[i]), nx, ny, &pixel_mode, &colr, &colg, &colb, &firea, &firer, &fireg, &fireb)) //That's a lot of args, a struct might be better
+ if ((*(ptypes[t].graphics_func))(&(parts[i]), nx, ny, &pixel_mode, &cola, &colr, &colg, &colb, &firea, &firer, &fireg, &fireb)) //That's a lot of args, a struct might be better
{
graphicscache[t].isready = 1;
graphicscache[t].pixel_mode = pixel_mode;
+ graphicscache[t].cola = cola;
graphicscache[t].colr = colr;
graphicscache[t].colg = colg;
graphicscache[t].colb = colb;
@@ -1700,10 +1703,11 @@ void render_parts(pixel *vid)
}
else
{
- if(graphics_DEFAULT(&(parts[i]), nx, ny, &pixel_mode, &colr, &colg, &colb, &firea, &firer, &fireg, &fireb))
+ if(graphics_DEFAULT(&(parts[i]), nx, ny, &pixel_mode, &cola, &colr, &colg, &colb, &firea, &firer, &fireg, &fireb))
{
graphicscache[t].isready = 1;
graphicscache[t].pixel_mode = pixel_mode;
+ graphicscache[t].cola = cola;
graphicscache[t].colr = colr;
graphicscache[t].colg = colg;
graphicscache[t].colb = colb;
@@ -1722,6 +1726,68 @@ void render_parts(pixel *vid)
colg += sin(gradv*caddress*4.55 +3.14) * 34;
colb += sin(gradv*caddress*2.22 +3.14) * 64;
}
+ //Alter colour based on display mode
+ switch(cmode)
+ {
+ case CM_HEAT:
+ caddress = restrict_flt((int)( restrict_flt((float)(parts[i].temp+(-MIN_TEMP)), 0.0f, MAX_TEMP+(-MIN_TEMP)) / ((MAX_TEMP+(-MIN_TEMP))/1024) ) *3, 0.0f, (1024.0f*3)-3);
+ firea = 255;
+ firer = colr = (unsigned char)color_data[caddress];
+ fireg = colg = (unsigned char)color_data[caddress+1];
+ fireb = colb = (unsigned char)color_data[caddress+2];
+ cola = 255;
+ if(pixel_mode & (FIRE_ADD | FIRE_BLEND)) pixel_mode = (pixel_mode & ~FIRE_ADD) | PMODE_BLUR | PMODE_FLAT;
+ break;
+ case CM_LIFE:
+ gradv = 0.4f;
+ if (!(parts[i].life<5))
+ q = sqrt(parts[i].life);
+ else
+ q = parts[i].life;
+ colr = colg = colb = sin(gradv*q) * 100 + 128;
+ cola = 255;
+ if(pixel_mode & (FIRE_ADD | FIRE_BLEND)) pixel_mode = (pixel_mode & ~FIRE_ADD) | PMODE_BLUR | PMODE_FLAT;
+ break;
+ case CM_PERS:
+ case CM_CRACK:
+ case CM_VEL:
+ case CM_PRESS:
+ case CM_GRAD:
+ if(pixel_mode & FIRE_ADD) pixel_mode = (pixel_mode & ~FIRE_ADD) | PMODE_GLOW | PMODE_FLAT;
+ if(pixel_mode & FIRE_BLEND) pixel_mode = (pixel_mode & ~FIRE_BLEND) | PMODE_BLUR;
+ case CM_FIRE:
+ if(pixel_mode & PMODE_BLOB) pixel_mode = (pixel_mode & ~PMODE_BLOB) | PMODE_FLAT;
+ if(pixel_mode & PMODE_BLUR) pixel_mode = (pixel_mode & ~PMODE_BLUR) | PMODE_FLAT;
+ break;
+ case CM_BLOB:
+ if(pixel_mode & PMODE_FLAT) pixel_mode = (pixel_mode & ~PMODE_FLAT) | PMODE_BLOB;
+ break;
+ case CM_FANCY:
+ break;
+ default:
+ break;
+ }
+
+ //Apply decoration colour
+ if(cmode != CM_NOTHING && cmode != CM_HEAT && decorations_enable)
+ {
+ colr = (deca*decr + (255-deca)*colr) >> 8;
+ colg = (deca*decg + (255-deca)*colg) >> 8;
+ colb = (deca*decb + (255-deca)*colb) >> 8;
+ }
+
+#ifndef OGLR
+ //All colours are now set, check ranges
+ if(colr>255) colr = 255;
+ else if(colr<0) colr = 0;
+ if(colg>255) colg = 255;
+ else if(colg<0) colg = 0;
+ if(colb>255) colb = 255;
+ else if(colb<0) colb = 0;
+ if(cola>255) cola = 255;
+ else if(cola<0) cola = 0;
+#endif
+
if(cmode == CM_NOTHING)
{
#ifdef OGLR
@@ -1738,52 +1804,6 @@ void render_parts(pixel *vid)
}
else
{
- //Alter colour based on display mode
- switch(cmode)
- {
- case CM_HEAT:
- caddress = restrict_flt((int)( restrict_flt((float)(parts[i].temp+(-MIN_TEMP)), 0.0f, MAX_TEMP+(-MIN_TEMP)) / ((MAX_TEMP+(-MIN_TEMP))/1024) ) *3, 0.0f, (1024.0f*3)-3);
- firea = 255;
- firer = colr = (unsigned char)color_data[caddress];
- fireg = colg = (unsigned char)color_data[caddress+1];
- fireb = colb = (unsigned char)color_data[caddress+2];
- case CM_PERS:
- case CM_CRACK:
- case CM_VEL:
- case CM_PRESS:
- case CM_LIFE:
- case CM_GRAD:
- if(pixel_mode & FIRE_ADD) pixel_mode = (pixel_mode & ~FIRE_ADD) | PMODE_GLOW | PMODE_FLAT;
- if(pixel_mode & FIRE_BLEND) pixel_mode = (pixel_mode & ~FIRE_BLEND) | PMODE_BLUR;
- case CM_FIRE:
- if(pixel_mode & PMODE_BLOB) pixel_mode = (pixel_mode & ~PMODE_BLOB) | PMODE_FLAT;
- if(pixel_mode & PMODE_BLUR) pixel_mode = (pixel_mode & ~PMODE_BLUR) | PMODE_FLAT;
- break;
- case CM_BLOB:
- if(pixel_mode & PMODE_FLAT) pixel_mode = (pixel_mode & ~PMODE_FLAT) | PMODE_BLOB;
- break;
- case CM_FANCY:
- break;
- default:
- break;
- }
-
- //Apply decoration colour
- if(cmode != CM_NOTHING && decorations_enable)
- {
- colr = (deca*decr + (255-deca)*colr) >> 8;
- colg = (deca*decg + (255-deca)*colg) >> 8;
- colb = (deca*decb + (255-deca)*colb) >> 8;
- }
-
- //All colours are now set, check ranges
- if(colr>255) colr = 255;
- else if(colr<0) colr = 0;
- if(colg>255) colg = 255;
- else if(colg<0) colg = 0;
- if(colb>255) colb = 255;
- else if(colb<0) colb = 0;
-
//Pixel rendering
if(pixel_mode & PSPEC_STICKMAN)
{
@@ -1865,6 +1885,34 @@ void render_parts(pixel *vid)
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(colr,colg,colb);
#endif
}
+ if(pixel_mode & PMODE_BLEND)
+ {
+#ifdef OGLR
+ flatV[cflatV++] = nx;
+ flatV[cflatV++] = ny;
+ flatC[cflatC++] = ((float)colr)/255.0f;
+ flatC[cflatC++] = ((float)colg)/255.0f;
+ flatC[cflatC++] = ((float)colb)/255.0f;
+ flatC[cflatC++] = ((float)cola)/255.0f;
+ cflat++;
+#else
+ addpixel(vid, nx, ny, colr, colg, colb, cola);
+#endif
+ }
+ if(pixel_mode & PMODE_ADD)
+ {
+#ifdef OGLR
+ flatV[cflatV++] = nx;
+ flatV[cflatV++] = ny;
+ flatC[cflatC++] = ((float)colr)/255.0f;
+ flatC[cflatC++] = ((float)colg)/255.0f;
+ flatC[cflatC++] = ((float)colb)/255.0f;
+ flatC[cflatC++] = ((float)cola)/255.0f;
+ cflat++;
+#else
+ addpixel(vid, nx, ny, colr, colg, colb, cola);
+#endif
+ }
if(pixel_mode & PMODE_BLOB)
{
#ifdef OGLR