Hey all,
I’m creating a simple tile-based map editor, and I have some funamental java/JOGL OOP design questions.
First, how does everyone deal with the GLCanvas and implementing the GLEventListener methods, so that the GLCanvas->display() method has access to all of the game information it needs to render a scene?
Right now, I have a large class whose data members are all of my game data (the map, tile information, images, etc), and one GLCanvas on which to draw. With this class I implement the GLEventListener methods, so that my GLCanvas can have access to the data it needs to render. For example:
public class myClass implements GLEventListener {
private map myMap;
private image myImage;
private GLCanvas canvas;
init() etc
then, in the implemented display, I can just do this:
display(){
myMap.Render(myImage, canvas); etc etc
}
}
I can’t think of a better way to let the canvas talk with all of the other objects in my map editor… How does everyone else implement this design? I would like to keep the rendering device separate from the game data as much as possible, but it seems like I have to entertwine them at some point.
Also, how can I do runtime texture loading with JOGL? It seems that the GLContext is only valid during init() and display(), so it seems impossible to load textures anywhere outside of init(). How can I make a map editor that lets users load in a new tileset whenever they wish? Will I have to destroy/create a new canvas each time I want to load a new set of textures?
That’s all I can think of for now… Sorry if none of this made sense, I just need some direction on good OOP practices with JOGL =]