Hello Programmers!
I am going to run tutorials for school kids about “how to make a computer game” - Woo hoo! By getting the kids to add extra units, maps, weapons etc to my existing skeleton 2D game my job is enthuse school kids about maths - coordinate geometry, trigonomentry, etc :-. To make it simple for them the games’ coordinate space needs to be their familiar cartersian coordinate system of positive Y going up and positive X going right.
Unfortunately for me Java2D has an inverted Y-axis with the origin in the top-left of the screen, not the bottom left. I know how to change the coordinate space in theory:
Graphics2D g = //get it somewhere
g.translate(0, 600); //for 800x600
g.scale(1.0, -1.0); //flip around the x-axis so +y is up
//all drawing goes after above transforms
(Courtesy of CaptainJester, http://www.java-gaming.org/forums/index.php?topic=12348.0)
but how can I do the necessary scale(1, -1) while still keeping hardware acceleration?
Currently my game runs at ~40 FPS, but with the above transforms the FPS drops to 1 :’(. This is due to the loss of acceleration when painting my VolatileImage unit sprites to the VolatileImage back-buffer.
What is strange is that non-negative scale operations (such as scale(0.6, 0.6) ) work fine but scale(1, -1) causes the problems.
Q1. Is it impossible to invert the y-axis and keep acceleration with Java2D?
Q2. Can you easily invert the y-axis with JOGL or LWJGL and should I switch to one of these, considering their complexity?
Cheers,
Keith