void D3DDrv_DrawStageGeneric( const shaderCommands_t *input ) { UpdateViewState(); UpdateTessBuffers(); // todo: wireframe mode? CommitRasterizerState( input->shader->cullType, input->shader->polygonOffset, qfalse ); g_pImmediateContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST ); g_pImmediateContext->IASetIndexBuffer( g_DrawState.tessBufs.indexes, DXGI_FORMAT_R32_UINT, 0 ); g_pImmediateContext->VSSetConstantBuffers( 0, 1, &g_DrawState.viewRenderData.vsConstantBuffer ); SetTessVertexBuffer( &g_DrawState.tessBufs ); IterateStagesGeneric( input ); // dynamic lighting if ( input->dlightBits && input->shader->sort <= SS_OPAQUE && !(input->shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) { TessProjectDynamicLights( input ); } // fog if ( input->fogNum && input->shader->fogPass ) { TessDrawFog( input ); } }
DeformableRegistration::DeformableRegistration(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) { ui.setupUi(this); ui.view->pParentDlg = this; ui.horizontalLayout->setContentsMargins(0, 0, 0, 0); connect(ui.actionNew, SIGNAL(triggered()), this, SLOT(OnFileNew())); connect(ui.actionOpenTemplate, SIGNAL(triggered()), this, SLOT(OnFileOpenTemplate())); connect(ui.actionOpenTarget, SIGNAL(triggered()), this, SLOT(OnFileOpenTarget())); connect(ui.actionSaveTemplate, SIGNAL(triggered()), this, SLOT(OnFileSaveTemplate())); connect(ui.actionSaveTarget, SIGNAL(triggered()), this, SLOT(OnFileSaveTarget())); connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(OnFileExit())); connect(ui.actionScreencapture, SIGNAL(triggered()), this, SLOT(OnScreenCapture())); connect(ui.actionPoint, SIGNAL(triggered()), this, SLOT(UpdateViewState())); connect(ui.actionWireframe, SIGNAL(triggered()), this, SLOT(UpdateViewState())); connect(ui.actionFace, SIGNAL(triggered()), this, SLOT(UpdateViewState())); connect(ui.actionSmooth, SIGNAL(triggered()), this, SLOT(UpdateViewState())); connect(ui.actionTemplateVisible, SIGNAL(triggered()), this, SLOT(UpdateViewState())); connect(ui.actionPoints_2, SIGNAL(triggered()), this, SLOT(UpdateViewState())); connect(ui.actionWireframe_2, SIGNAL(triggered()), this, SLOT(UpdateViewState())); connect(ui.actionFace_2, SIGNAL(triggered()), this, SLOT(UpdateViewState())); connect(ui.actionSmooth_2, SIGNAL(triggered()), this, SLOT(UpdateViewState())); connect(ui.actionTargetVisible, SIGNAL(triggered()), this, SLOT(UpdateViewState())); connect(ui.actionDecimate, SIGNAL(triggered()), this, SLOT(OnToolsDecimate())); connect(ui.actionRANDOM, SIGNAL(triggered()), this, SLOT(OnToolsSample_Random())); connect(ui.actionQuadricFitting, SIGNAL(triggered()), this, SLOT(OnToolsSample_Quad())); connect(ui.actionDartThrowing, SIGNAL(triggered()), this, SLOT(OnToolsSample_Uniform_Dart())); connect(ui.actionEmbededDeformation, SIGNAL(triggered()), this, SLOT(OnToolsEmbededDeformation())); srand((unsigned)time(NULL)); // 매번 다른 random number 생성을 위해 #ifdef HAO_LI connect(ui.actionInitalize_HaoLi, SIGNAL(triggered()), this, SLOT(OnToolsInitHaoLi())); connect(ui.actionStart_HaoLi, SIGNAL(triggered()), this, SLOT(OnToolsRunHaoLi())); connect(ui.actionGeodesic, SIGNAL(triggered()), this, SLOT(OnToolsGeodesic())); connect(ui.actionInitGeo, SIGNAL(triggered()), this, SLOT(OnInitGeo())); #endif }
void DeckView::Update(float dt) { last_user_activity += dt; UpdateViewState(dt); if(dirtyCardPos) { for(unsigned int i = 0; i < mCards.size(); ++i) { UpdateCardPosition(i); } dirtyCardPos = false; } }
static void DrawSkyBox( const d3dSkyBoxRenderData_t* sbrd, const skyboxDrawInfo_t* skybox, const float* eye_origin, const float* colorTint ) { D3DDrv_SetState(0); CommitRasterizerState( CT_TWO_SIDED, qfalse, qfalse ); UpdateViewState(); UpdateMaterialState(); // // Update the VS constant buffer // d3dSkyBoxVSConstantBuffer_t* vscb = QD3D::MapDynamicBuffer<d3dSkyBoxVSConstantBuffer_t>( g_pImmediateContext, sbrd->vsConstantBuffer ); memcpy( vscb->eyePos, eye_origin, sizeof(float) * 3 ); g_pImmediateContext->Unmap( sbrd->vsConstantBuffer, 0 ); // // Update the PS constant buffer // d3dSkyBoxPSConstantBuffer_t* pscb = QD3D::MapDynamicBuffer<d3dSkyBoxPSConstantBuffer_t>( g_pImmediateContext, sbrd->psConstantBuffer ); if ( colorTint ) { memcpy( pscb->color, colorTint, sizeof(float) * 3 ); pscb->color[3] = 1; } else { pscb->color[0] = 1; pscb->color[1] = 1; pscb->color[2] = 1; pscb->color[3] = 1; } g_pImmediateContext->Unmap( sbrd->psConstantBuffer, 0 ); // // Draw // UINT stride = sizeof(float) * 5; UINT offset = 0; ID3D11Buffer* vsBuffers[] = { g_DrawState.viewRenderData.vsConstantBuffer, g_DrawState.skyBoxRenderData.vsConstantBuffer }; ID3D11Buffer* psBuffers[] = { g_DrawState.skyBoxRenderData.psConstantBuffer }; g_pImmediateContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST ); g_pImmediateContext->IASetVertexBuffers( 0, 1, &sbrd->vertexBuffer, &stride, &offset ); g_pImmediateContext->IASetInputLayout( sbrd->inputLayout ); g_pImmediateContext->VSSetShader( sbrd->vertexShader, nullptr, 0 ); g_pImmediateContext->VSSetConstantBuffers( 0, _countof( vsBuffers ), vsBuffers ); g_pImmediateContext->PSSetShader( sbrd->pixelShader, nullptr, 0 ); g_pImmediateContext->PSSetConstantBuffers( 0, _countof( psBuffers ), psBuffers ); for ( int i = 0; i < 6; ++i ) { const skyboxSideDrawInfo_t* side = &skybox->sides[i]; if ( !side->image ) continue; const d3dImage_t* image = GetImageRenderInfo( side->image ); g_pImmediateContext->PSSetShaderResources( 0, 1, &image->pSRV ); g_pImmediateContext->PSSetSamplers( 0, 1, &image->pSampler ); g_pImmediateContext->Draw( 6, i * 6 ); } }
void DrawQuad( const d3dQuadRenderData_t* qrd, const d3dImage_t* image, const float* coords, const float* texcoords, const float* color ) { UpdateViewState(); UpdateMaterialState(); // // Update the constant buffer // d3dQuadRenderConstantBuffer_t* cb = QD3D::MapDynamicBuffer<d3dQuadRenderConstantBuffer_t>( g_pImmediateContext, qrd->constantBuffer ); if ( color ) { memcpy( cb->color, color, sizeof(float) * 3 ); cb->color[3] = 1; } else { cb->color[0] = 1; cb->color[1] = 1; cb->color[2] = 1; cb->color[3] = 1; } g_pImmediateContext->Unmap( qrd->constantBuffer, 0 ); // // Update the vertex buffer // d3dQuadRenderVertex_t* vb = QD3D::MapDynamicBuffer<d3dQuadRenderVertex_t>( g_pImmediateContext, qrd->vertexBuffer ); vb[0].texcoords[0] = texcoords[0]; vb[0].texcoords[1] = texcoords[1]; vb[1].texcoords[0] = texcoords[2]; vb[1].texcoords[1] = texcoords[1]; vb[2].texcoords[0] = texcoords[2]; vb[2].texcoords[1] = texcoords[3]; vb[3].texcoords[0] = texcoords[0]; vb[3].texcoords[1] = texcoords[3]; vb[0].coords[0] = coords[0]; vb[0].coords[1] = coords[1]; vb[1].coords[0] = coords[2]; vb[1].coords[1] = coords[1]; vb[2].coords[0] = coords[2]; vb[2].coords[1] = coords[3]; vb[3].coords[0] = coords[0]; vb[3].coords[1] = coords[3]; g_pImmediateContext->Unmap( qrd->vertexBuffer, 0 ); // // Draw // UINT stride = sizeof(float) * 4; UINT offset = 0; ID3D11Buffer* psBuffers[] = { g_DrawState.viewRenderData.psConstantBuffer, g_DrawState.quadRenderData.constantBuffer }; g_pImmediateContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST ); g_pImmediateContext->IASetVertexBuffers( 0, 1, &qrd->vertexBuffer, &stride, &offset ); g_pImmediateContext->IASetInputLayout( qrd->inputLayout ); g_pImmediateContext->IASetIndexBuffer( qrd->indexBuffer, DXGI_FORMAT_R16_UINT, 0 ); g_pImmediateContext->VSSetShader( qrd->vertexShader, nullptr, 0 ); g_pImmediateContext->VSSetConstantBuffers( 0, 1, &g_DrawState.viewRenderData.vsConstantBuffer ); g_pImmediateContext->PSSetShader( qrd->pixelShader, nullptr, 0 ); g_pImmediateContext->PSSetSamplers( 0, 1, &image->pSampler ); g_pImmediateContext->PSSetShaderResources( 0, 1, &image->pSRV ); g_pImmediateContext->PSSetConstantBuffers( 0, 2, psBuffers ); g_pImmediateContext->DrawIndexed( 6, 0, 0 ); }