本文整理汇总了C++中Sky::draw方法的典型用法代码示例。如果您正苦于以下问题:C++ Sky::draw方法的具体用法?C++ Sky::draw怎么用?C++ Sky::draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sky
的用法示例。
在下文中一共展示了Sky::draw方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawScene
void WaterDemo::drawScene()
{
HR(gd3dDevice->BeginScene());
mSky->draw();
HR(mFX->SetValue(mhLight, &mLight, sizeof(DirLight)));
HR(mFX->SetMatrix(mhWVP, &(mSceneWorld*gCamera->viewProj())));
HR(mFX->SetValue(mhEyePosW, &gCamera->pos(), sizeof(D3DXVECTOR3)));
UINT numPasses = 0;
HR(mFX->Begin(&numPasses, 0));
HR(mFX->BeginPass(0));
for(UINT j = 0; j < mSceneMtrls.size(); ++j)
{
HR(mFX->SetValue(mhMtrl, &mSceneMtrls[j], sizeof(Mtrl)));
// If there is a texture, then use.
if(mSceneTextures[j] != 0)
{
HR(mFX->SetTexture(mhTex, mSceneTextures[j]));
}
// But if not, then set a pure white texture. When the texture color
// is multiplied by the color from lighting, it is like multiplying by
// 1 and won't change the color from lighting.
else
{
HR(mFX->SetTexture(mhTex, mWhiteTex));
}
HR(mFX->SetTexture(mhNormalMap, mSceneNormalMaps[j]));
HR(mFX->CommitChanges());
HR(mSceneMesh->DrawSubset(j));
}
HR(mFX->EndPass());
HR(mFX->End());
// Draw alpha blended object last.
mWater->draw();
mGfxStats->display();
HR(gd3dDevice->EndScene());
// Present the backbuffer.
HR(gd3dDevice->Present(0, 0, 0, 0));
}
示例2: drawScene
void TerrainApp::drawScene()
{
D3DApp::drawScene();
// Restore default states, input layout and primitive topology
// because mFont->DrawText changes them. Note that we can
// restore the default states by passing null.
md3dDevice->OMSetDepthStencilState(0, 0);
float blendFactor[] = {0.0f, 0.0f, 0.0f, 0.0f};
md3dDevice->OMSetBlendState(0, blendFactor, 0xffffffff);
md3dDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
mLand.draw(mLandWorld);
// Draw sky last to save fill rate.
mSky.draw();
// We specify DT_NOCLIP, so we do not care about width/height of the rect.
RECT R = {5, 5, 0, 0};
md3dDevice->RSSetState(0);
mFont->DrawText(0, mFrameStats.c_str(), -1, &R, DT_NOCLIP, WHITE);
mSwapChain->Present(0, 0);
}
示例3: drawScene
void ColoredCubeApp::drawScene()
{
D3DApp::drawScene();
//Step through animation frame
animationTimeElapsed += mTimer.getGameTime() - animationTimePrev;
animationTimePrev = mTimer.getGameTime();
if(animationTimeElapsed > 0.0666f)
{
animationTimeElapsed = 0.0f;
frameOfAnimation++;
if(frameOfAnimation > fireFrameCount-1)
{
frameOfAnimation = 0;
}
}
// Restore default states, input layout and primitive topology
// because mFont->DrawText changes them. Note that we can
// restore the default states by passing null.
md3dDevice->OMSetDepthStencilState(0, 0);
float blendFactors[] = {0.0f, 0.0f, 0.0f, 0.0f};
md3dDevice->OMSetBlendState(0, blendFactors, 0xffffffff);
md3dDevice->IASetInputLayout(mVertexLayout);
md3dDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
// Set per frame constants
mfxEyePosVar->SetRawValue(&mCameraPos, 0, sizeof(D3DXVECTOR3));
mfxLightVar->SetRawValue(&mLights[0], 0, sizeof(Light));
mfxLightVar2->SetRawValue(&mLights[1], 0, sizeof(Light));
mfxCubeMapVR->SetResource(mCubeMapRV);
// set constants
mWVP = mView*mProj;
mfxWVPVar->SetMatrix((float*)&mWVP); //set gWVP in color.fx to mWVP
mTree.setEyePos(mCameraPos);
mTree.setLights(mLights, 2);
mTree.draw(mView, mProj);
mObjBox.setEyePos(mCameraPos);
mObjBox.setLights(mLights, 2);
mObjBox.draw(mView, mProj);
D3D10_TECHNIQUE_DESC techDesc;
mTech->GetDesc( &techDesc );
for(UINT p = 0; p < techDesc.Passes; ++p)
{
ID3D10EffectPass* pass = mTech->GetPassByIndex( p ); //zero is always used in D3D10
D3DXMATRIX texMtx;
mWVP = mBoxWorld*mView*mProj;
mfxWVPVar->SetMatrix((float*)&mWVP);
mfxWorldVar->SetMatrix((float*)&mBoxWorld);
mfxDiffuseMapVar->SetResource(mCrateMapRV);
//mfxDiffuseMapVar->SetResource(mFireAnimationMapRVs[frameOfAnimation]);
mfxSpecularMapVar->SetResource(mSpecularMapRV);
mfxNormalMapVR->SetResource(mDefaultNormalMapRV);
mfxReflectEnabledVar->SetBool(false);
D3DXMatrixIdentity(&texMtx);
mfxTexMtxVar->SetMatrix((float*)&texMtx);
pass->Apply(0);
mBox.draw();
mWVP = mPlaneWorld*mView*mProj;
mfxWVPVar->SetMatrix((float*)&mWVP);
mfxWorldVar->SetMatrix((float*)&mPlaneWorld);
mfxDiffuseMapVar->SetResource(mGrassMapRV);
mfxNormalMapVR->SetResource(mBrickNormalMapRV);
mfxReflectEnabledVar->SetBool(true);
D3DXMATRIX s;
D3DXMatrixScaling(&s, 5.0f, 5.0f, 1.0f);
texMtx = s;
D3DXMatrixIdentity(&texMtx);
mfxTexMtxVar->SetMatrix((float*)&texMtx);
pass->Apply(0);
mPlane.draw();
}
mSky.draw(mWVP);
// We specify DT_NOCLIP, so we do not care about width/height of the rect.
RECT R = {5, 5, 0, 0};
md3dDevice->RSSetState(0);
mFont->DrawText(0, mFrameStats.c_str(), -1, &R, DT_NOCLIP, BLACK);
mSwapChain->Present(0, 0);
}
示例4: main
int main()
{
srand (time (0));
sf::RenderWindow window (sf::VideoMode(480*0.5, 800*0.5), "Fighters");
window.setFramerateLimit(60);
PASS = 1;
Things::load ();
Sound::load ();
Text::load ();
Sky sky;
Hero hero;
Sound::GAME_MUSIC.play ();
while (window.isOpen())
{
// check all the window's events that were triggered since the last iteration of the loop
sf::Event event;
while (window.pollEvent(event))
{
// "close requested" event: we close the window
if (event.type == sf::Event::Closed)
window.close();
}
// clear the window with black color
window.clear( sf::Color::Black );
int test = 0;
if ( hero.getRed() < -1 )
test = 1;
switch ( test )
{
case 1:
sky.gameover ( window );
Sound::GAME_MUSIC.play ();
break;
case 0:
if ( hero.getRed() > 0 )
{
Game ( hero );
if ( timeNow > TIME-PASS*10 )
{
timeNow = 0;
sky.addEnemy ( enemy, PASS);
}
timeNow++;
gapNow++;
sky.heroGunRunInto ( hero, enemy );
}
hero.gunMove ();
sky.draw ( window, hero );
drawEnemy ( window );
break;
}
levelUp ();
Text::outText ( window, hero.getRed(), PASS );
// end the current frame
window.display();
}
return 0;
}
示例5: DrawScene
void Projekt::DrawScene()
{
//---------------------------------------------------------------------------
// Render scene to shadow map
//---------------------------------------------------------------------------
mShadowMap->BindDsvAndSetNullRenderTarget(mDirect3D->GetImmediateContext());
mShadowMap->DrawSceneToShadowMap(mGenericInstances, *mGame->GetCamera(), mDirect3D->GetImmediateContext());
mDirect3D->GetImmediateContext()->RSSetState(0);
// Restore back and depth buffer and viewport to the OM stage
ID3D11RenderTargetView* renderTargets[1] = {mDirect3D->GetRenderTargetView()};
mDirect3D->GetImmediateContext()->OMSetRenderTargets(1, renderTargets, mDirect3D->GetDepthStencilView());
mDirect3D->GetImmediateContext()->ClearRenderTargetView(mDirect3D->GetRenderTargetView(), reinterpret_cast<const float*>(&Colors::LightSteelBlue));
mDirect3D->GetImmediateContext()->ClearDepthStencilView(mDirect3D->GetDepthStencilView(), D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL, 1.0f, 0);
mDirect3D->GetImmediateContext()->RSSetViewports(1, &mDirect3D->GetScreenViewport());
//---------------------------------------------------------------------------
// Possible Wireframe render state
// if (mDirectInput->GetKeyboardState()[DIK_E] && 0x80)
// mDirect3D->GetImmediateContext()->RSSetState(RenderStates::WireFrameRS);
//--------------------------------------------------------------
// Set shader constants
//--------------------------------------------------------------
Effects::BasicFX->SetDirLights(mDirLights);
Effects::BasicFX->SetEyePosW(mGame->GetCamera()->GetPosition());
Effects::BasicFX->SetShadowMap(mShadowMap->getDepthMapSRV());
Effects::BasicFX->SetCubeMap(mSky->cubeMapSRV());
Effects::NormalMapFX->SetDirLights(mDirLights);
Effects::NormalMapFX->SetEyePosW(mGame->GetCamera()->GetPosition());
Effects::NormalMapFX->SetShadowMap(mShadowMap->getDepthMapSRV());
Effects::NormalMapFX->SetCubeMap(mSky->cubeMapSRV());
// Draw sky
mSky->draw(mDirect3D->GetImmediateContext(), *mGame->GetCamera(), Gui->InMenu());
// Draw game
mGame->Draw(mDirect3D->GetImmediateContext(), mShadowMap);
this->soundModule->updateAndPlay(mGame->GetCamera(), mGame->GetCamera()->GetPosition());
// Draw the GUI
Gui->Render(mDirect3D->GetImmediateContext(), mGame->GetPlayer()->GetPosition());
// Unbind shadow map and AmbientMap as a shader input because we are going to render
// to it next frame. These textures can be at any slot, so clear all slots.
ID3D11ShaderResourceView* nullSRV[16] = { 0 };
mDirect3D->GetImmediateContext()->PSSetShaderResources(0, 16, nullSRV);
// Restore default states
float blendFactor[] = {0.0f, 0.0f, 0.0f, 0.0f};
mDirect3D->GetImmediateContext()->RSSetState(0);
mDirect3D->GetImmediateContext()->OMSetDepthStencilState(0, 0);
mDirect3D->GetImmediateContext()->OMSetBlendState(0, blendFactor, 0xffffffff);
HR(mDirect3D->GetSwapChain()->Present(0, 0));
}
示例6: DrawScene
void Projekt::DrawScene()
{
//---------------------------------------------------------------------------
// Render scene to shadow map
//---------------------------------------------------------------------------
mShadowMap->BindDsvAndSetNullRenderTarget(mDirect3D->GetImmediateContext());
drawSceneToShadowMap();
mDirect3D->GetImmediateContext()->RSSetState(0);
// Restore back and depth buffer and viewport to the OM stage
ID3D11RenderTargetView* renderTargets[1] = {mDirect3D->GetRenderTargetView()};
mDirect3D->GetImmediateContext()->OMSetRenderTargets(1, renderTargets, mDirect3D->GetDepthStencilView());
mDirect3D->GetImmediateContext()->ClearRenderTargetView(mDirect3D->GetRenderTargetView(), reinterpret_cast<const float*>(&Colors::LightSteelBlue));
mDirect3D->GetImmediateContext()->ClearDepthStencilView(mDirect3D->GetDepthStencilView(), D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL, 1.0f, 0);
mDirect3D->GetImmediateContext()->RSSetViewports(1, &mDirect3D->GetScreenViewport());
// Possible Wireframe render state
if (GetAsyncKeyState('E') & 0x8000)
mDirect3D->GetImmediateContext()->RSSetState(WireFrameRS);
XMMATRIX shadowTransform = XMLoadFloat4x4(&mShadowTransform);
//---------------------------------------------------------------------------
// Draw terrain
//---------------------------------------------------------------------------
//mTerrain.Draw(mDirect3D->GetImmediateContext(), mCam, mDirLights);
mTerrain.DrawShadowed(mDirect3D->GetImmediateContext(), *mPlayer.GetCamera(), mDirLights,
mShadowMap->getDepthMapSRV(), &shadowTransform);
// --------------------------------------------------------------------------
// Camera matrices
XMMATRIX view = mPlayer.GetCamera()->getViewMatrix();
XMMATRIX proj = mPlayer.GetCamera()->getProjMatrix();
XMMATRIX viewproj = mPlayer.GetCamera()->getViewProjMatrix();
float blendFactor[] = {0.0f, 0.0f, 0.0f, 0.0f};
// Set per frame constants
Effects::BasicFX->SetDirLights(mDirLights);
Effects::BasicFX->SetEyePosW(mPlayer.GetCamera()->getPosition());
Effects::BasicFX->setShadowMap(mShadowMap->getDepthMapSRV());
Effects::BasicFX->SetCubeMap(mSky->cubeMapSRV());
Effects::NormalMapFX->SetDirLights(mDirLights);
Effects::NormalMapFX->SetEyePosW(mPlayer.GetCamera()->getPosition());
Effects::NormalMapFX->setShadowMap(mShadowMap->getDepthMapSRV());
Effects::NormalMapFX->SetCubeMap(mSky->cubeMapSRV());
XMMATRIX world;
XMMATRIX worldInvTranspose;
XMMATRIX worldViewProj;
// Transform NDC space [-1,+1]^2 to texture space [0,1]^2
XMMATRIX toTexSpace(
0.5f, 0.0f, 0.0f, 0.0f,
0.0f, -0.5f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.5f, 0.5f, 0.0f, 1.0f);
// Vertex size & offset
UINT stride = sizeof(Vertex::Basic32);
UINT offset = 0;
// Draw player
//mPlayer.Draw(mDirect3D->GetImmediateContext(), mDirLights,
//mShadowMap->getDepthMapSRV(), &shadowTransform);
//---------------------------------------------------------------------------
// Draw opaque objects
//---------------------------------------------------------------------------
// Bind information about primitive type, and set input layout
mDirect3D->GetImmediateContext()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
mDirect3D->GetImmediateContext()->IASetInputLayout(InputLayouts::Basic32);
// Set our effect technique to use
ID3DX11EffectTechnique* activeTech = Effects::BasicFX->DirLights3FogTexTech;
ID3DX11EffectTechnique* activeSkinnedTech = Effects::NormalMapFX->DirLights3TexTech;
D3DX11_TECHNIQUE_DESC techDesc;
//--------------------------------------------------------------------------------
// Draw opaque tessellated objects
//--------------------------------------------------------------------------------
Effects::BasicTessFX->SetDirLights(mDirLights);
Effects::BasicTessFX->SetEyePosW(mPlayer.GetCamera()->getPosition());
Effects::BasicTessFX->setShadowMap(mShadowMap->getDepthMapSRV());
Effects::BasicTessFX->SetCubeMap(mSky->cubeMapSRV());
mDirect3D->GetImmediateContext()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST);
mDirect3D->GetImmediateContext()->IASetInputLayout(InputLayouts::PosNormalTexTan);
activeTech = Effects::BasicTessFX->TessDirLights3FogTexTech;
activeTech->GetDesc(&techDesc);
for (UINT p = 0; p < techDesc.Passes; ++p)
{
for (UINT mIndex = 0; mIndex < mGenericInstances.size(); ++mIndex)
//.........这里部分代码省略.........
示例7: Render
void Render()
{
md3dDevice->ClearRenderTargetView(mRenderTargetView, mClearColor);
md3dDevice->ClearDepthStencilView(mDepthStencilView, D3D10_CLEAR_DEPTH|D3D10_CLEAR_STENCIL, 1.0f, 0);
md3dDevice->OMSetDepthStencilState(0, 0);
md3dDevice->OMSetBlendState(0, blendFactor, 0xffffffff);
//draw Trees
mTrees.draw(GetCamera().getPos(), GetCamera().view()*GetCamera().proj());
D3D10_TECHNIQUE_DESC techDesc;
fxU.setRenderUtil(techDesc);
for(UINT p = 0; p < techDesc.Passes; ++p)
{
//draw Cube
pWave->render(fxU,p);
//draw Cube "Tower"
for (UINT i=0; i < mTowers.size(); ++i)
{
fxU.setMfx(GetCamera().wvp(mTowers.at(i).getWorld()), mTowers.at(i).getWorld(), 1, nrOfTowers[i]);
fxU.ApplyPassByIndex(p);
mTowers.at(i).Draw();
}
//draw Pyramid
fxU.setMfx(GetCamera().wvp(mPyramid.getWorld()), mPyramid.getWorld(), 2, 3);
fxU.ApplyPassByIndex(p);
mPyramid.Draw();
//draw Cylinder
fxU.setMfx(GetCamera().wvp(mCylinder.getWorld()), mCylinder.getWorld(), 3, 6);
fxU.ApplyPassByIndex(p);
mCylinder.Draw();
//draw Terrain
//fxU.setMfx(GetCamera().wvp(mTerrain.getWorld()), mTerrain.getWorld(), 0, 9);
//fxU.ApplyPassByIndex(p);
//mTerrain.Draw();
fxU.setMfx(GetCamera().wvp(land.getWorld()), land.getWorld(), 0, 9);
fxU.ApplyPassByIndex(p);
land.draw();
}
//draw gui
gui.Render();
//draw grid
qtc.draw(GetCamera().view(), GetCamera().proj(), grid);
//draw Sky
sky.draw(GetCamera().view(), GetCamera().proj(), GetCamera().getPos(), mLight.lightType);
//draw Fire
fire.draw(GetCamera().view(), GetCamera().proj());
md3dDevice->OMSetBlendState(0, blendFactor, 0xffffffff);
//draw Rain
rain.draw(GetCamera().view(), GetCamera().proj());
mSwapChain->Present(0, 0);
}