summaryrefslogtreecommitdiff
path: root/src/graphics.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-24 19:20:49 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-26 07:30:39 +0000
commit4091bd9568e5aff4a1f24416d26da567a2c076ad (patch)
tree32285c49c19821d5d287fab29cf264a647735ded /src/graphics.cpp
parent4604ee1caf00fe1a8c095119c1046e7f625e1f0b (diff)
downloadmana-4091bd9568e5aff4a1f24416d26da567a2c076ad.tar.gz
mana-4091bd9568e5aff4a1f24416d26da567a2c076ad.tar.bz2
mana-4091bd9568e5aff4a1f24416d26da567a2c076ad.tar.xz
mana-4091bd9568e5aff4a1f24416d26da567a2c076ad.zip
Added functions to draw images at sub-pixel positions
This can be used for smoother mouse cursor movement when rendering our own mouse cursor (already changed in this commit) and is also necessary for implementing support for HiDPI font rendering. Also dropped some almost duplicated OpenGL code.
Diffstat (limited to 'src/graphics.cpp')
-rw-r--r--src/graphics.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 19f87e0c..13089b0c 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -47,6 +47,26 @@ bool Graphics::drawImage(Image *image, int x, int y)
return drawImage(image, 0, 0, x, y, image->getWidth(), image->getHeight());
}
+bool Graphics::drawImageF(Image *image, float x, float y)
+{
+ if (!image)
+ return false;
+
+ return drawImageF(image, 0, 0, x, y, image->getWidth(), image->getHeight());
+}
+
+bool Graphics::drawRescaledImageF(Image *image, int srcX, int srcY, float dstX, float dstY, int width, int height, float desiredWidth, float desiredHeight, bool useColor)
+{
+ return drawRescaledImage(image,
+ srcX, srcY,
+ static_cast<int>(dstX),
+ static_cast<int>(dstY),
+ width, height,
+ static_cast<int>(desiredWidth),
+ static_cast<int>(desiredHeight),
+ useColor);
+}
+
bool Graphics::drawImage(Image *image,
int srcX, int srcY,
int dstX, int dstY,
@@ -60,6 +80,15 @@ bool Graphics::drawImage(Image *image,
width, height, useColor);
}
+bool Graphics::drawImageF(Image *image, int srcX, int srcY, float dstX, float dstY, int width, int height, bool useColor)
+{
+ return drawRescaledImageF(image,
+ srcX, srcY,
+ dstX, dstY,
+ width, height,
+ width, height, useColor);
+}
+
void Graphics::drawImagePattern(Image *image, int x, int y, int w, int h)
{
if (!image)