Exemplo n.º 1
0
//--------------------------------------------------------------------------------------
// Preloads the music and sound effects
//--------------------------------------------------------------------------------------
void InitApp()
{
    //! Play bg music
    g_mp3p.PlayFile(g_cstrThemeSong, DXUTGetHWND(), WM_GRAPHNOTIFY);

    //! Setup Sound manager and Preload soundfx
    g_pGame->InitApp(DXUTGetHWND());
    //TODO:
}
Exemplo n.º 2
0
void MainHUD::CreateControls()
{
    RECT rect;
    int buttonHeight = 21;

    HWND hwnd = DXUTGetHWND();
    GetClientRect(hwnd, &rect);

    m_Dialog.SetLocation( 0, rect.bottom - buttonHeight );
    m_Dialog.SetSize( rect.right, buttonHeight );

    //m_Dialog.SetBackgroundColors( HudManager::BackgroundColor );
    //m_Dialog.SetLocation( (int)( rect.right*0.1f ), (int)( rect.bottom*0.1f )  );
    //m_Dialog.SetSize( (int)( rect.right*0.8f ), (int)( rect.bottom*0.8f ) );
    //m_Dialog.SetCaptionHeight( 31 );
    //m_Dialog.SetCaptionText(L"Test");
    //m_Dialog.EnableCaption( true );


    //bottom row
    int buttonTop = 0;//m_Dialog.GetHeight()-buttonHeight;

    int iButton = 0;
    int buttonWidth = m_Dialog.GetWidth()/6;
    m_Dialog.AddButton( MAINDLG_OPEN, L"Open", buttonWidth*iButton++, buttonTop, buttonWidth, buttonHeight, 0, true);//default control
    m_Dialog.AddButton( MAINDLG_VIEW, L"View", buttonWidth*iButton++, buttonTop, buttonWidth, buttonHeight );
    m_Dialog.AddButton( MAINDLG_EFFECTS, L"Effect Options", buttonWidth*iButton++, buttonTop, buttonWidth, buttonHeight );
    m_Dialog.AddButton( MAINDLG_REFRESH, L"Refresh", buttonWidth*iButton++,buttonTop, buttonWidth, buttonHeight );
    m_Dialog.AddButton( MAINDLG_DXCHANGE, L"", buttonWidth*iButton++,buttonTop, buttonWidth, buttonHeight );
    m_Dialog.AddButton( MAINDLG_HELP, L"Help", buttonWidth*iButton++, buttonTop, buttonWidth, buttonHeight );


}
Exemplo n.º 3
0
void Magnify::Capture()
{
	POINT Point;
	::GetCursorPos( &Point );

	RECT Rect;
	::GetWindowRect( DXUTGetHWND(), &Rect );

	int nWidthDiff = 0;
	int nHeightDiff = 0;
	
	if( DXUTIsWindowed() )
	{
		nWidthDiff = (int)( ( ( Rect.right - Rect.left ) - m_nBackBufferWidth ) * ( 1.0f / 2.0f ) );
		nHeightDiff = (int)( ( ( Rect.bottom - Rect.top ) - m_nBackBufferHeight ) * ( 4.0f / 5.0f ) );
	}
		
	SetPosition( Point.x - ( Rect.left + nWidthDiff ), Point.y - ( Rect.top + nHeightDiff ) );

	D3D10_BOX SourceRegion;
	SourceRegion.left = m_nPositionX - m_nHalfPixelRegion;
	SourceRegion.right = m_nPositionX + m_nHalfPixelRegion;
	SourceRegion.top = m_nPositionY - m_nHalfPixelRegion;
	SourceRegion.bottom = m_nPositionY + m_nHalfPixelRegion;
	SourceRegion.front = 0;
	SourceRegion.back = 1;
}
Exemplo n.º 4
0
void CALLBACK OnKeyboard(UINT character, bool keyDown, bool altDown, void* userContext)
{
    if(keyDown) {
        switch (character) {
        case VK_F8:
            // Toggle visibility of expert HUD
            gHUD[HUD_EXPERT].SetVisible(!gHUD[HUD_EXPERT].GetVisible());
            break;
        case VK_F9:
            // Toggle display of UI on/off
            gDisplayUI = !gDisplayUI;
            break;

		default:
			if(PXEngine)
			{
				POINT position;
				GetCursorPos(&position);
				ScreenToClient(DXUTGetHWND(), &position);

				PXEngine->ProcessKey(character, position.x, position.y);
			}
			break;
        }
    }
}
VOID RenderHUD( ID3D11DeviceContext* pd3dImmediateContext, FLOAT fElapsedTime )
{
    DXUT_BeginPerfEvent( DXUT_PERFEVENTCOLOR, L"HUD / Stats" );
    g_HUD.OnRender( fElapsedTime );
    g_SampleUI.OnRender( fElapsedTime );

    static FLOAT InspectionYOffset = 0;
    if( g_pInspectionTexture != NULL )
    {
        const INT ViewportHeight = (INT)g_HalfClientHeightPixels * 2;
        INT TotalHeight = 0;
        INT SliceHeight = 0;
        g_PageDebugRender.Render( pd3dImmediateContext, g_pTitleResidencyManager, g_pInspectionTexture, 10, ViewportHeight - (INT)InspectionYOffset, &TotalHeight, &SliceHeight );

        FLOAT fLerp = min( 1.0f, fElapsedTime * 8.0f );
        FLOAT TargetOffset = (FLOAT)( SliceHeight * ( g_InspectionSliceIndex + 1 ) );
        if( fabsf( TargetOffset - InspectionYOffset ) < 2.0f )
        {
            InspectionYOffset = TargetOffset;
        }
        else
        {
            InspectionYOffset = ( TargetOffset * fLerp + (FLOAT)InspectionYOffset * ( 1.0f - fLerp ) );
        }
    }
    else
    {
        InspectionYOffset = 0;
        g_InspectionSliceIndex = 0;
    }

    if( g_bDrawResidencySampleViews )
    {
        ID3D11ShaderResourceView* pSRViewUVGradientID = NULL;
        ID3D11ShaderResourceView* pSRViewExtendedUVSlice = NULL;

        g_pTitleResidencyManager->GetViewShaderResources( g_LastResidencySampleViewID, &pSRViewUVGradientID, &pSRViewExtendedUVSlice );

        if( pSRViewExtendedUVSlice != NULL && pSRViewUVGradientID != NULL )
        {
            RECT ClientRect;
            GetClientRect( DXUTGetHWND(), &ClientRect );

            UINT Width = 256;
            UINT Height = 144;
            UINT Margin = 10;
            UINT BottomMargin = 60 + Margin;

            RECT Rect2 = { ClientRect.right - ( Width + Margin ), ClientRect.bottom - ( Height + BottomMargin ), ClientRect.right - Margin, ClientRect.bottom - BottomMargin };
            RECT Rect1 = { Rect2.left, Rect2.top - ( Height + Margin ), Rect2.right, Rect2.top - Margin };

            g_PageDebugRender.RenderTexture( pd3dImmediateContext, pSRViewUVGradientID, Rect1 );
            g_PageDebugRender.RenderTexture( pd3dImmediateContext, pSRViewExtendedUVSlice, Rect2 );
        }
    }

    RenderText();

    DXUT_EndPerfEvent();
}
Exemplo n.º 6
0
//--------------------------------------------------------------------------------------
_Use_decl_annotations_
DXUTAPI bool CDXUTIMEEditBox::MsgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if (!m_bEnabled || !m_bVisible)
		return false;

