Charrua Posted January 11, 2016 Share Posted January 11, 2016 Hi I need 5 cameras and show what each is seeing in separate views. the description of the function SetRenderTarget says: This functions sets a camera to render directly to a texture. The texture can be used in a material and applied to an object, or drawn onscreen. so, i create the cameras, create the textures and set them as render target but textures don't get updated as i guessed. so textures can be drawn on screen but don't get updated. Searching i found this thread http://www.leadwerks.com/werkspace/topic/13211-trouble-with-render-targets/page__hl__setrendertarget#entry93400 and seems that SetRenderTarget can't be used as i supposed it should be. I started to use buffers but seems that i have to do one render world per camera/buffer to get what i want. is it possible to do the same thing without 5 renders? in a smart way which i don't imagine here is the code i get working #include "App.h" using namespace Leadwerks; App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete world; delete window; } Model* models[5]; //just to show something Camera *cams[5]; // five cameras one for each view Buffer *buffs[5]; // one buffer per view const int numViews = 5; bool App::Start() { window = Window::Create(); context = Context::Create(window); world = World::Create(); Light* light = DirectionalLight::Create(); light->SetRotation(35, 35, 0); // create one object per view models[0] = Model::Box(); models[0]->SetColor(1.0, 0.0, 0.0); models[0]->SetPosition(-4, 0, 0); models[1] = Model::Cylinder(); models[1]->SetColor(0.0, 1.0, 0.0); models[1]->SetPosition(-2, 0, 0); models[2] = Model::Cone(); models[2]->SetColor(0.0, 0.0, 1.0); models[2]->SetPosition(0, 0, 0); models[3] = Model::Cylinder(); models[3]->SetColor(0.0, 1.0, 1.0); models[3]->SetPosition(2, 0, 0); models[4] = Model::Box(); models[4]->SetColor(1.0, 0.0, 1.0); models[4]->SetPosition(4, 0, 0); //create each camera and buffer for (int i = 0; i < numViews; i++){ cams[i] = Camera::Create(); cams[i]->Move(-4 + i * 2, 0, -6); cams[i]->Hide(); buffs[i] = Buffer::Create(context->GetWidth() / numViews, context->GetHeight()); } return true; } bool App::Loop() { if (window->Closed() || window->KeyDown(Key::Escape)) return false; for (int i = 0; i < numViews; i++){ models[i]->Turn(Time::GetSpeed()*0.2*(i+1), 0, 0); } Time::Update(); world->Update(); for (int i = 0; i < numViews; i++){ buffs[i]->Enable(); cams[i]->Show(); world->Render(); //is it neccesary to do 5 world renders? cams[i]->Hide(); buffs[i]->Disable(); } context->Enable(); //draw each buffer for (int i = 0; i < numViews; i++){ context->DrawImage(buffs[i]->GetColorTexture(), i*context->GetWidth()/numViews, 0); context->DrawLine(i*context->GetWidth() / numViews, 0, i*context->GetWidth() / numViews, context->GetHeight()); } context->Sync(); return true; } thank's in advance jio Quote Paren el mundo!, me quiero bajar. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.