Beispiel #1
0
/*=========================================================================
// Name: DrawScene()
// Desc: Draws the whole scene!
//=======================================================================*/
static void DrawScene()
{
    char chScore[30],
         chLines[30],
         chLevel[30];

    /* Black background */
    SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0,0,0));
    DrawStars(); /* Starfield */

    if (bCrazy)
        WriteText(font, 250, 30+(boxdraw.box_x), "Cr4zY m0d3!"); /* woo hoo! */

    if (!bGameOver) {
        /* Draw border of the box */
        PutRect(boxdraw.box_x-5, boxdraw.box_y-5,
                boxdraw.box_width + 2*5, boxdraw.box_height + 2*5, 150,150,150);
        PutRect(boxdraw.box_x, boxdraw.box_y,
                boxdraw.box_width, boxdraw.box_height, 90,90,90);

        DrawCluster(); /* Draw cluster */
        sprintf(chScore, "%d", score);
        sprintf(chLines, "%d", lines);
        sprintf(chLevel, "%d", level);
        WriteText(font, 490, 80, "Score");  /*  Show SCORE */
        WriteText(font, 490, 105, chScore); 
        WriteText(font, 495, 180, "Next");  /*  Show NEXT piece */
        DrawNextPiece(490, 220);
        WriteText(font, 490, 350, "Lines"); /*  Show number of killed LINES */
        WriteText(font, 490, 375, chLines);
        WriteText(font, 95, 350, "Level");  /*  Show current LEVEL */
        WriteText(font, 95, 375, chLevel);
    }

    DrawBox();       /* Draw box bricks */
    DrawParticles();

    if (bPause)
        WriteText(font, 265, 20, "- PAUSE -");
    if (bGameOver && !bExplode) {
        WriteTextCenter(font, 120, "GAME OVER");
        sprintf(chScore, "Your Score: %d", score); 
        WriteTextCenter(font, 250, chScore);
    }

    SDL_Flip(screen); /* Let's flip! */
}
int
D3DOverdrawWindow::
Loop(int iClusterA, int iClusterB)
{
    int nOverdraw = 0;
    DWORD numberOfPixelsDrawn;
    int j = 0;
    SetupDraw(0);

    for (unsigned int iViewpoint = 0; iViewpoint < m_nViewpointCount; iViewpoint++)
    {
        SetupView(iViewpoint);
        m_iTested++;

        if (!CheckIsect(iClusterA, iClusterB))
        {
            continue;
        }

        m_iRendered++;
        SetupTransforms();
        d3d->Clear(0, NULL,  D3DCLEAR_ZBUFFER,
                   D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

        //Add this to remove triple dependencies
        //DrawComplement(iClusterA, iClusterB);

        // Add an end marker to the command buffer queue.
        m_pOcclusionQuery[j]->Issue(D3DISSUE_BEGIN);
        // Draw scene
        DrawCluster(iClusterA);
        DrawCluster(iClusterB);
        // Add an end marker to the command buffer queue.
        m_pOcclusionQuery[j]->Issue(D3DISSUE_END);
        // Force the driver to execute the commands from the command buffer.
        // Empty the command buffer and wait until the GPU is idle.
        j++;

        if (j == NUM_QUERIES)
        {
            for (j = 0; j < NUM_QUERIES; j++)
            {
                while (S_FALSE == m_pOcclusionQuery[j]->GetData(&numberOfPixelsDrawn,
                                                                sizeof(DWORD), D3DGETDATA_FLUSH))
                    ;

                nOverdraw += numberOfPixelsDrawn;
            }

            j = 0;
        }
    }

    int jnum = j;

    for (int j = 0; j < jnum; j++)
    {
        while (S_FALSE == m_pOcclusionQuery[j]->GetData(&numberOfPixelsDrawn,
                                                        sizeof(DWORD), D3DGETDATA_FLUSH))
            ;

        nOverdraw += numberOfPixelsDrawn;
    }

    return nOverdraw;
}