mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-13 06:51:51 +00:00
Merge branch 'sdl-try-2' of github.com:Ygrik2003/VoxelEngine-Cpp into sdl-try-2
This commit is contained in:
commit
640cfcc3d0
2 changed files with 14 additions and 3 deletions
|
|
@ -4,6 +4,8 @@
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <SDL3/SDL_error.h>
|
#include <SDL3/SDL_error.h>
|
||||||
#include <SDL3/SDL_mouse.h>
|
#include <SDL3/SDL_mouse.h>
|
||||||
|
#include <SDL3/SDL_render.h>
|
||||||
|
#include <SDL3/SDL_surface.h>
|
||||||
#include <SDL3/SDL_timer.h>
|
#include <SDL3/SDL_timer.h>
|
||||||
#include <SDL3/SDL_version.h>
|
#include <SDL3/SDL_version.h>
|
||||||
#include <SDL3/SDL_video.h>
|
#include <SDL3/SDL_video.h>
|
||||||
|
|
@ -212,6 +214,8 @@ window_sdl::window_sdl(DisplaySettings *settings, std::string title) noexcept {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderer = SDL_CreateRenderer(window, "vc_main");
|
||||||
|
|
||||||
float scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
float scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
||||||
|
|
||||||
logger.info() << "monitor content scale: " << scale;
|
logger.info() << "monitor content scale: " << scale;
|
||||||
|
|
@ -420,8 +424,15 @@ void window_sdl::setFramerate(int framerate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: move somewhere
|
// todo: move somewhere
|
||||||
|
// Possible do with SDL_RenderReadPixels
|
||||||
std::unique_ptr<ImageData> window_sdl::takeScreenshot() {
|
std::unique_ptr<ImageData> window_sdl::takeScreenshot() {
|
||||||
return {};
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
auto data = std::make_unique<ubyte[]>(size.x * size.y * 3);
|
||||||
|
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||||
|
glReadPixels(0, 0, size.x, size.y, GL_RGB, GL_UNSIGNED_BYTE, data.get());
|
||||||
|
return std::make_unique<ImageData>(
|
||||||
|
ImageFormat::rgb888, size.x, size.y, data.release()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool window_sdl::isValid() const {
|
[[nodiscard]] bool window_sdl::isValid() const {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
|
#include <SDL3/SDL_render.h>
|
||||||
#include <SDL3/SDL_video.h>
|
#include <SDL3/SDL_video.h>
|
||||||
|
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
|
||||||
#include "window/window.hpp"
|
#include "window/window.hpp"
|
||||||
|
|
||||||
struct SDL_Window;
|
|
||||||
|
|
||||||
class window_sdl final : public Window {
|
class window_sdl final : public Window {
|
||||||
public:
|
public:
|
||||||
window_sdl(DisplaySettings *settings, std::string title) noexcept;
|
window_sdl(DisplaySettings *settings, std::string title) noexcept;
|
||||||
|
|
@ -49,6 +48,7 @@ private:
|
||||||
bool fullscreen = false;
|
bool fullscreen = false;
|
||||||
|
|
||||||
SDL_Window *window = nullptr;
|
SDL_Window *window = nullptr;
|
||||||
|
SDL_Renderer *renderer = nullptr;
|
||||||
SDL_GLContext context = nullptr;
|
SDL_GLContext context = nullptr;
|
||||||
|
|
||||||
std::stack<glm::vec4> scissorStack;
|
std::stack<glm::vec4> scissorStack;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue