Jump to content

Can't save R16 Pixmap as DDS


SpiderPig
 Share

Go to solution Solved by Josh,

Recommended Posts

I'm not sure if I'm actually setting the buffer correctly, but the problem here is it fails to save as a DDS image.

#include "UltraEngine.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    auto displays = GetDisplays();
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    auto world = CreateWorld();
    auto framebuffer = CreateFramebuffer(window);

    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetFov(70);
    camera->SetPosition(0, 10, 0);

    auto light = CreateDirectionalLight(world);
    light->SetRotation(35, 35, 0);

    auto box = CreateBox(world);
    box->SetPosition(10.0f, 2049.0f, 10.0f);

    int size = 1024;
    unsigned short* buffer = new unsigned short[size * size];
    for (int y = 0; y < size; y++) {
        for (int x = 0; x < size; x++) {
            buffer[(y * size) + x] = (unsigned short)Random(USHRT_MAX);
        }
    }

    auto data = CreateBuffer(size * size * 2);
    data->Poke(0, (const char*)buffer, size * size * 2);

    auto map = CreatePixmap(size, size, TEXTURE_R16, data);
    map->Save("Test.dds");

    delete[] buffer;

    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

Output:

Saving texture "Test.dds"
Error: Unsupported pixel format 76 can't be saved to DDS.
Error: Failed to save texture "Test.dds".

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...