当前位置: 首页>>代码示例>>C++>>正文


C++ AdjustWindowRect函数代码示例

本文整理汇总了C++中AdjustWindowRect函数的典型用法代码示例。如果您正苦于以下问题:C++ AdjustWindowRect函数的具体用法?C++ AdjustWindowRect怎么用?C++ AdjustWindowRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了AdjustWindowRect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DEBUG_INFO

//------------------------------------------------------------------------------------------------
// Name: acquireGraphics
// Desc: Implements a robust algorithm to create the Direct3D device
//------------------------------------------------------------------------------------------------
bool EvidyonClient::createD3DDevice(bool windowed, unsigned int requiredNumberOfBlendMatrices)
{
  // Get the main Direct3D object from the display structure
  IDirect3D9* d3d = d3d_;

  { // Display the adapter that we are using
    D3DADAPTER_IDENTIFIER9 identifier;
    if (!APP_WARNING(FAILED(d3d->GetAdapterIdentifier(D3DADAPTER_DEFAULT, 0, &identifier)))("Failed to get adapter information"))
      DEBUG_INFO("Using \"%s\"", identifier.Description);
  }

  // Set up the structure used to create the Direct3D device.
  D3DPRESENT_PARAMETERS d3dpp;
  ZeroMemory(&d3dpp, sizeof(d3dpp));

  // Initialize some parts of the parameters
  d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
  d3dpp.EnableAutoDepthStencil = TRUE;
  d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
  //d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
  d3dpp.BackBufferCount = 1;
  //d3dpp.Flags = D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL;

  // Set up the rest of the parameters based on the windowed mode
  if (windowed)
  {
    d3dpp.Windowed = TRUE;
		d3dpp.BackBufferWidth  = config_.getSetting("Graphics", "ResolutionX", 800);
    d3dpp.BackBufferHeight = config_.getSetting("Graphics", "ResolutionY", 600);
    d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;

    // Create the application's window
    RECT rc = { 0, 0, d3dpp.BackBufferWidth, d3dpp.BackBufferHeight };
    AdjustWindowRect(&rc, WS_POPUPWINDOW|WS_CAPTION, FALSE);
    d3dpp.hDeviceWindow = CreateWindow(STRING_WINDOWCLASS,
                                       STRING_WINDOWTITLE, 
                                       WS_POPUPWINDOW|WS_CAPTION|WS_MINIMIZEBOX,
                                       50,
                                       50,
                                       rc.right-rc.left,
                                       rc.bottom-rc.top,
                                       NULL,
                                       NULL,
                                       GetModuleHandle(NULL),
                                       NULL);
  }
  else
  {
    // Get the current display mode (this should always succeed)
    D3DDISPLAYMODE displayMode;
    if (APP_ERROR(FAILED(d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &displayMode)))("Couldn't get current display mode"))
      return false;

    // Use the current display mode
    d3dpp.Windowed = FALSE;
		d3dpp.BackBufferWidth  = config_.getSetting("Graphics", "ResolutionX", (int)displayMode.Width);
    d3dpp.BackBufferHeight = config_.getSetting("Graphics", "ResolutionY", (int)displayMode.Height);

    switch (config_.getSetting("Graphics", "ColorDepth", 16)) {
      default:
      case 16: d3dpp.BackBufferFormat = D3DFMT_R5G6B5; break;
      case 15: d3dpp.BackBufferFormat = D3DFMT_X1R5G5B5; break;
      case 24: d3dpp.BackBufferFormat = D3DFMT_R8G8B8; break;
      case 32: d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; break;
    }

    // Create the application's window
    d3dpp.hDeviceWindow = CreateWindow(STRING_WINDOWCLASS, STRING_WINDOWTITLE, 
                      WS_POPUP, 0, 0, d3dpp.BackBufferWidth, d3dpp.BackBufferHeight,
                      NULL, NULL, GetModuleHandle(NULL), NULL);
  }

  // Make sure a window was created
  if (APP_ERROR(d3dpp.hDeviceWindow == NULL)("Unable to create application window"))
  {
    // Try again in windowed mode if this was fullscreen; otherwise, fail
    if (!windowed)
      return createD3DDevice(true, requiredNumberOfBlendMatrices);
    else
      return false;
  }

  // Should we force the rendering into software mode?
  bool forceSoftwareMode = config_.getSetting("Graphics", "ForceSoftwareRendering", 0) == 1;

  // Parameters that will be used to create the device
  bool createHardwareDevice = !forceSoftwareMode;  // Use D3DCREATE_HARDWARE_VERTEXPROCESSING; otherwise, D3DCREATE_SOFTWARE_VERTEXPROCESSING
  bool createPureDevice = false;    // Set the D3DCREATE_PUREDEVICE flag.  Only valid if createHardwareDevice is true.
  bool createMixedDevice = false;   // Set the D3DCREATE_MIXED_VERTEXPROCESSING flag.  Only valid if createHardwareDevice is false.

  // Get device capabilities so we can determine what kind of device to make
  D3DCAPS9 devCaps;
  if (!APP_ERROR(FAILED(d3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &devCaps)))("Couldn't get device capibilities"))
  {
    // Determine whether or not we can use a pure hardware device
    createPureDevice = createHardwareDevice && ((devCaps.DevCaps & D3DDEVCAPS_PUREDEVICE) != 0);
//.........这里部分代码省略.........
开发者ID:karlgluck,项目名称:Evidyon,代码行数:101,代码来源:acquiregraphics.cpp

示例2: WinMain

//-----------------------------------------------------------------------
// WinMain
//-----------------------------------------------------------------------
int APIENTRY WinMain(HINSTANCE _hInstance, HINSTANCE _hPrevInstance, LPSTR _lpCmdLine, int _nCmdShow)
{
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
	//_CrtSetBreakAlloc(143430);

	new CEngine();
	CEngine& engine = CEngine::GetSingleton();
	//*/
	// 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, WIDTH, HEIGHT
	};
	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

	engine.Init();
	engine.getPhysXManager()->InitPhysx();

	CContextManager& context = *(CEngine::GetSingleton().getContextManager());
	context.CreateContext(hWnd, WIDTH, HEIGHT);

	ShowWindow(hWnd, SW_SHOWDEFAULT);

	context.CreateBackBuffer(hWnd, WIDTH, HEIGHT);

#ifndef _DEBUG
	ToggleFullscreen( hWnd );
#endif


	CPlayer *videoPlayer = NULL;

	// Initialize the player object.
	HRESULT hr = CPlayer::CreateInstance(hWnd, hWnd, &videoPlayer);

	CEngine::GetSingleton().setPlayerManager(videoPlayer);

	engine.getTextureManager()->Init();
	engine.getDebugRender()->Init();
	engine.getEffectsManager()->load("Data\\effects.xml");
	engine.getRenderableObjectTechniqueManager()->Load("Data\\pool_renderable_objects.xml");
	engine.getMaterialManager()->load("Data\\materials.xml");
	engine.getCookedMeshManager()->SetCookedMeshPath("Cache\\Cooked\\");
	engine.getStaticMeshManager()->Load("Data\\static_meshes.xml");
	engine.getAnimatedMeshManager()->Load("Data\\animated_models.xml");
	engine.getParticleManager()->Load("Data\\particle_classes.xml");
	engine.getLightManager()->Load("Data\\lights.xml");
	engine.getSceneRendererCommandManager()->Load("Data\\scene_renderer_commands.xml");
	engine.getSceneManager()->Initialize("Data\\Scenes\\");
	engine.getSoundManager()->InitAll("Data\\Sound\\Soundbanks\\SoundbanksInfo.xml", "Data\\Sound\\speakers.xml");

	{
		CInputManagerImplementation inputManager(hWnd);
		CInputManager::SetCurrentInputManager(&inputManager);
		inputManager.LoadCommandsFromFile("Data\\input.xml");

		engine.getCinematicManager()->LoadFilesInDir("Data\\Animations\\");



//#ifdef _DEBUG
		CDebugHelperImplementation debugHelper(context.GetDevice());
		CDebugHelper::SetCurrentDebugHelper(&debugHelper);
//#endif

		CApplication application(&context);
		engine.setApplication( &application );


		engine.getScriptManager()->Initialize("Data\\scripting.xml");

		engine.getComponentManager()->FirstInitialization();


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

		HCURSOR cursor = LoadCursor( NULL, IDC_ARROW );
		SetCursor( cursor );

		// Añadir en el while la condición de salida del programa de la aplicación
		auto previousTime = std::chrono::high_resolution_clock::now();

		bool hasFocus = true;
//.........这里部分代码省略.........
开发者ID:rcrmn,项目名称:mastervj-basic-engine,代码行数:101,代码来源:videogame.cpp

示例3: SetRect

VOID CGameProcedure::CreateMainWnd(VOID)
{
	//------------------------------------------------------
	//计算窗口大小
	m_bMinimized		= FALSE;
	m_bFullScreen		= TRUE;
	fVector2 fResoution;
	if (CGameProcedure::s_pVariableSystem->GetAs_Int("View_FullScreen"))
	{
		fResoution.x  = (float)::GetSystemMetrics(SM_CXSCREEN);
		fResoution.y  = (float)::GetSystemMetrics(SM_CYSCREEN);	
	}
	else
	{
		fResoution = s_pVariableSystem->GetAs_Vector2("View_Resoution");
	}
	CGameProcedure::m_fWindowFOV = fResoution.x / fResoution.y;
	SetRect(&m_rectWindow, 0, 0, (int)fResoution.x, (int)fResoution.y);
	AdjustWindowRect(&m_rectWindow, DEFWINDOW_STYLE, FALSE);

	SetRect(&m_rectFCOffset, m_rectWindow.left, m_rectWindow.top, 
		m_rectWindow.right-(int)fResoution.x, m_rectWindow.bottom-(int)fResoution.y);

	UINT dwX = (::GetSystemMetrics(SM_CXFULLSCREEN)-(m_rectWindow.right-m_rectWindow.left))/2;
	UINT dwY = (::GetSystemMetrics(SM_CYFULLSCREEN)-(m_rectWindow.bottom-m_rectWindow.top))/2;
	OffsetRect(&m_rectWindow, -m_rectFCOffset.left, -m_rectFCOffset.top);
	OffsetRect(&m_rectWindow, dwX, dwY);

	m_bActive			= true;
	m_bRenderingPaused	= FALSE;

	//------------------------------------------------------
	//注册窗口类
	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX); 
	wcex.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
	wcex.lpfnWndProc	= (WNDPROC)_MainWndProc;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= 0;
	wcex.hInstance		= g_hInstance;
	wcex.hIcon			= LoadIcon(g_hInstance, (LPCTSTR)IDD_GAME_DIALOG);
	wcex.hCursor		= LoadCursor( NULL, IDC_ARROW );
	wcex.hbrBackground	= (HBRUSH)NULL; //GetStockObject(WHITE_BRUSH);
	wcex.lpszMenuName	= (LPCTSTR)NULL;
	wcex.lpszClassName	= MAINWINDOW_CLASS;
	wcex.hIconSm		= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);

	RegisterClassEx(&wcex);

	//------------------------------------------------------
	//创建窗口
	CHAR szTitle[MAX_PATH];
	_snprintf(szTitle, MAX_PATH, "%s %s (%s %s)", GAME_TITLE, VERSION_INFO, __DATE__, __TIME__);

	HWND hWnd = CreateWindowEx(NULL, MAINWINDOW_CLASS, szTitle, 
		DEFWINDOW_STYLE,
		m_rectWindow.left, m_rectWindow.top, 
		m_rectWindow.right-m_rectWindow.left, 
		m_rectWindow.bottom-m_rectWindow.top,
		NULL, NULL, g_hInstance, NULL);

	if (!hWnd)
	{
		TDThrow(_T("Can't create main window!"));
	}

	if (CGameProcedure::s_pVariableSystem->GetAs_Int("View_FullScreen"))
	{
		s_pEventSystem->PushEvent(GE_VARIABLE_CHANGED, "View_FullScreen", "1");
		s_pEventSystem->PushEvent(GE_CHAT_ADJUST_MOVE_CTL, (INT)fResoution.x, (INT)fResoution.y);
	}else
	{
		const STRING& strVariable = CGameProcedure::s_pVariableSystem->GetAs_String("View_Resoution");
		s_pEventSystem->PushEvent(GE_VARIABLE_CHANGED,"View_Resoution", strVariable.c_str());
		s_pEventSystem->PushEvent(GE_CHAT_ADJUST_MOVE_CTL, (INT)fResoution.x, (INT)fResoution.y);
	}

	ShowWindow(hWnd, SW_SHOW);
	UpdateWindow(hWnd);

	g_hMainWnd = hWnd;
}
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:83,代码来源:GameProcedure.cpp

