Advertisement
Guest User

CEGUI 64

a guest
Apr 6th, 2011
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.04 KB | None | 0 0
  1. #include "CL_Device.h"
  2. #include <CEGUI.h>
  3. #include <CEGUIDirect3D11Renderer.h>
  4.  
  5. CL_Device *Device ;
  6. using namespace CEGUI ;
  7.  
  8.  
  9.  
  10. LRESULT CALLBACK WndProc ( HWND hwnd , UINT Msg , WPARAM wParam , LPARAM lParam)
  11. {
  12.     switch(Msg)
  13.     {
  14.     case WM_CLOSE:
  15.         DestroyWindow ( hwnd );
  16.         PostQuitMessage(0);
  17.         break ;
  18.  
  19.  
  20.     default:
  21.         return DefWindowProc ( hwnd , Msg , wParam , lParam);
  22.     }
  23.  
  24.     return 0 ;
  25. }
  26.  
  27. int WINAPI wWinMain ( HINSTANCE hInst , HINSTANCE hPrev , LPWSTR lmcmdline , int nShowCmd )
  28. {
  29.     RECT Rect ;
  30.     ::DXGI_SWAP_CHAIN_DESC swp ;
  31.        
  32.     WNDCLASSEX Bel ;
  33.     Bel.cbClsExtra = 0 ;
  34.     Bel.cbSize = sizeof(Bel);
  35.     Bel.cbWndExtra = 0 ;
  36.     Bel.hbrBackground = (HBRUSH)(COLOR_WINDOW+12);
  37.     Bel.hCursor = LoadCursor ( NULL , IDC_ARROW);
  38.     Bel.hIcon = LoadIcon ( NULL , IDI_APPLICATION);
  39.     Bel.hIconSm = LoadIcon ( NULL , IDI_APPLICATION);
  40.     Bel.hInstance = hInst ;
  41.     Bel.lpfnWndProc = WndProc ;
  42.     Bel.lpszClassName = L"POIAF";
  43.     Bel.lpszMenuName = NULL ;
  44.     Bel.style = 0 ;
  45.  
  46.     RegisterClassEx (&Bel);
  47.  
  48.     HWND hwnd = CreateWindowEx ( 0 , L"POIAF" , L"TEST" , WS_OVERLAPPEDWINDOW , 0 , 0 , 650 , 650 , NULL , NULL , hInst , NULL);
  49.  
  50.     ZeroMemory(&swp , sizeof(DXGI_SWAP_CHAIN_DESC));
  51.  
  52.  
  53.     ::DXGI_SAMPLE_DESC SD ;
  54.     SD.Count = 1 ;
  55.     SD.Quality = 0 ;
  56.  
  57.     ::ShowWindow ( hwnd , SW_SHOW);
  58.     ::UpdateWindow ( hwnd );
  59.     Buffer Buf ;
  60.     Buf.Height = Buf.Width = 650 ;
  61.     Buf.Count = 1 ;
  62.     Buf.Format = DXGI_FORMAT_B8G8R8A8_UNORM ;
  63.     Device = new CL_Device (hwnd, Buf  , 0 , SD , true , ::DXGI_FORMAT_B8G8R8A8_UNORM);
  64.    
  65.     MSG Msg ;
  66.     ZeroMemory(&Msg , sizeof(MSG));
  67.    
  68.  
  69.  
  70.  
  71.     CEGUI::Direct3D11Renderer &myrender = CEGUI::Direct3D11Renderer::bootstrapSystem   ( Device->Get_Device () , Device->Get_DeviceContext());
  72.  
  73. CEGUI::SchemeManager::getSingleton().create( "TaharezLook.scheme" );
  74. System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
  75.  
  76.  
  77.  
  78.     WindowManager& wmgr = WindowManager::getSingleton();
  79.    
  80. Window* myRoot = wmgr.createWindow( "DefaultWindow", "root" );
  81. System::getSingleton().setGUISheet( myRoot );
  82.  
  83. FrameWindow *fWnd = (FrameWindow*)wmgr.createWindow("TaharezLook/FrameWindow", "Demo Window");
  84. myRoot->setMousePassThroughEnabled(true);
  85. myRoot->addChildWindow( fWnd );
  86.  
  87. fWnd->setText ( CEGUI::String() = "Bingo" );
  88. // position a quarter of the way in from the top-left of parent.
  89. fWnd->setPosition( UVector2( UDim( 0.25f, 0 ), UDim( 0.25f, 0 ) ) );
  90.  
  91. // set size to be half the size of the parent
  92. fWnd->setSize( UVector2( UDim( 0.5f, 0 ), UDim( 0.5f, 0 ) ) );
  93.  
  94.  
  95.  
  96. ::ShowCursor ( false );
  97.  
  98.  
  99.     float Color [4] = { 0.0f , 0.0f , 0.0f , 0.5f };
  100.     while ( Msg.message != WM_QUIT )
  101.     {
  102.        
  103.         if ( ::PeekMessageA ( &Msg , NULL , 0U , 0U , PM_REMOVE))
  104.         {
  105.             ::TranslateMessage ( &Msg);
  106.             ::DispatchMessageA ( &Msg);
  107.         }
  108.  
  109.         else
  110.         {
  111.        
  112.         Device->Get_DeviceContext()->ClearRenderTargetView ( Device->Get_Target() , Color );   
  113.    
  114.        
  115.         System::getSingleton().renderGUI();
  116.        
  117.        
  118.         Device->Get_SwapChain()->Present ( 0 , 0 );
  119.         }
  120.     }
  121.    
  122.     Device->~CL_Device();
  123.     ::UnregisterClass ( Bel.lpszClassName , Bel.hInstance);
  124.     return 0 ;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement