OpenGL Scaling Issues with Mojo Image Filtering

Monkey Forums/Monkey Programming/OpenGL Scaling Issues with Mojo Image Filtering

Marky Potatoes(Posted 2013) [#1]
Hi,

I wanted to report something related to OpenGL scaling. With image filtering enabled, whenever you have a target that uses OpenGL (for instance, iOS or GLFW), when you do a DrawImageRect and the image is scaled, the image doesn't cut nicely. The drawn image is actually taking part of the next pixel over with it when scaling, and you get a weird line effect on all your cut images on the right and on the bottom.

For instance, if I have a bunch of 16x16 squares in a PNG, and it gets loaded into the program, then I do Scale(3, 3) and DrawImageRect(img, 0, 0, 0, 0, 16, 16), the image will actually take a blurred part of the pixels at x = 16 and draw it.


ElectricBoogaloo(Posted 2013) [#2]
Yeah, modern systems aren't quite as good at cutting from spritesheets, are they!
If you look into the language, you'll find that LoadImage actually has the ability to account for "padded" images..

From the help file : If your images contain edge padding, you will need to use one of the padding flags such as XYPadding.

It's a good idea to pad your sprites, so you get less of those annoying glitchy bits.
.. It's annoying to have to do it, and I'm far too lazy to do it, myself, but it's there for a reason!


Xaron(Posted 2013) [#3]
Yes I've tried that XYPadding and it worked in my case. :)


dragon(Posted 2013) [#4]
I add 1 px around sprite (this is the new sprite size now)
and 1 px space between such blocks and to any other border
this remove any artefacts...

This is not a monkey problem, this is how OpenGL & Co was designed.