#if defined(DEBUG) || defined(_DEBUG)
	// DXUT.cpp used to call CDXUTIMEEditBox::StaticMsgProc() so that, but now
	// this is the application's responsiblity.  To do this, call
	// CDXUTDialogResourceManager::MsgProc() before calling this function.
	assert( m_bIMEStaticMsgProcCalled && L"To fix, call CDXUTDialogResourceManager::MsgProc() first" );
#endif
	switch (uMsg)
	{
	case WM_DESTROY:
		ImeUi_Uninitialize();
		break;
	}

	bool trappedData;
	bool* trapped = &trappedData;

	*trapped = false;
	if (!ImeUi_IsEnabled())
		return CDXUTEditBox::MsgProc(uMsg, wParam, lParam);

	ImeUi_ProcessMessage(DXUTGetHWND(), uMsg, wParam, lParam, trapped);
	if (*trapped == false)
		CDXUTEditBox::MsgProc(uMsg, wParam, lParam);

	return *trapped;
}
Exemplo n.º 7
0
/*
	마우스 절대 좌표
*/
POINT Input::getMousePos()
{
	POINT pt = {};
	GetCursorPos(&pt);
	ScreenToClient(DXUTGetHWND(), &pt);

	return pt;
}
Exemplo n.º 8
0
dx2dx::Point GET_MOUSE_POS()
{
	POINT mousePos;
	GetCursorPos(&mousePos);
	ScreenToClient(DXUTGetHWND(), &mousePos);

	return dx2dx::Point(mousePos.x, mousePos.y);
}
Exemplo n.º 9
0
HRESULT Input::Initialize()
{
	HRESULT hr = S_OK;
	
	Release();
	//grabMouse();
	
	m_mouseDelta[0] = 0;	// MOUSE DELTA X
	m_mouseDelta[1] = 0;	// MOUSE DELTA Y

	// DirectInput 장치 생성
	hr = DirectInput8Create(DXUTGetHINSTANCE(), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&m_dinput, NULL);
	if (FAILED(hr))
		return hr;

	// 키보드 생성 및 설정
	hr = m_dinput->CreateDevice(GUID_SysKeyboard, &m_keyboard, NULL);
	hr = m_keyboard->SetDataFormat(&c_dfDIKeyboard);
	hr = m_keyboard->SetCooperativeLevel(DXUTGetHWND(), DISCL_FOREGROUND | DISCL_EXCLUSIVE);
	hr = m_keyboard->Acquire();


	// 마우스 생성 및 설정
	hr = m_dinput->CreateDevice(GUID_SysMouse, &m_mouse, NULL);
	hr = m_mouse->SetDataFormat(&c_dfDIMouse/*&g_dfMouse*/);
	// NON-EXCULUSIVE 상태라면, 
	// 포커스를 잃었나 얻었나 항상 체크해야한다.
	hr = m_mouse->SetCooperativeLevel(DXUTGetHWND(), DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);
	hr = m_mouse->Acquire();

	//상대좌표, 절대좌표 설정
	/*DIPROPDWORD dipdw;
	dipdw.diph.dwSize = sizeof(DIPROPDWORD);
	dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
	dipdw.diph.dwObj = 0;
	dipdw.diph.dwHow = DIPH_DEVICE;
	dipdw.dwData = DIPROPAXISMODE_ABS;
	m_mouse->SetProperty(DIPROP_AXISMODE, &dipdw.diph);*/

	return hr;
}
Exemplo n.º 10
0
void MoveActor()
{
	double wx, wy, wz;

	POINT position;

	GetCursorPos(&position);

	ScreenToClient(DXUTGetHWND(), &position);

	PhysXUnProject(position.x, position.y, gMouseDepth, wx, wy, wz);

	PXEngine->MoveActor(wx, wy, wz);
}
Exemplo n.º 11
0
//--------------------------------------------------------------------------------------
// Entry point to the program. Initializes everything and goes into a message processing
// loop. Idle time is used to render the scene.
//--------------------------------------------------------------------------------------
INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
{
    // Enable run-time memory check for debug builds.
#if defined(DEBUG) | defined(_DEBUG)
    _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif

    // Set the callback functions. These functions allow DXUT to notify
    // the application about device changes, user input, and windows messages.  The
    // callbacks are optional so you need only set callbacks for events you're interested
    // in. However, if you don't handle the device reset/lost callbacks then the sample
    // framework won't be able to reset your device since the application must first
    // release all device resources before resetting.  Likewise, if you don't handle the
    // device created/destroyed callbacks then DXUT won't be able to
    // recreate your device resources.
    DXUTSetCallbackD3D9DeviceAcceptable( IsDeviceAcceptable );
	DXUTSetCallbackD3D9DeviceCreated( OnCreateDevice );
    DXUTSetCallbackD3D9DeviceReset( OnResetDevice );
    DXUTSetCallbackD3D9DeviceLost( OnLostDevice );
    DXUTSetCallbackD3D9DeviceDestroyed( OnDestroyDevice );
    DXUTSetCallbackMsgProc( MsgProc );
    DXUTSetCallbackKeyboard( KeyboardProc );
    DXUTSetCallbackD3D9FrameRender( OnFrameRender );
    DXUTSetCallbackFrameMove( OnFrameMove );

    // Show the cursor and clip it when in full screen
    DXUTSetCursorSettings( true, true );

    if (InitApp())
	{

        // Initialize DXUT and create the desired Win32 window and Direct3D
        // device for the application. Calling each of these functions is optional, but they
        // allow you to set several options which control the behavior of the framework.
        DXUTInit( true, true ); // Parse the command line, handle the default hotkeys, and show msgboxes
        DXUTCreateWindow( L"UWGame" );
        g_Sound.Initialize( DXUTGetHWND(), DSSCL_PRIORITY );
        
        DXUTCreateDevice( true, 800, 600 );

        // Pass control to DXUT for handling the message pump and
        // dispatching render calls. DXUT will call your FrameMove
        // and FrameRender callback when there is idle time between handling window messages.
        DXUTMainLoop();

        CleanupApp();
	}

    return DXUTGetExitCode();
}
Exemplo n.º 12
0
//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
									  void* pUserContext )
{
	vegetationRendering = new VegetationRendering();

	Window::setHandle(DXUTGetHWND());

	ID3D11DeviceContext* deviceContext = DXUTGetD3D11DeviceContext();
	dialogResourceManager.OnD3D11CreateDevice(pd3dDevice, deviceContext);
	textHelper = CDXUTTextHelper(pd3dDevice, deviceContext, &dialogResourceManager, 30);

	vegetationRendering->init(pd3dDevice);

	return S_OK;
}
Exemplo n.º 13
0
//--------------------------------------------------------------------------------------
// Used to handle mp3 player
//--------------------------------------------------------------------------------------
VOID HandleGraphEvent() {  
   if(!g_mp3p.IsEventInit())
      return;
   long evCode;
   LONG_PTR param1, param2;   
   while(SUCCEEDED(g_mp3p.pEvent->GetEvent(&evCode, &param1, &param2, 0))) {      
      g_mp3p.pEvent->FreeEventParams(evCode, param1, param2);
      switch(evCode) {
        case EC_COMPLETE:   // loop bg music
            g_mp3p.CleanUp();
            g_mp3p.PlayFile(g_cstrThemeSong, DXUTGetHWND(), WM_GRAPHNOTIFY);
            return;
        case EC_USERABORT: // Fall through.
        case EC_ERRORABORT:
           g_mp3p.CleanUp();
           return;           
      }      
   }
}
Exemplo n.º 14
0
//--------------------------------------------------------------------------------------
// Load new model
//--------------------------------------------------------------------------------------
static void LoadNewModel(bool bNeedUI = false)
{
    BOOL bResult = TRUE;
    if( bResult )
    {
        g_MeshScene.Destroy();
        // setup the camera view parameters
		static const UINT static_obj_num = 2;
		LPCTSTR	pSceneFileNames[static_obj_num] = {
			STATIC_OBJECT_SOURCE0,
			STATIC_OBJECT_SOURCE1,
		};

		if( g_MeshScene.Create( WARRIOR_MESH_SOURCE,
								WARRIOR_ANIM_SOURCE,
								WINDMILL_BASE_SOURCE,
								WINDMILL_FAN_SOURCE,
								PLANE_SOURCE,
								pSceneFileNames,
								static_obj_num,
								(D3D10_INPUT_ELEMENT_DESC*)suitlayout,//defined in OGRE_LAYOUT.H
								(D3D10_INPUT_ELEMENT_DESC*)bodylayout,//defined in OGRE_LAYOUT.H
								(D3D10_INPUT_ELEMENT_DESC*)scenemeshlayout,//defined in OGRE_LAYOUT.H
								DXUTGetD3D10Device()
								)
		   )

        {
            MessageBox(DXUTGetHWND(), L"Could not load geometry from sunclock.x", L"Error", MB_OK);
            exit(0);
        }
        D3DXVECTOR3 vLight[NUM_LIGHT]		= LIGHT_POS;
        D3DXVECTOR3 vLookAt		= LOOK_AT_POS;

		//light management
		for( int light_idx = 0; light_idx < NUM_LIGHT; ++light_idx )
		{
			g_LCamera[light_idx].SetViewParams(&vLight[light_idx], &vLookAt);
		}

    }
}
Exemplo n.º 15
0
//--------------------------------------------------------------------------------------
// Create any D3D9 resources that will live through a device reset (D3DPOOL_MANAGED)
// and aren't tied to the back buffer size
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,
                                 void* pUserContext )
{
    HRESULT hr;

    CDXUTIMEEditBox::Initialize( DXUTGetHWND() );

    V_RETURN( g_DialogResourceManager.OnD3D9CreateDevice( pd3dDevice ) );
    V_RETURN( g_SettingsDlg.OnD3D9CreateDevice( pd3dDevice ) );
    // Initialize the font
    V_RETURN( D3DXCreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
                              OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
                              L"Arial", &g_pFont ) );

    DWORD dwShaderFlags = D3DXFX_NOT_CLONEABLE;
