StarlingGraphics / Starling-Extension-Graphics

flash.display.Graphics style extension for the Starling Flash GPU rendering framework
https://github.com/StarlingGraphics/Starling-Extension-Graphics/wiki
MIT License
285 stars 88 forks source link

beginTextureFills being scaled incorrectly sometimes #82

Closed Selonie closed 10 years ago

Selonie commented 10 years ago

Hi, I'm not sure if this an extension issue, but I've just plugged in the latest version and my textures are now being scaled up whereas before they weren't. It works fine in a simple demo but in my current project it looks terrible. The project is using starling's Scaffold and AssetManager and I wonder whether the scale factor is responsible for the distortion. Is there something I should do to compensate for whatever has changed in the latest version? Thanks.

jonathanrpace commented 10 years ago

Could you supply some example code that used to look fine? Under-the-hood, the graphics API makes use of a number of simpler primitives, so any examples would help me narrow down where the problem lies.

Selonie commented 10 years ago

Hi Jonathan - I don't know if this is relevant but when I use textures of 256x256 everything looks fine. In my project I had been using textures of 32x32, 64,64, 128x128 etc. This looked ok in the last version I had installed. I wasn't aware 256 was now a requirement but if it is I'll go and sort my textures out! I wouldn't be at all suprised to discover everyone else knows this and I'm being a little slow, however if it isn't a requirement and it works fine for everyone else I must have a problem with my code. Regards Selonie

jonathanrpace commented 10 years ago

Nope - there isn't any 256x256 requirement. Everything is supposed to still work like before - it was a pretty thorough refactor, so I've likely broken something.

So I'm guessing you're using beginTextureFill() then using what? lineTo() - drawCircle(), drawRect()?

Jon

IonSwitz commented 10 years ago

There is a uvMatrix.scale(1.0 / 256, 1.0 / 256); somewhere. In the Fill constructor, maybe?

I don't have access to the code right now, but I remember seeing it somewhere.

EDIT: I downloaded the ZIP code base, and yeah, in the Fill constructor, there is a uvMatrix.Scale-call

    public function Fill()
    {
        clear();

        _uvMatrix = new Matrix();
        _uvMatrix.scale(1/256, 1/256);
    }

Maybe that is what is causing this?

Selonie commented 10 years ago

I am using using beginTextureFill() and lineTo() - I just ran a test on the supplied example 01_Graphics_API_Example replacing the checker image with a 32x32 of small squares which get scaled up and a 512x512 image which gets scaled down. The Marble in the example also looks blurry.

jonathanrpace commented 10 years ago

Thanks for the info - I'm on it.

jonathanrpace commented 10 years ago

I overlooked the uvMatrix during the refactor - so all texture fills were behaving incorrectly. Sorry.

This should now be working as-before. https://github.com/StarlingGraphics/Starling-Extension-Graphics/commit/9314c35a357e7ee23ae04e2460fd77170088478f