示例4: ZeroMemory

DEMO::DEMO(HINSTANCE hinst, WNDPROC proc)
{
	// ****************** BEGIN WARNING ***********************// 
	application = hinst;
	appWndProc = proc;

	WNDCLASSEX  wndClass;
	ZeroMemory(&wndClass, sizeof(wndClass));
	wndClass.cbSize = sizeof(WNDCLASSEX);
	wndClass.lpfnWndProc = appWndProc;
	wndClass.lpszClassName = L"DirectXApplication";
	wndClass.hInstance = application;
	wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
	wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOWFRAME);
	//wndClass.hIcon			= LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_FSICON));
	RegisterClassEx(&wndClass);

	RECT window_size = { 0, 0, (long)BACKBUFFER_WIDTH, (long)BACKBUFFER_HEIGHT };
	AdjustWindowRect(&window_size, WS_OVERLAPPEDWINDOW, false);

	window = CreateWindow(L"DirectXApplication", L"Mockingbird", WS_OVERLAPPEDWINDOW /*& ~(WS_THICKFRAME | WS_MAXIMIZEBOX)*/,
		CW_USEDEFAULT, CW_USEDEFAULT, window_size.right - window_size.left, window_size.bottom - window_size.top,
		NULL, NULL, application, this);

	ShowWindow(window, SW_SHOW);
	//********************* END WARNING ************************//



	//D3D Init
	DXGI_SWAP_CHAIN_DESC swapchain_DESC;
	ZeroMemory(&swapchain_DESC, sizeof(swapchain_DESC));
	swapchain_DESC.BufferCount = 1;
	swapchain_DESC.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
	swapchain_DESC.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_SHADER_INPUT;
	swapchain_DESC.BufferDesc.Width = (UINT)BACKBUFFER_WIDTH;
	swapchain_DESC.BufferDesc.Height = (UINT)BACKBUFFER_HEIGHT;
	swapchain_DESC.BufferDesc.RefreshRate.Numerator = 60;
	swapchain_DESC.BufferDesc.RefreshRate.Denominator = 1;
	swapchain_DESC.OutputWindow = window;
