LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: scythe on August 19, 2011, 06:58:54

Title: Vector arcade game in LWJGL
Post by: scythe on August 19, 2011, 06:58:54
Hey all!  I've been programming in Java for the past four years, yet I am a complete newb with LWJGL.  But I'm willing to learn!  Having said that, any advice you could give me to point me in the best direction would be helpful.

I am coding a vector-based game in LWJGL( think old school arcade games like Asteroidshttp://upload.wikimedia.org/wikipedia/en/1/13/Asteroi1.png (http://upload.wikimedia.org/wikipedia/en/1/13/Asteroi1.png), or Major Havoc http://www.appolo.com/Emulators/mhav0003.jpg (http://www.appolo.com/Emulators/mhav0003.jpg), or Lunar Lander http://gnm5.tripod.com/images/lunar1.jpg (http://gnm5.tripod.com/images/lunar1.jpg))

My question is, what might be the best way to render the graphics for a vector-based game?  What LWJGL libraries would you recommend I check out?  The thought crossed my mind that I could simply draw the vector graphics in GIMP and use Slick 2D features to import the pictures, but I am afraid that the visual quality would not be as "crisp" as if the vectors were drawn by LWJGL.

Again, any advice would be gratefully received.  Thanks in advance for any help!
Title: Re: Vector arcade game in LWJGL
Post by: princec on August 19, 2011, 08:58:14
Use plain old GL_TRIANGLES, and draw very thin rectangles for the lines, with just a teeny bit of alpha so the corners get a bit brighter like a real vector display.

Cas :)
Title: Re: Vector arcade game in LWJGL
Post by: Fool Running on August 19, 2011, 13:14:44
Quote from: princec on August 19, 2011, 08:58:14
Use plain old GL_TRIANGLES, and draw very thin rectangles for the lines, with just a teeny bit of alpha so the corners get a bit brighter like a real vector display.
You think that would produce better effects then GL_LINES? Looks like a great time to draw with lines to me.
Granted, I'm not 100% sure that lines are supported across all vendors well, but I know NVidia does them well. :P
Title: Re: Vector arcade game in LWJGL
Post by: kappa on August 19, 2011, 13:19:32
Kevglass (Slick2D author) did something similar a while back with just vertex colors, e.g.

(http://old.cokeandcode.com/slick/bz6.png) (http://old.cokeandcode.com/slick/bz6.png) (http://old.cokeandcode.com/slick/bz7.png) (http://old.cokeandcode.com/slick/bz7.png)

(http://old.cokeandcode.com/slick/bz8.png) (http://old.cokeandcode.com/slick/bz8.png)  (http://old.cokeandcode.com/slick/bz9.png) (http://old.cokeandcode.com/slick/bz9.png)

He describes that he did it as follows:
QuoteKev: I just did what seemed logical, for each line I create a quad with the line across the centre. I set the outer colour to black and the inner to the colour the line wants to be. Overdraw this with a additive blending and a few different shades to build up a glow. Wouldn't really work on sprites of course.
Title: Re: Vector arcade game in LWJGL
Post by: scythe on August 19, 2011, 16:11:48
Wow!  Thanks princec, Fool Running, and especially kappa, I never would have thought a "glow" would be possible with the methods available for line/quad rendering.  You guys rock!  I'll check out those GL methods
Title: Re: Vector arcade game in LWJGL
Post by: princec on August 19, 2011, 16:38:42
GL_LINES are poo. Mostly the ends look crap, and antialiasing is crap. GL_TRIANGLES is the way to go. Also get used to using GL_TRIANGLES and using indexed geometry instead of GL_QUADS because GL_QUADS aren't in OpenGL ES which is where the drivers are all slowly headed.

Cas :)