Пример #1
0
Bool VIV2DGPUCtxDeInit(GALINFOPTR galInfo) {
    TRACE_ENTER();
    gctBOOL ret = gcvTRUE;
    VIVGPUPtr gpuctx = gcvNULL;
    if (galInfo->mGpu == NULL) {
        TRACE_ERROR("GPU CTX IS NULL\n");
        TRACE_EXIT(TRUE);
    }

    VDestroySurf();

    gpuctx = (VIVGPUPtr) (galInfo->mGpu);
    ret = DestroyDevice(gpuctx->mDevice);
    if (ret != gcvTRUE) {
        TRACE_ERROR("ERROR WHILE DESTROYING DEVICE \n");
        TRACE_EXIT(FALSE);
    }
    ret = DestroyDriver(gpuctx->mDriver);
    if (ret != gcvTRUE) {
        TRACE_ERROR("ERROR WHILE DESTROYING DRIVER\n");
        TRACE_EXIT(FALSE);
    }
    TRACE_EXIT(TRUE);
}
Пример #2
0
    int32 rwmain( Interface *engineInterface )
    {
        // Matrix test.
        {
            static RwMatrix newMat =
            {
                { 1, 2, 3, 4 },
                { 6, 5, 3, 7 },
                { 2, 7, 5, 4 },
                { 2, 5, 4, 6 }
            };

            static RwMatrix srcIdent =
            {
                { 4, 5, 3, 4 },
                { 8, 3, 7, 5 },
                { 2, 1, 6, 3 },
                { 5, 8, 4, 5 }
            };

            static RwMatrix target( newMat * srcIdent );

            target *= 4.5;

            __debugbreak();
        }

        // Give information about the running application to the runtime.
        softwareMetaInfo metaInfo;
        metaInfo.applicationName = "RenderWare Sample";
        metaInfo.applicationVersion = "test";
        metaInfo.description = "A test application for the rwtools runtime";

        engineInterface->SetApplicationInfo( metaInfo );

        // Create a window and render into it.
        Window *rwWindow = MakeWindow( engineInterface, 640, 480 );

        if ( !rwWindow )
            return -1;

        // We hold an extra reference.
        AcquireObject( rwWindow );

        // Handle the window closing event.
        RegisterEventHandler( rwWindow, event_t::WINDOW_CLOSING, window_closing_event_handler );
        RegisterEventHandler( rwWindow, event_t::WINDOW_QUIT, window_closing_event_handler );

        // Show the window, since we have set it up by now.
        rwWindow->SetVisible( true );
        
        // Create the game renderer.
        Driver *d3dDriver = CreateDriver( engineInterface, "Direct3D12" );

        assert( d3dDriver != NULL );

        // Set up the game resources.
        DriverSwapChain *swapChain = d3dDriver->CreateSwapChain( rwWindow, 2 ); // we want to double-buffer.

        DrawingLayer2D *guiContext = CreateDrawingLayer2D( d3dDriver );

        // We have to get the ref count over here, because the swap chain increases the ref count as well.
        uint32 wndBaseRefCount = GetRefCount( rwWindow );

        // Execute the main loop
        while ( GetRefCount( rwWindow ) >= wndBaseRefCount )   // we wait until somebody requested to destroy the window.
        {
            // Draw the game scene.
            {
                // Set render states.
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_UTEXADDRESSMODE, RWTEXADDRESS_WRAP );
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_VTEXADDRESSMODE, RWTEXADDRESS_WRAP );
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_ZWRITEENABLE, true );
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_TEXFILTER, RWFILTER_POINT );
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_SRCBLEND, RWBLEND_ONE );
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_DSTBLEND, RWBLEND_ZERO );
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_ALPHABLENDENABLE, true );
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_ALPHAFUNC, RWCMP_ALWAYS );
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_ALPHAREF, 0 );

#if 0
                // Execute draws.
                guiContext->Begin();

                guiContext->DrawRect( 50, 50, 100, 100 );
                guiContext->DrawRect( 60, 60, 80, 80 );
                guiContext->DrawLine( 10, 10, 290, 150 );

                guiContext->End();
#endif
            }

            // Give cycles to the window manager.
            // In the multi-threaded environment, this will effectively be a no-op.
            PulseWindowingSystem( engineInterface );

            // We want to give some cycles to the OS.
            // Otherwise our thread would starve everything.
            YieldExecution( 1 );
        }

        // Hide the window.
        // Do this because terminating resources takes some time and
        // the user already knows this application is terminating.
        rwWindow->SetVisible( false );

        // Destroy drawing contexts.
        DeleteDrawingLayer2D( guiContext );

        // Release the swap chain device resource.
        d3dDriver->DestroySwapChain( swapChain );

        // Terminate the driver.
        DestroyDriver( engineInterface, d3dDriver );

        // Release our window reference.
        // This will destroy it.
        engineInterface->DeleteRwObject( rwWindow );

        return 0;
    }