void CSetRenderTargetSceneRendererCommand::Execute(CContextManager &_context)
{
	ID3D11DepthStencilView *l_DepthStencilView
		= m_DynamicTextures.empty() ? NULL : m_DynamicTextures[0]->GetDepthStencilView();
	_context.SetRenderTargets((UINT)m_DynamicTextures.size(),
							  &m_RenderTargetViews[0],
							  l_DepthStencilView == NULL ?
									_context.GetDepthStencilView() : l_DepthStencilView);
}
Esempio n. 2
0
//-----------------------------------------------------------------------------
// Name: MsgProc()
// Desc: The window's message handler
//-----------------------------------------------------------------------------
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{

  switch( msg )
  {
  case WM_DESTROY:
    {
      PostQuitMessage( 0 );
      return 0;
    }
    break;
  case WM_KEYDOWN:
    {
      switch( wParam )
      {
      case VK_ESCAPE:
        //Cleanup();
        PostQuitMessage( 0 );
        return 0;
        break;
	  }
    }
    break;
	case WM_SIZE:
		if (wParam != SIZE_MINIMIZED)
		{
			context.Resize(hWnd, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam));
		}
		return 0;
	  }//end switch( msg )

  return DefWindowProc( hWnd, msg, wParam, lParam );
}
Esempio n. 3
0
//-----------------------------------------------------------------------------
// Name: MsgProc()
// Desc: The window's message handler
//-----------------------------------------------------------------------------
LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
	case WM_SIZE:
		if (wParam != SIZE_MINIMIZED)
		{
			// TODO: Resetear el AntTeakBar
			// TwWindowSize(0, 0);
			s_Context.Resize(hWnd, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam));
			// TODO: Resetear el AntTeakBar
			// TwWindowSize((UINT)LOWORD(lParam), (UINT)HIWORD(lParam));
		}
		return 0;
	case WM_DESTROY:
	{
		PostQuitMessage(0);
		return 0;
	}
	break;
	}//end switch( msg )

	return DefWindowProc(hWnd, msg, wParam, lParam);
}
Esempio n. 4
0
//-----------------------------------------------------------------------
// WinMain
//-----------------------------------------------------------------------
int APIENTRY WinMain(HINSTANCE _hInstance, HINSTANCE _hPrevInstance, LPSTR _lpCmdLine, int _nCmdShow)
{
	// Register the window class
	WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, APPLICATION_NAME, NULL };

	RegisterClassEx(&wc);


	// Calcular el tamano de nuestra ventana
	RECT rc = {
		0, 0, 800, 600
	};
	AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE);

	// Create the application's window
	HWND hWnd = CreateWindow(APPLICATION_NAME, APPLICATION_NAME, WS_OVERLAPPEDWINDOW, 100, 100, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, wc.hInstance, NULL);

	// Añadir aquí el Init de la applicacioón

	s_Context.CreateContext(hWnd, 800, 600);

	ShowWindow(hWnd, SW_SHOWDEFAULT);

	s_Context.CreateBackBuffer(hWnd, 800, 600);
	s_Context.InitStates();
	{
		CDebugRender debugRender(s_Context.GetDevice());

		CInputManagerImplementation inputManager(hWnd);
		CInputManager::SetCurrentInputManager(&inputManager);

		inputManager.LoadCommandsFromFile("Data\\input.xml");

		CDebugHelperImplementation debugHelper(s_Context.GetDevice());
		CDebugHelper::SetCurrentDebugHelper(&debugHelper);

		CApplication application(&debugRender, &s_Context);

		UpdateWindow(hWnd);
		MSG msg;
		ZeroMemory(&msg, sizeof(msg));

		// Añadir en el while la condición de salida del programa de la aplicación
		DWORD m_PreviousTime = timeGetTime();

		bool hasFocus = true;

		while (msg.message != WM_QUIT)
		{
			if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
			{
				if (!debugHelper.Update(msg.hwnd, msg.message, msg.wParam, msg.lParam))
				{
					bool WasDown = false, IsDown = false, Alt = false;

					switch (msg.message)
					{
					case WM_SETFOCUS:
						hasFocus = true;
						inputManager.SetFocus(true);
						break;
					case  WM_KILLFOCUS:
						hasFocus = false;
						inputManager.SetFocus(false);
						break;
					case WM_SYSKEYDOWN:
					case WM_SYSKEYUP:
					case WM_KEYDOWN:
					case WM_KEYUP:
						WasDown = ((msg.lParam & (1 << 30)) != 0);
						IsDown = ((msg.lParam & (1 << 31)) == 0);
						Alt = ((msg.lParam & (1 << 29)) != 0);

						if (WasDown != IsDown)
						{
							if (IsDown)
							{
								bool consumed = false;
								switch (msg.wParam)
								{
								case VK_RETURN:
									if (Alt)
									{
										WINDOWPLACEMENT windowPosition = { sizeof(WINDOWPLACEMENT) };
										GetWindowPlacement(msg.hwnd, &windowPosition);

										ToggleFullscreen(msg.hwnd, windowPosition);
										consumed = true;
									}
									break;
								case VK_ESCAPE:
									PostQuitMessage(0);
									consumed = true;
									break;
								case VK_F4:
									if (Alt)
									{
										PostQuitMessage(0);
										consumed = true;
									}
									break;
								}
								if (consumed)
								{
									break;
								}
							}
						}
						if (!hasFocus || !inputManager.KeyEventReceived(msg.wParam, msg.lParam))
						{
							TranslateMessage(&msg);
							DispatchMessage(&msg);
						}
						break;
					case WM_MOUSEMOVE:
						if (hasFocus)
						{
							int xPosAbsolute = GET_X_LPARAM(msg.lParam);
							int yPosAbsolute = GET_Y_LPARAM(msg.lParam);

							inputManager.UpdateCursor(xPosAbsolute, yPosAbsolute);
						}
						else
						{
							TranslateMessage(&msg);
							DispatchMessage(&msg);
						}
						break;
					default:
						TranslateMessage(&msg);
						DispatchMessage(&msg);
					}
				}
			}
			else
			{
				inputManager.BeginFrame();

				DWORD l_CurrentTime = timeGetTime();
				float m_ElapsedTime = (float)(l_CurrentTime - m_PreviousTime)*0.001f;
				m_PreviousTime = l_CurrentTime;


				application.Update(m_ElapsedTime);
				application.Render();


				inputManager.EndFrame();
			}
		}
		UnregisterClass(APPLICATION_NAME, wc.hInstance);
	}
	// Añadir una llamada a la alicación para finalizar/liberar memoria de todos sus datos
	s_Context.Dispose();

	return 0;
}
Esempio n. 5
0
//-----------------------------------------------------------------------
// WinMain
//-----------------------------------------------------------------------
int APIENTRY WinMain(HINSTANCE _hInstance, HINSTANCE _hPrevInstance, LPSTR _lpCmdLine, int _nCmdShow)
{
	// Register the window class
	WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, APPLICATION_NAME, NULL };

	input = new CInputManagerImplementation;
	CInputManager::SetCurrentInputManager(input);
	input->LoadCommandsFromFile("Data\\input.xml");

	RegisterClassEx( &wc );

  	l_D3DDevice = 0;
	l_DeviceContext = 0;
	l_SwapChain = 0;

	// Calcular el tamano de nuestra ventana
	RECT rc = {0, 0, WIDTH_APPLICATION, HEIGHT_APPLICATION};
	AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE);
	
	//width =  rc.right - rc.left;
	//height =  rc.bottom - rc.top;

	// Create the application's window
	HWND hWnd = CreateWindow(	APPLICATION_NAME, APPLICATION_NAME, WS_OVERLAPPEDWINDOW, 100, 100, 800, 600, NULL, NULL, wc.hInstance, NULL );
  	
	// Añadir aquí el Init de la applicacioón
	context.CreateContext(hWnd, WIDTH_APPLICATION, HEIGHT_APPLICATION);

	ShowWindow( hWnd, SW_SHOWDEFAULT );

	context.CreateBackBuffer(hWnd,800,600); 
	context.InitStates();
	CDebugRender debugRender(context.GetDevice());

	CApplication application(&debugRender, &context);
		
	UpdateWindow(hWnd);
	MSG msg;
	ZeroMemory(&msg, sizeof(msg));



  // Añadir en el while la condición de salida del programa de la aplicación
	
	DWORD m_PreviousTime = timeGetTime();
	while( msg.message != WM_QUIT )
	{
		if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
			{
				switch (msg.message)
				{
				case WM_SYSKEYDOWN:
				case WM_SYSKEYUP:
				case WM_KEYDOWN:
				case WM_KEYUP:
					if (!input->KeyEventReceived(msg.wParam, msg.lParam))
					{
						TranslateMessage(&msg);
						DispatchMessage(&msg);
					}
					break;
				default:
					TranslateMessage(&msg);
					DispatchMessage(&msg);
				}
			}
			else
			{
				input->BeginFrame();
				// Main loop: Añadir aquí el Update y Render de la aplicación principal
				l_CurrentTime = timeGetTime();
				l_ElapsedTime = (float)(l_CurrentTime - l_PreviousTime)*0.001f;
				l_PreviousTime = l_CurrentTime;
				application.Update(l_ElapsedTime);
				application.Render();
				input->EndFrame();
		}

	}

  UnregisterClass( APPLICATION_NAME, wc.hInstance );

  // Añadir una llamada a la alicación para finalizar/liberar memoria de todos sus datos

  return 0;
}