tot mes ben estructuraet i ara amb gestió d'events, context i subsystems. arreglos en el main loop
This commit is contained in:
1 parent
1837844b03
commit
4e0b819b96
12 files changed
+94
-49
No files matched your search
@@ -30,7 +30,7 @@ auto Video::initSDL() -> int {
|
||||
return 1;
|
||||
}
|
||||
|
||||
window_ = SDL_CreateWindow("Mi ventana", config_.width, config_.height, 0);
|
||||
window_ = SDL_CreateWindow(config_.window_caption.c_str(), config_.width, config_.height, 0);
|
||||
if (window_ == nullptr) {
|
||||
SDL_Log("No se pudo crear la ventana: %s", SDL_GetError());
|
||||
cleanup();
|
||||
@@ -46,8 +46,8 @@ auto Video::initSDL() -> int {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// SDL_SetRenderVSync(renderer_, config_.vsync ? 1 : 0);
|
||||
// SDL_SetRenderLogicalPresentation(renderer_, GameCanvas::WIDTH, GameCanvas::HEIGHT, toSdlPresentation(config_.scaling_mode));
|
||||
SDL_SetRenderVSync(renderer_, config_.vsync ? 1 : 0);
|
||||
SDL_SetRenderLogicalPresentation(renderer_, config_.width * config_.zoom, config_.height * config_.zoom, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE);
|
||||
|
||||
game_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, config_.width, config_.height);
|
||||
if (game_texture_ == nullptr) {
|
||||
|
||||
@@ -3,14 +3,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <string>
|
||||
|
||||
class Video {
|
||||
public:
|
||||
struct Config {
|
||||
bool fullscreen{false};
|
||||
float zoom{1.0F};
|
||||
float zoom{2.0F};
|
||||
float width{320.0F};
|
||||
float height{240.0F};
|
||||
std::string window_caption{};
|
||||
bool vsync{true};
|
||||
};
|
||||
|
||||
Video(Config config);
|
||||
|
||||
Reference in new issue
Block a user