Josh Posted April 7 Posted April 7 If you want to render at a low resolution to a higher resolution window, this can be done with the following example. (If you are using a fullscreen window, there is no need for this, since it will change the display resolution to match the window.) #include "Leadwerks.h" using namespace Leadwerks; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Leadwerks", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a world auto world = CreateWorld(); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create a camera auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetPosition(0, 0, -2); // Render to texture auto texbuffer = CreateTextureBuffer(framebuffer->size.x / 4, framebuffer->size.y / 4); camera->SetRenderTarget(texbuffer); // Create a second camera auto orthocam = CreateCamera(world); orthocam->SetLighting(false);// Disable sending lighting data orthocam->SetRenderLayers(0); // Create a rectangle to go onscreen auto screen = CreateTile(orthocam, framebuffer->size.x, framebuffer->size.y); auto mtl = CreateMaterial(); // Create a material and apply the render texture to it mtl->SetShaderFamily(LoadShaderFamily("Shaders/Unlit.fam")); auto tex = texbuffer->GetColorAttachment(); tex->SetFilter(TEXTUREFILTER_LINEAR);// enables linear sampling, looks softer mtl->SetTexture(tex); screen->SetMaterial(mtl); //Create a light auto light = CreateBoxLight(world); light->SetRotation(45, 35, 0); light->SetRange(-10, 10); light->SetColor(2); //Create a model auto model = CreateBox(world); model->SetColor(0, 0, 1); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { model->Turn(0, 1, 0); world->Update(); world->Render(framebuffer); } return 0; } 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without.
Josh Posted April 7 Author Posted April 7 And here is the Lua version: --Get the displays displays = GetDisplays() --Create a window window = CreateWindow("Leadwerks", 0, 0, 1280, 720, displays[1], WINDOW_CENTER | WINDOW_TITLEBAR) --Create a world world = CreateWorld() --Create a framebuffer framebuffer = CreateFramebuffer(window) --Create a camera camera = CreateCamera(world) camera:SetClearColor(0.125) camera:SetPosition(0, 0, -2) -- Render to texture texbuffer = CreateTextureBuffer(framebuffer.size.x / 4, framebuffer.size.y / 4) camera:SetRenderTarget(texbuffer) -- Create a second camera orthocam = CreateCamera(world) orthocam:SetRenderLayers(0) --orthocam->SetLighting(false)-- Disable sending lighting data -- Create a rectangle to go onscreen screen = CreateTile(orthocam, framebuffer.size.x, framebuffer.size.y); mtl = CreateMaterial(); -- Create a material and apply the render texture to it mtl:SetShaderFamily(LoadShaderFamily("Shaders/Unlit.fam")) tex = texbuffer:GetColorAttachment() mtl:SetTexture(tex) screen:SetMaterial(mtl) --Create a light light = CreateBoxLight(world) light:SetRotation(45, 35, 0) light:SetRange(-10, 10) light:SetColor(2) --Create a model model = CreateBox(world) model:SetColor(0, 0, 1) --Main loop while window:Closed() == false and window:KeyDown(KEY_ESCAPE) == false do model:Turn(0, 1, 0) world:Update() world:Render(framebuffer) end 2 Quote My job is to make tools you love, with the features you want, and performance you can't live without.
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.