#if MSAA
	swapchain_DESC.SampleDesc.Count = MSAA_COUNT;
#else
	swapchain_DESC.SampleDesc.Count = 1;
#endif
	swapchain_DESC.SampleDesc.Quality = D3D11_STANDARD_MULTISAMPLE_PATTERN;
	swapchain_DESC.Windowed = TRUE;

	//Create Device and Swapchain DEBUG
	D3D_FEATURE_LEVEL FeatureLevel = D3D_FEATURE_LEVEL_11_0;
	HRESULT hr = D3D11CreateDeviceAndSwapChain(
		NULL,
		D3D_DRIVER_TYPE_HARDWARE,
		NULL,
		D3D11_CREATE_DEVICE_DEBUG,
		&FeatureLevel,
		1,
		D3D11_SDK_VERSION,
		&swapchain_DESC,
		&pSwapchain,
		&pDevice,
		&featureLevel,
		&pDeviceContext);



	pDevice->CreateDeferredContext(0, &pDeferredDeviceContext);
	//Create Render Target View from back buffer
	ID3D11Texture2D* pBackBuffer = nullptr;
	pSwapchain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&pBackBuffer));
	pDevice->CreateRenderTargetView(pBackBuffer, 0, &pRenderTargetView);
	SecureRelease(pBackBuffer);



	D3D11_TEXTURE2D_DESC renderToTextureDesc;
	ZeroMemory(&renderToTextureDesc, sizeof(renderToTextureDesc));
	renderToTextureDesc.Usage = D3D11_USAGE_DEFAULT;
	renderToTextureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
	renderToTextureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
	renderToTextureDesc.Height = swapchain_DESC.BufferDesc.Height;
	renderToTextureDesc.Width = swapchain_DESC.BufferDesc.Width;
	renderToTextureDesc.SampleDesc.Count = 1;
	renderToTextureDesc.ArraySize = 1;
	renderToTextureDesc.MipLevels = 1;
	pDevice->CreateTexture2D(&renderToTextureDesc, NULL, &pQuad_texture);
	pDevice->CreateRenderTargetView(pQuad_texture, 0, &pQuadRTV);
	quadDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
	quadDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
	quadDesc.Texture2D.MipLevels = 1;
	quadDesc.Texture2D.MostDetailedMip = 0;
	pDevice->CreateShaderResourceView(pQuad_texture, &quadDesc, &pQuadSRV);





	//Set up view port
	ZeroMemory(&viewport, sizeof(viewport));
	viewport.MaxDepth = 1;
//.........这里部分代码省略.........
开发者ID:locpk,项目名称:Mockingbird,代码行数:101,代码来源:DEMO.cpp

示例5: destroy


//.........这里部分代码省略.........

			mWidth = mDesiredWidth = width;
			mHeight = mDesiredHeight = height;
			mTop = top;
			mLeft = left;

			if (fullScreen)
			{
				dwStyleEx |= WS_EX_TOPMOST;
				dwStyle |= WS_POPUP;
				mTop = monitorInfo.rcMonitor.top;
				mLeft = monitorInfo.rcMonitor.left;		
			}
			else
			{
				if (parentHWnd)
				{
					dwStyle |= WS_CHILD;
				}
				else
				{
					if (border == "none")
						dwStyle |= WS_POPUP;
					else if (border == "fixed")
						dwStyle |= WS_OVERLAPPED | WS_BORDER | WS_CAPTION |
						WS_SYSMENU | WS_MINIMIZEBOX;
					else
						dwStyle |= WS_OVERLAPPEDWINDOW;
				}

				if (!outerSize)
				{
					// Calculate window dimensions required
					// to get the requested client area
					SetRect(&rc, 0, 0, mWidth, mHeight);
					AdjustWindowRect(&rc, dwStyle, false);
					mWidth = rc.right - rc.left;
					mHeight = rc.bottom - rc.top;

					// Clamp window rect to the nearest display monitor.
					if (mLeft < monitorInfo.rcWork.left)
						mLeft = monitorInfo.rcWork.left;		

					if (mTop < monitorInfo.rcWork.top)					
						mTop = monitorInfo.rcWork.top;					
				
					if (static_cast<int>(winWidth) > monitorInfo.rcWork.right - mLeft)					
						winWidth = monitorInfo.rcWork.right - mLeft;	

					if (static_cast<int>(winHeight) > monitorInfo.rcWork.bottom - mTop)					
						winHeight = monitorInfo.rcWork.bottom - mTop;										
				}
			}
			

			// Register the window class
			// NB allow 4 bytes of window data for D3D9RenderWindow pointer
			WNDCLASS wc = { 0, WindowEventUtilities::_WndProc, 0, 0, hInst,
				LoadIcon(0, IDI_APPLICATION), LoadCursor(NULL, IDC_ARROW),
				(HBRUSH)GetStockObject(BLACK_BRUSH), 0, "OgreD3D9Wnd" };
			RegisterClass(&wc);

			// Create our main window
			// Pass pointer to self
			mIsExternal = false;
			mHWnd = CreateWindowEx(dwStyleEx, "OgreD3D9Wnd", title.c_str(), dwStyle,
				mLeft, mTop, winWidth, winHeight, parentHWnd, 0, hInst, this);

			WindowEventUtilities::_addRenderWindow(this);
		}
		else
		{
			mHWnd = externalHandle;
			mIsExternal = true;
		}

		RECT rc;
		// top and left represent outer window coordinates
		GetWindowRect(mHWnd, &rc);
		mTop = rc.top;
		mLeft = rc.left;
		// width and height represent interior drawable area
		GetClientRect(mHWnd, &rc);
		mWidth = rc.right;
		mHeight = rc.bottom;

		mName = name;
		mDepthBufferPoolId = depthBuffer ? DepthBuffer::POOL_DEFAULT : DepthBuffer::POOL_NO_DEPTH;
		mDepthBuffer = 0;
		mIsFullScreen = fullScreen;
		mColourDepth = colourDepth;

		LogManager::getSingleton().stream()
			<< "D3D9 : Created D3D9 Rendering Window '"
			<< mName << "' : " << mWidth << "x" << mHeight 
			<< ", " << mColourDepth << "bpp";
									
		mActive = true;
		mClosed = false;
	}
开发者ID:gbruce,项目名称:ogre3d_trunk,代码行数:101,代码来源:OgreD3D9RenderWindow.cpp

示例6: LoadIcon

