PDA

View Full Version : Cross-platform OpenGL



Lokken
07-30-2008, 06:32 AM
Hello All

I have recently picked up OpenGL again after not having used it since school.

Back then (~2003) the tool to use to make an opengl program as platform independant as possible was GLUT (or at least thats how I understood it).

Is this still the case? I dont seem to see any recent updates to it (last i found was 3.7.x in 2001?).

Are there new tools I am missing? I know GLUT wasnt really designed for full featured 3d applications but for what im going to be doing it will more than suffice, I just dont want to be oblivious to any new developments I may have missed.

Thanks!

-Lokken

T101
07-30-2008, 08:48 AM
GLUT takes care of opening the windows and acting upon input, so it does not need to be updated often. You still use normal GL calls for the fancy stuff (VBOs, shaders etc).
If GLUT supports opening windows with multisample support (I don't use GLUT myself), I doubt it needs to be updated.

dletozeun
07-30-2008, 08:57 AM
If you want something that is updated more often, use freeglut, its API is the GLUT one and it is still maintained and has fixed some GLUT bugs.

Z-Knight
07-30-2008, 09:09 AM
Use JOGL to be true cross-platform. Mixed with Swing buttons, etc you can make nice apps. And the best part is that JOGL code is almost identical to OPENGL code.

Zengar
07-30-2008, 12:07 PM
And the best part is that JOGL code is almost identical to OPENGL code.

Jogl is not almost identical to OpenGL, jogl *is* OpenGL, but for a different programming language (Java).

Lokken, if you want to write some small apps or demos, use GLFW or (free)GLUT. If you have a larger application, write your system-dependent part yourself.

Z-Knight
07-30-2008, 01:29 PM
And the best part is that JOGL code is almost identical to OPENGL code.

Jogl is not almost identical to OpenGL, jogl *is* OpenGL, but for a different programming language (Java).

Lokken, if you want to write some small apps or demos, use GLFW or (free)GLUT. If you have a larger application, write your system-dependent part yourself.


I don't want to argue semantics but that is not exactly true. There are several concepts of OpenGL that are currently either not defined in JOGL or are only placeholders. In addition, the creation of an OpenGL program is different than a JOGL program...I'm referring to how JOGL use the JAVA language and hence it has different conventions for declaring a JOGL instance, etc or the use of listeners for mouse/keyboard/etc interactions. So those part are not directly transferred over from OpenGL the same way. Yes, the basic calls to various routines are nearly identical though I could even point out several that are different because they have additional parameters that OpenGL does not.

So I stand by my comment that they are not identical but are almost identical.

I would still recommend JOGL with Swing over any other OpenGL implementation if you are interested in making applications with a user interface (buttons, etc)...you can use GLUI if you tweak it yourself or use Tcl/Tk or Python but I personally don't like to mix and match like that...just my preference.

dletozeun
07-30-2008, 01:46 PM
Z-knight, actually, Opengl itself draws nothing, has no knowlegde of inputs and outputs and this make its portability. This knowledge is a added with some tookit like GLUT; whereas JOGL encapsulates all this stuff through some specilized java class, as far as I know.

There is also Qt to build user interface with opengl in a portable way.

Z-Knight
07-30-2008, 02:37 PM
good point...you are correct that GLUT serves as the interface, much like JAVA does to OpenGL.

The main aspect of portability that I prefer with JAVA is that I can use the same development environment on a majority of the major platforms: MAC, Windows, Linux and once I compile my code I can use that code on all of the platforms without having to make any platform specific designs within my code as I would with OpenGL and any user interfaces that exist for it. The convenience is what I like.

Zengar
07-30-2008, 04:20 PM
Z-Knight, you seem to confuse some things here... OpenGL is an API, not an implementation, it defines semantics and syntax of 3D rendering. It is independent of programming language and windowing system. JOGL is simply a library that accesses the OpenGL API from java (and not an OpenGL implementation!), providing some Java-specific wrappers. But the syntax and semantics used by any OpenGL applications are the same, no matter if they are written in java, c, python, perl or haskell, just because the API is strictly defined. There is no doubt tht Java is very portable, but it also goes beyond any discussion that it accesses the API implementation on a particular platform (like win32, mac or linux) using a wrapper library: in this case Jogl (or some other one, there are more to choose from). And if you add some convenient syntactical sugar to make programming more easier, well, it doesn't change the API.

Z-Knight
07-31-2008, 08:34 AM
Z-Knight, you seem to confuse some things here... OpenGL is an API, not an implementation, it defines semantics and syntax of 3D rendering. It is independent of programming language and windowing system. JOGL is simply a library that accesses the OpenGL API from java (and not an OpenGL implementation!), providing some Java-specific wrappers. But the syntax and semantics used by any OpenGL applications are the same, no matter if they are written in java, c, python, perl or haskell, just because the API is strictly defined. There is no doubt tht Java is very portable, but it also goes beyond any discussion that it accesses the API implementation on a particular platform (like win32, mac or linux) using a wrapper library: in this case Jogl (or some other one, there are more to choose from). And if you add some convenient syntactical sugar to make programming more easier, well, it doesn't change the API.

No I'm not confusing things... I know JOGL uses OpenGL and it sits on top, I'm well aware of this. That was never my issue and I think you are confusing what I mean. When I say that JOGL code is NOT exactly the same as OpenGL I am simply saying that the actual code that you write in JOGL will NOT be the same as the OpenGL one. And I'm not referring to the fact that in JOGL you have to define a GL instance and all of the calls like glTranslated(), etc require to be prefixed with the GL instance as in gl.glTranslated()...I'm saying that many calls have additional parameters in JOGL that are not present in OpenGL. For example, glLightfv() takes 3 parameters in OpenGL but 4 in JOGL. This means that your OpenGL code will require extra care to convert to JOGL but that conversion is relatively simply. SO, as I said before, the code is "nearly" identical but not exactly and that was my entire point...and then everyone apparently thought I was saying that JOGL is different from OpenGL much like DirectX is different....to be clear, NO that is not what I intended.