Skip to content

Commit

Permalink
iV_DrawImageTint: Use floats for x,y
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Sep 1, 2023
1 parent 7f757b5 commit 8f3f877
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
27 changes: 24 additions & 3 deletions lib/ivis_opengl/pieblitfunc.cpp
Expand Up @@ -613,7 +613,7 @@ static inline void pie_DrawImageTemplate(IMAGEFILE *imageFile, int id, Vector2i

glm::mat4 mvp = modelViewProjection * glm::translate(glm::vec3((float)dest->x, (float)dest->y, 0.f));

iv_DrawImageImpl<PSO>(pie_Texture(texPage), Vector2i(0, 0), Vector2i(dest->w, dest->h), Vector2f(tu, tv), Vector2f(su, sv), colour, mvp);
iv_DrawImageImpl<PSO>(pie_Texture(texPage), Vector2i(0, 0), Vector2f(dest->w, dest->h), Vector2f(tu, tv), Vector2f(su, sv), colour, mvp);
}

static void pie_DrawImage(IMAGEFILE *imageFile, int id, Vector2i size, const PIERECT *dest, PIELIGHT colour, const glm::mat4 &modelViewProjection, Vector2i textureInset = Vector2i(0, 0))
Expand Down Expand Up @@ -685,6 +685,22 @@ static Vector2i makePieImage(IMAGEFILE *imageFile, unsigned id, PIERECT *dest, i
return pieImage;
}

static Vector2i makePieImagef(IMAGEFILE *imageFile, unsigned id, PIERECT *dest, float x, float y)
{
AtlasImageDef const &image = imageFile->imageDefs[id];
Vector2i pieImage;
pieImage.x = image.Width;
pieImage.y = image.Height;
if (dest != nullptr)
{
dest->x = x + static_cast<float>(image.XOffset);
dest->y = y + static_cast<float>(image.YOffset);
dest->w = static_cast<float>(image.Width);
dest->h = static_cast<float>(image.Height);
}
return pieImage;
}

void iV_DrawImage2(const WzString &filename, float x, float y, float width, float height)
{
if (filename.isEmpty()) { return; }
Expand Down Expand Up @@ -733,15 +749,20 @@ void iV_DrawImage(IMAGEFILE *ImageFile, UWORD ID, int x, int y, const glm::mat4
}
}

void iV_DrawImageTint(IMAGEFILE *ImageFile, UWORD ID, int x, int y, PIELIGHT color, const glm::mat4 &modelViewProjection, BatchedImageDrawRequests* pBatchedRequests)
void iV_DrawImageTint(IMAGEFILE *ImageFile, UWORD ID, float x, float y, PIELIGHT color, optional<Vector2f> size, const glm::mat4 &modelViewProjection, BatchedImageDrawRequests* pBatchedRequests)
{
if (!assertValidImage(ImageFile, ID))
{
return;
}

PIERECT dest;
Vector2i pieImage = makePieImage(ImageFile, ID, &dest, x, y);
Vector2i pieImage = makePieImagef(ImageFile, ID, &dest, x, y);
if (size.has_value())
{
dest.w = size.value().x;
dest.h = size.value().y;
}

if (pBatchedRequests == nullptr)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/ivis_opengl/pieblitfunc.h
Expand Up @@ -276,7 +276,7 @@ void iV_DrawImageAnisotropic(gfx_api::texture& TextureID, Vector2i Position, Vec
void iV_DrawImageText(gfx_api::texture& TextureID, Vector2f Position, Vector2f offset, Vector2f size, float angle, PIELIGHT colour);
void iV_DrawImageTextClipped(gfx_api::texture& TextureID, Vector2i textureSize, Vector2f Position, Vector2f offset, Vector2f size, float angle, PIELIGHT colour, WzRect clippingRect);
void iV_DrawImage(IMAGEFILE *ImageFile, UWORD ID, int x, int y, const glm::mat4 &modelViewProjection = defaultProjectionMatrix(), BatchedImageDrawRequests* pBatchedRequests = nullptr, uint8_t alpha = 255);
void iV_DrawImageTint(IMAGEFILE *ImageFile, UWORD ID, int x, int y, PIELIGHT color, const glm::mat4 &modelViewProjection = defaultProjectionMatrix(), BatchedImageDrawRequests* pBatchedRequests = nullptr);
void iV_DrawImageTint(IMAGEFILE *ImageFile, UWORD ID, float x, float y, PIELIGHT color, optional<Vector2f> size = nullopt, const glm::mat4 &modelViewProjection = defaultProjectionMatrix(), BatchedImageDrawRequests* pBatchedRequests = nullptr);
void iV_DrawImageFileAnisotropic(IMAGEFILE *ImageFile, UWORD ID, int x, int y, Vector2f size, const glm::mat4 &modelViewProjection = defaultProjectionMatrix(), uint8_t alpha = 255);
void iV_DrawImage2(const WzString &filename, float x, float y, float width = -0.0f, float height = -0.0f);
void iV_DrawImage2(const AtlasImageDef *image, float x, float y, float width = -0.0f, float height = -0.0f);
Expand Down

0 comments on commit 8f3f877

Please sign in to comment.