CWindowsToolkit::CWindowsToolkit(void *parentWindow, CEditor *editor)
{
    this->parentWindow  = parentWindow;
    this->editor        = editor;

    g_useCount++;
    if (g_useCount == 1)
    {
        WNDCLASSW windowClass;
        windowClass.style         = CS_DBLCLKS;
        windowClass.lpfnWndProc   = WindowProc;
        windowClass.cbClsExtra    = 0;
        windowClass.cbWndExtra    = 0;
        windowClass.hInstance     = (HINSTANCE)hInstance;
        windowClass.hIcon         = LoadIcon((HINSTANCE)hInstance,MAKEINTRESOURCE(IDI_ICON));
        windowClass.hCursor       = LoadCursor( NULL, IDC_ARROW );
        windowClass.hbrBackground = NULL;
        windowClass.lpszMenuName  = 0;
        windowClass.lpszClassName = L"OxeVstEditorClass";
        RegisterClassW(&windowClass);
    }

    if (!parentWindow)
    {
        RECT rect;
        rect.left   = 100;
        rect.top    = 100;
        rect.right  = GUI_WIDTH;
        rect.bottom = GUI_HEIGHT;
        AdjustWindowRect(&rect, WS_SYSMENU | WS_CAPTION, FALSE);
        rect.bottom += GetSystemMetrics(SM_CYCAPTION);
        rect.bottom += GetSystemMetrics(SM_CYFIXEDFRAME);
        rect.right  += GetSystemMetrics(SM_CXFIXEDFRAME);

        this->hWnd = CreateWindowW
        (
            L"OxeVstEditorClass",
            L"",
            WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX,
            rect.left,
            rect.top,
            rect.right,
            rect.bottom,
            0,
            0,
            (HINSTANCE)hInstance,
            NULL
        );
    }
    else
    {
        this->hWnd = CreateWindowExW
        (
            0,
            L"OxeVstEditorClass",
            L"",
            WS_CHILD | WS_VISIBLE,
            0,
            0,
            GUI_WIDTH,
            GUI_HEIGHT,
            (HWND)parentWindow,
            NULL,
            (HINSTANCE)hInstance,
            NULL
        );
    }

#ifdef _WIN64
    SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)this);
#else
    SetWindowLong(hWnd, GWL_USERDATA, (LONG)this);
