void Render::Draw(IDirect3DSurface9* renderTarget, D3DXMATRIX* view, D3DXMATRIX* projection) { // Get or create device LPDIRECT3DDEVICE9 device = GetDevice(); if (device == NULL) return; // Load shaders if it is required // if (!EnsureShaders()) return; // Prepare depth surface D3DSURFACE_DESC renderTargetDescription; renderTarget->GetDesc(&renderTargetDescription); D3DSURFACE_DESC depthSurfaceDescription; if (depthSurface != NULL) depthSurface->GetDesc(&depthSurfaceDescription); if (depthSurface == NULL || depthSurfaceDescription.Width != renderTargetDescription.Width || depthSurfaceDescription.Height != renderTargetDescription.Height) { if (depthSurface != NULL) depthSurface->Release(); device->CreateDepthStencilSurface(renderTargetDescription.Width, renderTargetDescription.Height, D3DFMT_D24X8, D3DMULTISAMPLE_NONE, 0, FALSE, &depthSurface, NULL); if (depthSurface == NULL) return; } device->SetRenderTarget(0, renderTarget); device->SetDepthStencilSurface(depthSurface); device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0); if (lowPolySphere == NULL) { // Create spheres lowPolySphere = CreateSphere(2); middlePolySphere = CreateSphere(3); highPolySphere = CreateSphere(5); // Create cylinders lowPolyCylinder = CreateCylinder(3); middlePolyCylinder = CreateCylinder(12); highPolyCylinder = CreateCylinder(24); } // FIXME: light dir must be slightly different! D3DVECTOR lightDirection; lightDirection.x = view->_13; lightDirection.y = view->_23; lightDirection.z = view->_33; D3DVECTOR viewDirection; viewDirection.x = view->_13; viewDirection.y = view->_23; viewDirection.z = view->_33; elementMaterials[0].SetViewLightDirection(&viewDirection, &lightDirection); // Rendering device->BeginScene(); DrawAtoms(view, projection); DrawBonds(view, projection); DrawResidues(view, projection); device->EndScene(); }
void CVXS_SimGLView::Draw(int Selected, bool ViewSection, int SectionLayer) { if (!pSim->IsInitalized()) return; if (CurViewMode == RVM_NONE) return; else if (CurViewMode == RVM_VOXELS){ switch (CurViewVox){ case RVV_DISCRETE: DrawGeometry(Selected, ViewSection, SectionLayer); break; //section view only currently enabled in voxel view mode case RVV_DEFORMED: DrawVoxMesh(Selected); break; case RVV_SMOOTH: DrawSurfMesh(); break; } } else { //CurViewMode == RVT_BONDS vfloat VoxScale=0.2; if (ViewForce){ DrawForce(); DrawGeometry(Selected, ViewSection, SectionLayer, VoxScale); } else { if (CurViewVox == RVV_SMOOTH) VoxScale=0.1; DrawBonds(); DrawGeometry(Selected, ViewSection, SectionLayer, VoxScale); } DrawStaticFric(); } if (ViewAngles) DrawAngles(); if (pSim->IsFeatureEnabled(VXSFEAT_FLOOR)) DrawFloor(); //draw the floor if its in use // if (pEnv->IsFloorEnabled()) DrawFloor(); //draw the floor if its in use NeedStatsUpdate=true; }
void CVX_Sim::Draw(int Selected, bool ViewSection, int SectionLayer) { if (!Initalized) return; if (CurViewMode == RVM_NONE) return; else if (CurViewMode == RVM_VOXELS){ switch (CurViewVox){ case RVV_DISCRETE: DrawGeometry(Selected, ViewSection, SectionLayer); break; //section view only currently enabled in voxel view mode case RVV_DEFORMED: DrawVoxMesh(Selected); break; case RVV_SMOOTH: DrawSurfMesh(); break; } } else { //CurViewMode == RVT_BONDS DrawBonds(); DrawStaticFric(); } if (ViewAngles) DrawAngles(); if (ViewForce) DrawForce(); if (pEnv->IsFloorEnabled()) DrawFloor(); //draw the floor if its in use NeedStatsUpdate=true; }