Jump to content

Framebuffer::Capture no longer works.


reepblue
 Share

Go to solution Solved by Josh,

Recommended Posts

This example no longer works. The EVENT_FRAMECAPTURE doesn't seem like it gets emitted anymore. 

#include "UltraEngine.h"

using namespace UltraEngine;

void main(const char* args, const int argc)
{
    //Get the displays
    auto displays = GetDisplays();

    //Create a window
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_TITLEBAR | WINDOW_CENTER);

    //Create a framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Create a world
    auto world = CreateWorld();

    //Create a camera
    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125f);
    camera->SetPosition(0, 0, -2);

    //Create a light
    auto light = CreateBoxLight(world);
    light->SetRotation(45, 35, 0);
    light->SetRange(-10, 10);
    light->SetColor(2);

    //Create a model
    auto box = CreateBox(world);
    box->SetColor(0, 0, 1);

    //Load the FreeImage plugin
    auto plugin = LoadPlugin("Plugins/FITextureLoader");

    //Main loop
    while (!window->Closed() and !window->KeyHit(KEY_ESCAPE))
    {
        //Rotate the model
        box->Turn(0, 1, 0);

        //Press the space key to queue a screenshot
        if (window->KeyHit(KEY_SPACE)) 
            framebuffer->Capture();

        //Look for captured frames
        while (PeekEvent())
        {
            const auto e = WaitEvent();
            if (e.id == EVENT_FRAMECAPTURE)
            {
                //Get the pixmap containing the captured frame, save and open it
                auto pixmap = e.extra->As<Pixmap>();
                WString path = GetPath(PATH_DESKTOP) + "/screenshot" + String(e.data + 1) + ".jpg";
                pixmap->Save(path);
                RunFile(path);
            }
        }

        //Update world
        world->Update();

        //Render world
        world->Render(framebuffer, true);
    }
}

 

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

  • Josh locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...