本文整理汇总了C++中camera::Ptr::SetRenderTargets方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::SetRenderTargets方法的具体用法?C++ Ptr::SetRenderTargets怎么用?C++ Ptr::SetRenderTargets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类camera::Ptr
的用法示例。
在下文中一共展示了Ptr::SetRenderTargets方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
Game game(Graphics::DirectX11, Vector2i(1920, 1080), 60.0f);
Auto<Graphics> graphics = game.GetGraphics();
Auto<ResourceManager> resourceManager = game.GetResourceManager();
Auto<WindowRenderTarget> windowRenderTarget = game.GetWindowRenderTarget();
Auto<VertexShader> vertexShader;
Auto<PixelShader> pixelShader;
Auto<Mesh> meshTest;
Auto<Sampler> linearSampler;
Auto<Sampler> pointSampler;
kge::Scene::Ptr scene = game.CreateScene();
GameObject::Ptr conrellBox = AddObject(scene, "Media/Meshes/CornellBox.obj#Cube", "Media/Materials/CornellBox.json");
conrellBox->GetTransform()->SetLocalOrientation(Quaternionf(Vector3f(0.0f, 1.0f, 0.0f), Degreesf(180.0f)));
GameObject::Ptr suzanne = scene->CreateGameObject().lock();
suzanne->GetTransform()->SetLocalOrientation(Quaternionf(Vector3f(0.0f, 1.0f, 0.0f), Degreesf(225.0f)));
suzanne->GetTransform()->SetLocalScale(Vector3f(0.6f, 0.6f, 0.6f));
suzanne->GetTransform()->SetLocalPosition(Vector3f(0.0f, -1.0f, 0.0f));
suzanne->AddComponent<SpinBehavior>();
game.GetLuaContext().AddBehaviorScript(resourceManager->LoadResource<LuaScript>("Media/Scripts/Test.lua"));
game.GetLuaContext().AddBehaviorScript(resourceManager->LoadResource<LuaScript>("Media/Scripts/BaseTest.lua"));
//suzanne->AddComponent<LuaBehavior>().lock()->SetLuaClassName("Test");
Renderer::Ref renderer = suzanne->AddComponent<Renderer>();
scene->GetRenderManager().SetCompositor(
RenderManager::DefaultCompositor,
Auto<Compositor>(new DeferredCompositor(*graphics, *resourceManager))
);
Camera::Ptr leftEye = AddCamera(*scene, Rectf(0.0f, 0.0f, 1.0f, 1.0f));
//Camera::Ptr rightEye = AddCamera(*scene, Rectf(0.0f, 0.5f, 1.0f, 0.5f));
GameObject::Ptr cameraObject = scene->CreateGameObject().lock();
cameraObject->AddComponent<FlyCamera>();
leftEye->GetGameObject().GetTransform()->SetParent(cameraObject->GetTransform());
leftEye->GetGameObject().GetTransform()->SetLocalPosition(Vector3f(-0.025f, 0.0f, 0.0f));
//rightEye->GetGameObject().GetTransform()->SetParent(cameraObject->GetTransform());
//rightEye->GetGameObject().GetTransform()->SetLocalPosition(Vector3f(0.025f, 0.0f, 0.0f));
GameObject::Ptr cubeTest = AddObject(scene, "Media/Meshes/Cube.obj#Cube", "Media/Materials/Cube.json");
cubeTest->GetTransform()->SetLocalScale(Vector3f(0.1f, 0.1f, 0.1f));
cubeTest->GetTransform()->SetLocalPosition(Vector3f(0.0f, -0.5f, -0.8f));
SpinBehavior::Ptr cubeSpin = cubeTest->AddComponent<SpinBehavior>().lock();
cubeSpin->SetAxis(Vector3f(1.0f, 0.0f, 0.0f));
cubeSpin = cubeTest->AddComponent<SpinBehavior>().lock();
cubeSpin->SetAxis(Vector3f(0.0f, 1.0f, 0.0f));
cubeSpin->SetRotationRate(Degreesf(7.0f));
{
GameObject::Ptr lightObject = scene->CreateGameObject().lock();
lightObject->GetTransform()->SetLocalPosition(Vector3f(0.0f, 0.9f, 0.0f));
PointLight::Ptr pointLight = lightObject->AddComponent<PointLight>().lock();
pointLight->SetRange(4.0f);
pointLight->SetColor(Colorf(1.0f, 1.0f, 1.0f));
}
for (int i = 1; i <= 5; ++i)
{
for (int j = 0; j < 5; ++j) {
AddEmmisiveSphere(scene, Vector3f(0.4f * i - 1.2f, -0.9f, -0.8f + j * 0.4f), Colorf(0.3f, 0.5f + i * 0.3f, 2.0f - j * 0.3f));
}
}
try
{
vertexShader = resourceManager->LoadResource<VertexShader>("Media/Shaders/Bundle/VertexShaderTest.shader");
pixelShader = resourceManager->LoadResource<PixelShader>("Media/Shaders/Bundle/PixelShaderTest.shader");
meshTest = resourceManager->LoadResource<Mesh>("Media/Meshes/Suzanne.obj#Suzanne");
SamplerDescription samplerDesc;
linearSampler = graphics->CreateSampler(samplerDesc);
samplerDesc.minFilter = InterpolationMode::Point;
samplerDesc.magFilter = InterpolationMode::Point;
samplerDesc.mipFilter = InterpolationMode::Point;
pointSampler = graphics->CreateSampler(samplerDesc);
Material::Ptr suzanneMaterial = resourceManager->LoadResource<Material>("Media/Materials/Suzanne.json");
Renderer::Ptr rendererPtr = renderer.lock();
rendererPtr->SetMesh(meshTest);
rendererPtr->SetMaterial(suzanneMaterial, 0);
RenderTargetConfiguration renderTarget;
renderTarget.AddRenderTarget(windowRenderTarget);
leftEye->SetRenderTargets(renderTarget);
//rightEye->SetRenderTargets(renderTarget);
//.........这里部分代码省略.........