Emu?
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

73 lines
2.2 KiB

/* SdlWindow.h
*
* Implements a SDL2 rendering window.
*/
#pragma once
#include <SDL.h>
#include "Video/PlipVideo.h"
namespace PlipSdl {
class SdlWindow : public Plip::PlipVideo {
public:
explicit SdlWindow(int gameScale = 1, const std::string &title = "");
~SdlWindow();
bool BeginDraw() override;
void Clear() override;
void Draw(void *data) override;
bool EndDraw() override;
[[nodiscard]] Plip::PlipVideoFormat GetFormat() override;
[[nodiscard]] int GetHeight() override;
[[nodiscard]] int GetWidth() override;
void Render() override;
void Resize(int width, int height) override;
void SetTitle(std::string title) override;
bool BeginDrawConsole();
bool EndDrawConsole();
[[nodiscard]] int GetGameScale() const;
[[nodiscard]] SDL_Renderer *GetRenderer() const;
void SetConsoleEnabled(bool enabled);
void SetDrawPauseIcon(bool value);
void SetGameScale(int scale);
private:
void CreateTexture(SDL_Texture **texture, int width, int height,
SDL_BlendMode blendMode = SDL_BLENDMODE_NONE,
SDL_TextureAccess access = SDL_TEXTUREACCESS_STREAMING);
void CreateConsoleTexture();
void CreateGameTexture();
bool SelectFormat(uint32_t format);
static uint32_t SelectSdlFormat(Plip::PlipVideoFormat format);
const int m_initWidth = 64;
const int m_initHeight = 64;
const int m_pauseOffsetX = 8;
const int m_pauseOffsetY = 8;
const int m_pauseSizeX = 24; // should be a multiple of 3
const int m_pauseSizeY = 24;
int m_width = m_initWidth;
int m_height = m_initHeight;
int m_gameScale;
bool m_drawPauseIcon = false;
void *m_texData = nullptr;
int m_pitch = -1;
bool m_drawConsole = false;
SDL_Window *m_window = nullptr;
SDL_Renderer *m_renderer = nullptr;
SDL_Texture *m_conTex = nullptr;
SDL_Texture *m_gameTex = nullptr;
Plip::PlipVideoFormat m_format = Plip::PlipVideoFormat::Unknown;
Plip::PlipVideoFormatInfo m_fmtInfo {};
};
}