following this question: Best approach for playing the tree-like bilingual version of oldschool
Thanks to the previous answers and with great inspiration from http://insanitydesign.com/wp/projects/nehe-android-ports/ , I started creating a simple tile generator for my simple 2D zelda-like game project.
Now I can create a map with the same textured tile, using 2 for (..) fixed iterations to draw horizontal and vertical tiles, and get some basic DPAD key input listeners to scroll along the x and y axis.
but now I am facing my first performance issues, with only one texture and one model.
When you try to build a 10x10 map, the scroll will be beautiful and smooth.
When you try with 50x50, everything gets worse, and with 100x100 it’s unacceptable.
Is there a way to tell OpenGL about the “visible” part of my map set and ignore hidden fragments? im brand new to this.
im using
GLU.gluLookAt(gl, cameraPosX, cameraPosY, 10.0f,cameraPosX, cameraPosY, 0.0f, 0.0f, 1.0f, 0.0f);
to set the camera and point of view for a 2D feel.
Any help? :)
for (int j = 0; j < 10; j++) {
for (int i = 0; i < 10; i++) {
gl.glPushMatrix();
gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[filter]);
gl.glFrontFace(GL10.GL_CW);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
gl.glTranslatef(1.0f, 0.0f, 0.0f);
}
gl.glPopMatrix();
gl.glTranslatef(0.0f, -1.0f, 0.0f);
}