/** ** Takes an array of new Viewports which are supposed to have their ** pixel geometry (CViewport::[XY] and CViewport::End[XY]) already ** computed. Using this information as well as old viewport's ** parameters fills in new viewports' CViewport::Map* parameters. ** Then it replaces the old viewports with the new ones and finishes ** the set-up of the new mode. ** ** @param new_vps The array of the new viewports ** @param num_vps The number of elements in the new_vps[] array. */ static void FinishViewportModeConfiguration(CViewport new_vps[], int num_vps) { // Compute location of the viewport using oldviewport for (int i = 0; i < num_vps; ++i) { new_vps[i].MapPos.x = 0; new_vps[i].MapPos.y = 0; const CViewport *vp = GetViewport(new_vps[i].GetTopLeftPos()); if (vp) { const PixelDiff relDiff = new_vps[i].GetTopLeftPos() - vp->GetTopLeftPos(); new_vps[i].Offset = relDiff + Map.TilePosToMapPixelPos_TopLeft(vp->MapPos, UI.CurrentMapLayer) + vp->Offset; } else { new_vps[i].Offset.x = 0; new_vps[i].Offset.y = 0; } } // Affect the old viewport. for (int i = 0; i < num_vps; ++i) { CViewport &vp = UI.Viewports[i]; vp.TopLeftPos = new_vps[i].TopLeftPos; vp.BottomRightPos = new_vps[i].BottomRightPos; vp.Set(new_vps[i].MapPos, new_vps[i].Offset); } UI.NumViewports = num_vps; // // Update the viewport pointers // UI.MouseViewport = GetViewport(CursorScreenPos); UI.SelectedViewport = std::min(UI.Viewports + UI.NumViewports - 1, UI.SelectedViewport); }
ITexture* CDynamicRenderTargets::CreateMaskGameUITexture() { return m_pMaterialSystem->CreateNamedRenderTargetTextureEx2( "_rt_MaskGameUI", GetViewport().x, GetViewport().y, RT_SIZE_FULL_FRAME_BUFFER, m_pMaterialSystem->GetBackBufferFormat(), MATERIAL_RT_DEPTH_SHARED, 0, CREATERENDERTARGETFLAGS_HDR); }
void ModelRenderer::ClearModel() { if (!node_) { return; } GetViewport()->makeCurrent(); GetScene()->DestroyNode(node_); node_ = nullptr; GetViewport()->ScheduleRedraw(); }
void Main::InitCompositor() { mSceneRenderCompositor = Ogre::CompositorManager::getSingleton().addCompositor(GetViewport(), "RenderHDRScene"); mSceneRenderCompositor->addListener(new VolumetricLightListener()); Ogre::CompositorManager::getSingleton().setCompositorEnabled(GetViewport(), "RenderHDRScene", true); Ogre::CompositorInstance *hdrinstance = Ogre::CompositorManager::getSingleton().addCompositor(Main::Instance().GetViewport(), "DownsampleHDR1"); HDRListener *hdrListener = new HDRListener(); hdrinstance->addListener(hdrListener); hdrListener->notifyViewportSize(mViewport->getActualWidth(), mViewport->getActualHeight()); hdrListener->notifyCompositor(hdrinstance); Ogre::CompositorManager::getSingleton().setCompositorEnabled(GetViewport(), "DownsampleHDR1", true); }
void CDynamicRenderTargets::UpdateDynamicRenderTargets() { if (!m_pMaterialSystem) return; if (m_pOldViewport != GetViewport()) { ShutdownDynamicRenderTargets(); InitDynamicRenderTargets(); m_pOldViewport = GetViewport(); } }
// overrides base Show behavior. bool GSFrame::Show( bool shown ) { if( shown ) { GSPanel* gsPanel = GetViewport(); if( !gsPanel || gsPanel->IsBeingDeleted() ) { gsPanel = new GSPanel( this ); m_id_gspanel = gsPanel->GetId(); } gsPanel->Show( !EmuConfig.GS.DisableOutput ); gsPanel->DoResize(); gsPanel->SetFocus(); if( wxStaticText* label = GetLabel_OutputDisabled() ) label->Show( EmuConfig.GS.DisableOutput ); if( !m_timer_UpdateTitle.IsRunning() ) m_timer_UpdateTitle.Start( TitleBarUpdateMs ); } else { m_timer_UpdateTitle.Stop(); } return _parent::Show( shown ); }
void ModelRenderer::LoadModelGL() { Scene::Ptr scene = GetScene(); // Clear out any previously loaded model. ClearModel(); // Load the model as a scene graph resource. Scene::Ptr model = AssetImporter::ImportFile(GetResources(), model_fname_); if (!model) { return; } // Create a node in the main scene graph. node_ = scene->MakeGroup(GetBaseNode()); // Instantiate the model as a child of the newly created node. scene->MakeGroupFromScene(node_, model); // Scale and translate the model so that it fits inside a unit cube // centered at the origin. const AxisAlignedBox& box = model->Root()->WorldBoundingBox(); const QVector3D span = box.Max() - box.Min(); const float max_span = std::max(std::max(span.x(), span.y()), span.z()); const double scale_factor = 1.0 / max_span; node_->SetScale(QVector3D(scale_factor, scale_factor, scale_factor)); node_->SetTranslation(-0.5 * scale_factor * (box.Max() + box.Min())); GetViewport()->ScheduleRedraw(); }
void RenderSystem_GL30::UpdateViewport() { DisplayManager *dm = DisplayManager::GetSingleton(); SetViewport(dm->GetViewport()); glm::vec4 view = GetViewport(); glViewport((GLsizei)view.x, (GLsizei)view.y, (GLsizei)view.z, (GLsizei)view.w); }
void Container::HandleViewportUpdate() { for( const auto& child : m_children ) { child->SetViewport( GetViewport() ); } Widget::HandleViewportUpdate(); }
HRESULT hookIDirect3DDevice9::EndScene(THIS) { if (_modManager != NULL) { D3DVIEWPORT9 viewport; GetViewport(&viewport); D3DDEVICE_CREATION_PARAMETERS cparams; RECT rect; GetCreationParameters(&cparams); GetClientRect(cparams.hFocusWindow, &rect); //only draw when the viewport is the same size as the window, ie: we are in the downscaling/upscaling step or if you are playing at 720p just always if (rect.right - rect.left == viewport.Width) { LARGE_INTEGER curTime = oldTime; LARGE_INTEGER freq; QueryPerformanceCounter(&oldTime); QueryPerformanceFrequency(&freq); float dt = float(oldTime.QuadPart - curTime.QuadPart) / float(freq.QuadPart); input::update(); _modManager->update(dt); } } return _hookee->EndScene(); }
/** * Set the state of the path build GUI. * @param opened If \c true the path GUI just opened, else it closed. */ void PathBuildManager::SetPathGuiState(bool opened) { PathBuildState state = opened ? PBS_SINGLE : PBS_IDLE; this->SetState(state); Viewport *vp = GetViewport(); if (opened || (vp != nullptr && _mouse_modes.GetMouseMode() == MM_PATH_BUILDING)) _mouse_modes.SetViewportMousemode(); }
void App::Draw() { const FLOAT bgColor[4] = {0.0, 0.0, 0.0, 1.0}; devContext->ClearRenderTargetView(renderTarget, bgColor); devContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); devContext->IASetInputLayout(inLayout); for(auto it = viewports.begin(); it != viewports.end(); it++) { // Map and copy cb data D3D11_MAPPED_SUBRESOURCE msr; devContext->Map(viewportBuffer, NULL, D3D11_MAP_WRITE_DISCARD, NULL, &msr); memcpy(msr.pData, it->GetBufferData(), sizeof(RawData)); devContext->Unmap(viewportBuffer, NULL); // Map and copy shader data devContext->Map(shaderParamsBuffer, NULL, D3D11_MAP_WRITE_DISCARD, NULL, &msr); memcpy(msr.pData, shaderParams, sizeof(ShaderParams)); devContext->Unmap(shaderParamsBuffer, NULL); // Set constant buffers ID3D11Buffer* cBuffers[2]; cBuffers[0] = viewportBuffer; cBuffers[1] = shaderParamsBuffer; devContext->PSSetConstantBuffers(0, 2, cBuffers); // set viewport and draw to it devContext->RSSetViewports(1, &(it->GetViewport())); devContext->Draw(6, 0); } swapChain->Present(0,0); }
// overrides base Show behavior. bool GSFrame::Show( bool shown ) { if( shown ) { GSPanel* gsPanel = GetViewport(); if( !gsPanel || gsPanel->IsBeingDeleted() ) { gsPanel = new GSPanel( this ); m_id_gspanel = gsPanel->GetId(); } gsPanel->DoResize(); gsPanel->SetFocus(); if( !m_timer_UpdateTitle.IsRunning() ) m_timer_UpdateTitle.Start( TitleBarUpdateMs ); } else { m_timer_UpdateTitle.Stop(); } return _parent::Show( shown ); }
void GSFrame::OnActivate( wxActivateEvent& evt ) { if( IsBeingDeleted() ) return; evt.Skip(); if( wxWindow* gsPanel = GetViewport() ) gsPanel->SetFocus(); }
void OpenGLEngine::Draw (int x, int y, glm::vec4 const& color, std::string const& message) { if (message.length () > 0) { int vx, vy, vw, vh; GetViewport (vx, vy, vw, vh); m_ActiveFont->SetStringData (vw, vh, x, y, color, message); Update (m_ActiveFont->GetTextEffect () ->GetTranslate ()); Update (m_ActiveFont->GetTextEffect () ->GetColor ()); Update (m_ActiveFont->GetVertexBuffer ()); std::shared_ptr<BlendState> blendState = GetBlendState (); std::shared_ptr<DepthStencilState> depthState = GetDepthStencilState (); std::shared_ptr<RasterizerState> rasterizerState = GetRasterizerState (); SetDefaultBlendState (); SetDefaultDepthStencilState (); SetDefaultRasterizerState (); Draw (m_ActiveFont->GetVertexBuffer (), m_ActiveFont->GetIndexBuffer (), m_ActiveFont->GetTextEffect ()); SetBlendState (blendState); SetDepthStencilState (depthState); SetRasterizerState (rasterizerState); } }
void Task::InitLayout() { auto stage = new ee3::StagePanel(m_parent, m_parent, nullptr); auto canvas = std::make_shared<eterrain3d::StageCanvas>(stage); stage->SetCanvas(canvas); stage->SetEditOP(std::make_shared<ee3::CamControlOP>( stage, stage->GetStageImpl(), canvas->GetCamera(), canvas->GetViewport(), stage->GetSubjectMgr())); }
void Container::HandleViewportUpdate() { std::size_t children_size = m_children.size(); for( std::size_t index = 0; index < children_size; ++index ) { m_children[index]->SetViewport( GetViewport() ); } Widget::HandleViewportUpdate(); }
void CDynamicRenderTargets::InitClientRenderTargets(IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig) { BaseClass::InitClientRenderTargets(pMaterialSystem, pHardwareConfig); m_pMaterialSystem = pMaterialSystem; m_pOldViewport = GetViewport(); InitDynamicRenderTargets(); }
bool Window::bind() { uth::Graphics::BindFrameBuffer(0); const pmath::Rect& vp = GetViewport(); uth::Graphics::SetViewport( static_cast<int>(vp.position.x + 0.5f), static_cast<int>(vp.position.y + 0.5f), static_cast<int>(vp.size.x + 0.5f), static_cast<int>(vp.size.y + 0.5f) ); return true; }
/** * Moves relevant windows if they've been moved offscreen by a window resize. * Also forces the bottom toolbar to be moved, as that will always be in the wrong position. */ void WindowManager::RepositionAllWindows() { Viewport *vp = GetViewport(); if (vp == nullptr) return; Rectangle32 vp_rect = vp->rect; for (Window *w = this->top; w != nullptr; w = w->lower) { if (w->wtype == WC_MAINDISPLAY) continue; /* Add an arbitrary amount for closebox/titlebar, * so the window is still actually accessible. */ if (!vp_rect.IsPointInside(Point32(w->rect.base.x + 20, w->rect.base.y + 20)) || w->wtype == WC_BOTTOM_TOOLBAR) { w->SetPosition(w->OnInitialPosition()); } } }
/** Set the buttons at the path builder GUI. */ void PathBuildGui::SetButtons() { Viewport *vp = GetViewport(); if (vp == nullptr) return; /* Update arrow buttons. */ uint8 directions = _path_builder.GetAllowedArrows(); TileEdge sel_dir = _path_builder.GetSelectedArrow(); for (TileEdge edge = EDGE_BEGIN; edge < EDGE_COUNT; edge++) { TileEdge rot_edge = (TileEdge)SubtractOrientations((ViewOrientation)edge, vp->orientation); if (((0x11 << edge) & directions) != 0) { this->SetWidgetShaded(PATH_GUI_NE_DIRECTION + rot_edge, false); this->SetWidgetPressed(PATH_GUI_NE_DIRECTION + rot_edge, edge == sel_dir); } else { this->SetWidgetShaded(PATH_GUI_NE_DIRECTION + rot_edge, true); } } /* Update the slope buttons. */ uint8 allowed_slopes = _path_builder.GetAllowedSlopes(); TrackSlope sel_slope = _path_builder.GetSelectedSlope(); for (TrackSlope ts = TSL_BEGIN; ts < TSL_COUNT_GENTLE; ts++) { bool option_allowed = ((1 << ts) & allowed_slopes) != 0; this->SetWidgetShaded(PATH_GUI_SLOPE_DOWN + ts, !option_allowed); this->SetWidgetPressed(PATH_GUI_SLOPE_DOWN + ts, ts == sel_slope && option_allowed); } this->SetWidgetShaded(PATH_GUI_BUY, !_path_builder.GetBuyIsEnabled()); this->SetWidgetShaded(PATH_GUI_REMOVE, !_path_builder.GetRemoveIsEnabled()); this->SetWidgetShaded(PATH_GUI_FORWARD, !_path_builder.GetForwardIsEnabled()); this->SetWidgetShaded(PATH_GUI_BACKWARD, !_path_builder.GetBackwardIsEnabled()); this->SetWidgetShaded(PATH_GUI_LONG, !_path_builder.GetLongButtonIsEnabled()); this->SetWidgetPressed(PATH_GUI_LONG, _path_builder.GetLongButtonIsPressed()); for (int i = 0; i < PAT_COUNT; i++) { if (this->normal_path_types[i]) { this->SetWidgetShaded(PATH_GUI_NORMAL_PATH0 + i, false); this->SetWidgetShaded(PATH_GUI_QUEUE_PATH0 + i, true); this->SetWidgetPressed(PATH_GUI_NORMAL_PATH0 + i, (i == _path_builder.path_type)); } else if (this->queue_path_types[i]) { this->SetWidgetShaded(PATH_GUI_NORMAL_PATH0 + i, true); this->SetWidgetShaded(PATH_GUI_QUEUE_PATH0 + i, false); this->SetWidgetPressed(PATH_GUI_QUEUE_PATH0 + i, (i == _path_builder.path_type)); } else { this->SetWidgetShaded(PATH_GUI_NORMAL_PATH0 + i, true); this->SetWidgetShaded(PATH_GUI_QUEUE_PATH0 + i, true); } } this->SetWidgetPressed(PATH_GUI_SINGLE, _path_builder.GetState() == PBS_SINGLE); this->SetWidgetPressed(PATH_GUI_DIRECTIONAL, _path_builder.GetState() != PBS_SINGLE); }
Vector3f AbstractViewer::Project(const Nz::Vector3f& worldPosition) const { Vector4f pos4D(worldPosition, 1.f); pos4D = GetViewMatrix() * pos4D; pos4D = GetProjectionMatrix() * pos4D; pos4D /= pos4D.w; Rectf viewport = Rectf(GetViewport()); Nz::Vector3f screenPosition(pos4D.x * 0.5f + 0.5f, -pos4D.y * 0.5f + 0.5f, pos4D.z * 0.5f + 0.5f); screenPosition.x = screenPosition.x * viewport.width + viewport.x; screenPosition.y = screenPosition.y * viewport.height + viewport.y; return screenPosition; }
TEyeXMaybeValue<FVector2D> FEyeXUtils::VirtualDesktopPixelToViewportPixel(FVector2D Point) { auto viewport = GetViewport(); if (viewport == nullptr) { return TEyeXMaybeValue<FVector2D>(FVector2D::ZeroVector, false); } FIntPoint intPoint((int32)Point.X, (int32)Point.Y); FVector2D viewportPoint = viewport->VirtualDesktopPixelToViewport(intPoint); auto viewportSize = viewport->GetSizeXY(); FVector2D viewportPixels(viewportPoint.X * viewportSize.X, viewportPoint.Y * viewportSize.Y); return TEyeXMaybeValue<FVector2D>(viewportPixels); }
void CGraphicsDevice::SetRenderTarget(CRenderTarget** rt, IZ_UINT num) { // レンダーターゲットを入れ替える SetRenderTargetInternal(rt, num); // TODO // 強制的に0番目のサーフェスのサイズにビューポートを変換する const SViewport& curVp = GetViewport(); SViewport vp; memcpy(&vp, &curVp, sizeof(vp)); vp.x = vp.y = 0; vp.width = rt[0]->GetWidth(); vp.height = rt[0]->GetHeight(); SetViewport(vp); }
bool C4ObjectMenu::IsReadOnly() { // get viewport C4Viewport *pVP = GetViewport(); if (!pVP) return false; // is it an observer viewport? if (pVP->fIsNoOwnerViewport) // is this a synced menu? if (eCallbackType == CB_Object || eCallbackType == CB_Scenario) // then don't control it! return true; // if the player is eliminated, do not control either! if (!pVP->fIsNoOwnerViewport) { C4Player *pPlr = ::Players.Get(::MouseControl.GetPlayer()); if (pPlr && pPlr->Eliminated) return true; } return false; }
eeVector3f cGL::UnProjectCurrent( const eeVector3f& point ) { GLfloat projMat[16]; GetCurrentMatrix( GL_PROJECTION_MATRIX, projMat ); GLfloat modelMat[16]; GetCurrentMatrix( GL_MODELVIEW_MATRIX, modelMat ); GLint viewPort[4]; GetViewport( viewPort ); eeVector3f fPoint( point ); fPoint.y = viewPort[3] - point.y; Vector3<GLfloat> tv3; UnProject( (GLfloat)fPoint.x, (GLfloat)fPoint.y, (GLfloat)fPoint.z, projMat, modelMat, viewPort, &tv3.x, &tv3.y, &tv3.z ); return eeVector3f( tv3.x, tv3.y, tv3.z ); }
Vector3f AbstractViewer::Unproject(const Nz::Vector3f& screenPos) const { Rectf viewport = Rectf(GetViewport()); Nz::Vector4f normalizedPosition; normalizedPosition.x = (screenPos.x - viewport.x) / viewport.width * 2.f - 1.f; normalizedPosition.y = (screenPos.y - viewport.y) / viewport.height * 2.f - 1.f; normalizedPosition.z = screenPos.z * 2.f - 1.f; normalizedPosition.w = 1.f; normalizedPosition.y = -normalizedPosition.y; Nz::Matrix4f invMatrix = GetViewMatrix() * GetProjectionMatrix(); invMatrix.Inverse(); Nz::Vector4f worldPos = invMatrix * normalizedPosition; worldPos /= worldPos.w; return Nz::Vector3f(worldPos.x, worldPos.y, worldPos.z); }
void GSFrame::OnResize( wxSizeEvent& evt ) { if( IsBeingDeleted() ) return; if( !IsFullScreen() && !IsMaximized() && IsVisible() ) { g_Conf->GSWindow.WindowSize = GetClientSize(); } if( GSPanel* gsPanel = GetViewport() ) { gsPanel->DoResize(); gsPanel->SetFocus(); } //wxPoint hudpos = wxPoint(-10,-10) + (GetClientSize() - m_hud->GetSize()); //m_hud->SetPosition( hudpos ); //+ GetScreenPosition() + GetClientAreaOrigin() ); // if we skip, the panel is auto-sized to fit our window anyway, which we do not want! //evt.Skip(); }
///描画処理 void CubeObject::DrawObject() { auto Dev = App::GetApp()->GetDeviceResources(); //コマンドリストのリセット CommandList::Reset(m_PipelineState, m_CommandList); //メッシュが更新されていればリソース更新 m_CubeMesh->UpdateResources<VertexPositionColor>(m_CommandList); //ルートシグネチャのセット m_CommandList->SetGraphicsRootSignature(m_RootSignature.Get()); //デスクプリタヒープのセット ID3D12DescriptorHeap* ppHeaps[] = { m_CbvSrvUavDescriptorHeap.Get() }; m_CommandList->SetDescriptorHeaps(_countof(ppHeaps), ppHeaps); //GPUデスクプリタヒープハンドルのセット for (size_t i = 0; i < m_GPUDescriptorHandleVec.size(); i++) { m_CommandList->SetGraphicsRootDescriptorTable(i, m_GPUDescriptorHandleVec[i]); } m_CommandList->RSSetViewports(1, &Dev->GetViewport()); m_CommandList->RSSetScissorRects(1, &Dev->GetScissorRect()); //レンダーターゲットビューのハンドルを取得 CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle = Dev->GetRtvHandle(); //デプスステンシルビューのハンドルを取得 CD3DX12_CPU_DESCRIPTOR_HANDLE dsvHandle = Dev->GetDsvHandle(); //取得したハンドルをセット m_CommandList->OMSetRenderTargets(1, &rtvHandle, FALSE, &dsvHandle); m_CommandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); m_CommandList->IASetVertexBuffers(0, 1, &m_CubeMesh->GetVertexBufferView()); //インデックスバッファをセット m_CommandList->IASetIndexBuffer(&m_CubeMesh->GetIndexBufferView()); //インデックス描画 m_CommandList->DrawIndexedInstanced(m_CubeMesh->GetNumIndicis(), 1, 0, 0, 0); //コマンドリストのクローズ CommandList::Close(m_CommandList); //デバイスにコマンドリストを送る Dev->InsertDrawCommandLists(m_CommandList.Get()); }
void gld_NEW_VIEWPORT( struct gl_context *ctx) { GLD_context *gldCtx = GLD_GET_CONTEXT(ctx); GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx); D3DVIEWPORT7 d3dvp; // GLint x, y; // GLsizei w, h; // Set depth range _GLD_DX7_DEV(GetViewport(gld->pDev, &d3dvp)); // D3D can't do Quake1/Quake2 z-trick if (ctx->Viewport.Near <= ctx->Viewport.Far) { d3dvp.dvMinZ = ctx->Viewport.Near; d3dvp.dvMaxZ = ctx->Viewport.Far; } else { d3dvp.dvMinZ = ctx->Viewport.Far; d3dvp.dvMaxZ = ctx->Viewport.Near; } /* x = ctx->Viewport.X; y = ctx->Viewport.Y; w = ctx->Viewport.Width; h = ctx->Viewport.Height; if (x < 0) x = 0; if (y < 0) y = 0; if (w > gldCtx->dwWidth) w = gldCtx->dwWidth; if (h > gldCtx->dwHeight) h = gldCtx->dwHeight; // Ditto for D3D viewport dimensions if (w+x > gldCtx->dwWidth) w = gldCtx->dwWidth-x; if (h+y > gldCtx->dwHeight) h = gldCtx->dwHeight-y; d3dvp.X = x; d3dvp.Y = gldCtx->dwHeight - (y + h); d3dvp.Width = w; d3dvp.Height = h;*/ _GLD_DX7_DEV(SetViewport(gld->pDev, &d3dvp)); // gld->fFlipWindowY = (float)gldCtx->dwHeight; }