Hey everyone! I'm working on implementing a 3D game in Java using LWJGL and the Artemis Entity System Framework. I've done the tutorials on the LWJGL site, and they have examples for older OpenGL (the term I use for OpenGL < 3.2) and modern OpenGL (the term I use for OpenGL >= 3.2). Even though the majority of my player base will be able to play games made with modern OpenGL, I'm wondering if I should support older OpenGL too. However, that's not my primary question.
Even if I decide not to implement a renderer for older OpenGL the possibility has raised what I consider to be an interesting design question. How would I implement a rendering system supporting multiple renderer implementations? My initial thoughts on the subject lead me to believe that by using well designed interfaces I can abstract the rendering process to a set of steps. Then it would be a simple matter of having different implementations of that interface for the renderer variants.
I'm implementing rendering within the confines of the Artemis Entity System Framework, and that basically involves systems processing a collection of entities using their components. So far I think that the minimum components needed to render a renderable entity are its position, scale, orientation, vertex data, textures, and shaders. This is kind of what a not yet implemented rendering system would like.
import com.artemis.Aspect;
import com.artemis.Component;
import com.artemis.ComponentMapper;
import com.artemis.Entity;
import com.artemis.annotations.Mapper;
import com.artemis.systems.EntityProcessingSystem;
public class NotImplementedRenderingSystem extends EntityProcessingSystem
{
@Mapper ComponentMapper<Component> cm;
public NotImplementedRenderingSystem()
{
super(Aspect.getAspectForAll(Component.type));
}
@Override
protected void process(Entity e)
{
/*
* render using entity components:
* position
* scale
* orientation
* vertex data
* textures & shaders
* e.g.:
*/
Component component = cm.get(e);
//do something with component
}
}
Other people I've spoken to on IRC have shot this idea down. I'm not really sure how I would name each implementation, but I suggested Renderer20 (OpenGL 2.0), Renderer32 (OpenGL 3.2), etc. and that was panned as a horrible idea. The same people suggested abstraction, but they didn't say where I should put my implementations or what I should call them. Any advice, ideas, questions, guidance?
I've heard that the best way for an indie game programmer to make games is to get a minimal working framework as soon as possible and expand from that, and I'd really like to be able to get into a rendered world (even if it is just basic geometric primitives with vertex color) as quickly as possible. Thanks for reading!