Skip to content

Commit

Permalink
Adição de escala na construção da janela.
Browse files Browse the repository at this point in the history
  • Loading branch information
edsomjr committed Jun 1, 2016
1 parent e620dd3 commit 2a6d777
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace ijengine {
};

namespace video {
Window * create_window(const string& title, int w, int h);
Window * create_window(const string& title, int w, int h, double scale);
}

namespace audio {
Expand Down
3 changes: 2 additions & 1 deletion include/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace ijengine {

class Game : public GameEventsListener {
public:
Game(const string& title, int w = 800, int h = 600);
Game(const string& title, int w = 800, int h = 600, double scale = 1.0);
~Game();

int run(const string& level_id);
Expand All @@ -24,6 +24,7 @@ namespace ijengine {

string m_title;
int m_w, m_h;
double m_scale;
State m_state;
};

Expand Down
3 changes: 2 additions & 1 deletion include/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ namespace ijengine {
public:
virtual ~Kernel() {}

virtual Window * create_window(const string& title, int w, int h) = 0;
virtual Window * create_window(const string& title, int w, int h,
double scale) = 0;

virtual void set_audio_dir(const string& dir_path) = 0;
virtual void play_audio_from_path(const string& title) = 0;
Expand Down
3 changes: 2 additions & 1 deletion kernel/sdl2/sdl2kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ SDL2Kernel::~SDL2Kernel()
}

Window *
SDL2Kernel::create_window(const string& title, int w, int h)
SDL2Kernel::create_window(const string& title, int w, int h, double scale)
{
SDL_Window *window;
SDL_Renderer *renderer;
Expand All @@ -58,6 +58,7 @@ SDL2Kernel::create_window(const string& title, int w, int h)
return nullptr;

SDL_SetWindowTitle(window, title.c_str());
SDL_RenderSetScale(renderer, scale, scale);

return new SDL2Window(window, renderer);
}
Expand Down
2 changes: 1 addition & 1 deletion kernel/sdl2/sdl2kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SDL2Kernel : public Kernel {
SDL2Kernel();
~SDL2Kernel();

Window * create_window(const string& title, int w, int h);
Window * create_window(const string& title, int w, int h, double scale);

void set_audio_dir(const string& dir_path);
void play_audio_from_path(const string& title);
Expand Down
4 changes: 2 additions & 2 deletions src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ namespace ijengine
namespace video
{
Window *
create_window(const string& title, int w, int h)
create_window(const string& title, int w, int h, double scale)
{
return kernel->create_window(title, w, h);
return kernel->create_window(title, w, h, scale);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ using std::unique_ptr;

namespace ijengine {

Game::Game(const string& title, int w, int h)
: m_title(title), m_w(w), m_h(h), m_state(PAUSED)
Game::Game(const string& title, int w, int h, double scale)
: m_title(title), m_w(w), m_h(h), m_scale(scale), m_state(PAUSED)
{
event::register_listener(this);
}
Expand All @@ -25,7 +25,7 @@ namespace ijengine {
int
Game::run(const string& level_id)
{
auto test = video::create_window(m_title, m_w, m_h);
auto test = video::create_window(m_title, m_w, m_h, m_scale);
auto window = unique_ptr<Window>(test);

if (not window)
Expand Down

0 comments on commit 2a6d777

Please sign in to comment.