smartGL icon indicating copy to clipboard operation
smartGL copied to clipboard

SmartGLRenderer renders object off screen

Open creek23 opened this issue 5 years ago • 2 comments

Tried rendering 100x100 iso tile, and FPS dropped to 2frames/second

How come SmartGLRenderer tries to render objects outside the screen? I had to implement my own clipping by checking tile position if it's off screen and got a 30~fps. Not sure how to further improve to get back to 60fps.

~creek23

creek23 avatar Apr 17 '19 13:04 creek23

there are no rules and no clipping when rendering objects, but the framerate should not drop. I could not reproduce so far.

smart-fun avatar May 17 '19 17:05 smart-fun

Somehow, I think frame rate drop is somewhat related to how I first wrote the Collada DAE parser -- I had 1 Face3D per triangle inside an Object3D.

In this case, I had 1 Sprite per "tile" in my tile-map.

What is the proper way of rendering the "tile"? Will it be like a single Face3D with multiple triangle represented by float-array? As such, in this case, 1 Sprite with multiple "tile"? but how will I populate the "tile" inside 1 Sprite?

Below is my sample code:

Texture pngGrass = new Texture(this.getBaseContext(), R.drawable.grass);
for (int i = 0; i < 100; ++i) {
    for (int j = 0; j < 100; ++j) {
        Sprite sprMap = new Sprite(pngGrass.getWidth(), pngGrass.getHeight());
        sprMap.setTexture(pngGrassC);
            newX -= (sprMap.getWidth() / 2);
            newY += (sprMap.getHeight() / 4);
            sprMap.setPos(newX, newY);
        renderPassSprite.addSprite(sprMap);
    }
    newX += (tmpX * 101);
    newY -= (tmpY * 99);
    newY -= (tmpY * 99);
}

Below is the sprite I used. grass

~creek23

creek23 avatar May 18 '19 14:05 creek23