2
\$\begingroup\$

I'm working on a small game library for me and some people I know that just handles the window and nothing special that we weren't gonna use. I know how to use OpenGL and stuff I just don't like having to deal with more then one library at a time like OpenGL and Swing so I want to combine them into something basic. Anyway my question is, is there any way I can use OpenGL's rendering onto Swing? I need a simple answer. I also don't want to have to include other libraries into my library, I just want it to be the only jar in the program that isn't program specific.

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

Yes, JOGL (Java™ Binding for the OpenGL® API) allows exactly that. See also this post for more information about OpenGL and Swing interoperability. Also see XTrans demo on JOGL demos page.

Mixing Swing and OpenGL has a little performance penalty though, so you should consider other options if realtime 3D is your primary feature and Swing is just a small user interface in the game.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Can I pack everything into 1 jar so it contains all the OpenGL stuff when I build it? \$\endgroup\$ Feb 2, 2013 at 8:32
  • 2
    \$\begingroup\$ Yes, at least everything except the native binaries (.dll files on Windows) \$\endgroup\$
    – msell
    Feb 2, 2013 at 11:21
  • \$\begingroup\$ @msell Are JOGL and LWJGL equivalent? JOGL is external library. Is there any solution built into JDK for this? \$\endgroup\$ May 1, 2016 at 20:41
  • \$\begingroup\$ @iamcreasy No they are not equivalent. No there is no built in OpenGL API in JDK. \$\endgroup\$
    – msell
    May 2, 2016 at 5:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .