Esempio n. 1
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);
}
Esempio n. 2
0
/*-----------------------------------------------------------------------------
    Name        : primLineLoopEnd2
    Description : End a line - loop sequence
    Inputs      : void
    Outputs     :
    Return      : void
----------------------------------------------------------------------------*/
void primLineLoopEnd2(void)
{
    glEnd();
    glPopAttrib();
    if (glCapFeatureExists(GL_LINE_SMOOTH))
    {
        if (!LLblendon) glDisable(GL_BLEND);
        glDisable(GL_LINE_SMOOTH);
    }
}
Esempio n. 3
0
void tutDrawLinePulse(sdword x0, sdword y0, sdword x1, sdword y1, ubyte pulsevalue, sdword segsize)
{
    real32 x0f = (real32)x0;
    real32 y0f = (real32)y0;
    real32 x1f = (real32)x1;
    real32 y1f = (real32)y1;

    real32 diffx = (x1f - x0f);
    real32 diffy = (y1f - y0f);
    sdword segment;
    real32 segments;
    bool blendon;

    segments = fsqrt(diffx*diffx + diffy*diffy) / (real32)segsize;

    diffx /= segments;
    diffy /= segments;

    if (glCapFeatureExists(GL_LINE_SMOOTH))
    {
        blendon = (bool)glIsEnabled(GL_BLEND);
        if (!blendon) glEnable(GL_BLEND);
        glEnable(GL_LINE_SMOOTH);
    }
    glBegin(GL_LINES);
    for(segment = 0; segment <= segments; segment++)
    {
        glColor3ub(pulsevalue, pulsevalue, pulsevalue);
        glVertex2f(primScreenToGLX((sdword)x0f), primScreenToGLY((sdword)y0f));
        x0f += diffx;
        y0f += diffy;
        glVertex2f(primScreenToGLX((sdword)x0f), primScreenToGLY((sdword)y0f));
        pulsevalue += 25;
    }
    glEnd();
    if (glCapFeatureExists(GL_LINE_SMOOTH))
    {
        glDisable(GL_LINE_SMOOTH);
        if (!blendon) glDisable(GL_BLEND);
    }
}
Esempio n. 4
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);
}
Esempio n. 5
0
/*-----------------------------------------------------------------------------
    Name        : primLine3
    Description : Draw a line in 3D using having a thickness of 1 pixel
    Inputs      : p1, p2 - end points of line segment to draw
                  c - color to draw it in.
    Outputs     :
    Return      : void
----------------------------------------------------------------------------*/
void primLine3(vector *p1, vector *p2, color c)
{
    bool blendon;

    if (glCapFeatureExists(GL_LINE_SMOOTH))
    {
        blendon = glIsEnabled(GL_BLEND);
        if (!blendon) glEnable(GL_BLEND);
        glEnable(GL_LINE_SMOOTH);
        rndAdditiveBlends(FALSE);
    }

    glColor3ub(colRed(c), colGreen(c), colBlue(c));
    glBegin(GL_LINES);
    glVertex3fv((const GLfloat *)p1);
    glVertex3fv((const GLfloat *)p2);
    glEnd();

    if (glCapFeatureExists(GL_LINE_SMOOTH))
    {
        if (!blendon) glDisable(GL_BLEND);
        glDisable(GL_LINE_SMOOTH);
    }
}
Esempio n. 6
0
/*-----------------------------------------------------------------------------
    Name        : primBeginPointSize3Fade
    Description : begin drawing multiple 3D points
    Inputs      : size - size of point (ie. 1.0f, 2.0f, ...)
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void primBeginPointSize3Fade(real32 size)
{
    if (glCapFeatureExists(GL_POINT_SIZE))
    {
        glPointSize(size);
    }
    gFastBlends = glCapFastFeature(GL_BLEND);
    if (gFastBlends)
    {
        gWasBlending = glIsEnabled(GL_BLEND);
        if (!gWasBlending)
        {
            glEnable(GL_BLEND);
        }
        rndAdditiveBlends(FALSE);
    }
    glBegin(GL_POINTS);
}
Esempio n. 7
0
/*-----------------------------------------------------------------------------
    Name        : primSolidTexture3
    Description : Draw a 3D point with size
    Inputs      : p1 - location of point
                  size - physical size of point
                  c - color of point
    Outputs     :
    Return      : void
----------------------------------------------------------------------------*/
void primSolidTexture3(vector *p1, real32 size, color c, trhandle tex)
{
    real32 halfsize;
    real32 biasRed, biasGreen, biasBlue;
    texreg* reg;

    if (!glCapFeatureExists(RGL_COLOROP_ADD))
    {
        //multi-pass render to approximate a missing feature
        primSolidTexture3_multi(p1, size, c, tex);
        return;
    }

    halfsize = 0.5f * size;

    rndTextureEnable(TRUE);
//    glDepthMask(GL_FALSE);

    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);
    }
    glColor3f(biasRed, biasGreen, biasBlue);

    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);
