smart-fun / smartGL

SmartGL is a Graphic Engine for creating Android Games and Apps. It is based on OpenGL and handles 2D Sprites and 3D Textured Objects.
Apache License 2.0
109 stars 24 forks source link

SmartGLRenderer renders object off screen #23

Open creek23 opened 5 years ago

creek23 commented 5 years ago

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

smart-fun commented 5 years ago

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

creek23 commented 5 years ago

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