Remove kissfft third party library and update OpenGL screenshot

This commit is contained in:
2026-03-21 15:54:42 +08:00
parent a6c6482125
commit 7a6cd412c8
8 changed files with 10 additions and 960 deletions

View File

@@ -3,12 +3,12 @@
#include <stdlib.h>
#include <string.h>
#include <glad/glad.h>
#include <windows.h>
#include "XCEngine/RHI/OpenGL/OpenGLDevice.h"
#include "XCEngine/RHI/OpenGL/OpenGLSwapChain.h"
#include "XCEngine/RHI/OpenGL/OpenGLCommandList.h"
#include "XCEngine/RHI/OpenGL/OpenGLScreenshot.h"
#include "XCEngine/Debug/Logger.h"
#include "XCEngine/Debug/ConsoleLogSink.h"
#include "XCEngine/Containers/String.h"
@@ -31,43 +31,6 @@ void Log(const char* format, ...) {
Logger::Get().Debug(LogCategory::Rendering, String(buffer));
}
void SaveScreenshotPPM(const char* filename, int width, int height) {
unsigned char* pixels = (unsigned char*)malloc(width * height * 3);
if (!pixels) {
Log("[ERROR] Failed to allocate pixel buffer");
return;
}
glFinish();
glReadBuffer(GL_BACK);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
glPixelStorei(GL_PACK_SKIP_ROWS, 0);
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels);
FILE* f = fopen(filename, "wb");
if (!f) {
Log("[ERROR] Failed to open file for screenshot: %s", filename);
free(pixels);
return;
}
fprintf(f, "P6\n%d %d\n255\n", width, height);
unsigned char* row = (unsigned char*)malloc(width * 3);
for (int y = height - 1; y >= 0; y--) {
memcpy(row, pixels + y * width * 3, width * 3);
fwrite(row, 1, width * 3, f);
}
free(row);
free(pixels);
fclose(f);
Log("[INFO] Screenshot saved to %s", filename);
}
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_CLOSE:
@@ -163,9 +126,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
}
// Take screenshot after target frame count is reached
// glFinish ensures all OpenGL commands are completed before reading pixels
Log("[INFO] Reached target frame count %d - taking screenshot!", targetFrameCount);
SaveScreenshotPPM("minimal.ppm", gWidth, gHeight);
OpenGLScreenshot::Capture(device, swapChain, "minimal.ppm");
// Shutdown in reverse order of initialization
swapChain.Shutdown();