Fix Life and heat display, implement alpha, blend and add, fix FILT, INVS and BRAY + others
This commit is contained in:
parent
7413654b9f
commit
e46f26684b
@ -75,7 +75,7 @@ struct gcache_item
|
|||||||
{
|
{
|
||||||
int isready;
|
int isready;
|
||||||
int pixel_mode;
|
int pixel_mode;
|
||||||
int colr, colg, colb;
|
int cola, colr, colg, colb;
|
||||||
int firea, firer, fireg, fireb;
|
int firea, firer, fireg, fireb;
|
||||||
};
|
};
|
||||||
typedef struct gcache_item gcache_item;
|
typedef struct gcache_item gcache_item;
|
||||||
|
@ -246,8 +246,8 @@
|
|||||||
|
|
||||||
#define FLAG_STAGNANT 1
|
#define FLAG_STAGNANT 1
|
||||||
|
|
||||||
#define GRAPHICS_FUNC_ARGS particle *cpart, int nx, int ny, int *pixel_mode, int *colr, int *colg, int *colb, int *firea, int *firer, int *fireg, int *fireb
|
#define GRAPHICS_FUNC_ARGS particle *cpart, int nx, int ny, int *pixel_mode, int* cola, int *colr, int *colg, int *colb, int *firea, int *firer, int *fireg, int *fireb
|
||||||
#define GRAPHICS_FUNC_SUBCALL_ARGS cpart, nx, ny, pixel_mode, colr, colg, colb, firea, firer, fireg, fireb
|
#define GRAPHICS_FUNC_SUBCALL_ARGS cpart, nx, ny, pixel_mode, cola, colr, colg, colb, firea, firer, fireg, fireb
|
||||||
|
|
||||||
|
|
||||||
struct particle
|
struct particle
|
||||||
|
@ -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)
|
if(pv[ny/CELL][nx/CELL]>4.0f || pv[ny/CELL][nx/CELL]<-4.0f)
|
||||||
{
|
{
|
||||||
|
*cola = 100;
|
||||||
*colr = 15;
|
*colr = 15;
|
||||||
*colg = 0;
|
*colg = 0;
|
||||||
*colb = 150;
|
*colb = 150;
|
||||||
@ -253,9 +254,12 @@ int graphics_FILT(GRAPHICS_FUNC_ARGS)
|
|||||||
for (x=0; x<12; x++)
|
for (x=0; x<12; x++)
|
||||||
*colg += (cpart->ctype >> (x+9)) & 1;
|
*colg += (cpart->ctype >> (x+9)) & 1;
|
||||||
x = 624/(*colr+*colg+*colb+1);
|
x = 624/(*colr+*colg+*colb+1);
|
||||||
|
*cola = 127;
|
||||||
*colr *= x;
|
*colr *= x;
|
||||||
*colg *= x;
|
*colg *= x;
|
||||||
*colb *= x;
|
*colb *= x;
|
||||||
|
*pixel_mode &= ~PMODE;
|
||||||
|
*pixel_mode |= PMODE_BLEND;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int graphics_BRAY(GRAPHICS_FUNC_ARGS)
|
int graphics_BRAY(GRAPHICS_FUNC_ARGS)
|
||||||
@ -309,7 +313,7 @@ int graphics_BRAY(GRAPHICS_FUNC_ARGS)
|
|||||||
*colr = 150;
|
*colr = 150;
|
||||||
*colr = 50;
|
*colr = 50;
|
||||||
}
|
}
|
||||||
//*cola = trans;
|
*cola = trans;
|
||||||
*pixel_mode &= ~PMODE;
|
*pixel_mode &= ~PMODE;
|
||||||
*pixel_mode |= PMODE_BLEND;
|
*pixel_mode |= PMODE_BLEND;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -304,11 +304,11 @@ int graphics_PIPE(GRAPHICS_FUNC_ARGS)
|
|||||||
{
|
{
|
||||||
if (ptypes[t].graphics_func)
|
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
|
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);
|
//*colr = PIXR(ptypes[cpart->tmp&0xFF].pcolors);
|
||||||
|
@ -1626,7 +1626,7 @@ GLfloat lineC[(((YRES*XRES)*2)*6)];
|
|||||||
void render_parts(pixel *vid)
|
void render_parts(pixel *vid)
|
||||||
{
|
{
|
||||||
//TODO: Replace cmode with a set of flags
|
//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;
|
float gradv, flicker, fnx, fny;
|
||||||
#ifdef OGLR
|
#ifdef OGLR
|
||||||
int cfireV = 0, cfireC = 0, cfire = 0;
|
int cfireV = 0, cfireC = 0, cfire = 0;
|
||||||
@ -1660,6 +1660,7 @@ void render_parts(pixel *vid)
|
|||||||
|
|
||||||
//Defaults
|
//Defaults
|
||||||
pixel_mode = 0 | PMODE_FLAT;
|
pixel_mode = 0 | PMODE_FLAT;
|
||||||
|
cola = 255;
|
||||||
colr = PIXR(ptypes[t].pcolors);
|
colr = PIXR(ptypes[t].pcolors);
|
||||||
colg = PIXG(ptypes[t].pcolors);
|
colg = PIXG(ptypes[t].pcolors);
|
||||||
colb = PIXB(ptypes[t].pcolors);
|
colb = PIXB(ptypes[t].pcolors);
|
||||||
@ -1673,6 +1674,7 @@ void render_parts(pixel *vid)
|
|||||||
if (graphicscache[t].isready)
|
if (graphicscache[t].isready)
|
||||||
{
|
{
|
||||||
pixel_mode = graphicscache[t].pixel_mode;
|
pixel_mode = graphicscache[t].pixel_mode;
|
||||||
|
cola = graphicscache[t].cola;
|
||||||
colr = graphicscache[t].colr;
|
colr = graphicscache[t].colr;
|
||||||
colg = graphicscache[t].colg;
|
colg = graphicscache[t].colg;
|
||||||
colb = graphicscache[t].colb;
|
colb = graphicscache[t].colb;
|
||||||
@ -1685,10 +1687,11 @@ void render_parts(pixel *vid)
|
|||||||
{
|
{
|
||||||
if (ptypes[t].graphics_func)
|
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].isready = 1;
|
||||||
graphicscache[t].pixel_mode = pixel_mode;
|
graphicscache[t].pixel_mode = pixel_mode;
|
||||||
|
graphicscache[t].cola = cola;
|
||||||
graphicscache[t].colr = colr;
|
graphicscache[t].colr = colr;
|
||||||
graphicscache[t].colg = colg;
|
graphicscache[t].colg = colg;
|
||||||
graphicscache[t].colb = colb;
|
graphicscache[t].colb = colb;
|
||||||
@ -1700,10 +1703,11 @@ void render_parts(pixel *vid)
|
|||||||
}
|
}
|
||||||
else
|
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].isready = 1;
|
||||||
graphicscache[t].pixel_mode = pixel_mode;
|
graphicscache[t].pixel_mode = pixel_mode;
|
||||||
|
graphicscache[t].cola = cola;
|
||||||
graphicscache[t].colr = colr;
|
graphicscache[t].colr = colr;
|
||||||
graphicscache[t].colg = colg;
|
graphicscache[t].colg = colg;
|
||||||
graphicscache[t].colb = colb;
|
graphicscache[t].colb = colb;
|
||||||
@ -1722,22 +1726,6 @@ void render_parts(pixel *vid)
|
|||||||
colg += sin(gradv*caddress*4.55 +3.14) * 34;
|
colg += sin(gradv*caddress*4.55 +3.14) * 34;
|
||||||
colb += sin(gradv*caddress*2.22 +3.14) * 64;
|
colb += sin(gradv*caddress*2.22 +3.14) * 64;
|
||||||
}
|
}
|
||||||
if(cmode == CM_NOTHING)
|
|
||||||
{
|
|
||||||
#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++] = 1.0f;
|
|
||||||
cflat++;
|
|
||||||
#else
|
|
||||||
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(colr,colg,colb);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Alter colour based on display mode
|
//Alter colour based on display mode
|
||||||
switch(cmode)
|
switch(cmode)
|
||||||
{
|
{
|
||||||
@ -1747,11 +1735,23 @@ void render_parts(pixel *vid)
|
|||||||
firer = colr = (unsigned char)color_data[caddress];
|
firer = colr = (unsigned char)color_data[caddress];
|
||||||
fireg = colg = (unsigned char)color_data[caddress+1];
|
fireg = colg = (unsigned char)color_data[caddress+1];
|
||||||
fireb = colb = (unsigned char)color_data[caddress+2];
|
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_PERS:
|
||||||
case CM_CRACK:
|
case CM_CRACK:
|
||||||
case CM_VEL:
|
case CM_VEL:
|
||||||
case CM_PRESS:
|
case CM_PRESS:
|
||||||
case CM_LIFE:
|
|
||||||
case CM_GRAD:
|
case CM_GRAD:
|
||||||
if(pixel_mode & FIRE_ADD) pixel_mode = (pixel_mode & ~FIRE_ADD) | PMODE_GLOW | PMODE_FLAT;
|
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;
|
if(pixel_mode & FIRE_BLEND) pixel_mode = (pixel_mode & ~FIRE_BLEND) | PMODE_BLUR;
|
||||||
@ -1769,13 +1769,14 @@ void render_parts(pixel *vid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Apply decoration colour
|
//Apply decoration colour
|
||||||
if(cmode != CM_NOTHING && decorations_enable)
|
if(cmode != CM_NOTHING && cmode != CM_HEAT && decorations_enable)
|
||||||
{
|
{
|
||||||
colr = (deca*decr + (255-deca)*colr) >> 8;
|
colr = (deca*decr + (255-deca)*colr) >> 8;
|
||||||
colg = (deca*decg + (255-deca)*colg) >> 8;
|
colg = (deca*decg + (255-deca)*colg) >> 8;
|
||||||
colb = (deca*decb + (255-deca)*colb) >> 8;
|
colb = (deca*decb + (255-deca)*colb) >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef OGLR
|
||||||
//All colours are now set, check ranges
|
//All colours are now set, check ranges
|
||||||
if(colr>255) colr = 255;
|
if(colr>255) colr = 255;
|
||||||
else if(colr<0) colr = 0;
|
else if(colr<0) colr = 0;
|
||||||
@ -1783,7 +1784,26 @@ void render_parts(pixel *vid)
|
|||||||
else if(colg<0) colg = 0;
|
else if(colg<0) colg = 0;
|
||||||
if(colb>255) colb = 255;
|
if(colb>255) colb = 255;
|
||||||
else if(colb<0) colb = 0;
|
else if(colb<0) colb = 0;
|
||||||
|
if(cola>255) cola = 255;
|
||||||
|
else if(cola<0) cola = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(cmode == CM_NOTHING)
|
||||||
|
{
|
||||||
|
#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++] = 1.0f;
|
||||||
|
cflat++;
|
||||||
|
#else
|
||||||
|
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(colr,colg,colb);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//Pixel rendering
|
//Pixel rendering
|
||||||
if(pixel_mode & PSPEC_STICKMAN)
|
if(pixel_mode & PSPEC_STICKMAN)
|
||||||
{
|
{
|
||||||
@ -1863,6 +1883,34 @@ void render_parts(pixel *vid)
|
|||||||
cflat++;
|
cflat++;
|
||||||
#else
|
#else
|
||||||
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(colr,colg,colb);
|
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
|
#endif
|
||||||
}
|
}
|
||||||
if(pixel_mode & PMODE_BLOB)
|
if(pixel_mode & PMODE_BLOB)
|
||||||
|
Loading…
Reference in New Issue
Block a user