Is opengl syntax on linux is the same on windows

This is the first time for me working with opengl in linux any way i managed to break through and using this tutorial coned
and i tested some of the codes from the tutorials on this site and every thing is going ok but when i try an opengl sample code made for windows it refuses to compile so my question is

is there is a huge syntax difference between writing opengl on linux and windows?and why?
if there is any links tutorials books it will be great.
Thanks

There is no difference regarding to the OpenGL spec, but… Each platform OpenGL is implemented on has it’s own platform specific bindings with which you can open rendering contexes to draw upon.

On Windows, this is called WGL (Windows OpenGL) and on Linux this is GLX (OpenGL for X Windows system). So these samples you were talking about probably used WGL to initialize all the graphics stuff like opening a window. There are many cross platform libraries that allows you to do this platform dependent stuff in platform independent manner. One of them is SDL, other is glut.

Hope this settles down some things. I don’t know any links into tutorials, maybe some other could?

The NeHe tutorials are a great place to start. They also provide source code for windows/linux/mac.

If you’re gonna use glut consider using freeglut instead (http://freeglut.sourceforge.net/) - it’s a live clone of glut that seems to be abandoned by its author.

I have always used GLFW for cross platform OpenGL, it is simple and to the point. License allows you maximum freedom and the manuals are clear and easy to read. Last I checked, it was still fully supported by the author… but that was quite a while ago.

Briefly, no. 99% of your GL code is exactly the same. What’s different is the tiny platform-specific part up-front where you ask the OS to “create me a window to draw on and a context to draw on it with”.

For Windows, you use wgl… (wiggle) functions for this part. For Linux/UNIX, you use glX… functions. For Apple, you use agl… functions.

If you’re just starting out, just use freeglut and it takes care of the OS-specific piece for you so you can concentrate on GL.

and why?

OpenGL aims to be portable across multiple platforms, and window creation and management is very different between platforms. Consequently, the window-system specific part of the API (wgl/glX/agl/etc.) is tied to the platform and its specific capabilities so you can make the most of the capabilities on each platform.

One you get your window/context created, the rest of your GL code is pretty much the same across platforms.

The opposite approach would have been to take the intersection of the capabilities across all platforms (Linux/Apple/MSWin) and provide access only to the common subset of features (lowest-common denominator) via a general API that’s the same between platforms. That’s the approach freeglut takes, essentially providing an abstraction layer on top of glX/wgl/agl. In practice, it works fine for test programs, tutorials, and little demos, but not for complex applications which often want platform-specific control of window functions.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.