Example #1
0
// -------------------------------------------------------------------------------------------------------
// drawTexture() - Draws a tile at a specific position.
// -------------------------------------------------------------------------------------------------------
void MapDrawer::drawTexture(const int row, const int column, const int idx)
{
    if (pagers[idx] != 0 && myMap != 0 && getDisplay() != 0) {
        TextureTable& tbl = pagers[idx]->getTable();    
        BasicGL::Texture* newTex = dynamic_cast<BasicGL::Texture*>(tbl.getTexture(row, column));
        if (newTex != 0) {
            // Bind our texture and set up our modulation
            glBindTexture(GL_TEXTURE_2D, newTex->getTexture());
            glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);


            LCreal transX = (LCreal) column * pixPerTile * scalingEast[idx];
            LCreal transY = (LCreal) -row * pixPerTile * scalingNorth[idx];
            glPushMatrix();
                glTranslatef(GLfloat(transX), GLfloat(transY), 0.0f);
                glBegin(GL_POLYGON);
                    glTexCoord2f(0.0f, 0.0f); lcVertex2(0.0f, -pixPerTile * scalingNorth[idx]);
                    glTexCoord2f(1.0f, 0.0f); lcVertex2(pixPerTile * scalingEast[idx], -pixPerTile * scalingNorth[idx]);
                    glTexCoord2f(1.0f, 1.0f); lcVertex2(pixPerTile * scalingEast[idx], 0.0f);
                    glTexCoord2f(0.0f, 1.0f); lcVertex2(0.0f, 0.0f);
                glEnd();
            glPopMatrix();
        }
    }    
}
Example #2
0
//------------------------------------------------------------------------------
// goDrawDGrid() - Draw the grid, if needed
//------------------------------------------------------------------------------
void MapDrawer::goDrawGrid(const int row, const int column, const int idx)
{   
	glPushMatrix();
        glTranslatef(GLfloat(column * pixPerTile), GLfloat(-row * pixPerTile), 0.5f);
        glColor3f(1,0,0);
        glLineWidth(2.0);
        glBegin(GL_LINE_LOOP);
            lcVertex2(0.0f, -pixPerTile * scalingNorth[idx]);
            lcVertex2(pixPerTile * scalingEast[idx], -pixPerTile * scalingNorth[idx]);
            lcVertex2(pixPerTile * scalingEast[idx], 0.0f);
            lcVertex2(0.0f, 0.0f);
        glEnd();
	glPopMatrix();
}
Example #3
0
//------------------------------------------------------------------------------
// drawFunc() -- draws the object(s)
//------------------------------------------------------------------------------
void AnalogGauge::drawFunc()
{   
    if (drawMe) {
    glPushMatrix();
        // move us just slightly into the background, so things will overlay us
        gaugePos = getInstValue();
        //glTranslatef(0, 0, -0.1f);
        // if we are vertical, draw us growing up and down, else draw us growing left to right
        if (vertical) {
            if (outline) glBegin(GL_LINE_STRIP);
            else glBegin(GL_POLYGON); 
                    lcVertex2(leftBoundary, 0);
                    lcVertex2(leftBoundary, gaugePos);
                    lcVertex2(rightBoundary, gaugePos);
                    lcVertex2(rightBoundary, 0);
                glEnd();                
        }
        else {
            if (outline) glBegin(GL_LINE_STRIP);
            else glBegin(GL_POLYGON);
                    lcVertex2(0, leftBoundary);
                    lcVertex2(gaugePos, leftBoundary);
                    lcVertex2(gaugePos, rightBoundary);
                    lcVertex2(0, rightBoundary);
                glEnd(); 
        }               
    glPopMatrix();    
}
}
Example #4
0
//------------------------------------------------------------------------------
// drawFunc() -- draws the object(s)
//------------------------------------------------------------------------------
void DialTickMarks::drawFunc()
{
    GLfloat currentColor[4];
    glGetFloatv(GL_CURRENT_COLOR, currentColor);

    // get our data from our baseclass (AnalogDial)
    double sweepAngle = getSweepAngle();
    double startAngle = getStartAngle();
    double tRadius = getRadius();

    // figure our rotation angle per tick mark (deg)
    double rotation = sweepAngle/quantity;

    glPushMatrix();
        // rotate to our start angle
        glRotatef(static_cast<GLfloat>(-startAngle), 0, 0, 1);
        for (int i = 0; i < quantity + 1; i++) {
            // if we have a graphic, draw that, else we draw a line
            if (myGraphic == nullptr) {
                glBegin(GL_LINES);
                    lcVertex2(0, tRadius);
                    lcVertex2(0, tRadius - length);
                glEnd();
            }
            else {
                myGraphic->lcSaveMatrix();
                    myGraphic->lcTranslate(0, tRadius);
                    myGraphic->draw();
                myGraphic->lcRestoreMatrix();
            }
            glRotatef(static_cast<GLfloat>(-rotation), 0, 0, 1);
        }
    glPopMatrix();

    glColor4fv(currentColor);
}
Example #5
0
//------------------------------------------------------------------------------
// drawFunc() -- draws the object(s)
//------------------------------------------------------------------------------
void GhostHorizon::drawFunc()
{
    GLfloat ocolor[4];
    glGetFloatv(GL_CURRENT_COLOR, ocolor);

    glPushMatrix();

    // if we are negative translation (pitch up), we show the ground background below us
    // ground
    // get our table to determine our min and max value
    LCreal maxPitch = 90;
    LCreal minPitch = -90;
    const Basic::Table1* table = getScalingTable();
    if (table != nullptr) {
        maxPitch = table->getMaxX();
        minPitch = table->getMinX();
    }

    LCreal value = getPreScaleInstValue();

    if (value > maxPitch) {
            glColor3d(groundColor.x(), groundColor.y(), groundColor.z());
            glBegin(GL_POLYGON);
                lcVertex2(-width, -height);
                lcVertex2(-width, 0);
                lcVertex2( width, 0);
                lcVertex2( width, -height);
            glEnd();

    }
    // sky
    else if (value < minPitch) {
        glColor3d(skyColor.x(), skyColor.y(), skyColor.z());
        glBegin(GL_POLYGON);
            lcVertex2(-width, height);
            lcVertex2(-width, 0);
            lcVertex2(width, 0);
            lcVertex2(width, height);
        glEnd();

    }
    glPopMatrix();

    glColor4fv(ocolor);
}
//------------------------------------------------------------------------------
// drawFunc() - draw our objects
//------------------------------------------------------------------------------
void SpdLines::drawFunc()
{    
    GLfloat ocolor[4];
    GLfloat lw;
    glGetFloatv(GL_CURRENT_COLOR, ocolor);
    glGetFloatv(GL_LINE_WIDTH, &lw);
    
    BEGIN_DLIST

        if (!isAlt) {
            LCreal startPoint = 0;
            // now step through and draw all the lines (100 of them)
            // draw the big lines first
            glLineWidth(2);
            for (int i = 0; i < 51; i++) {
                glPushMatrix();
                    glBegin(GL_LINES);
                        lcVertex2(0.6f, startPoint);
                        lcVertex2(0.48f, startPoint);
                    glEnd();
                glPopMatrix();
                // move up to the next line
                startPoint += 0.9f;
            }
            // now draw the small lines
            startPoint = 0.45f;
            for (int i = 0; i < 50; i++) {
                glPushMatrix();
                    glBegin(GL_LINES);
                        lcVertex2(0.6f, startPoint);
                        lcVertex2(0.52f, startPoint);
                    glEnd();
                glPopMatrix();
                // move up to the next line
                startPoint += 0.9f;
            }
            
            if (drawBack) {
                glLineWidth(1);
                glColor3f(0, 0, 0);
                // make the polygon last
                glPushMatrix();
                    glBegin(GL_POLYGON);
                        glVertex2f(0, 15);
                        glVertex2f(0, -15);
                        glVertex2f(0.6f, -15);
                        glVertex2f(0.6f, 15);
                    glEnd();
                glPopMatrix();
            }
        }
        else {
            // if we are drawing the altitude lines
            LCreal startPoint = 0;
            // now step through and draw all the lines (approx 280 of them, gets us to about 55,800 feet)
            // draw the big lines first
            glLineWidth(2);
            for (int i = 0; i < 281; i++) {
                glPushMatrix();
                    glBegin(GL_LINES);
                        lcVertex2(0, startPoint);
                        lcVertex2(0.12f, startPoint);
                    glEnd();
                glPopMatrix();
                // move up to the next line
                startPoint += 0.9f;
            }
            // now draw the small lines
            startPoint = 0.45f;
            for (int i = 0; i < 280; i++) {
                glPushMatrix();
                    glBegin(GL_LINES);
                        lcVertex2(0, startPoint);
                        lcVertex2(0.08f, startPoint);
                    glEnd();
                glPopMatrix();
                // move up to the next line
                startPoint += 0.9f;
            }

            if (drawBack) {
                glLineWidth(1);
                glColor3f(0, 0, 0);

                // make the polygon last
                glPushMatrix();
                    glBegin(GL_POLYGON);
                        glVertex2f(0, 15);
                        glVertex2f(0, -15);
                        glVertex2f(0.879f, -15);
                        glVertex2f(0.879f, 15);
                    glEnd();
                glPopMatrix();
            }
        }        
    END_DLIST  
      
    glColor4fv(ocolor);
    glLineWidth(lw);
}