brandonborkholder / glg2d

Graphics2D wrapper for JOGL
77 stars 31 forks source link

Example of how to implement #7

Closed amigax closed 11 years ago

amigax commented 11 years ago

Hey this is great, exactly what Im looking for! I have built an entire 2D games design tool in Swing, and the game itself runs in a Java2D canvas. I would love to see the performance gains I can get from swapping it over to your library.

However is there a basic tutorial that shows you how to simply replace whatever lines need to be replaced to implement this? It would be great if the code doesnt have to change much, perhaps only the imports?

Im drawin 32x32 tiles at 1920x1080, id like to see how it feels with this lib, and also do you get zooming etc since its base don OpenGL?

Any docs on how to transition from swing/java2d to this would be great, keep up the good work !!

brandonborkholder commented 11 years ago

Thanks for the suggestion. I created a new gist https://gist.github.com/3909397 that might help you out. I'll try to come up with some more documentation and put it on the website.

As for zooming: you'll handle zooming with OpenGL the same way you do with Java2D - using the modelview matrix. Use the scale http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics2D.html#scale%28double,%20double%29 and translate http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics2D.html#translate%28double,%20double%29 methods in the Graphics2D http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics2D.html class. If this is already working with your existing 2D game, it should work without issue in GLG2D.

brandonborkholder commented 11 years ago

I'm closing this issue with the gist I posted and the updated website which has some example code on how to do exactly this.

I also added several example source files at https://github.com/brandonborkholder/glg2d/tree/master/src/test/java/org/jogamp/glg2d/examples