Beispiel #1
0
void liBlendScreen(color *buffer, color *layer, real32 opacity, sdword nPixels)
{
    real32 redSource, greenSource, blueSource, alpha;
    real32 redDest, greenDest, blueDest;//, alphaDest;
    real32 oneMinusAlpha;

    while (nPixels > 0)
    {
        alpha = colUbyteToReal(colAlpha(*layer)) * opacity;
        oneMinusAlpha = 1.0f - alpha;
        redSource = colUbyteToReal(colRed(*layer));    //read pixel to floating point
        greenSource = colUbyteToReal(colGreen(*layer));
        blueSource = colUbyteToReal(colBlue(*layer));
        redDest = colUbyteToReal(colRed(*buffer));
        greenDest = colUbyteToReal(colGreen(*buffer));
        blueDest = colUbyteToReal(colBlue(*buffer));

        redDest = (1.0f - (1.0f - redDest) * (1.0f - redSource)) * alpha + redDest * oneMinusAlpha;
        greenDest = (1.0f - (1.0f - greenDest) * (1.0f - greenSource)) * alpha + greenDest * oneMinusAlpha;
        blueDest = (1.0f - (1.0f - blueDest) * (1.0f - blueSource)) * alpha + blueDest * oneMinusAlpha;
        redDest = min(redDest, 1.0f);
        greenDest = min(greenDest, 1.0f);
        blueDest = min(blueDest, 1.0f);
        *buffer = colRGB(colRealToUbyte(redDest), colRealToUbyte(greenDest),
                         colRealToUbyte(blueDest));
        buffer++;
        layer++;
        nPixels--;
    }
}
Beispiel #2
0
/*-----------------------------------------------------------------------------
    Name        : primRectShaded2
    Description : Draw a shaded 2d rectangle.
    Inputs      : rect - pointer to rectangle structure containing coordinates.
                  c - pointer to 4 color values to draw it in.
    Outputs     : ..
    Return      : void
----------------------------------------------------------------------------*/
void primRectShaded2(rectangle *rect, color *c)
{
    if (glcActive())
    {
        glcRectShaded2(rect, c);
        return;
    }

    glShadeModel(GL_SMOOTH);

    glBegin(GL_QUADS);

    glColor3ub(colRed(c[0]), colGreen(c[0]), colBlue(c[0]));
    glVertex2f(primScreenToGLX(rect->x0), primScreenToGLY(rect->y0));

    glColor3ub(colRed(c[1]), colGreen(c[1]), colBlue(c[1]));
    glVertex2f(primScreenToGLX(rect->x0), primScreenToGLY(rect->y1));

    glColor3ub(colRed(c[2]), colGreen(c[2]), colBlue(c[2]));
    glVertex2f(primScreenToGLX(rect->x1), primScreenToGLY(rect->y1));

    glColor3ub(colRed(c[3]), colGreen(c[3]), colBlue(c[3]));
    glVertex2f(primScreenToGLX(rect->x1), primScreenToGLY(rect->y0));

    glEnd();
}
Beispiel #3
0
void liBlendOverlay(color *buffer, color *layer, real32 opacity, sdword nPixels)
{
    real32 redSource, greenSource, blueSource, alpha;
    real32 redDest, greenDest, blueDest;//, alphaDest;
    real32 oneMinusAlpha;
    real32 redTemp, greenTemp, blueTemp;

    while (nPixels > 0)
    {
        alpha = colUbyteToReal(colAlpha(*layer)) * opacity;
        oneMinusAlpha = 1.0f - alpha;
        redSource = colUbyteToReal(colRed(*layer));    //read pixel to floating point
        greenSource = colUbyteToReal(colGreen(*layer));
        blueSource = colUbyteToReal(colBlue(*layer));
        redDest = colUbyteToReal(colRed(*buffer));
        greenDest = colUbyteToReal(colGreen(*buffer));
        blueDest = colUbyteToReal(colBlue(*buffer));
        if (redDest < 0.5f)
        {
            redTemp = (2.0f * redSource * 2.0f * redDest) / 2.0f;
        }
        else
        {
            redTemp = 1.0f - ((2.0f * (1.0f - redSource)) * (2.0f * (1.0f - redDest)) / 2.0f);
        }
        if (greenDest < 0.5f)
        {
            greenTemp = (2.0f * greenSource * 2.0f * greenDest) / 2.0f;
        }
        else
        {
            greenTemp = 1.0f - ((2.0f * (1.0f - greenSource)) * (2.0f * (1.0f - greenDest)) / 2.0f);
        }
        if (blueDest < 0.5f)
        {
            blueTemp = (2.0f * blueSource * 2.0f * blueDest) / 2.0f;
        }
        else
        {
            blueTemp = 1.0f - ((2.0f * (1.0f - blueSource)) * (2.0f * (1.0f - blueDest)) / 2.0f);
        }
        redDest = redTemp * alpha + redDest * oneMinusAlpha;
        greenDest = greenTemp * alpha + greenDest * oneMinusAlpha;
        blueDest = blueTemp * alpha + blueDest * oneMinusAlpha;
        redDest = min(redDest, 1.0f);
        greenDest = min(greenDest, 1.0f);
        blueDest = min(blueDest, 1.0f);
        *buffer = colRGB(colRealToUbyte(redDest), colRealToUbyte(greenDest),
                         colRealToUbyte(blueDest));
        buffer++;
        layer++;
        nPixels--;
    }
}
Beispiel #4
0
/*-----------------------------------------------------------------------------
    Name        : shDockLightColor
    Description : sets the docking light colour
    Inputs      : c - the colour of the light
    Outputs     : shDockColor == c
    Return      :
----------------------------------------------------------------------------*/
void shDockLightColor(color c)
{
    shDockColor = c;
    shDockScalarRed = colReal32(colRed(c));
    shDockScalarGreen = colReal32(colGreen(c));
    shDockScalarBlue = colReal32(colBlue(c));
}
Beispiel #5
0
/*-----------------------------------------------------------------------------
    Name        : primPoint3
    Description : Draw a 3D point
    Inputs      : p1 - location of point
                  c - color of point
    Outputs     :
    Return      : void
----------------------------------------------------------------------------*/
void primPoint3(vector *p1, color c)
{
    glColor3ub(colRed(c), colGreen(c), colBlue(c));
    glBegin(GL_POINTS);
    glVertex3f(p1->x, p1->y, p1->z);                        //!!! no size
    glEnd();
}
Beispiel #6
0
/*-----------------------------------------------------------------------------
    Name        : primRectOutline2
    Description : Draw an outline 2d rectangle.
    Inputs      : rect - pointer to rectangle structure containing coordinates.
                  thickness - thickness of the lines
                  c - color to draw it in.
    Outputs     : ..
    Return      : void
----------------------------------------------------------------------------*/
void primRectOutline2(rectangle *rect, sdword thickness, color c)
{
    sdword bottom;

    if (glcActive())
    {
        glcRectOutline2(rect, thickness, c);
        return;
    }

    bottom = rect->y1 - 1;

    glColor3ub(colRed(c), colGreen(c), colBlue(c));
    glPushAttrib(GL_LINE_BIT);
    glLineWidth((GLfloat)thickness);

    glBegin(GL_LINE_LOOP);
    glVertex2f(primScreenToGLX(rect->x0), primScreenToGLY(rect->y0));
    glVertex2f(primScreenToGLX(rect->x1), primScreenToGLY(rect->y0));
    glVertex2f(primScreenToGLX(rect->x1), primScreenToGLY(bottom));
    glVertex2f(primScreenToGLX(rect->x0), primScreenToGLY(bottom));
    glEnd();

    glPopAttrib();
}
Beispiel #7
0
/*-----------------------------------------------------------------------------
    Name        : primLine2
    Description : Draw a line 1 pixel wide
    Inputs      : c - attributes of line to be drawn
                  x0, y0, x1, y1 - start/end of line segment
    Outputs     : Sets GL_COLOR
    Return      : void
----------------------------------------------------------------------------*/
void primLine2(sdword x0, sdword y0, sdword x1, sdword y1, color c)
{
    bool blendon;

    if (glcActive())
    {
        glcLine2(x0, y0, x1, y1, 1, c);
        return;
    }

    if (!glCapFeatureExists(GL_LINE_SMOOTH))
    {
        primNonAALine2(x0, y0, x1, y1, c);
        return;
    }

    blendon = glIsEnabled(GL_BLEND);
    if (!blendon) glEnable(GL_BLEND);
    glEnable(GL_LINE_SMOOTH);
    glColor3ub(colRed(c), colGreen(c), colBlue(c));
    glBegin(GL_LINES);
    glVertex2f(primScreenToGLX(x0), primScreenToGLY(y0));
    glVertex2f(primScreenToGLX(x1), primScreenToGLY(y1));
    glEnd();
    glDisable(GL_LINE_SMOOTH);
    if (!blendon) glDisable(GL_BLEND);
}
Beispiel #8
0
/*-----------------------------------------------------------------------------
    Name        : teColorAdjust
    Description : Adjust a color according to a HLS colorizing table.
    Inputs      : baseColor - origional color
                  colorize - HLS parameters to adjust by.
    Outputs     :
    Return      : newly adjusted color
----------------------------------------------------------------------------*/
color teColorAdjust(color baseColor, trhlscolorize *colorize)
{
    real32 red, green, blue, hue, lum, sat;
    colRGBToHLS(&hue, &lum, &sat, colUbyteToReal(colRed(baseColor)),
                colUbyteToReal(colGreen(baseColor)),
                colUbyteToReal(colBlue(baseColor)));
    hue += colorize->hue;
    if (hue < 0)
    {
        hue += 1.0f;
    }
    if (hue > 1.0f)
    {
        hue -= 1.0f;
    }
    lum *= colorize->lum;
    sat *= colorize->sat;
    if (lum > 1.0f)
    {
        lum = 1.0f;
    }
    if (sat > 1.0f)
    {
        sat = 1.0f;
    }
    colHLSToRGB(&red, &green, &blue, hue, lum, sat);
    return(colRGB(colRealToUbyte(red), colRealToUbyte(green), colRealToUbyte(blue)));
}
Beispiel #9
0
/*-----------------------------------------------------------------------------
    Name        : primRectSolid2
    Description : Draw a solid 2d rectangle.
    Inputs      : rect - pointer to rectangle structure containing coordinates.
                  c - color to draw it in, xb - x offset, yb - y offset
    Outputs     : ..
    Return      : void
----------------------------------------------------------------------------*/
void primBeveledRectSolid(rectangle *rect, color c, uword xb, uword yb)
{
    bool cull;

    if (glcActive())
    {
        glcBeveledRectSolid2(rect, c, (sdword)xb, (sdword)yb);
        return;
    }

    cull = glIsEnabled(GL_CULL_FACE) ? TRUE : FALSE;
    glDisable(GL_CULL_FACE);
    glBegin(GL_POLYGON);
    glColor3ub(colRed(c), colGreen(c), colBlue(c));
    glVertex2f(SX(X0+xb), SY(Y0));
    glVertex2f(SX(X1-xb), SY(Y0));
    glVertex2f(SX(X1), SY(Y0+yb));
    glVertex2f(SX(X1), SY(Y1-yb));
    glVertex2f(SX(X1-xb), SY(Y1));
    glVertex2f(SX(X0+xb), SY(Y1));
    glVertex2f(SX(X0), SY(Y1-yb));
    glVertex2f(SX(X0), SY(Y0+yb));
    glEnd();
    if (cull)
    {
        glEnable(GL_CULL_FACE);
    }
}
Beispiel #10
0
/*-----------------------------------------------------------------------------
    Name        : liLayerColorAverage
    Description : Returns the average color of a layer
    Inputs      : layer - layer to find average color of
    Outputs     :
    Return      : average color
----------------------------------------------------------------------------*/
color liLayerColorAverage(lilayer *layer)
{
    udword red = 0, green = 0, blue = 0, alpha = 0, count, totalPixels;
    color *pColor;

    dbgAssert(layer->decompressed != NULL);
    dbgAssert(!bitTest(layer->flags, LFF_Channeled));
    totalPixels = count = (layer->bounds.x1 - layer->bounds.x0) *
        (layer->bounds.y1 - layer->bounds.y0);
    pColor = layer->decompressed;
    while (count > 0)
    {
        red += colRed(*pColor);
        green += colGreen(*pColor);
        blue += colBlue(*pColor);
        alpha += colAlpha(*pColor);
        count--;
        pColor++;
    }
    red /= totalPixels;
    green /= totalPixels;
    blue /= totalPixels;
    alpha /= totalPixels;

    return(colRGBA(red, green, blue, alpha));
}
Beispiel #11
0
/*-----------------------------------------------------------------------------
    Name        : primRectTranslucent2
    Description : Draw a translucent 2d rectangle.
    Inputs      : rect - pointer to rectangle structure containing coordinates.
                  c - color to draw it in.
    Outputs     : ..
    Return      : void
----------------------------------------------------------------------------*/
void primRectTranslucent2(rectangle* rect, color c)
{
    GLboolean blendOn;

    if (RGL && RGLtype == SWtype)
    {
        primRectTranslucentRGL2(rect, c);
        return;
    }

    blendOn = glIsEnabled(GL_BLEND);
    if (!blendOn) glEnable(GL_BLEND);
    if (glcActive())
    {
        glcRectTranslucent2(rect, c);
    }
    else
    {
        glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
        glBegin(GL_QUADS);
        glVertex2f(primScreenToGLX(rect->x0), primScreenToGLY(rect->y0));
        glVertex2f(primScreenToGLX(rect->x0), primScreenToGLY(rect->y1));
        glVertex2f(primScreenToGLX(rect->x1), primScreenToGLY(rect->y1));
        glVertex2f(primScreenToGLX(rect->x1), primScreenToGLY(rect->y0));
        glEnd();
    }
    if (!blendOn) glDisable(GL_BLEND);
}
Beispiel #12
0
void primCircleBorder(sdword x, sdword y, sdword radInner, sdword radOuter, sdword nSlices, color colInner)
{
    sdword index;
    real32 centreX, centreY;
    double theta, addAmount;
    real32 radXInner, radXOuter, radYInner, radYOuter;
    real32 x0, y0, x1, y1, x2, y2;
    real32 sinTheta, cosTheta;
    ubyte red = colRed(colInner);
    ubyte green = colGreen(colInner);
    ubyte blue = colBlue(colInner);

    dbgAssert(nSlices >= 3);

    centreX = primScreenToGLX(x);                           //make floating-point versions of parameters
    centreY = primScreenToGLY(y);
    radXInner = primScreenToGLScaleX(radInner);
    radYInner = primScreenToGLScaleY(radInner);
    radXOuter = primScreenToGLScaleX(radOuter);
    radYOuter = primScreenToGLScaleY(radOuter);
    addAmount = (double)(2.0f * PI / (real32)(nSlices - 1));
    theta = addAmount;

    x0 = x2 = centreX;
    y0 = centreY - radYInner;
    y2 = centreY - radYOuter;

    glShadeModel(GL_SMOOTH);
    glEnable(GL_BLEND);
    for (index = 0; index < nSlices; index++)
    {
        glBegin(GL_TRIANGLE_FAN);
        glColor4ub(red, green, blue, 255);

        glVertex2f(x0, y0);                                 //2 common points
        glVertex2f(centreX, centreY);

        sinTheta = (real32)sin(theta);
        cosTheta = (real32)cos(theta);

        x0 = centreX + sinTheta * radXInner;
        y0 = centreY + cosTheta * radYInner;
        glVertex2f(x0, y0);                                 //complete
        glColor4ub(red, green, blue, 0);

        x1 = centreX + sinTheta * radXOuter;
        y1 = centreY + cosTheta * radYOuter;

        glVertex2f(x1, y1);                                 //complete
        glVertex2f(x2, y2);
        x2 = x1;
        y2 = y1;

        glEnd();
        theta += addAmount;
    }
    glDisable(GL_BLEND);
    glShadeModel(GL_FLAT);
}
Beispiel #13
0
/*-----------------------------------------------------------------------------
    Name        : primNextPointSize3Fade
    Description : render a 3D point (call from inside Begin/End block only)
    Inputs      : p1 - location of point
                  c - color of point
                  fade - fadeness of point (1.0f == no fade, 0.0f == faded to black)
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void primNextPointSize3Fade(vector* p1, color c, real32 fade)
{
    sdword ifade = (sdword)(fade * 255.0f);
    if (gFastBlends)
    {
        glColor4ub((GLubyte)colRed(c),
                   (GLubyte)colGreen(c),
                   (GLubyte)colBlue(c),
                   (GLubyte)ifade);
    }
    else
    {
        glColor3ub((GLubyte)(((sdword)colRed(c) * ifade) >> 8),
                   (GLubyte)(((sdword)colGreen(c) * ifade) >> 8),
                   (GLubyte)(((sdword)colBlue(c) * ifade) >> 8));
    }
}
Beispiel #14
0
/*-----------------------------------------------------------------------------
    Name        : primNonAALine2
    Description : Draw a non-antialiased line 1 pixel wide
    Inputs      : c - attributes of line to be drawn
                  x0, y0, x1, y1 - start/end of line segment
    Outputs     : sets GL_COLOR
    Return      :
----------------------------------------------------------------------------*/
void primNonAALine2(sdword x0, sdword y0, sdword x1, sdword y1, color c)
{
    glColor3ub(colRed(c), colGreen(c), colBlue(c));
    glBegin(GL_LINES);
    glVertex2f(primScreenToGLX(x0), primScreenToGLY(y0));
    glVertex2f(primScreenToGLX(x1), primScreenToGLY(y1));
    glEnd();
}
Beispiel #15
0
/*-----------------------------------------------------------------------------
    Name        : colBlend
    Description : Blend 2 colors together into a single color.
    Inputs      : c0 - color multiplied by factor
                  c1 - color multiplied by (1 - factor)
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
color colBlend(color c0, color c1, real32 factor)
{
    udword red, green, blue, red1, green1, blue1;
    udword intFactor, oneFactor;

    intFactor = (udword)colRealToUbyte(factor);
    oneFactor = 255 - intFactor;
    red = colRed(c0);
    green = colGreen(c0);
    blue = colBlue(c0);
    red1 = colRed(c1);
    green1 = colGreen(c1);
    blue1 = colBlue(c1);
    return(colRGB(((red * intFactor) + (red1 * oneFactor)) >> 8,
                  ((green * intFactor) + (green1 * oneFactor)) >> 8,
                  ((blue * intFactor) + (blue1 * oneFactor)) >> 8));
}
Beispiel #16
0
//This one not a perfect copy, but pretty close
void liBlendColor(color *buffer, color *layer, real32 opacity, sdword nPixels)
{
    real32 redSource, greenSource, blueSource, alpha;
    real32 redDest, greenDest, blueDest;//, alphaDest;
    real32 oneMinusAlpha;
    real32 hueS, satS, hueD, satD, lumS, lumD;
    real32 clumD, clumS;
    real32 redTemp, greenTemp, blueTemp;

#if LI_VERBOSE_LEVEL >= 2
    dbgMessagef("\nColor: Blending mode not implemented perfectly.");
#endif

    while (nPixels > 0)
    {
        alpha = colUbyteToReal(colAlpha(*layer)) * opacity;
        oneMinusAlpha = 1.0f - alpha;
        redSource = colUbyteToReal(colRed(*layer));    //read pixel to floating point
        greenSource = colUbyteToReal(colGreen(*layer));
        blueSource = colUbyteToReal(colBlue(*layer));
        redDest = colUbyteToReal(colRed(*buffer));
        greenDest = colUbyteToReal(colGreen(*buffer));
        blueDest = colUbyteToReal(colBlue(*buffer));
        clumS = (redSource * LI_RedGamma + greenSource * LI_GreenGamma + blueSource * LI_BlueGamma) / LI_TotalGamma;
        clumD = (redDest * LI_RedGamma + greenDest * LI_GreenGamma + blueDest * LI_BlueGamma) / LI_TotalGamma;

        colRGBToHLS(&hueS, &lumS, &satS, redSource, greenSource, blueSource);
        colRGBToHLS(&hueD, &lumD, &satD, redDest, greenDest, blueDest);
        colHLSToRGB(&redTemp, &greenTemp, &blueTemp, hueS, clumD, satS);

        redDest = redTemp * alpha + redDest * oneMinusAlpha;
        greenDest = greenTemp * alpha + greenDest * oneMinusAlpha;
        blueDest = blueTemp * alpha + blueDest * oneMinusAlpha;
        redDest = min(redDest, 1.0f);
        greenDest = min(greenDest, 1.0f);
        blueDest = min(blueDest, 1.0f);

        *buffer = colRGB(colRealToUbyte(redDest), colRealToUbyte(greenDest),
                         colRealToUbyte(blueDest));
        buffer++;
        layer++;
        nPixels--;
    }
}
Beispiel #17
0
udword colIntensityNTSC(color c)
{
    udword red, green, blue, returnValue;

    red = colRed(c);
    green = colGreen(c);
    blue = colBlue(c);
    returnValue = Fixed2Int(red * Float2Fixed(0.229f) + green * Float2Fixed(0.587f) + blue * Float2Fixed(0.114));
    return(returnValue);
}
Beispiel #18
0
/*-----------------------------------------------------------------------------
    Name        : primLineThick2
    Description : Draw a line "thickness" pixels wide
    Inputs      : c - attributes of line to be drawn
                  x0, y0, y1, y1 - start/end of line segment
                  thickness - width of line
    Outputs     : Sets GL_COLOR
    Return      : void
----------------------------------------------------------------------------*/
void primLineThick2(sdword x0, sdword y0, sdword x1, sdword y1, sdword thickness, color c)
{
    glPushAttrib(GL_LINE_BIT);
    glLineWidth((GLfloat)thickness);
    glColor3ub(colRed(c), colGreen(c), colBlue(c));
    glBegin(GL_LINES);
    glVertex2f(primScreenToGLX(x0), primScreenToGLY(y0));
    glVertex2f(primScreenToGLX(x1), primScreenToGLY(y1));
    glEnd();
    glPopAttrib();
}
Beispiel #19
0
/*-----------------------------------------------------------------------------
    Name        : colMultiply
    Description : multiply a color by a floating-point factor
    Inputs      :
    Outputs     :
    Return      : multiplied color
----------------------------------------------------------------------------*/
color colMultiply(color c, real32 factor)
{
    udword red, green, blue;
    udword intFactor;

    intFactor = (udword)colRealToUbyte(factor);
    red = colRed(c);
    green = colGreen(c);
    blue = colBlue(c);
    return(colRGB((red * intFactor) >> 8, (green * intFactor) >> 8, (blue * intFactor) >> 8));
}
Beispiel #20
0
void primLineLoopStart2(sdword thickness, color c)
{
    if (glCapFeatureExists(GL_LINE_SMOOTH))
    {
        LLblendon = glIsEnabled(GL_BLEND);
        glEnable(GL_LINE_SMOOTH);
        if (!LLblendon) glEnable(GL_BLEND);
    }
    glColor3ub(colRed(c), colGreen(c), colBlue(c));
    glPushAttrib(GL_LINE_BIT);
    glLineWidth((GLfloat)thickness);
    glBegin(GL_LINE_LOOP);
}
Beispiel #21
0
/*-----------------------------------------------------------------------------
    Name        : colBestFitFindRGB
    Description : Find a color in a palette, or a reasonable match, using
                    a manhattan distance in RGB space.
    Inputs      : palette - palette to search in.
                  colorToMatch - color to match as closly as possible.
                  length - length of palette to search in.
    Outputs     :
    Return      : index into palette of closest match of colorToMatch
----------------------------------------------------------------------------*/
color colBestFitFindRGB(color *palette, color colorToMatch, sdword length)
{
    sdword index, error, bestError = SDWORD_Max, bestIndex;//, bestColor;

    for (index = 0; index < length; index++, palette++)
    {
        error = abs(colRed(*palette) - colRed(colorToMatch)) +
            abs(colGreen(*palette) - colGreen(colorToMatch)) +
            abs(colBlue(*palette) - colBlue(colorToMatch));
        if (error < bestError)
        {
            if (error == 0)
            {
                return(index);
            }
            bestError = error;
            bestIndex = index;
//            bestColor = *palette;
        }
    }
    return(bestIndex);
}
Beispiel #22
0
void teTeamColorsSet(sdword iTeam, color baseColor, color stripeColor)
{
    sdword index;
    real32 red, green, blue, hue, sat, val;

    dbgAssert(iTeam >= 0 && iTeam < TE_NumberPlayers);

    if (multiPlayerGame)
    {                                                       //if somebody in a multiplayer game
        red = colUbyteToReal(colRed(baseColor));
        green = colUbyteToReal(colGreen(baseColor));
        blue = colUbyteToReal(colBlue(baseColor));
        colRGBToHSV(&hue, &sat, &val, red, green, blue);
        if (colRealToUbyte(val) < cpDarkestColor0 * TE_DarkColorGraceFactor)
        {                                                   //is trying to set his ships to black
            baseColor = TE_DorkyCheaterBaseColor;
            stripeColor = TE_DorkyCheaterStripeColor;
        }
    }
    teColorSchemes[iTeam].textureColor.base = baseColor;
    teColorSchemes[iTeam].textureColor.detail = stripeColor;

#if !TO_STANDARD_COLORS
    teColorSchemes[iTeam].tacticalColor =
        teColorAdjust(baseColor, &teTacticalColorize);
#endif
    for (index = 0; index < TE_NumberTrailColors; index++)
    {
        teColorSchemes[iTeam].trailColors[index] =
            teColorAdjust(baseColor, &teTrailColorize[index]);
    }
    for (iTeam = 0; iTeam < TE_NumberPlayers; iTeam++)
    {
        teColorSchemes[iTeam].ambient = colRGB(colClamp256(colRed(teColorSchemes[iTeam].textureColor.base) * teAmbientAdjust / 65536),
            colClamp256(colGreen(teColorSchemes[iTeam].textureColor.base) * teAmbientAdjust / 65536),
            colClamp256(colBlue(teColorSchemes[iTeam].textureColor.base) * teAmbientAdjust / 65536));
        teColorSchemes[iTeam].diffuse = colRGB(colClamp256(colRed(teColorSchemes[iTeam].textureColor.base) * teDiffuseAdjust / 65536),
            colClamp256(colGreen(teColorSchemes[iTeam].textureColor.base) * teDiffuseAdjust / 65536),
            colClamp256(colBlue(teColorSchemes[iTeam].textureColor.base) * teDiffuseAdjust / 65536));
        teColorSchemes[iTeam].specular = colRGB(colClamp256(colRed(teColorSchemes[iTeam].textureColor.base) * teSpecularAdjust / 65536),
            colClamp256(colGreen(teColorSchemes[iTeam].textureColor.base) * teSpecularAdjust / 65536),
            colClamp256(colBlue(teColorSchemes[iTeam].textureColor.base) * teSpecularAdjust / 65536));
        teColorSchemes[iTeam].stripeAmbient = colRGB(colClamp256(colRed(teColorSchemes[iTeam].textureColor.base) * teAmbientAdjust / 65536),
            colClamp256(colGreen(teColorSchemes[iTeam].textureColor.base) * teAmbientAdjust / 65536),
            colClamp256(colBlue(teColorSchemes[iTeam].textureColor.base) * teAmbientAdjust / 65536));
        teColorSchemes[iTeam].stripeDiffuse = colRGB(colClamp256(colRed(teColorSchemes[iTeam].textureColor.base) * teDiffuseAdjust / 65536),
            colClamp256(colGreen(teColorSchemes[iTeam].textureColor.base) * teDiffuseAdjust / 65536),
            colClamp256(colBlue(teColorSchemes[iTeam].textureColor.base) * teDiffuseAdjust / 65536));
        teColorSchemes[iTeam].stripeSpecular = colRGB(colClamp256(colRed(teColorSchemes[iTeam].textureColor.base) * teSpecularAdjust / 65536),
            colClamp256(colGreen(teColorSchemes[iTeam].textureColor.base) * teSpecularAdjust / 65536),
            colClamp256(colBlue(teColorSchemes[iTeam].textureColor.base) * teSpecularAdjust / 65536));
    }
}
Beispiel #23
0
/*-----------------------------------------------------------------------------
    Name        : partCircleSolid2
    Description : Render a 2d circle, like the 3D one.
    Inputs      :
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void primCircleSolid2(sdword x, sdword y, sdword rad, sdword nSlices, color c)
{
    sdword index;
    GLfloat v[3];
    double theta;
    vector centre;
    real32 radiusX, radiusY;
    bool cull;

    if (glcActive())
    {
        rectangle r;
        r.x0 = x - rad;
        r.y0 = y - rad;
        r.x1 = x + rad;
        r.y1 = y + rad;
        glcRectSolid2(&r, c);
        return;
    }

    cull = glIsEnabled(GL_CULL_FACE) ? TRUE : FALSE;

    centre.x = primScreenToGLX(x);
    centre.y = primScreenToGLY(y);
    radiusX = primScreenToGLScaleX(rad);
    radiusY = primScreenToGLScaleY(rad);

    glColor4ub(colRed(c), colGreen(c),
               colBlue(c), colAlpha(c));
    v[0] = centre.x;
    v[1] = centre.y;
    glDisable(GL_CULL_FACE);
    glBegin(GL_TRIANGLE_FAN);
    glVertex2f(v[0], v[1]);
    for (index = 0, theta = 0.0; index < nSlices; index++)
    {
        v[0] = centre.x + (real32)(sin(theta)) * radiusX;
        v[1] = centre.y + (real32)(cos(theta)) * radiusY;
        theta += 2.0 * PI / (double)nSlices;
        glVertex2f(v[0], v[1]);
    }
    v[0] = centre.x;
    v[1] = centre.y + radiusY;
    glVertex2f(v[0], v[1]);
    glEnd();
    if (cull)
    {
        glEnable(GL_CULL_FACE);
    }
}
Beispiel #24
0
void primSolidTexture3Fade(vector *p1, real32 size, color c, trhandle tex, real32 fade)
{
   real32 halfsize = size / 2;
   real32 biasRed, biasGreen, biasBlue;
   texreg* reg;

   rndTextureEnable(TRUE);

   trMakeCurrent(tex);
   reg = trStructureGet(tex);
   if (bitTest(reg->flags, TRF_Alpha))
   {
      glEnable(GL_BLEND);
      glDisable(GL_ALPHA_TEST);
      rndAdditiveBlends(TRUE);
   }

   biasRed = colReal32(colRed(c));
   biasGreen = colReal32(colGreen(c));
   biasBlue = colReal32(colBlue(c));

   if (RGL)
   {
       glPixelTransferf(GL_RED_BIAS, biasRed);
       glPixelTransferf(GL_GREEN_BIAS, biasGreen);
       glPixelTransferf(GL_BLUE_BIAS, biasBlue);
   }
   glColor4f(biasRed, biasGreen, biasBlue, fade);

   glBegin(GL_QUADS);
   glTexCoord2f(0.0f, 0.0f);
   glVertex3f(p1->x-halfsize, p1->y-halfsize, 0.0f);
   glTexCoord2f(1.0f, 0.0f);
   glVertex3f(p1->x+halfsize, p1->y-halfsize, 0.0f);
   glTexCoord2f(1.0f, 1.0f);
   glVertex3f(p1->x+halfsize, p1->y+halfsize, 0.0f);
   glTexCoord2f(0.0f, 1.0f);
   glVertex3f(p1->x-halfsize, p1->y+halfsize, 0.0f);
   glEnd();

   if (RGL)
   {
       glPixelTransferf(GL_RED_BIAS, 0.0f);
       glPixelTransferf(GL_GREEN_BIAS, 0.0f);
       glPixelTransferf(GL_BLUE_BIAS, 0.0f);
   }

   glDisable(GL_BLEND);
   rndAdditiveBlends(FALSE);
}
Beispiel #25
0
sdword lodAutoSave(lodinfo *LOD)
{
    sdword level;
    FILE *fp;
    char *filePath;
    real32 baseScalar = 1.0f, stripeScalar = 1.0f;

    fp = fopen(LOD->fileName, "wt");
    if (fp == NULL)
    {
        dbgWarningf(DBG_Loc, "Cannot open '%s' for writing - not checked out?", LOD->fileName);
        return(ERROR);
    }
    fprintf(fp, "[Auto-Saved LOD file]\n");
    fprintf(fp, "pointColor                  %d,%d,%d\n\n", colRed(LOD->pointColor), colGreen(LOD->pointColor), colBlue(LOD->pointColor));

    for (level = 0; level < LOD->nLevels; level++)
    {
        fprintf(fp, "\n");
        if (LOD->level[level].baseScalar != baseScalar)
        {
            baseScalar = LOD->level[level].baseScalar;
            fprintf(fp, "baseScalar                  %.2f\n", baseScalar == 0.0f ? 1.0f : baseScalar);
        }
        if (LOD->level[level].stripeScalar != stripeScalar)
        {
            stripeScalar = LOD->level[level].stripeScalar;
            fprintf(fp, "stripeScalar                %.2f\n", stripeScalar == 0.0f ? 1.0f : stripeScalar);
        }
        fprintf(fp, "type%d                       %s\n", level, lodTypeStrings[LOD->level[level].flags & LM_LODType]);
        if ((LOD->level[level].flags & LM_LODType) == LT_Mesh)
        {
            filePath = strchr(((meshdata *)LOD->level[level].pData)->fileName, '\\') + 1;
#if LOD_ERROR_CHECKING
            if (*filePath == 0)
            {
                dbgFatalf(DBG_Loc, "Could not find '\\' in '%s'", ((meshdata *)LOD->level[level].pData)->fileName);
            }
#endif
            fprintf(fp, "pMeshFile%d                  %s\n", level, filePath);
        }
        fprintf(fp, "mOn%d                        %.1f\n", level, LOD->level[level].mOn);
        fprintf(fp, "bOn%d                        %.0f\n", level, LOD->level[level].bOn);
        fprintf(fp, "mOff%d                       %.1f\n", level, LOD->level[level].mOff);
        fprintf(fp, "bOff%d                       %.0f\n", level, LOD->level[level].bOff);
    }
    fclose(fp);
    return(0);
}
Beispiel #26
0
static void primSolidTexture3_multi(vector* p1, real32 size, color c, trhandle tex)
{
    real32 halfsize;
    texreg* reg;
    extern udword gDevcaps;

    halfsize = 0.5f * size;

    rndTextureEnable(TRUE);

    trMakeCurrent(tex);
    reg = trStructureGet(tex);
    if (bitTest(reg->flags, TRF_Alpha))
    {
        glEnable(GL_BLEND);
        glDisable(GL_ALPHA_TEST);
        rndAdditiveBlends(TRUE);
    }

    glBegin(GL_QUADS);

    glColor3ub(colRed(c), colGreen(c), colBlue(c));
    glTexCoord2f(0.0f, 0.0f);
    glVertex3f(p1->x-halfsize, p1->y-halfsize, 0.0f);
    glTexCoord2f(1.0f, 0.0f);
    glVertex3f(p1->x+halfsize, p1->y-halfsize, 0.0f);
    glTexCoord2f(1.0f, 1.0f);
    glVertex3f(p1->x+halfsize, p1->y+halfsize, 0.0f);
    glTexCoord2f(0.0f, 1.0f);
    glVertex3f(p1->x-halfsize, p1->y+halfsize, 0.0f);

    if (!bitTest(gDevcaps, DEVSTAT_NO_GETTEXIMAGE))
    {
        glColor3ub(172, 172, 172);
        glTexCoord2f(0.0f, 0.0f);
        glVertex3f(p1->x-halfsize, p1->y-halfsize, 0.0f);
        glTexCoord2f(1.0f, 0.0f);
        glVertex3f(p1->x+halfsize, p1->y-halfsize, 0.0f);
        glTexCoord2f(1.0f, 1.0f);
        glVertex3f(p1->x+halfsize, p1->y+halfsize, 0.0f);
        glTexCoord2f(0.0f, 1.0f);
        glVertex3f(p1->x-halfsize, p1->y+halfsize, 0.0f);
    }

    glEnd();

    glDisable(GL_BLEND);
    rndAdditiveBlends(FALSE);
}
Beispiel #27
0
/*-----------------------------------------------------------------------------
    Name        : primCircleOutline2
    Description : Draw a circle
    Inputs      :
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void primGLCircleOutline2(real32 x, real32 y, real32 radius, sdword nSegments, color c)
{
    sdword index;
    double angle, angleInc = 2.0 * PI / (double)nSegments;
    real32 radiusY = radius * MAIN_WindowWidth / MAIN_WindowHeight;

    glColor3ub(colRed(c), colGreen(c), colBlue(c));
    glBegin(GL_LINE_STRIP);
    glVertex2f(x, y + radiusY);
    for (index = 0, angle = angleInc; index <= nSegments; index++, angle += angleInc)
    {
        glVertex2f(x + (real32)sin(angle) * radius, y + (real32)cos(angle) * radiusY);
    }
    glEnd();
}
Beispiel #28
0
void primRectSolidTexturedFullRectC2(rectangle *rect, color c)
{
    glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));

    rndTextureEnable(TRUE);

    glBegin(GL_QUADS);
    COORD(0.0f, 0.0f, rect->x0, rect->y0);
    COORD(0.0f, 1.0f, rect->x0, rect->y1);
    COORD(1.0f, 1.0f, rect->x1, rect->y1);
    COORD(1.0f, 0.0f, rect->x1, rect->y0);
    glEnd();

    rndTextureEnable(FALSE);
}
Beispiel #29
0
/*-----------------------------------------------------------------------------
    Name        : primTriSolid2
    Description : Draw a solid 2D triangle
    Inputs      : tri - pointer to triangle structure containing coordinates of corners
                  c - color to draw it in
    Outputs     :
    Return      : void
----------------------------------------------------------------------------*/
void primTriSolid2(triangle *tri, color c)
{
    if (glcActive())
    {
        glcTriSolid2(tri, c);
    }
    else
    {
        glColor3ub(colRed(c), colGreen(c), colBlue(c));
        glBegin(GL_TRIANGLES);
        glVertex2f(primScreenToGLX(tri->x0), primScreenToGLY(tri->y0));
        glVertex2f(primScreenToGLX(tri->x1), primScreenToGLY(tri->y1));
        glVertex2f(primScreenToGLX(tri->x2), primScreenToGLY(tri->y2));
        glEnd();
    }
}
Beispiel #30
0
// FIXME
void CirclePoints(int x, int y, color c, int cx, int cy)
{
    glColor3ub(colRed(c), colGreen(c), colBlue(c));
    glPointSize(4.0f);
    glBegin(GL_POINTS);
    dbgMessagef("\nCirclePoints %d %d %d %d", x, y, cx, cy);
    glVertex2i(x + cx, y + cy);
    glVertex2i(y + cx, x + cy);
    glVertex2i(y + cx, -x + cy);
    glVertex2i(x + cx, -y + cy);
    glVertex2i(-x + cx, -y + cy);
    glVertex2i(-y + cx, x + cy);
    glVertex2i(-x + cx, y + cy);
    glEnd();
    glPointSize(1.0f);
}