fredsa / playn

Cross platform game library for N≥4 platforms
0 stars 1 forks source link

Pattern on android #191

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create pattern from loaded image
2. Set fill pattern in surface of direct rendering layer
3. Fill rectangle with pattern

What is the expected output? What do you see instead?

I expect pattern drawn correctly. Instead I get jibberish output on Android 
(but Java works as expected)

What version of the product are you using? On what operating system?

I compile on ubuntu 12.12. using 1.5-SNAPSHOT from git (tried with 1.4, same 
result)

Please provide any additional information below.

Sample code:

Image image = currentTileType.getImage();
int startX = aOffsetX + currentTileXStart * 10;
int startY = aOffsetY + y * 10;
aBuffer.save();
aBuffer.translate(startX, startY);
aBuffer.setFillPattern(image.toPattern());
aBuffer.fillRect(0, 0, (x-currentTileXStart)*10, 10);
aBuffer.restore();

Original issue reported on code.google.com by alexande...@gmail.com on 17 Jul 2012 at 9:09

Attachments:

GoogleCodeExporter commented 9 years ago
The little guy and the coins are drawn directly as images, thus not affected by 
the bug

Original comment by alexande...@gmail.com on 17 Jul 2012 at 9:09

GoogleCodeExporter commented 9 years ago
It works in the SurfaceTest in playn/tests/core. Can you try running that app 
on your device and see if the surface tests shows a pattern or shows garbage?

    final Pattern pattern = assets().getImage("images/tile.png").toPattern();
    addTest("fillRect/Triangles with pattern", 180, 10, 120, 220, new ImmediateLayer.Renderer() {
      public void render (Surface surf) {
        // fill some shapes with patterns
        surf.setFillPattern(pattern).fillRect(10, 0, 100, 100);
        // use same fill pattern for the triangles
        surf.translate(0, 160);
        surf.fillTriangles(verts, indices);
      }
    });

Or perhaps you're rendering to an off-screen buffer rather than to the main 
framebuffer?

Original comment by m...@samskivert.com on 17 Jul 2012 at 7:45

GoogleCodeExporter commented 9 years ago
There was a bug if you tiled a non-power-of-two image to a surface. That bug is 
fixed in trunk, if you want to give that a shot and see if it works. Though the 
bug was such that it should have failed in the Java backend as well, so I'm not 
sure whether this is your issue.

Original comment by m...@samskivert.com on 17 Jul 2012 at 8:16

GoogleCodeExporter commented 9 years ago
The difference between the test and my case is that I am using a clipped 
immediate layer. This make all the difference. 

Original comment by alexande...@gmail.com on 18 Jul 2012 at 5:00

GoogleCodeExporter commented 9 years ago
Changing the test to a clipped layer breaks the test as well...

Original comment by alexande...@gmail.com on 18 Jul 2012 at 5:15

GoogleCodeExporter commented 9 years ago
I added a test that fills a pattern inside a clipped immediate layer and it 
works fine on my Android device (with my latest fix). Try the latest code in 
trunk and see if it solves your problem.

If it doesn't, then this is a ICS versus JellyBean problem.

Original comment by m...@samskivert.com on 18 Jul 2012 at 4:22

GoogleCodeExporter commented 9 years ago
I still have problems with this, same issue. Did you try this on Galaxy Nexus 
or another ICS device?

Original comment by alexande...@gmail.com on 19 Jul 2012 at 4:23