VOID SwapChainController12::ToggleFullscreen() { HRESULT hr = S_OK; BOOL Fullscreen = IsFullscreen(); if (Fullscreen == FALSE) { //Not in fullscreen currently, let's enter RECT DesktopArea; Output12* output = m_OutputEnum.SearchOutput(m_Handle); output->GetDesktopArea(&DesktopArea); DXGI_MODE_DESC mode; Zero(mode); CComPtr<IDXGIOutput4> obj = output->GetObj(); mode.Width = DesktopArea.right - DesktopArea.left; mode.Height = DesktopArea.bottom - DesktopArea.top; //ResizeTarget() should be called before SetFullscreenState(), as per MSDN recommendations hr = m_SwapChain->ResizeTarget ( &mode ); CHECK_HR(__LINE__); hr = m_SwapChain->SetFullscreenState ( TRUE, obj ); CHECK_HR(__LINE__); ResizeBuffers(); } else { hr = m_SwapChain->SetFullscreenState ( FALSE, nullptr ); CHECK_HR(__LINE__); } }
void BlockOrientedCipherModeBase::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms) { m_cipher->SetKey(key, length, params); ResizeBuffers(); if (IsResynchronizable()) Resynchronize(GetIVAndThrowIfInvalid(params)); }
void Renderer::OnWindowSizeChange(_In_ const Window::WindowSize & NewSize) { Fence.SetAndWait(DeviceContext.GetCommandQueue()); ResizeBuffers(NewSize); UpdateViewportAndScissorRect(NewSize); Camera.UpdateCamera(NewSize); }
void Renderer::SetResolution(UINT _width, UINT _height) { // We have to release all references to the swap chain before we can resize it ReleaseCOM(theRenderTargetViewPtr); ReleaseCOM(theDepthStencilBufferPtr); ReleaseCOM(theDepthStencilViewPtr); ReleaseCOM(theBackBufferPtr); resolutionWidth = _width; resolutionHeight = _height; ResizeBuffers(); }
KnotVector& splineknots::Tridiagonal::Solve(size_t num_unknowns) { auto resize = std::max(num_unknowns, right_side_buffer_.size()); auto minsize = std::min(Buffer().size(), RightSideBuffer().size()); if (resize > minsize) ResizeBuffers(resize); auto& buffer = Buffer(); utils::SolveDeboorTridiagonalSystemBuffered( main_diagonal_value, &right_side_buffer_.front(), num_unknowns, &buffer.front()); return right_side_buffer_; }
// Here is the WndProc that handles all the messages LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { // Check which message was passed in switch (iMsg) { // This message is sent when the window is created (CreateWindow()) case WM_CREATE: // Create the double buffer and load the bitmaps Init(hwnd); break; // This message is sent when the window is resized case WM_SIZE: // This resizes the buffers to the new screen/window size ResizeBuffers(&gBuffer); break; // This message is sent when the mouse moves case WM_MOUSEMOVE: // Set the first sprite's position to the mouse position SetSpritePosition(&gSprite, LOWORD(lParam), HIWORD(lParam)); // Set the second sprite's position to the mouse's X position gSprite2.position.x = LOWORD(lParam); break; // This message is sent when the window is destroyed case WM_DESTROY: // Free all the data and set everything back to normal, then post the quit message DeInit(); break; } // Process/handle the default messages return DefWindowProc (hwnd, iMsg, wParam, lParam); }
void CanvasSwapChain::ResizeBuffersImpl( D2DResourceLock const& lock, float newWidth, float newHeight, float newDpi, DirectXPixelFormat newFormat, int32_t bufferCount) { auto swapChain = As<IDXGISwapChain2>(GetResource()); int widthInPixels = SizeDipsToPixels(newWidth, newDpi); int heightInPixels = SizeDipsToPixels(newHeight, newDpi); ThrowIfNegative(bufferCount); ThrowIfNegative(widthInPixels); ThrowIfNegative(heightInPixels); ThrowIfFailed(swapChain->ResizeBuffers( bufferCount, widthInPixels, heightInPixels, static_cast<DXGI_FORMAT>(newFormat), 0)); if (m_isCoreWindowSwapChain) { // CoreWindow swap chains can't get or set the transform matrix. m_dpi = newDpi; } else { // Update the transform matrix to account for any DPI changes DXGI_MATRIX_3X2_F dpiIndependentTransform = GetMatrixInternal(lock, swapChain); m_dpi = newDpi; SetMatrixInternal(lock, swapChain, &dpiIndependentTransform); } }
Graphics3D::Graphics3D(MS_AppInstance* instance, const int32_t attrib_list[]) : is_null_(false) { SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); int i = 0; int32_t width = 0, height = 0; bool done = false; while (!done) { switch (attrib_list[i++]) { case MS_GRAPHICS3DATTRIB_NONE: done = true; break; case MS_GRAPHICS3DATTRIB_WIDTH: width = attrib_list[i++]; break; case MS_GRAPHICS3DATTRIB_HEIGHT: height = attrib_list[i++]; break; default: { auto v = attrib_list[i-1]; if (v > MS_GRAPHICS3DATTRIB_NONE) ++i; // ignore this one, must be some pepper-special one else SDL_GL_SetAttribute( (SDL_GLattr)v, attrib_list[i++] ); break; } } } ResizeBuffers(width, height); }
void FSpriteBatch::Render(const FDrawCall& DrawCall) { if (Sprites.Size() >= MaxSprites) { ResizeBuffers(Sprites.Size() * 2); } UploadVertexData(DrawCall.DeviceContext); const float BlendFactor[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; DrawCall.DeviceContext->OMSetBlendState(GraphicsContext->GetRenderStates()->AlphaBlendState, BlendFactor, 0xFFFFFFF); DrawCall.DeviceContext->RSSetState(GraphicsContext->GetRenderStates()->SolidNoCullRasterizer); ID3D11Buffer* Vb = VertexBuffer->GetBuffer(); UINT Offsets = 0; UINT VertexSize = sizeof(FSpriteVertex); DrawCall.DeviceContext->IASetVertexBuffers(0, 1, &Vb, &VertexSize, &Offsets); DrawCall.DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); FMaterialParameters* Parameters = DefaultMaterial->GetParameters(); if (DrawCall.InstanceData != nullptr) { Parameters->UpdateUniform(DrawCall.DeviceContext, FInstanceBuffer::kBufferName, DrawCall.InstanceData, sizeof(FInstanceBuffer)); } DefaultMaterial->Apply(DrawCall.DeviceContext); ID3D11ShaderResourceView* CurrentTexture = nullptr; int StartVertex = 0; int SpriteCount = 0; for (SizeType i = 0; i < Sprites.Size(); ++i) { const FSprite& Sprite = Sprites[i]; if (CurrentTexture != Sprite.ColourTexture) { // Flush if (SpriteCount > 0) { DrawCall.Draw(SpriteCount, StartVertex); StartVertex += SpriteCount; } SpriteCount = 1; CurrentTexture = Sprite.ColourTexture; Parameters->SetResource(FTextureNames::kDiffuseMap, CurrentTexture); Parameters->Apply(DrawCall.DeviceContext); } else { ++SpriteCount; } } if (SpriteCount > 0) { DrawCall.Draw(SpriteCount, StartVertex); } DrawCall.DeviceContext->RSSetState(GraphicsContext->GetRenderStates()->SolidRasterizer); DrawCall.DeviceContext->OMSetBlendState(GraphicsContext->GetRenderStates()->OpaqueBlendState, BlendFactor, 0xFFFFFFF); Sprites.Clear(); }
FSpriteBatch::FSpriteBatch(FGraphicsContext* GraphicsContext, FMaterial* Material, int MaxSprites) : DefaultMaterial(Material), MaxSprites(MaxSprites), GraphicsContext(GraphicsContext) { ResizeBuffers(MaxSprites); }