SpiderPig Posted August 17, 2023 Posted August 17, 2023 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". Quote
klepto2 Posted August 18, 2023 Posted August 18, 2023 Try it with this: auto map = CreatePixmap(size, size, (TextureFormat)VK_FORMAT_R16_UNORM, data); 1 Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI
klepto2 Posted August 18, 2023 Posted August 18, 2023 or (TextureFormat)VK_FORMAT_R16_UINT if you want to save the shorts. the previous solution will store normlaized floats. 1 Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI
Solution Josh Posted August 18, 2023 Solution Posted August 18, 2023 I think I have it worked out for the next build. 2 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without.
SpiderPig Posted August 20, 2023 Author Posted August 20, 2023 Yes it saves now, thanks. Thanks @klepto2 I think VK_FORMAT_R16_UINT does what I want it too. Quote
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.