This is my first venture into game/opengl programming, so bear with me.
I’ve got my engine setup and working. My goal in writing was to limit the amount of overhead needed to initialize the engine- essentially, I wanted the main entry point of the game to have as little clutter as possible (main entry point being the ‘driver class’, or whichever class has the static main). With less clutter, setting up sepecific game rules would be easier and more efficient as they are commonly written at the first point of entry. The result was the creation of utility classes to do work outside of the driver class. However, I havn’t been able to figure out how these classes should be written. Which leads me to my first question:
Singleton Class vs. Class with static methods/data members- Which is faster to deal with? The class which manages entities (things to be drawn to the screen) is currently a singleton. Therefore, whenever I wish to spawn a new entity, I must do something like this:
EntityManager.getEntityManager().spawnEntity(new FakeEntity());
If the class had static methods/data members, I would do something like this:
EntityManager.spawnEntity(new FakeEntity());
I understand that for security reasons the singleton would be the best choice, as you can guarantee that only one instance of the EntityManager would exist at a time. Still even, when dealing with massive numbers of entities, something tells me things will be faster using the latter method. To better help describe things, here’s a link to a file which speaks in code: http://www.funkapotamus.org/Singleton.java
My second problem deals with drawing images to the screen. I get severe slowdown when I throw a few hundred up there.
When I look around on NeHe’s website, I see many great c++ demos of particle engines which boast 3k+ particles on screen with no noticable slowdown on my machine(which by today’s standards is low-end). Is it unrealistic to expect these kind of results with LWJGL? I ask because I am unable to get more than 750 96X96px images on the screen without dipping below 60fps. I imagine it has to do with how I’m initializing OpenGL and how I’m drawing sprites to the screen. Could flipping between blending/no blending many times hurt fps?
Here’s my GL init and sprite draw code:
GL Init
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glViewport(0, 0, Globals.width, Globals.height);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
// 2D Game
GL11.glOrtho(0.0f, Globals.width, Globals.height, 0.0f, Globals.minDepth, Globals.maxDepth);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
Sprite Draw:
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID[0]);
GL11.glColor3f(1.0f, 1.0f, 1.0f);
GL11.glEnable(GL11.GL_BLEND);
if(!blend)
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
else
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
if(alpha > 0.0f)
GL11.glColor4f(1.0f, 1.0f, 1.0f, alpha);
GL11.glLoadIdentity();
GL11.glTranslatef((float)origin.getX(), (float)origin.getY(), 0.0f);
GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex3f(-width / 2, -height / 2, 0.0f); GL11.glTexCoord2f(0, 0); //Bottom Left
GL11.glVertex3f(width / 2, -height / 2, 0.0f); GL11.glTexCoord2f(1, 0); //Bottom Right
GL11.glVertex3f(width / 2, height / 2, 0.0f); GL11.glTexCoord2f(1, 1); //Top Right
GL11.glVertex3f(-width / 2, height / 2, 0.0f); GL11.glTexCoord2f(0, 1); //Top Left
GL11.glEnd();
To close, here’s a pic of the game’s action thus far:
http://www.funkapotamus.org/crs2.jpg
Edit: I hit save when I meant to preview… everything should make sense now.

VBOs come in different flavours. You can get VBOs that are designed to stream data to the card over high-bandwidth buses (eg. AGP). Like NV_vertex_array on steroids.