Verified Commit c6b3915b authored by RobLoach's avatar RobLoach
Browse files

Add love.graphics.setDefaultFilter()

parent 996a1c90
......@@ -8,7 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- `love` namespace
- Example: `love.graphics.draw()`
- Rotation and scaling for `love.graphics.draw()`
- `love.graphics.draw()` rotation and scaling
- `love.graphics.setDefaultFilter()`
### Changed
- ChaiScript_Extras now using original source, upstream GCC issue fixed
......
......@@ -106,9 +106,8 @@ void graphics::draw(Image* image, Quad quad, int x, int y) {
void graphics::draw(Image* image, int x, int y, float r, float sx, float sy, float ox, float oy) {
if (image && image->loaded()) {
ChaiLove* app = ChaiLove::getInstance();
int smooth = app->config.options["alphablending"];
float angle = app->math.degrees(r);
SDL_Surface* tempSurface = rotozoomSurfaceXY(image->surface, angle, sx, sy, smooth);
SDL_Surface* tempSurface = rotozoomSurfaceXY(image->surface, angle, sx, sy, m_smooth);
if (tempSurface) {
float aspectX = ox / image->getWidth();
float aspectY = oy / image->getHeight();
......@@ -184,6 +183,32 @@ void graphics::setBackgroundColor(int red, int green, int blue, int alpha) {
backB = blue;
backA = alpha;
}
/**
* @brief Sets the default scaling filters used with images, and fonts.
*/
void graphics::setDefaultFilter(const std::string& filter) {
if (filter == "linear") {
m_smooth = 0;
}
else if (filter == "nearest") {
m_smooth = 1;
}
}
/**
* @brief Returns the default scaling filters used with images and fonts.
*/
std::string graphics::getDefaultFilter() {
switch (m_smooth) {
case 0:
return "linear";
case 1:
return "nearest";
}
}
int graphics::getWidth() {
return getScreen()->w;
}
......
......@@ -185,6 +185,16 @@ class graphics {
*/
void setBackgroundColor(int red, int green, int blue);
/**
* @brief Sets the default scaling filters used with images, and fonts.
*/
void setDefaultFilter(const std::string& filter);
/**
* @brief Returns the default scaling filters used with images and fonts.
*/
std::string getDefaultFilter();
/**
* @brief Retrieve the width of the screen.
*/
......@@ -233,6 +243,8 @@ class graphics {
SDL_Surface* getScreen();
Font* activeFont;
Font defaultFont;
int m_smooth = 0;
};
} // namespace Modules
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment