EDIT: I should probably prefix this with “I DO NOT OPENGL” just to stress that nothing is too obvious here.
I’m currently working on an AI for an open-source RTS game, which uses a couple of offscreen images as databases for looking up certain things wrt the game state. Basically all I needed to do was paint a bunch of add-blended single-color 2D circles, which graphics2d would have been fine for except that it had no add compositor and making a custom one-pixel-at-a-time compositor led to pathologically bad performance.
The issue is that the AI uses a framework provided by the game engine which handles all the necessary state updates. Using a slick game container would probably break the AI framework, and even if not I don’t want it to display a window at all except when its debug mode is activated. The problem is that the game containers do some magic which initializes the GL state and allows for images/image buffers to be created and manipulated, and without which any attempt to create an image leads to null pointer errors.
Basically I need to know what it is that I need to do in order to provide an offscreen GL environment so that the graphics functions of slick will work properly without having to rely on slick’s game framework. The only thing I was able to find digging through the slick source was that it creates a display, which I don’t want or need for offscreen rendering. :-\
Solution:
System.setProperty("org.lwjgl.opengl.Window.undecorated", "true");
try {
Display.setDisplayMode(new DisplayMode(0, 0));
Display.create();
}catch (LWJGLException e){
Log.error("Failed to initialize OpenGL display!");
System.exit(-1);
}
I’m not sure if this qualifies as horrible hack or correct solution, but it works.