Beispiel #1
0
Datei: main.c Projekt: huangjs/cl
void DrawIntroMessage(void)
{
    SetBackgndColorHex(COLOR_BOX);
    SetPenColorHex(COLOR_TEXT);
    DrawText2D(helv18, TEXT_X, TEXT_Y, "INSTRUCTIONS:");
    DrawText2D(helv18, TEXT_X, TEXT_Y * 2, "--Click on the largest house to win!!");
    DrawText2D(helv18, TEXT_X, TEXT_Y * 3, "--Press the right or left arrows for more or less houses");
    DrawText2D(helv18, TEXT_X, TEXT_Y * 4, "--Press any other key to exit");
}
Beispiel #2
0
Datei: main.c Projekt: huangjs/cl
void WinMessage(void)
{    
    SetPenColorHex(COLOR_BOX);
    DrawFillBox(TEXT_X * 3, TEXT_Y * 5, TEXT_X * 8, TEXT_Y);
    SetPenColorHex(COLOR_TEXT);
    DrawBox(TEXT_X * 3, TEXT_Y * 5, TEXT_X * 8, TEXT_Y);
    DrawText2D(helv18, TEXT_X * 4, TEXT_Y * 2, "********************");
    DrawText2D(helv18, TEXT_X * 4, TEXT_Y * 3, "****You Win!!!****");
    DrawText2D(helv18, TEXT_X * 4, TEXT_Y * 4, "********************");
}
Beispiel #3
0
void World::Render()
{
    UseMainWindowContext();

    glGetIntegerv(GL_VIEWPORT, viewport);
    int fHeight = viewport[3];
    int fWidth = viewport[2];

    if(m_bRunning)
    {
        if(!luaCall("prerender()", "onerrorgl"))
        {
            m_bRunning = false;
        }

        //ioCall("render()");
    }

    glViewport(0,0,fWidth, fHeight);

    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LESS);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    // glEnable(GL_CULL_FACE);
    glDisable(GL_CULL_FACE);

    // Turned this off for the Vivo Smart Tab
    // Turn it back on again if needed.
    //glEnable(GL_POLYGON_OFFSET_FILL);
    //glPolygonOffset (1., 1.);

    glClearColor(Int2FloatCol(m_nClearColorRed),
                 Int2FloatCol(m_nClearColorGreen),
                 Int2FloatCol(m_nClearColorBlue),
                 1.0f);
    //glClearColor(0.0f, (float)(rand()%1000) * 0.001f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();

    BuildGLMatrices();

    RenderFloorPlane();
    if(m_bUpdatePickPosition && !m_bDoubleClick)
        RefreshFloorPickPosition();

    glClearColor(Int2FloatCol(m_nClearColorRed),
                 Int2FloatCol(m_nClearColorGreen),
                 Int2FloatCol(m_nClearColorBlue),
                 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // turned off the lighting code for now
    // too much to tune
    // 3d ck didn't have lighting
    // just a simple scheme for coloring the different faces
    // of the object primitives so that they were distinct

    //glEnable(GL_LIGHTING);
    //glEnable(GL_LIGHT0);
    //glEnable(GL_LIGHT1);
    //glEnable(GL_MULTISAMPLE);
    glEnable(GL_COLOR_MATERIAL);

    if(m_bRenderFloorGrid)
        RenderFloorGrid();

    //static GLfloat lightPosition[4] = { 0.5, 5.0, 7.0, 1.0 };
    //static GLfloat lightPosition1[4] = {  30, 10,  30, 1.0 };
    //static GLfloat lightPosition2[4] = {   0, 20, 400, 1.0 };
    //glLightfv(GL_LIGHT0, GL_POSITION, lightPosition2);
    //glLightfv(GL_LIGHT1, GL_POSITION, lightPosition2);
    // x = 400, y = -300 + i * 60, z = 20
    //glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
    //glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);

    glColor4ub(255,255,255,255);

    if(m_bRunning)
    {
        if(!luaCall("render()", "onerrorgl"))
        {
            m_bRunning = false;
        }

        //ioCall("render()");
    }

    // Restore a sane render state in case render left it in a bad condition
    glDisable(GL_STENCIL_TEST);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LESS);
    glColorMask(1,1,1,1);

    // If there is an error, then stop the automatic lua calls.

    UseMainWindowContext();

    glColor4ub(0,255,0,255); // green

    //if(m_bRenderOutput)
    //    DrawText3DStroked(mlVector3D(-50,0,0  ), SelectEndLines(luaGetOutput(),100));

    //if(m_bRenderError)
    //    DrawText3DStroked(mlVector3D(-50,0,200), SelectEndLines(luaGetError(),100));

    if(m_bRenderFloorPlane)
        RenderFloorPlane();

    if(m_bUpdatePickPosition && !m_bDoubleClick)
		RefreshPickPosition();

    if(m_bRenderMousePickSphere)
        RenderMousePickSphere();


    if(m_bRenderProbesHUD)
        RenderProbes();

    if(m_bRunning)
    {
        if(!luaCall("postrender()", "onerrorgl"))
        {
            m_bRunning = false;
        }
    }

    // Restore a sane render state in case postrender left it in a bad condition
    glDisable(GL_STENCIL_TEST);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LESS);
    glColorMask(1,1,1,1);

    glDisable(GL_LIGHTING);
    glDisable(GL_LIGHT0);
    glDisable(GL_LIGHT1);
    glDisable(GL_MULTISAMPLE);

    glMatrixMode(GL_PROJECTION);
    glPopMatrix();

    if(m_bRenderEditor)
    {
        // Get rid of this completely.
        qt_save_gl_state();
        GetEditor()->Render();
        qt_restore_gl_state();

        DrawText2D(mlVector3D(5,2), std::string("Buffer: ") + GetEditor()->GetName());
    }

    if(m_bRenderFPS)
    {
#ifdef __PRAXIS_WINDOWS__
        int nCurrentTime = ::timeGetTime();
#endif
#ifdef __PRAXIS_LINUX__
        int nCurrentTime = glutGet(GLUT_ELAPSED_TIME);
#endif
        if(m_nRenderCount % 10 == 0)
        {
            int nTimeDelta = nCurrentTime - g_nLastFrameTime;
            g_nLastFrameTime = nCurrentTime;
            g_fFPS = 1000.0f / (float)nTimeDelta;
            g_fFPS *= 10.0f;
        }

        //qt_save_gl_state();
        //GetEditor()->Render();
        //qt_restore_gl_state();

        // Render a graph
        // A widget
        // A camera aligned widget
        // A widget for the 2D world
        // Just a camera aligned widget will do.

        stringstream ss; ss << std::setprecision(0) << std::fixed << g_fFPS << "fps";
        DrawText2D(mlVector3D(90,95), ss.str());
    }


    // Also, FPS
    // Get current time
    // Compare with previous time
    // Calculate and display FPS
    // ????
    // PROFIT

    if(m_bRenderOutput)
        DrawText2D(mlVector3D(10 + GLEditor::m_nDesiredTextureSize + 10, 35 + GLEditor::m_nDesiredTextureSize - 13),  SelectEndLines(PraxisLog::trace,20), fWidth, fHeight);

    if(m_bRenderError)
        DrawText2D(mlVector3D(10 + GLEditor::m_nDesiredTextureSize + 10, 35 + (GLEditor::m_nDesiredTextureSize / 4)),  SelectEndLines(PraxisLog::error,20), fWidth, fHeight);

    m_nRenderCount++;
}
void iGraphics::draw_text (int x, int y, const char* c)
{
	DrawText2D (x, invert (y), c);
};