//    glDepthMask(GL_TRUE);
    rndAdditiveBlends(FALSE);
}
Esempio n. 8
0
/*-----------------------------------------------------------------------------
    Name        : primCircleOutline3
    Description : Draw a solid circle on the z = centre->z plane
    Inputs      : centre - centre point (in 3D coords) of the circle
                  radius - radius of circle (actually, distance
                    from centre to vertices)
                  nSlices - number of polygons to draw
                  nSpokes - number of 'spokes' which actually get drawn.
                    nSlices should integer divide by this with no remainder.
                  color - color of circle
                  axis - axis on which to draw the circle
    Outputs     : ..
    Return      : void
----------------------------------------------------------------------------*/
void primCircleOutline3(vector *centre, real32 radius, sdword nSlices,
                        sdword nSpokes, color color, uword axis)
{
    Node *node;
    vertice_array *vertices;
    register vector *vec_ptr;
    sdword index;
    GLfloat c[3], rim[3];

    // find the vertice list containing the unit circle that has the same
    // number of slices and is aligned along the same axis as the circle to be drawn
    node = CircleList.head;
    while (node != NULL)
    {
        vertices = (vertice_array *)listGetStructOfNode(node);
        if ((vertices->num_vertices == (nSlices + 1)) && (vertices->axis == axis))
        {
            //found the correct unit circle
            break;
        }

        node = node->next;
    }

    //if the unit circle isn't found, generate a new one
    if (node == NULL)
    {
        vertices = primCreateNewCircleVerticeArray(nSlices, axis);
    }

    if (nSpokes != 0)
    {
        nSpokes = nSlices / nSpokes;
    }

    glColor3ub(colRed(color), colGreen(color), colBlue(color));
    c[0] = centre->x;                                       //compute centre point
    c[1] = centre->y;
    c[2] = centre->z;

    glShadeModel(GL_SMOOTH);
    if (glCapFeatureExists(GL_LINE_SMOOTH))
    {
        glEnable(GL_BLEND);
        glEnable(GL_LINE_SMOOTH);
        rndAdditiveBlends(FALSE);
    }

    vec_ptr = &vertices->vertice[0];

    switch (axis)
    {
        case X_AXIS:
            rim[0] = centre->x + vec_ptr->x * radius;

            //draw the circle
            glBegin(GL_LINE_LOOP);
            for (index = 0; index <= nSlices; index++, vec_ptr++)
            {
                rim[1] = centre->y + vec_ptr->y * radius;
                rim[2] = centre->z + vec_ptr->z * radius;
                glVertex3fv(rim);                                   //vertex on rim
            }
            glEnd();

            //now draw the spokes
            if (nSpokes)
            {
                vec_ptr = &vertices->vertice[0];
                glBegin(GL_LINES);
                for (index = 0; index <= nSlices; index += nSpokes, vec_ptr += nSpokes)
                {
                    rim[1] = centre->y + vec_ptr->y * radius;
                    rim[2] = centre->z + vec_ptr->z * radius;
                    glVertex3fv(c);
                    glVertex3fv(rim);
                }
                glEnd();
            }
            break;

        case Y_AXIS:
            rim[1] = centre->y + vec_ptr->y * radius;

            //draw the circle
            glBegin(GL_LINE_LOOP);
            for (index = 0; index <= nSlices; index++, vec_ptr++)
            {
                rim[0] = centre->x + vec_ptr->x * radius;
                rim[2] = centre->z + vec_ptr->z * radius;
                glVertex3fv(rim);                                   //vertex on rim
            }
            glEnd();

            //draw the spokes
            if (nSpokes)
            {
                vec_ptr = &vertices->vertice[0];
                glBegin(GL_LINES);
                for (index = 0; index <= nSlices; index += nSpokes, vec_ptr += nSpokes)
                {
                    rim[0] = centre->x + vec_ptr->x * radius;
                    rim[2] = centre->z + vec_ptr->z * radius;
                    glVertex3fv(c);
                    glVertex3fv(rim);
                }
                glEnd();
            }
            break;

        case Z_AXIS:
            rim[2] = centre->z + vec_ptr->z * radius;

            //draw the circle
            glBegin(GL_LINE_LOOP);
            for (index = 0; index <= nSlices; index++, vec_ptr++)
            {
                rim[0] = centre->x + vec_ptr->x * radius;
                rim[1] = centre->y + vec_ptr->y * radius;
                glVertex3fv(rim);                                   //vertex on rim
            }
            glEnd();

            //draw the spokes
            if (nSpokes)
            {
                vec_ptr = &vertices->vertice[0];
                glBegin(GL_LINES);
                for (index = 0; index <= nSlices; index += nSpokes, vec_ptr += nSpokes)
                {
                    rim[0] = centre->x + vec_ptr->x * radius;
                    rim[1] = centre->y + vec_ptr->y * radius;
                    glVertex3fv(c);
                    glVertex3fv(rim);
                }
                glEnd();
            }
            break;

        default:
            break;
    }

    if (glCapFeatureExists(GL_LINE_SMOOTH))
    {
        glDisable(GL_BLEND);
        glDisable(GL_LINE_SMOOTH);
    }
}