I am developing a project using modern OpenGL through OpenTK. I want to use Gwen dot net GUI library in my project. Unfortunately, Gwen dot net uses old OpenGL for its widget rendering. I have tried merging both modern OpenGL and Gwen dot net and so far, have been unsuccessfull. Before I waste my time debugging my code, I would like to know, is it possible to merge both old OpenGL and modern OpenGL?
If you create a compatibility profile context, it should support all all legacy functionality. From OpenGL 4.3 compatibility spec, 1.2.4:
Older generations of graphics hardware were not programmable using shaders,
although they were configurable by setting state controlling specific details of their
operation. The compatibility profile of OpenGL continues to support the legacy
OpenGL commands developed for such fixed-function hardware, although they
are typically implemented by writing shaders which reproduce the operation of
such hardware. Fixed-function OpenGL commands and operations are described
as alternative interfaces following descriptions of the corresponding shader stages.
These days mixing old style and new style OpenGL is best avoided. On MS Windows and Linux you can, but weird stuff tends to happen.
For MacOS, Apple have declared that they're not going to support compatibility contexts at all, so you can't mix.
Since you're stuck with the GUI toolkit, I would try to isolate all your new style OpenGL code in a separate context and render to an offscreen target, then blit that to the main display.
OpenTK render for GWEN is a separate class. Just rewrite it modern way. There's no problem with that.
I'm just trying to get a grasp on OpenGL that I can build from, so all I'm looking for is something basic to build windows etc. One of the things I'm noticing as I read tutorials and such is that it seems like a lot of the information is out of date - for example a lot of tutorials (many of which were written a number of years ago) refer to using GLUT, but GLUT hasn't been updated in over 10 years - eons in computer time. What do people use nowadays? I know freeglut is out there, but there isn't a whole lot of info on it - how to get it set up, etc... what do most people do? What's the simplest way to get a simple window system up and running so that I can start playing around with OpenGL?
You should first understand the difference between Legacy OpenGL which is a fixed function pipeline, and modern OpenGL which is a completely shader driven pipeline. Most online tutorials teach legacy OpenGL because it is easy to get started and has been around a long time. Legacy still works fine, but you probably want to get into modern OpenGL (at least version 3.0). Modern OpenGL is cleaner, and more flexible, but also harder to get started in, and therefore has fewer tutorials. It requires a lot more setup and libraries by the user and there is no "one way" to do things making it difficult to structure a quick tutorial around.
Some good resources for learning modern OpenGL are:
http://www.opengl-tutorial.org/ - Great lessons written by Stack overflow user.
http://opengles-book.com/ - OpenGL ES 2.0 programming guide - OpenGL ES 2.0 is directly compatible with OpenGL 3.0, so it works great for getting started. Even if you don't want to buy the book you can download sample code which is excellent.
http://www.swiftless.com/ - Swiftless Tutorials - Great OpenGL 4.0 and WebGL tutorials.
To your main question I know of 3 main libraries for cross platform OpenGL window creation. I would recommend GLFW for a cross platform tool kit. You could also learn a lot by creating a context directly in your respective platform (WGL window creation on Windows, Cocoa on MacOS X etc) rather than using a windowing library.
GLUT - you are correct it has not been updated in years. It still works, especially for legacy OpenGL, but I'm not sure how good the modern support is.
SDL - Also old and legacy OpenGL (I think this is resolved with 2.0), and includes a lot more cross platform features beyond OpenGL like threads. It is a pretty heavyweight library but I still prefer it over GLUT. A modern, updated SDL was in the works, but i haven't seen anything for it in a long time, possibly discontinued... It also has a nasty license associated with it so watch out for that.
GLFW - My personal favorite. It is clean and lightweight like GLUT and allows you to target modern OpenGL contexts on most major desktop platforms.
I am aware that there were similar questions in past few years, but after doing some researches I still can't decide where from and what should I learn.
I would also like to see your current, actual view on modern OpenGL programming with more C++ OOP and shader approach. And get sure that my actual understanding on some things is valid.
So... currently we have OpenGL 4.2 out, which as I read somewhere requires dx11 hardware
(what does it mean?) and set of 'side' libraries, to for example create window.
There is the most common GLUT, which I extremely hate. One of main reason are function calls, which doesn't allow freedom in the way how we create main loop. As some people were telling, it was not meant for games.
There is also GLFW, which actually is quite nice and straight-forward to me. For some reason people use it with GLUT. ( which provides not only window initialisation, but also other utilities? )
And there is also SFML and SDL ( SDL < SFML imo ), whereas both of them sometimes need strange approach to work with OGL and in some cases are not really fast.
And we have also GLEW, which is extension loading utility... wait... isn't GLUT/GLFW already an extension? Is there any reason to use it, like are there any really important extensions to get interested with?
Untill now we have window creation (and some utilities), but... OGL doesn't take care of loading textures, neither 3D models. How many other libs do I need?
Let's mention education part now. There is (in)famous NeHe tutorial. Written in C with use of WinApi, with extremely unclear code and outdated solutions, yet still the most popular one. Some stuff like Red Book can be found, which are related to versions like 2.x or 3.x, however there are just few (and unfinished) tutorials mentioning 4.x.
What to go with?
So... currently we have OpenGL 4.2 out, which as I read somewhere requires dx11 hardware (what does it mean?) and set of 'side' libraries, to for example create window.
DX11 hardware is... hardware that has "supports DirectX 11" written on the side of the box. I'm not sure what it is you're asking here; are you unclear on what Direct3D is, what D3D 11 is, or what separates D3D 11 from prior versions?
FYI: D3D is a Windows-only alternative to using OpenGL to access rendering hardware. Version 11 is just the most recent version of the API. And D3D11 adds a few new things compared to D3D10, but nothing much that a beginner would need.
OpenGL is a specification that describes a certain interface for graphics operations. How this interface is created is not part of OpenGL. Therefore, every platform has its own way for creating an OpenGL context. Windows uses the Win32 API with WGL. X-Windows uses the X-Windows API with GLX functions. And so forth.
Libraries like GLUT, GLFW, etc are libraries that abstract all of these differences. They create and manage an OpenGL window for you, so that you don't have to dirty your code with platform-specific details. You do not have to use any of them.
Granted, if you're interested in learning OpenGL, it's best to avoid dealing with platform-specific minutae like how to take care of a HWND and such.
And we have also GLEW, which is extension loading utility... wait... isn't GLUT/GLFW already an extension? Is there any reason to use it, like are there any really important extensions to get interested with?
This is another misunderstanding. GLUT is a library, not an extension. An OpenGL extension is part of OpenGL. See, OpenGL is just a specification, a document. The implementation of OpenGL that you're currently using implements the OpenGL graphics system, but it may also implement a number of extensions to that graphics system.
GLUT is not part of OpenGL; it's just a library. The job of GLUT is to create and manage an OpenGL window. GLEW is also a library, which is used for loading OpenGL functions. It's not the only alternative, but it is a popular one.
Untill now we have window creation (and some utilities), but... OGL doesn't take care of loading textures, neither 3D models. How many other libs do I need?
OpenGL is not a game engine. It is a graphics system, designed for interfacing with dedicated graphics hardware. This job has nothing to do with things like loading anything from any kind of file. Yes, making a game requires this, but as previously stated, OpenGL is not a game engine.
If you need to load a file format to do something you wish to do, then you will need to either write code to do the loading (and format adjustment needed to interface with GL) or download a library that does it for you. The OpenGL Wiki maintains a pretty good list of tools for different tasks.
There is (in)famous NeHe tutorial. Written in C with use of WinApi, with extremely unclear code and outdated solutions, yet still the most popular one. Some stuff like Red Book can be found, which are related to versions like 2.x or 3.x, however there are just few (and unfinished) tutorials mentioning 4.x.
What to go with?
The OpenGL Wiki maintains a list of online materials for learning OpenGL stuff, both old-school and more modern.
WARNING: Shameless Self-Promotion Follows!
My tutorials on learning graphics are pretty good, with many sections and is still actively being worked on. It doesn't teach any OpenGL 4.x-specific functionality, but OpenGL 3.3 is completely compatible with 4.2. All of those programs will run just fine on 4.x hardware.
If you are writing a game, I would avoid things like GLUT, and write your own wrappers that will make the most sense for your game rendering architecture.
I would also avoid OpenGL 4.2 at this point, unless you only want to target specific hardware on specific platforms, because support is minimal. i.e., the latest version of Mac OSX Lion just added support for OpenGL 3.2.
For the most comprehensive coverage of machines made in the last few years, build your framework around OpenGL 2.1 and add additional support for newer OpenGL features where they make sense. The overall design should be the same. If you're only interested in targeting "current" machines, i.e. machines from late 2011 and forward, build your framework around OpenGL 3. Only the newest hardware supports 4.2, and only on Windows and some Linux. If you're interested in targeting mobile devices and consoles, use OpenGL ES 2.0.
GLEW loads and manages OpenGL Extensions, which are hardware extensions from different vendors, as opposed to GLUT which is a toolkit for building OpenGL applications, completely different things. I would highly recommend using GLEW, as it will provide a clean mechanism for determining which features are available on the hardware it is being run on, and will free you from the task of having to manually assign function pointers to the appropriate functions.
OpenGL SuperBible is a pretty good book, also check OpenGL Shading Language. Everything you do with modern OpenGL is going to involve the use of shaders - no more fixed functionality - so your biggest challenge is going to be understanding GLSL and how the shader pipelines work.
I'm currently learning modern OpenGL as well. I've also had hard time finding good resources, but here's what I've discovered so far.
I searched for a good book and ended up with OpenGL ES 2.0 Programming Guide, which I think is the best choice for learning modern OpenGL right now. Yes, the book is about OpenGL ES, but don't let that scare you. The good thing about OpenGL ES 2.0 is that all the slow parts of the API have been removed so you don't get any bad habits from learning it while it's still very close to desktop OpenGL otherwise, with only a few features missing, which I think you can learn rather easily after you've mastered OpenGL ES 2.0.
On the other hand, you don't have the mess with windowing libraries etc. that you have with desktop OpenGL and so the book on OpenGL ES won't help you there. I think it's very subjective which libraries to use, but so far I've managed fine with SDL, ImageMagick and Open Asset Import Library.
Now, the book has been a good help, but apart from that, there's also a nice collection of tutorials teaching modern OpenGL from ground up at OpenGL development on Linux. (I think it's valid on other OSes the name nevertheless.) The book, the tutorials and a glance or two every now and then to the Orange Book have been enough in getting me understand the basics of modern OpenGL. Note that I'm still not a master in the area, but it's definitely got me started.
I agree that it's king of hard to get in to OpenGL these days when all the tutorials and examples use outdated project files, boken links etc, and if you ask for help you are just directed to those same old tutorials.
I was really confused with the NeHe tutorials at first, but when I got a little better understanding of C, compiling libraries on UNIX and other basic stuff, it all fell into place.
As far as texture loading, I can recommend SOIL:
http://www.lonesock.net/soil.html
I'm not sure but I recall I had trouble compiling it correctly, but that may have been my low experience at the time. Give me a shout if you run into trouble!
Another usefull tip is to get a Linux VM running and then you can download the NeHe Linux example code and compile it out of the box. I think you just need GLUT for it to work.
I also prefer GLFW before GLUT, mainly because GLUT isn't maintained actively.
Good luck!
The major point of modern OpenGL is tesselation and new type of shader programs so i would like to recommend to start from a standalone tutorial on OpenGL 4 tesselation, i.e: http://prideout.net/blog/?p=48
After manuals and tutorials a good follow-up is to take a look at the open-source engines out there that are based on top of "new" OpenGL 3/4. As one of the developers, I would point at Linderdaum Engine.
"Modern OpenGL programming with more C++ OOP and shader approach" makes me mention Qt. It hasn't been mentioned yet but Qt is a library that is worth learning and is the easiest way to write cross platform C++ apps. I also found it the easiest way to learn OpenGL in general since it easily handles the initialization and hardware specific code for you. Qt has it's own math libraries as well so all you need to get started with OpenGL is Qt. VPlay is a library that uses Qt to help people make games easily so there are obviously some people using Qt to make games as well.
For a short introduction to Qt and OpenGL see my post here.
I will mention that since Qt abstracts some OpenGL code, if you are trying to use the Qt wrappers, the API is slightly different than just OpenGL (although arguably simpler).
As for my vote for good tutorials or book check out Anton's OpenGL tutorials and Swiftless tutorials. Anton's ebook on Amazon is also rated higher than any other OpenGL published resource I have seen so far (and far cheaper).
I need to port a legacy app which uses deprecated OpenGL code (glRotate etc.) into shaders. However, OpenGL has been changing rapidly lately and I'd like to avoid learning an approach that is already marked as deprecated. So, is there a modern day OpenGL shaders book, perhaps similar in style to the old "The Cg tutorial" book?
Learning Modern 3D Graphics Programming is rather new and already covers a lot of topics.
The OpenGL SuperBible Fifth Edition covers OpenGL 3.3
I am going to buy a book on OpenGL, but I have a few questions as to what I should be learning.
I am torn between dedicating myself to learn OpenGL 1.x or OpenGL 2.0, because OpenGL ES 2.0 only exists on 3G and beyond, and if I were to develop an app and place it on the app store, I would want everyone with an iphone capable of utilizing the app.
Also, I want to experiment with desktop OpenGL.
So, my question is as follows:
simply put, what should I be learning? If I learn Desktop OpenGL, would this be easily transferable to OpenGL ES? Like if I knew OpenGL in c/c++, would I also know OpenGL ES, what major differences are there?
Also, would you recommend I learn both 1.x and 2.0, for the specific reason I stated previously, that I would want all iphone owners capable of utilizing my app, not just 3G and beyond?
Lastly, are there any books you would recommend? I really enjoy the style of this tutorial. It's very easy to follow, shows a lot of code, and explains every line of code carefully.
I faced the same question myself, and my decision was to go with OpenGL ES 2.0. Firstly because the great majority of iOS devices in use today can run it (iPhone 3GS or better). Secondly because the future of OpenGL is shaders because they offer so much more flexibility than the fixed pipeline of ES 1.
That said, I will add that using shaders is NOT easy. It takes a lot more effort to set everything up in ES 2 than it does in ES 1. Many more things can go wrong, with many more times that you'll be looking at your program creating nothing but a blank screen leaving you scratching your head and wondering why.
Once you get the basics, though, ES 2 isn't really all that bad. It's just a pretty steep learning curve.
As for the desktop vs ES question, I would recommend learning ES. It's a very nice & functional subset of OpenGL, and will allow you to write programs that run on many more platforms. Using full OpenGL might get you into trouble if you want to port your code to ES, since there are aspects of it that don't translate.
To get you started with OpenGL ES 2, I highly recommend this tutorial and this book.
OpenGL ES 1.1 uses much of the old deprecated functionality, whereas OpenGL ES 2.0 uses the modern shader-only vertex array/buffer approach, being more future ready. If you learn desktop GL, you won't have too much difficulties using OpenGL ES, as they are quite similar.
If you really want to use the old-style OpenGL ES 1.1, then I suggest you to learn desktop OpenGL 2.0 (best done with the "OpenGL Programming Guide"/"Red Book") which will teach you the old immediate API along with the modern vertex array/buffer functionality and (in conjunction with the book "OpenGL Shading Language"/"Orange Book") also the use of programmable shaders. So this way you will be ready to use old-style (1/(2)) and modern ((2)/3/4) desktop GL along with OpenGL ES 1.1 and 2.0.
But if you want to start directly with the new and modern way of programming OpenGL (which might be advisable, although the old-style is a valuable experience), then I would rather suggest to use the newest edition of the "OpenGL SuperBible", which will teach you modern-style ((2)/3/4) desktop OpenGL without the old deprecated functionality. But then much OpenGL ES 1.1 code won't be of much use to you (although you will surely understand its principles). Although I really appreciate my knowledge of the fixed-function old-style OpenGL, I would rather suggest beginners to start with modern OpenGL right-away, even if it might be a bit harder to learn for a beginner, as this is the way to do hardware-accelerated real-time graphics today (and tomorrow).
But what really matters is, that in contrast to learning the API by mind you should understand the underlying principles and the principles of 3d graphics in general. Then you won't have much difficulty switching to other APIs, like Direct3D, anyway.