SetProjectionMode
This function sets the projection mode of a camera.
Syntax
- void SetProjectionMode(int projectionmode)
Parameters
- projectionmode: the new field of view to set.
- Camera::Orthographic: flat 2D rendering.
- Camera::Perspective: 3D perspective rendering.
Example
#include "Leadwerks.h"
using namespace Leadwerks;
int main(int argc, const char *argv[])
{
Leadwerks::Window* window = Leadwerks::Window::Create();
Context* context = Context::Create(window);
World* world = World::Create();
Camera* camera = Camera::Create();
camera->Move(0, 0, -3);
Light* light = DirectionalLight::Create();
light->SetRotation(35, 35, 0);
Model* model = Model::Box();
model->SetColor(0.0, 0.0, 1.0);
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) break;
model->Turn(0, Leadwerks::Leadwerks::Time::GetSpeed(), 0);
if (window->KeyHit(Key::Space))
{
if (camera->GetProjectionMode() == Camera::Orthographic)
{
camera->SetProjectionMode(Camera::Perspective);
camera->SetZoom(1);
}
else
{
camera->SetProjectionMode(Camera::Orthographic);
camera->SetZoom(100);
}
}
Leadwerks::Leadwerks::Time::Update();
world->Update();
world->Render();
context->SetBlendMode(Blend::Alpha);
context->DrawText("Projection mode: " + String(camera->GetProjectionMode()), 2, 2);
context->DrawText("Zoom: " + String(camera->GetZoom()), 2, 22);
context->Sync();
}
}