View Full Version : is opengl syntax on linux is the same on windows
03-10-2008, 09:37 PM
This is the first time for me working with opengl in linux any way i managed to break through and using this tutorial coned (http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/ogladv/tut1)
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.
03-11-2008, 01:41 AM
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?
03-11-2008, 02:53 AM
The NeHe (http://nehe.gamedev.net/) tutorials are a great place to start. They also provide source code for windows/linux/mac.
03-17-2008, 12:09 PM
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.
04-16-2008, 01:47 PM
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.
04-18-2008, 12:37 PM
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?
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 (http://freeglut.sourceforge.net/) and it takes care of the OS-specific piece for you so you can concentrate on GL.
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 (http://freeglut.sourceforge.net/) 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.
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.