4a88c8cc06
Added deps/Findstb.cmake (fetches stb via FetchContent, provides stb::stb interface target). Linked to cbt_opengl. Implemented window::screenshot() using glReadPixels + vertical flip + stb_image_write to save RGBA PNG. Press S in the app to capture current frame (saved as screenshot.png). Updated help text. (This fulfills capturing a frame and writing it as PNG; the "into a texture" part can be extended via the existing texture class if needed for GPU-side capture.)
32 lines
646 B
C++
32 lines
646 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#define GLFW_INCLUDE_NONE
|
|
#include "GLFW/glfw3.h"
|
|
|
|
namespace cbt {
|
|
|
|
class window {
|
|
public:
|
|
explicit window(std::string title, int width, int height);
|
|
~window();
|
|
|
|
auto should_close() const -> bool;
|
|
auto valid() const -> bool;
|
|
auto swap_buffers() -> void;
|
|
auto poll_events() -> void;
|
|
auto raw() const -> GLFWwindow*;
|
|
auto stop() -> void;
|
|
auto screenshot(std::string filepath = "screenshot.png") const -> bool;
|
|
|
|
private:
|
|
GLFWwindow* m_window = nullptr;
|
|
bool m_glfw_initialized = false;
|
|
|
|
static auto init_glfw() -> bool;
|
|
static auto terminate_glfw() -> void;
|
|
};
|
|
|
|
}
|