#if defined( DEBUG ) || defined( _DEBUG )
        dwShaderFlags |= D3DXSHADER_DEBUG;
    #endif
#ifdef DEBUG_VS
        dwShaderFlags |= D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT;
    #endif
#ifdef DEBUG_PS
        dwShaderFlags |= D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT;
    #endif

    // Read the D3DX effect file
    WCHAR str[MAX_PATH];
    V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"CustomUI.fx" ) );
    V_RETURN( D3DXCreateEffectFromFile( pd3dDevice, str, NULL, NULL, dwShaderFlags,
                                        NULL, &g_pEffect, NULL ) );

    g_Mesh.Create( pd3dDevice, L"misc\\cell.x" );

    // Setup the camera's view parameters
    D3DXVECTOR3 vecEye( 0.0f, 1.5f, -7.0f );
    D3DXVECTOR3 vecAt ( 0.0f, 0.2f, 0.0f );
    D3DXVECTOR3 vecUp ( 0.0f, 1.0f, 0.0f );
    g_Camera.SetViewParams( &vecEye, &vecAt );
    D3DXMatrixLookAtLH( &g_mView, &vecEye, &vecAt, &vecUp );

    return S_OK;
}
Exemplo n.º 16
0
void PickActor()
{
	PXEngine->UnpickActor();

	POINT position;

	GetCursorPos(&position);

	ScreenToClient(DXUTGetHWND(), &position);

	double origX, origY, origZ;
	double dirX, dirY, dirZ;

	PhysXUnProject(position.x, position.y, 0.0f, origX, origY, origZ);
	PhysXUnProject(position.x, position.y, 1.0f, dirX, dirY, dirZ);

	physx::PxRaycastHit* hit = PXEngine->PickActor((float)origX, (float)origY, (float)origZ, (float)dirX, (float)dirY, (float)dirZ);

	if(hit)
	{
		int hitx, hity;
		PhysXProject(hit->impact.x, hit->impact.y, hit->impact.z, hitx, hity, gMouseDepth);
	}
}
Exemplo n.º 17
0
HWND RenderWin32DX9Imp::getHWND() {
    return DXUTGetHWND();
}
Exemplo n.º 18
0
//--------------------------------------------------------------------------------------
// Create any D3D9 resources that will live through a device reset (D3DPOOL_MANAGED)
// and aren't tied to the back buffer size
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,
                                 void* pUserContext )
{
    HRESULT hr;

    V_RETURN( g_DialogResourceManager.OnD3D9CreateDevice( pd3dDevice ) );
    V_RETURN( g_SettingsDlg.OnD3D9CreateDevice( pd3dDevice ) );

    // Initialize the font
    V_RETURN( D3DXCreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
                              OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
                              L"Arial", &g_pFont ) );

    // Load the mesh
    V_RETURN( g_Mesh.Create( pd3dDevice, L"dwarf\\dwarf.x" ) );

    // Find the mesh's center, then generate a centering matrix.
    IDirect3DVertexBuffer9* pVB = NULL;
    V_RETURN( g_Mesh.m_pMesh->GetVertexBuffer( &pVB ) );

    void* pVertices = NULL;
    hr = pVB->Lock( 0, 0, &pVertices, 0 );
    if( FAILED( hr ) )
    {
        SAFE_RELEASE( pVB );
        return hr;
    }

    hr = D3DXComputeBoundingSphere( ( D3DXVECTOR3* )pVertices, g_Mesh.m_pMesh->GetNumVertices(),
                                    D3DXGetFVFVertexSize( g_Mesh.m_pMesh->GetFVF() ), &g_vObjectCenter,
                                    &g_fObjectRadius );

    pVB->Unlock();
    SAFE_RELEASE( pVB );

    if( FAILED( hr ) )
        return hr;

    D3DXMatrixTranslation( &g_mCenterWorld, -g_vObjectCenter.x, -g_vObjectCenter.y, -g_vObjectCenter.z );

    // Read the D3DX effect file
    TCHAR str[MAX_PATH];
    hr = DXUTFindDXSDKMediaFileCch( str, MAX_PATH, TEXT( "CompiledEffect.fxo" ) );
    if( FAILED( hr ) )
    {
        MessageBox( DXUTGetHWND(), TEXT( "Could not locate \"CompiledEffect.fxo\".\n\n" )
                                   TEXT( "This file is created as part of the project build process,\n" )
                                   TEXT( "so the associated project must be compiled inside Visual\n" )
                                   TEXT( "Studio before attempting to run this sample.\n\n" )
                                   TEXT( "If receiving this error even after compiling the project,\n" )
                                   TEXT( "it's likely there was a problem compiling the effect file.\n" )
                                   TEXT( "Check the build log to verify the custom build step was\n" )
                                   TEXT( "run and to look for possible fxc compile errors." ),
                                   TEXT( "File Not Found" ), MB_OK );
        return E_FAIL;
    }

    // Since we are loading a binary file here and this effect has already been compiled,
    // you can not pass compiler flags here (for example to debug the shaders). 
    // To debug the shaders, you must pass these flags to the compiler that generated the
    // binary (for example fxc.exe).  In this sample, there are 2 extra Visual Studio configurations
    // called "Debug Shaders" and "Unicode Debug Shaders" that pass the debug shader flags to fxc.exe.
    V_RETURN( D3DXCreateEffectFromFile( pd3dDevice, str, NULL, NULL, D3DXFX_NOT_CLONEABLE, NULL, &g_pEffect, NULL ) );

    // Setup the camera's view parameters
    D3DXVECTOR3 vecEye( 0.0f, 0.0f, -5.0f );
    D3DXVECTOR3 vecAt ( 0.0f, 0.0f, -0.0f );
    g_Camera.SetViewParams( &vecEye, &vecAt );

    return S_OK;
}
Exemplo n.º 19
0
//--------------------------------------------------------------------------------------
// Create any D3D10 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D10CreateDevice(ID3D10Device* pDev10, const DXGI_SURFACE_DESC *pBackBufferSurfaceDesc, void* pUserContext)
{
	HRESULT hr;

	g_pSkyBox    = new S3UTSkybox();
	//g_pEnvMap    = new HDRCubeTexture;

    V_RETURN(DXUTSetMediaSearchPath(L"..\\Source\\SoftShadows"));
    V_RETURN(g_DialogResourceManager.OnD3D10CreateDevice(pDev10));
    V_RETURN(g_D3DSettingsDlg.OnD3D10CreateDevice(pDev10));
    V_RETURN(D3DX10CreateFont(pDev10, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Arial", &g_pFont10));

    g_SampleUI.GetSlider(IDC_LIGHT_SIZE)->SetValue((int)(g_fFilterSize * 200.0));
	g_SampleUI.GetComboBox(IDC_SHADOW_ALGORITHM)->SetSelectedByIndex(ssmap.bAccurateShadow == true ? 0 : 1);

    switch( ShadowAlgorithm )
    {
    case    STANDARD_BP:
        	g_ABP.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);
            break;
    case    BP_MSSM_KERNEL:
	        g_BPMSSMKernel.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);
            break;
    case    STD_VSM:
	        g_StdVSM.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);
            break;
    case    MIP_VSM:
	        g_MipVSM.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);
            break;
    case    HIR_BP:
        	g_HBP.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);
            break;
    case    BP_GI:
        	g_BPGI.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);
            break;
    case    STD_PCSS:
        	g_PCSS.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);
            break;
    default:
            break;
    }

	g_NoShadow.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);
	g_Final.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);
	g_GBuffer.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);
	g_ScrQuadRender.OnD3D10CreateDevice(g_ABP.m_pEffect,pDev10,pBackBufferSurfaceDesc,pUserContext);
	ssmap.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);

	g_Widget.OnD3D10CreateDevice( pDev10,pBackBufferSurfaceDesc,pUserContext );
	g_Blender.OnD3D10CreateDevice( pDev10,pBackBufferSurfaceDesc,pUserContext );

    V_RETURN(D3DX10CreateSprite(pDev10, 512, &g_pSprite10));
	{//must be after g_ABP create a device,because they uses the members of g_ABP
		static const D3D10_INPUT_ELEMENT_DESC scenemeshlayout[] =
		{
			{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
			{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0 },
			{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0 },
		};
		if (g_MeshLight.Create(pDev10, L"arrow.x", (D3D10_INPUT_ELEMENT_DESC*)scenemeshlayout, 3) != S_OK)
		{
			MessageBox(DXUTGetHWND(), L"Could not load geometry from arrow.x", L"Error", MB_OK);
			exit(0);
		}
		D3D10_PASS_DESC PassDesc;
		V_RETURN(g_NoShadow.m_pEffect->GetTechniqueByName("RenderAcc")->GetPassByIndex(0)->GetDesc(&PassDesc));
		V_RETURN(pDev10->CreateInputLayout(scenemeshlayout, 3, PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize, &g_pMaxLayout));
	}

    LoadNewModel();

	//V_RETURN( DXUTFindDXSDKMediaFileCch( g_EnvMapFilePath, MAX_PATH_STR, g_DefaultEnvMapName[0] ) );
    //g_pEnvMap->OnCreateDevice(pDev10, g_EnvMapFilePath, DXGI_FORMAT_R8G8B8A8_UNORM);
	g_pSkyBox->OnCreateDevice( pDev10 );
   // g_pSkyBox->SetTexture( g_pEnvMap->m_TextureRV );

	g_pFloatBufferSurfaceDesc.SampleDesc.Count   = pBackBufferSurfaceDesc->SampleDesc.Count;
    g_pFloatBufferSurfaceDesc.SampleDesc.Quality = pBackBufferSurfaceDesc->SampleDesc.Quality;



    D3DXVECTOR3 vTmp = D3DXVECTOR3(1, 2, 3);
    D3DXVec3Normalize(&g_vLightDir, &vTmp);

    SAFE_RELEASE(g_pRenderState);
    D3D10_RASTERIZER_DESC RasterizerState;
    RasterizerState.FillMode = D3D10_FILL_SOLID;
    RasterizerState.CullMode = D3D10_CULL_FRONT;
    RasterizerState.FrontCounterClockwise = true;
    RasterizerState.DepthBias = false;
    RasterizerState.DepthBiasClamp = 0.1;
    RasterizerState.SlopeScaledDepthBias = 0;
    RasterizerState.DepthClipEnable = true;
    RasterizerState.ScissorEnable = false;
    RasterizerState.MultisampleEnable = false;
    RasterizerState.AntialiasedLineEnable = false;
    V(pDev10->CreateRasterizerState(&RasterizerState, &g_pRenderState));

    SAFE_RELEASE(g_pDSState);
    D3D10_DEPTH_STENCIL_DESC DSState;
    ZeroMemory(&DSState, sizeof(DSState));
    DSState.DepthEnable = true;
    DSState.DepthWriteMask = D3D10_DEPTH_WRITE_MASK_ALL;
    DSState.DepthFunc = D3D10_COMPARISON_LESS_EQUAL;
    V(pDev10->CreateDepthStencilState(&DSState, &g_pDSState));


	//light management
	for( int light_idx = 0; light_idx < NUM_LIGHT; ++light_idx )
	{
		g_pLightLumiBuffer[light_idx] = new RenderObject( "RenderScreenPixelPos" );
		g_pLightLumiBuffer[light_idx] ->OnD3D10CreateDevice( NULL,pDev10, pBackBufferSurfaceDesc, pUserContext);
	}

		g_pBlendBuffer = new RenderObject( "RenderScreenPixelPos" );
		g_pBlendBuffer->OnD3D10CreateDevice( NULL,pDev10, pBackBufferSurfaceDesc, pUserContext);
		g_pWidgetBuffer = new RenderObject( "RenderScreenPixelPos" );//fake tech name,we dont want to use it. We only want to utilize its buffers
		g_pWidgetBuffer->OnD3D10CreateDevice( NULL,pDev10, pBackBufferSurfaceDesc, pUserContext);
//--------------------------------------------------------------------------------------------------------

    return S_OK;
}
Exemplo n.º 20
0
HWND GameApp::GetHwnd()
{

	return DXUTGetHWND();
}
Exemplo n.º 21
0
void GAME_SHUTDOWN()
{
	PostMessage(DXUTGetHWND(), WM_CLOSE, 0, 0);
}