Ejemplo n.º 1
0
bool CD3DObj::toggleFullScreen()
{
	assert(mDevice != NULL);

	static RECT winRect = {0};
	D3DPRESENT_PARAMETERS params = {0}; // Presentation parameters to be filled

	// Toggle full screen flag
	mFullScreen = !mFullScreen; 

	// Get presentation parameters for the new current full screen mode
	setPresentationParams(params);

	// If we're changing to full screen mode, save off the window's RECT so
	// we can put the window back in position when switching back to windowed mode
	if(mFullScreen == true)
		GetWindowRect(mHWND, &winRect);
	
	// Notify the effect interface that a device reset is about to happen	
	if(mEffect->OnLostDevice() != D3D_OK)
	{
		// Put flag back
		mFullScreen = !mFullScreen;
			return false;
	}
	
	// Reset the device to the new parameters
	if(mDevice->Reset(&params) != D3D_OK)
	{
		// Put flag back
		mFullScreen = !mFullScreen;
			return false;
	}
	
	// Update the effect file so it knows Reset() has been called on the device
	mEffect->OnResetDevice();

	// If we've changed to windowed mode
	if(mFullScreen == false)
	{
		// Move and resize window
		SetWindowPos(mHWND, HWND_NOTOPMOST, winRect.left, winRect.top, winRect.right - winRect.left,
					 winRect.bottom - winRect.top, SWP_SHOWWINDOW);
	}

	// We must reset the render states
	setDefaultStates();
	setProjMatrix(mFOV, mNearClip, mFarClip);
		return true;
}
Ejemplo n.º 2
0
bool CD3DObj::toggleFullScreen()
{
	assert(mDevice != NULL);

	static RECT winRect = {0};
	D3DPRESENT_PARAMETERS params = {0}; // Presentation parameters to be filled

	// Toggle full screen flag
	mFullScreen = !mFullScreen; 

	// Get presentation parameters for the new current full screen mode
	setPresentationParams(params);

	// If we're changing to full screen mode, save off the window's RECT so
	// we can put the window back in position when switching back to windowed mode
	if(mFullScreen == true)
		GetWindowRect(mHWND, &winRect);

	// Reset the device to the new parameters
	if(mDevice->Reset(&params) != D3D_OK)
	{
		// Put flag back
		mFullScreen = !mFullScreen;
		return false;
	}

	// If we've changed to windowed mode
	if(mFullScreen == false)
	{
		// Move and resize window
		SetWindowPos(mHWND, HWND_NOTOPMOST, winRect.left, winRect.top, winRect.right - winRect.left,
			winRect.bottom - winRect.top, SWP_SHOWWINDOW);
	}

	// Calculate the new aspect ratio
	float aspectRatio = (float)params.BackBufferWidth / (float)params.BackBufferHeight;

	// We must reset the render states
	setDefaultRenderState();
	setProjMatrix(mFOV, aspectRatio, mNearClip, mFarClip);
	return true;
}
Ejemplo n.º 3
0
void Quad::setMatrices(D3DXMATRIX * view, D3DXMATRIX * proj)
{
	setViewMatrix(view);
	setProjMatrix(proj);
}
Ejemplo n.º 4
0
Camera::Camera(float fov, float aspect, float nearDepth, float farDepth) {
    setProjMatrix(fov, aspect, nearDepth, farDepth);
}