Hi all,
I know the idea of using enums instead of constants has been mentioned for 2.0 and I was musing on the idea and have come up with something that might be useful for making jME more render implementation independant.
Basically we create enums for all the areas that need them (i.e. texture types) and inside each enum we have a method for getting the render specific code.
For example,
public enum TextureType {
RGB("rgb", "glrgb", "dxrgb"),
RGBA("rgba", "glrgba", "dxrgba");
private String jmeCode, glCode, dxCode;
private TextureType(String jmeCode, String glCode, String dxCode) {
this.jmeCode = jmeCode;
etc
}
public Object getJmeCode() {
return jmeCode;
}
etc
}
Then the usage would be:
Renderer.doSomething(blah, blah, TextureType.RGB);
Inside a LWJGL implementation for example you'd have:
public void doSomething(Object a, Object b, TextureType tt) {
GL11.doSomething(a, b, tt.getGLCode());
}
This would save some kind of horrible "if enum equals rgb then use code xyz" statement in each method that uses enums. This would also be handy if for example, the one implementation required an int constant but another required a string (would require some autoboxing for primitives, hmm).
I'm not sure if this would work or not or even if we'd need a bunch more codes (i.e. GL11Code, GL20Code, GLARBCode, DX9Code, DX10Code etc etc) but I figured I'd mention it as it might not be an approach anyone has thought of yet.
Would also like to point out I've never used DX and I'm just assuming it doesn't use the same constants...
Thanks,
Chris