Hello,
Basicly im using jogl to write a 2D game. The problem is that its much slower than i expected. Curently im working on some old computer with some 1,6Ghz cpu and some acient Geforce card, still i remember pretty decent fps when i played years ago some quake 3 engine based games ;).
In my engine(well maybe engine is too big word for now ;)) i get 30-35, and that is after some basic optimalzations i’ve made: culling - without it was horrible.
Needless to say im disspointed since i expected simple 2d game to be much less resource demanding than quake iii.
I have about 300 textured quads on my screen, most of them are ground tiles. Without the ground i get twice as much fps, still i expected some crazy number like 400 or something.
There might be something wrong in my code(its a mess so i’ll post only the opengl part):
public void init(GLAutoDrawable glDrawable) {
GL gl = glDrawable.getGL();
gl. glEnable( GL.GL_BLEND );
gl. glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA );
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glClearColor(255, 255, 255, 0);
gl.glViewport(0, 0, width, height);
gl.glDisable(GL.GL_DEPTH_TEST);
initGame();
animator = new Animator(glDrawable);
animator.start();
}
public void display(GLAutoDrawable glDrawable) {
GL gl=glDrawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
...//drawing sprites
gl.glFlush();
}
and the method i use to draw the sprite:
public void draw(GL gl , boolean bind) {
Texture texture = getTexture();
if(bind){
texture.enable();
texture.bind();
}
TextureCoords coords = texture.getImageTexCoords();
gl.glPushMatrix();
gl.glTranslatef(x, y, 0);
gl.glColor3f(1,1,1);
gl.glBegin(GL.GL_QUADS);
{
gl.glTexCoord2f(coords.left(), coords.top());
gl.glVertex2f(0, 0);
gl.glTexCoord2f(coords.left(), coords.bottom());
gl.glVertex2f(0, height);
gl.glTexCoord2f(coords.right(), coords.bottom());
gl.glVertex2f(width, height);
gl.glTexCoord2f(coords.right(), coords.top());
gl.glVertex2f(width, 0);
}
gl.glEnd();
//texture.disable();
gl.glPopMatrix();
}
Any ideas?
thanks