SDLPP: Renderer/Scene - use Vec2D instead of std::pair
This commit is contained in:
parent
aaae85a932
commit
6ecdb6d90d
@ -17,26 +17,26 @@ Renderer::~Renderer() {
|
|||||||
SDL_Renderer *Renderer::getRendererPtr() {
|
SDL_Renderer *Renderer::getRendererPtr() {
|
||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
std::pair< int, int > Renderer::getDimensions() const {
|
Vec2D< int > Renderer::getDimensions() const {
|
||||||
int width = 0, height = 0;
|
int width = 0, height = 0;
|
||||||
SDL_GetRendererOutputSize( renderer, &width, &height );
|
SDL_GetRendererOutputSize( renderer, &width, &height );
|
||||||
return { width, height };
|
return { width, height };
|
||||||
}
|
}
|
||||||
int Renderer::getWidth() const {
|
int Renderer::getWidth() const {
|
||||||
return getDimensions().first;
|
return getDimensions().getX();
|
||||||
}
|
}
|
||||||
int Renderer::getHeight() const {
|
int Renderer::getHeight() const {
|
||||||
return getDimensions().second;
|
return getDimensions().getY();
|
||||||
}
|
}
|
||||||
int Renderer::getSmallerSide() const {
|
int Renderer::getSmallerSide() const {
|
||||||
auto dimensions = getDimensions();
|
auto dimensions = getDimensions();
|
||||||
return dimensions.first < dimensions.second ? dimensions.first
|
return dimensions.getX() < dimensions.getY() ? dimensions.getX()
|
||||||
: dimensions.second;
|
: dimensions.getY();
|
||||||
}
|
}
|
||||||
int Renderer::getLargerSide() const {
|
int Renderer::getLargerSide() const {
|
||||||
auto dimensions = getDimensions();
|
auto dimensions = getDimensions();
|
||||||
return dimensions.first > dimensions.second ? dimensions.first
|
return dimensions.getX() > dimensions.getY() ? dimensions.getX()
|
||||||
: dimensions.second;
|
: dimensions.getY();
|
||||||
}
|
}
|
||||||
void Renderer::setBlendMode( SDL_BlendMode blendMode ) {
|
void Renderer::setBlendMode( SDL_BlendMode blendMode ) {
|
||||||
SDL_SetRenderDrawBlendMode( renderer, blendMode );
|
SDL_SetRenderDrawBlendMode( renderer, blendMode );
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "sdlpp_common.hpp"
|
#include "sdlpp_common.hpp"
|
||||||
#include "sdlpp_window.hpp"
|
#include "sdlpp_window.hpp"
|
||||||
|
#include "sdlpp_vector.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ public:
|
|||||||
Renderer( Window &window );
|
Renderer( Window &window );
|
||||||
virtual ~Renderer();
|
virtual ~Renderer();
|
||||||
SDL_Renderer *getRendererPtr();
|
SDL_Renderer *getRendererPtr();
|
||||||
std::pair< int, int > getDimensions() const;
|
Vec2D<int> getDimensions() const;
|
||||||
int getWidth() const;
|
int getWidth() const;
|
||||||
int getHeight() const;
|
int getHeight() const;
|
||||||
int getSmallerSide() const;
|
int getSmallerSide() const;
|
||||||
|
@ -163,7 +163,7 @@ const std::shared_ptr< RenderObject > &Scene::leftmost() {
|
|||||||
const std::shared_ptr< RenderObject > &Scene::rightmost() {
|
const std::shared_ptr< RenderObject > &Scene::rightmost() {
|
||||||
return rightmost_obj;
|
return rightmost_obj;
|
||||||
}
|
}
|
||||||
std::pair< int, int > Scene::getDimensions() const {
|
Vec2D<int> Scene::getDimensions() const {
|
||||||
return renderer->getDimensions();
|
return renderer->getDimensions();
|
||||||
}
|
}
|
||||||
int Scene::getWidth() const {
|
int Scene::getWidth() const {
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
void moveEverything( double x, double y );
|
void moveEverything( double x, double y );
|
||||||
const std::shared_ptr< RenderObject > &leftmost();
|
const std::shared_ptr< RenderObject > &leftmost();
|
||||||
const std::shared_ptr< RenderObject > &rightmost();
|
const std::shared_ptr< RenderObject > &rightmost();
|
||||||
std::pair< int, int > getDimensions() const;
|
Vec2D< int > getDimensions() const;
|
||||||
int getWidth() const;
|
int getWidth() const;
|
||||||
int getHeight() const;
|
int getHeight() const;
|
||||||
Renderer &getRenderer();
|
Renderer &getRenderer();
|
||||||
|
Loading…
Reference in New Issue
Block a user