#endif

    // load resources
    char path[MAX_PATH];
    GetResourcesPath(path, MAX_PATH);

    char fullPath[MAX_PATH];
    StringCchPrintf(fullPath, MAX_PATH, "%s\\%s", path, "chars.bmp");
    bmps[BMP_CHARS]   = (HBITMAP)LoadImageA(NULL, fullPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    StringCchPrintf(fullPath, MAX_PATH, "%s\\%s", path, "knob.bmp");
    bmps[BMP_KNOB]    = (HBITMAP)LoadImageA(NULL, fullPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    StringCchPrintf(fullPath, MAX_PATH, "%s\\%s", path, "knob2.bmp");
    bmps[BMP_KNOB2]   = (HBITMAP)LoadImageA(NULL, fullPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    StringCchPrintf(fullPath, MAX_PATH, "%s\\%s", path, "knob3.bmp");
    bmps[BMP_KNOB3]   = (HBITMAP)LoadImageA(NULL, fullPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    StringCchPrintf(fullPath, MAX_PATH, "%s\\%s", path, "key.bmp");
    bmps[BMP_KEY]     = (HBITMAP)LoadImageA(NULL, fullPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    StringCchPrintf(fullPath, MAX_PATH, "%s\\%s", path, "bg.bmp");
    bmps[BMP_BG]      = (HBITMAP)LoadImageA(NULL, fullPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    StringCchPrintf(fullPath, MAX_PATH, "%s\\%s", path, "buttons.bmp");
    bmps[BMP_BUTTONS] = (HBITMAP)LoadImageA(NULL, fullPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    StringCchPrintf(fullPath, MAX_PATH, "%s\\%s", path, "ops.bmp");
    bmps[BMP_OPS]     = (HBITMAP)LoadImageA(NULL, fullPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    
    if (!bmps[BMP_CHARS  ]) bmps[BMP_CHARS  ] = LoadBitmap((HINSTANCE)hInstance,MAKEINTRESOURCE(IDB_CHARS));
    if (!bmps[BMP_KNOB   ]) bmps[BMP_KNOB   ] = LoadBitmap((HINSTANCE)hInstance,MAKEINTRESOURCE(IDB_KNOB));
    if (!bmps[BMP_KNOB2  ]) bmps[BMP_KNOB2  ] = LoadBitmap((HINSTANCE)hInstance,MAKEINTRESOURCE(IDB_KNOB2));
    if (!bmps[BMP_KNOB3  ]) bmps[BMP_KNOB3  ] = LoadBitmap((HINSTANCE)hInstance,MAKEINTRESOURCE(IDB_KNOB3));
//.........这里部分代码省略.........
开发者ID:OpenDAWN,项目名称:oxefmsynth,代码行数:101,代码来源:windowstoolkit.cpp

示例7: window_init

static int window_init( WININFO *info )
{
	unsigned int	PixelFormat;
    DWORD			dwExStyle, dwStyle;
    DEVMODE			dmScreenSettings;
	RECT			rec;

    WNDCLASS		wc;

    ZeroMemory( &wc, sizeof(WNDCLASS) );
    wc.style         = CS_OWNDC|CS_HREDRAW|CS_VREDRAW;
    wc.lpfnWndProc   = WndProc;
    wc.hInstance     = info->hInstance;
    wc.lpszClassName = info->wndclass;
	
    if( !RegisterClass(&wc) )
        return( 0 );

    if( info->full )
    {
        dmScreenSettings.dmSize       = sizeof(DEVMODE);
        dmScreenSettings.dmFields     = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
        dmScreenSettings.dmBitsPerPel = 24;
        dmScreenSettings.dmPelsWidth  = XRES;
        dmScreenSettings.dmPelsHeight = YRES;
        if( ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
            return( 0 );
        dwExStyle = WS_EX_APPWINDOW;
        dwStyle   = WS_VISIBLE | WS_POPUP;// | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
		ShowCursor( 0 );
    }
    else
    {
        dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
        dwStyle   = WS_VISIBLE | WS_CAPTION | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU;
    }

    rec.left   = 0;
    rec.top    = 0;
    rec.right  = XRES;
    rec.bottom = YRES;
    AdjustWindowRect( &rec, dwStyle, 0 );
	windowRect.left = 0;
	windowRect.top = 0;
	windowRect.right = XRES;
	windowRect.bottom = YRES;

    info->hWnd = CreateWindowEx( dwExStyle, wc.lpszClassName, "live coding", dwStyle,
                               (GetSystemMetrics(SM_CXSCREEN)-rec.right+rec.left)>>1,
                               (GetSystemMetrics(SM_CYSCREEN)-rec.bottom+rec.top)>>1,
                               rec.right-rec.left, rec.bottom-rec.top, 0, 0, info->hInstance, 0 );
    if( !info->hWnd )
        return( 0 );

    if( !(info->hDC=GetDC(info->hWnd)) )
        return( 0 );

    if( !(PixelFormat=ChoosePixelFormat(info->hDC,&pfd)) )
        return( 0 );

    if( !SetPixelFormat(info->hDC,PixelFormat,&pfd) )
        return( 0 );

    if( !(info->hRC=wglCreateContext(info->hDC)) )
        return( 0 );

    if( !wglMakeCurrent(info->hDC,info->hRC) )
        return( 0 );
    
    return( 1 );
}
开发者ID:chock-mostlyharmless,项目名称:mostlyharmless,代码行数:71,代码来源:LiveCoding.cpp

示例8: AdjustVideoModeParams

/* Set the final window size, set the window text and icon, and then unhide the
 * window. */
void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForceRecreateWindow )
{
	g_CurrentParams = p;

	// Adjust g_CurrentParams to reflect the actual display settings.
	AdjustVideoModeParams( g_CurrentParams );

	if( g_hWndMain == NULL || bForceRecreateWindow )
	{
		int iWindowStyle = GetWindowStyle( p.windowed );

		AppInstance inst;
		HWND hWnd = CreateWindow( g_sClassName, "app", iWindowStyle,
						0, 0, 0, 0, NULL, NULL, inst, NULL );
		if( hWnd == NULL )
			RageException::Throw( "%s", werr_ssprintf( GetLastError(), "CreateWindow" ).c_str() );

		/* If an old window exists, transfer focus to the new window before
		 * deleting it, or some other window may temporarily get focus, which
		 * can cause it to be resized. */
		if( g_hWndMain != NULL )
		{
			// While we change to the new window, don't do ChangeDisplaySettings in WM_ACTIVATE.
			g_bRecreatingVideoMode = true;
			SetForegroundWindow( hWnd );
			g_bRecreatingVideoMode = false;

			GraphicsWindow::DestroyGraphicsWindow();
		}

		g_hWndMain = hWnd;
		CrashHandler::SetForegroundWindow( g_hWndMain );
		g_HDC = GetDC( g_hWndMain );
	}

	// Update the window title.
	do
	{
		if( m_bWideWindowClass )
		{
			if( SetWindowText( g_hWndMain, ConvertUTF8ToACP(p.sWindowTitle).c_str() ) )
				break;
		}

		SetWindowTextA( g_hWndMain, ConvertUTF8ToACP(p.sWindowTitle) );
	} while(0);

	// Update the window icon.
	if( g_hIcon != NULL )
	{
		SetClassLong( g_hWndMain, GCL_HICON, (LONG) LoadIcon(NULL,IDI_APPLICATION) );
		DestroyIcon( g_hIcon );
		g_hIcon = NULL;
	}
	g_hIcon = IconFromFile( p.sIconFile );
	if( g_hIcon != NULL )
		SetClassLong( g_hWndMain, GCL_HICON, (LONG) g_hIcon );

	/* The window style may change as a result of switching to or from fullscreen;
	 * apply it. Don't change the WS_VISIBLE bit. */
	int iWindowStyle = GetWindowStyle( p.windowed );
	if( GetWindowLong( g_hWndMain, GWL_STYLE ) & WS_VISIBLE )
		iWindowStyle |= WS_VISIBLE;
	SetWindowLong( g_hWndMain, GWL_STYLE, iWindowStyle );

	RECT WindowRect;
	SetRect( &WindowRect, 0, 0, p.width, p.height );
	AdjustWindowRect( &WindowRect, iWindowStyle, FALSE );

	//LOG->Warn( "w = %d, h = %d", p.width, p.height );

	const int iWidth = WindowRect.right - WindowRect.left;
	const int iHeight = WindowRect.bottom - WindowRect.top;

	// If windowed, center the window.
	int x = 0, y = 0;
	if( p.windowed )
	{
		x = GetSystemMetrics(SM_CXSCREEN)/2-iWidth/2;
		y = GetSystemMetrics(SM_CYSCREEN)/2-iHeight/2;
	}

	/* Move and resize the window. SWP_FRAMECHANGED causes the above
	 * SetWindowLong to take effect. */
	if( !SetWindowPos( g_hWndMain, HWND_NOTOPMOST, x, y, iWidth, iHeight, SWP_FRAMECHANGED|SWP_SHOWWINDOW ) )
		LOG->Warn( "%s", werr_ssprintf( GetLastError(), "SetWindowPos" ).c_str() );

	SetForegroundWindow( g_hWndMain );

	/* Pump messages quickly, to make sure the window is completely set up.
	 * If we don't do this, then starting up in a D3D fullscreen window may
	 * cause all other windows on the system to be resized. */
	MSG msg;
	while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
	{
		GetMessage( &msg, NULL, 0, 0 );
		DispatchMessage( &msg );
	}
//.........这里部分代码省略.........
开发者ID:AratnitY,项目名称:stepmania,代码行数:101,代码来源:GraphicsWindow.cpp

示例9: main

int main()
{
	OnStart( "." );

	const char WinName[] = "MyWin";

	WNDCLASS wcl;
	memset( &wcl, 0, sizeof( WNDCLASS ) );
	wcl.lpszClassName = WinName;
	wcl.lpfnWndProc = MyFunc;
	wcl.hCursor = LoadCursor( NULL, IDC_ARROW );

	if ( !RegisterClass( &wcl ) ) { return 0; }

	RECT Rect;

	Rect.left = 0;
	Rect.top = 0;
	Rect.right  = ImageWidth;
	Rect.bottom = ImageHeight;

	DWORD dwStyle = WS_OVERLAPPEDWINDOW;

	AdjustWindowRect( &Rect, dwStyle, false );

	int WinWidth  = Rect.right  - Rect.left;
	int WinHeight = Rect.bottom - Rect.top;

	HWND hWnd = CreateWindowA( WinName, "App8", dwStyle, 100, 100, WinWidth, WinHeight, 0, NULL, NULL, NULL );

	ShowWindow( hWnd, SW_SHOW );

	HDC dc = GetDC( hWnd );

	// Create the offscreen device context and buffer
	hMemDC = CreateCompatibleDC( dc );
	hTmpBmp = CreateCompatibleBitmap( dc, ImageWidth, ImageHeight );

	// filling the RGB555 bitmap header
	memset( &BitmapInfo.bmiHeader, 0, sizeof( BITMAPINFOHEADER ) );
	BitmapInfo.bmiHeader.biSize = sizeof( BITMAPINFOHEADER );
	BitmapInfo.bmiHeader.biWidth = ImageWidth;
	BitmapInfo.bmiHeader.biHeight = ImageHeight;
	BitmapInfo.bmiHeader.biPlanes = 1;
	BitmapInfo.bmiHeader.biBitCount = 32;
	BitmapInfo.bmiHeader.biSizeImage = ImageWidth * ImageHeight * 4;

	UpdateWindow( hWnd );

	MSG msg;

	SetTimer( hWnd, 1, 10, NULL );

	while ( GetMessage( &msg, NULL, 0, 0 ) )
	{
		TranslateMessage( &msg );
		DispatchMessage( &msg );
	}

	DeleteDC( hMemDC );
	DeleteObject( hTmpBmp );
	free( g_FrameBuffer );

	return msg.wParam;
}
开发者ID:BlastarIndia,项目名称:Android-NDK-Game-Development-Cookbook,代码行数:65,代码来源:Wrapper_Windows.cpp

示例10: ZeroMemory

// 初始化ThisApp
HRESULT ThisApp::Initialize(){
	WNDCLASS wc;

	ZeroMemory(&wc, sizeof(wc));
	wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.cbWndExtra = DLGWINDOWEXTRA;
	wc.hInstance = HINST_THISCOMPONENT;
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hIcon = LoadIconW(HINST_THISCOMPONENT, MAKEINTRESOURCE(IDI_APP_ICON));
	wc.lpfnWndProc = ThisApp::WndProc;
	wc.lpszClassName = AppInfo::APP_WINDOW_CLASS_NAME;
	wc.cbWndExtra = sizeof(LONG_PTR);
	RegisterClass(&wc);
	// 读取ini文件
	RECT window_rect = { 0, 0, AppInfo::SHOW_WIDTH, AppInfo::SHOW_HEIGHT };
	wchar_t title[32];
	DWORD rc = GetPrivateProfileStringW(L"Game", L"title", L"", title, sizeof title, L".\\Game.ini");
	if (rc){
		char buffer[8];
		if (GetPrivateProfileStringA("Game", "width", "", buffer, sizeof buffer, ".\\Game.ini"))
			window_rect.right = atoi(buffer);
		
		if (GetPrivateProfileStringA("Game", "height", "", buffer, sizeof buffer, ".\\Game.ini"))
			window_rect.bottom = atoi(buffer);
		
	}
	else
		wcscpy_s(title, AppInfo::APP_WINDOW_TITLE_NAME);
	// 调整窗口大小
	DWORD window_style = WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU | WS_MINIMIZEBOX;
	AdjustWindowRect(&window_rect, window_style, FALSE);
	window_rect.right -= window_rect.left;
	window_rect.bottom -= window_rect.top;
	window_rect.left = (GetSystemMetrics(SM_CXFULLSCREEN) - window_rect.right) / 2;
	window_rect.top = (GetSystemMetrics(SM_CYFULLSCREEN) - window_rect.right) / 2;
	//window_rect.right += window_rect.left;
	//window_rect.bottom += window_rect.top;
	// 创建窗口
	m_hwnd = CreateWindowW(wc.lpszClassName, title, window_style,
		window_rect.left, window_rect.top, window_rect.right, window_rect.bottom, 0, 0, HINST_THISCOMPONENT, this);
	// 显示窗口
	if (m_hwnd){
		::GetClientRect(m_hwnd, &window_rect);
#ifdef _DEBUG
		_cwprintf(L"Window: %4d, %4d\n", window_rect.right, window_rect.bottom);
#endif
		ClientToScreen(m_hwnd, (LPPOINT)(&window_rect));
		window_rect.right += window_rect.left;
		window_rect.bottom += window_rect.top;
		ShowWindow(m_hwnd, SW_NORMAL);
		UpdateWindow(m_hwnd);
		// 设定并初始化渲染
		HRESULT hr = m_imageRender.SetHwnd(m_hwnd);
		if (SUCCEEDED(hr)){
			// 成功的话,创建渲染线程
			m_pRenderThread = (std::thread*)MPool.Alloc(sizeof std::thread);
			// 检查指针
			hr = m_pRenderThread ? S_OK : E_OUTOFMEMORY;
		}
		if (SUCCEEDED(hr)){
			// 显式析构
			new(m_pRenderThread) std::thread(ImageRender::RenderThread, &m_imageRender);
			// 成功的话,创建游戏逻辑线程
			m_pGameLogicThread = (std::thread*)MPool.Alloc(sizeof std::thread);
			// 检查指针
			hr = m_pGameLogicThread ? S_OK : E_OUTOFMEMORY;
			// 隐藏鼠标
			//::ShowCursor(FALSE);
			//ClipCursor(&window_rect);
		}
		if (SUCCEEDED(hr)){
			// 显式析构
			new(m_pGameLogicThread)std::thread(Game::LogicThread, m_hwnd);
			// 初始化输入接口
			hr = KMInput.Init(HINST_THISCOMPONENT, m_hwnd);
		}
		return hr;
	}
	return E_FAIL;
}
开发者ID:profile1p,项目名称:RubyGM,代码行数:82,代码来源:ThisApp.cpp

示例11: VID_SetWindowSize

static void VID_SetWindowSize( bool fullscreen )
{
	RECT r;
	int stylebits;
	int exstyle;
	int x = glw_state.win_x, y = glw_state.win_y;
	int width = glConfig.width, height = glConfig.height;
	HWND parentHWND = glw_state.parenthWnd;

	if( fullscreen )
	{
		exstyle = WS_EX_TOPMOST;
		stylebits = ( WS_POPUP|WS_VISIBLE );
		parentHWND = NULL;
	}
	else if( parentHWND )
	{
		exstyle = 0;
		stylebits = WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_VISIBLE;
	}
	else
	{
		exstyle = 0;
		stylebits = WINDOW_STYLE;
	}

	r.left = 0;
	r.top = 0;
	r.right  = width;
	r.bottom = height;

	AdjustWindowRect( &r, stylebits, FALSE );

	width = r.right - r.left;
	height = r.bottom - r.top;

	if( fullscreen )
	{
		x = 0;
		y = 0;
	}
	else if( parentHWND )
	{
		RECT parentWindowRect;

		GetWindowRect( parentHWND, &parentWindowRect );

		// share centre with the parent window
		x = (parentWindowRect.right - parentWindowRect.left - width) / 2;
		y = (parentWindowRect.bottom - parentWindowRect.top - height) / 2;
	}

	SetActiveWindow( glw_state.hWnd );

	SetWindowLong( glw_state.hWnd, GWL_EXSTYLE, exstyle );
	SetWindowLong( glw_state.hWnd, GWL_STYLE, stylebits );

	SetWindowPos( glw_state.hWnd, HWND_TOP, x, y, width, height, SWP_FRAMECHANGED );

	ShowWindow( glw_state.hWnd, SW_SHOW );
	UpdateWindow( glw_state.hWnd );

	SetForegroundWindow( glw_state.hWnd );
	SetFocus( glw_state.hWnd );
}
开发者ID:cfr,项目名称:qfusion,代码行数:65,代码来源:win_glw.c

示例12: ZeroMemory

bool DX11Application::Initialize()
{
    WNDCLASSEXW wc;

    ZeroMemory(&wc, sizeof(WNDCLASSEX));

    wc.cbSize = sizeof(WNDCLASSEX);
    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = WindowProc;
    wc.hInstance = mInstanceHandle;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
    wc.lpszClassName = L"WindowClass";

    RegisterClassExW(&wc);
    int argc = 0;

    RECT wr = {0, 0, mScreenWidth, mScreenHeight};
    AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);

    mWindowHandle = CreateWindowExW(NULL,
                          L"WindowClass",
                          L"DX11 Template",
                          WS_OVERLAPPEDWINDOW,
                          0,
                          0,
                          wr.right - wr.left,
                          wr.bottom - wr.top,
                          NULL,
                          NULL,
                          mInstanceHandle,
                          NULL);

    ShowWindow(mWindowHandle, SW_SHOW);

    DXGI_SWAP_CHAIN_DESC scd;

    ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC));

    scd.BufferCount					= 1;
    scd.BufferDesc.Format			= DXGI_FORMAT_R8G8B8A8_UNORM;
    scd.BufferDesc.Width			= mScreenWidth;
    scd.BufferDesc.Height			= mScreenHeight;
    scd.BufferUsage					= DXGI_USAGE_RENDER_TARGET_OUTPUT;
    scd.OutputWindow				= mWindowHandle;
    scd.SampleDesc.Count			= 1;
    scd.SampleDesc.Quality			= 0;
    scd.Windowed					= TRUE;
    scd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
    scd.BufferDesc.Scaling			= DXGI_MODE_SCALING_UNSPECIFIED;
    scd.SwapEffect					= DXGI_SWAP_EFFECT_DISCARD;
    scd.Flags						= DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;

    D3D_FEATURE_LEVEL featureLevels[] = {D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0};
    D3D11CreateDeviceAndSwapChain(NULL,
                                  D3D_DRIVER_TYPE_HARDWARE,
                                  NULL,
                                  NULL,
                                  featureLevels,
                                  3,
                                  D3D11_SDK_VERSION,
                                  &scd,
                                  &mSwapChain,
                                  &mDevice,
                                  NULL,
                                  &mDeviceContext);

    ID3D11Texture2D *BackBuffer;
    mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&BackBuffer);
    mDevice->CreateRenderTargetView(BackBuffer, NULL, &mBackBuffer);
    BackBuffer->Release();


    // Create the depth/stencil buffer and view.
    D3D11_TEXTURE2D_DESC depthBufferDesc;
    ZeroMemory(&depthBufferDesc, sizeof(depthBufferDesc));
    depthBufferDesc.Width     = mScreenWidth;
    depthBufferDesc.Height    = mScreenHeight;
    depthBufferDesc.MipLevels = 1;
    depthBufferDesc.ArraySize = 1;
    depthBufferDesc.Format    = DXGI_FORMAT_D24_UNORM_S8_UINT;
    depthBufferDesc.SampleDesc.Count   = 1; // multisampling must match
    depthBufferDesc.SampleDesc.Quality = 0; // swap chain values.
    depthBufferDesc.Usage          = D3D11_USAGE_DEFAULT;
    depthBufferDesc.BindFlags      = D3D11_BIND_DEPTH_STENCIL;
    depthBufferDesc.CPUAccessFlags = 0; 
    depthBufferDesc.MiscFlags      = 0;

    int result = mDevice->CreateTexture2D(&depthBufferDesc, 0, &mDepthStencilBuffer);
    if(FAILED(result))
    {
        return false;
    }

    D3D11_DEPTH_STENCIL_DESC depthStencilDesc;
    ZeroMemory(&depthStencilDesc, sizeof(depthStencilDesc));

    // Set up the description of the stencil state.
    depthStencilDesc.DepthEnable = true;
    depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
//.........这里部分代码省略.........
开发者ID:MattiasLiljeson,项目名称:Amalgamation,代码行数:101,代码来源:DX11Application.cpp

示例13: WinMain

int CALLBACK
WinMain(HINSTANCE instance, HINSTANCE prev_instance, LPSTR command_line, int show_code)
{
    static Bank s_stack = {0};
    static Bank s_storage = {0};
    static Core s_core = {0};
    static Bitmap s_canvas = {0};
    WNDCLASSA window_class = {0};
    u32 *window_buffer = NULL;
    BITMAPINFO window_bmi = {0};


    if (align_to(CANVAS_WIDTH, 16) != CANVAS_WIDTH) {
        printf("CANVAS_WIDTH must be aligned to 16.\n");
        return 1;
    }


    CORE = &s_core;
    CORE->running = 1;
    CORE->stack = &s_stack;
    CORE->storage = &s_storage;

    bank_init(CORE->stack, STACK_CAPACITY);
    bank_init(CORE->storage, STORAGE_CAPACITY);

    // TODO: Push canvas to storage? Storage is not initialized yet, so we cannot push it there.
    CORE->canvas = &s_canvas;
    bitmap_init(CORE->canvas, CANVAS_WIDTH, CANVAS_HEIGHT, 0, 0);
    bitmap_clear(CORE->canvas, COLOR_TRANSPARENT);

    clip_reset();

    CORE->audio_volume = PUNP_SOUND_DEFAULT_MASTER_VOLUME;

    //
    //
    //

    punp_win32_instance = instance;
    QueryPerformanceFrequency((LARGE_INTEGER *)&punp_win32_perf_counter_frequency);

    // b32 sleep_is_granular = (timeBeginPeriod(1 /*ms*/) == TIMERR_NOERROR);

#ifndef RELEASE_BUILD
    printf("Debug build...");
    if (AttachConsole(ATTACH_PARENT_PROCESS) || AllocConsole()) {
        freopen("CONOUT$", "w", stdout);
        freopen("CONOUT$", "w", stderr);
    }
#else
    printf("Release build...");
#endif

    window_class.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
    window_class.lpfnWndProc = win32_window_callback;
    window_class.hInstance = punp_win32_instance;
    // window_class.hIcon = (HICON)LoadImage(0, "icon.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE | LR_SHARED);
    window_class.hIcon = (HICON)LoadIcon(instance, "icon.ico");
    window_class.hCursor = LoadCursor(0, IDC_ARROW);
    window_class.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
    window_class.lpszClassName = "Punity";

    if (!RegisterClassA(&window_class)) {
        printf("RegisterClassA failed.\n");
        return 1;
    }

    {
        int screen_width = GetSystemMetrics(SM_CXSCREEN);
        int screen_height = GetSystemMetrics(SM_CYSCREEN);
        RECT rc;
        DWORD style = WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;

        rc.left = (screen_width - (PUNP_WINDOW_WIDTH)) / 2;
        rc.top = (screen_height - (PUNP_WINDOW_HEIGHT)) / 2;
        rc.right = rc.left + PUNP_WINDOW_WIDTH;
        rc.bottom = rc.top + PUNP_WINDOW_HEIGHT;


        ASSERT(AdjustWindowRect(&rc, style, FALSE) != 0);

        // int window_width  = rc.right - rc.left;
        // int window_height = rc.bottom - rc.top;
        // rc.left = (screen_width  - width) / 2;
        // rc.top  = (screen_height - height) / 2;

        punp_win32_window = CreateWindowExA(
                0,
                window_class.lpszClassName,
                WINDOW_TITLE,
                style,
                rc.left, rc.top,
                rc.right - rc.left, rc.bottom - rc.top,
                0, 0,
                punp_win32_instance,
                0);
    }
    if (!punp_win32_window) {
        printf("CreateWindowExA failed.\n");
//.........这里部分代码省略.........
开发者ID:gingerBill,项目名称:LD35,代码行数:101,代码来源:punity.c

示例14: SetRect

VOID CGameProcedure::CreateMainWnd(VOID)
{
	INT nWinWidth  = 0;
	INT nWinHeight = 0;

	if( s_pVariableSystem )
	{
		BOOL bHave = FALSE;
		fVector2 fResoution = CVariableSystem::GetMe()->GetAs_Vector2( "View_Resoution" , &bHave);

		if (bHave)
		{
			nWinWidth  = (INT)fResoution.x;
			nWinHeight = (INT)fResoution.y;
		}
		else
		{
			nWinWidth  = DEFWINDOW_WIDTH;
			nWinHeight = DEFWINDOW_HEIGHT;
		}
	}
	else
	{
		nWinWidth  = DEFWINDOW_WIDTH;
		nWinHeight = DEFWINDOW_HEIGHT;
	}


	// 计算窗口大小
	m_bMinimized		= FALSE;
	m_bFullScreen		= TRUE;

	SetRect( &m_rectWindow, 0, 0, nWinWidth, nWinHeight );
	AdjustWindowRect( &m_rectWindow, DEFWINDOW_STYLE, FALSE );

	SetRect( &m_rectFCOffset, 
			 m_rectWindow.left, 
			 m_rectWindow.top, 
			 m_rectWindow.right  - nWinWidth, 
			 m_rectWindow.bottom - nWinHeight
			);

	UINT dwX = (::GetSystemMetrics(SM_CXFULLSCREEN)-(m_rectWindow.right-m_rectWindow.left))/2;
	UINT dwY = (::GetSystemMetrics(SM_CYFULLSCREEN)-(m_rectWindow.bottom-m_rectWindow.top))/2;
	OffsetRect(&m_rectWindow, -m_rectFCOffset.left, -m_rectFCOffset.top);
	OffsetRect(&m_rectWindow, dwX, dwY);

	m_bActive			= true;
	m_bRenderingPaused	= FALSE;

	// 注册窗口类
	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX); 

	wcex.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
	wcex.lpfnWndProc	= (WNDPROC)_MainWndProc;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= 0;
	wcex.hInstance		= g_hInstance;
	wcex.hIcon			= LoadIcon(g_hInstance, (LPCTSTR)IDD_GAME_DIALOG);
	wcex.hCursor		= LoadCursor( NULL, IDC_ARROW );
	wcex.hbrBackground	= (HBRUSH)NULL; //GetStockObject(WHITE_BRUSH);
	wcex.lpszMenuName	= (LPCTSTR)NULL;
	wcex.lpszClassName	= MAINWINDOW_CLASS;
	wcex.hIconSm		= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);

	RegisterClassEx(&wcex);

	// 创建窗口
	CHAR szTitle[MAX_PATH];
	_snprintf(szTitle, MAX_PATH, "%s %s (%s %s)", GAME_TITLE, VERSION_INFO, __DATE__, __TIME__);

	HWND hWnd = CreateWindowEx(	NULL, MAINWINDOW_CLASS, szTitle, 
								DEFWINDOW_STYLE,
								m_rectWindow.left, m_rectWindow.top, 
								m_rectWindow.right-m_rectWindow.left, 
								m_rectWindow.bottom-m_rectWindow.top,
								NULL, NULL, g_hInstance, NULL);

	if(!hWnd)
	{
		KLThrow(_T("Can't create main window!"));
	}

	ShowWindow(hWnd, SW_SHOW);
	UpdateWindow(hWnd);

	g_hMainWnd = hWnd;
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:90,代码来源:GameProcedure.cpp

示例15: SetRect

void	CHW::updateWindowProps	(HWND m_hWnd)
{
//	BOOL	bWindowed				= strstr(Core.Params,"-dedicated") ? TRUE : !psDeviceFlags.is	(rsFullscreen);
//#ifndef DEDICATED_SERVER
//	BOOL	bWindowed				= !psDeviceFlags.is	(rsFullscreen);
//#else
//	BOOL	bWindowed				= TRUE;
//#endif

	BOOL	bWindowed				= TRUE;
#ifndef _EDITOR
	if (!g_dedicated_server)
		bWindowed			= !psDeviceFlags.is(rsFullscreen);
#endif	

	u32		dwWindowStyle			= 0;
	// Set window properties depending on what mode were in.
	if (bWindowed)		{
		if (m_move_window) {
			if (strstr(Core.Params,"-no_dialog_header"))
				SetWindowLong	( m_hWnd, GWL_STYLE, dwWindowStyle=(WS_BORDER|WS_VISIBLE) );
			else
				SetWindowLong	( m_hWnd, GWL_STYLE, dwWindowStyle=(WS_BORDER|WS_DLGFRAME|WS_VISIBLE|WS_SYSMENU|WS_MINIMIZEBOX ) );
			// When moving from fullscreen to windowed mode, it is important to
			// adjust the window size after recreating the device rather than
			// beforehand to ensure that you get the window size you want.  For
			// example, when switching from 640x480 fullscreen to windowed with
			// a 1000x600 window on a 1024x768 desktop, it is impossible to set
			// the window size to 1000x600 until after the display mode has
			// changed to 1024x768, because windows cannot be larger than the
			// desktop.

			RECT			m_rcWindowBounds;
			BOOL			bCenter = FALSE;
			if (strstr(Core.Params, "-center_screen"))	bCenter = TRUE;

#ifndef _EDITOR
			if (g_dedicated_server)
				bCenter		= TRUE;
#endif

			if(bCenter){
				RECT				DesktopRect;
				
				GetClientRect		(GetDesktopWindow(), &DesktopRect);

				SetRect(			&m_rcWindowBounds, 
									(DesktopRect.right-DevPP.BackBufferWidth)/2, 
									(DesktopRect.bottom-DevPP.BackBufferHeight)/2, 
									(DesktopRect.right+DevPP.BackBufferWidth)/2, 
									(DesktopRect.bottom+DevPP.BackBufferHeight)/2			);
			}else{
				SetRect(			&m_rcWindowBounds,
									0, 
									0, 
									DevPP.BackBufferWidth, 
									DevPP.BackBufferHeight );
			};

			AdjustWindowRect		(	&m_rcWindowBounds, dwWindowStyle, FALSE );

			SetWindowPos			(	m_hWnd, 
										HWND_NOTOPMOST,	
										m_rcWindowBounds.left, 
										m_rcWindowBounds.top,
										( m_rcWindowBounds.right - m_rcWindowBounds.left ),
										( m_rcWindowBounds.bottom - m_rcWindowBounds.top ),
										SWP_SHOWWINDOW|SWP_NOCOPYBITS|SWP_DRAWFRAME );
		}
	}
	else
	{
		SetWindowLong			( m_hWnd, GWL_STYLE, dwWindowStyle=(WS_POPUP|WS_VISIBLE) );
		SetWindowLong			( m_hWnd, GWL_EXSTYLE, WS_EX_TOPMOST);
	}

#ifndef _EDITOR
	if (!g_dedicated_server)
	{
		ShowCursor	(FALSE);
		SetForegroundWindow( m_hWnd );
	}
#endif
}
开发者ID:BeaconDev,项目名称:xray-16,代码行数:84,代码来源:HW.cpp


注:本文中的AdjustWindowRect函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。