Though I know gluCylinder is somewhat old(and glu too) and glut is still there(through freeglut) but I saw those two and wondering what's the difference ? besides that gluCylinder requires that you define a Quadric, and what's faster ? .
The original GLUT did not have a glutSolidCylinder() function. That appears to be something FreeGLUT added.
gluCylinder
Pros:
Supports texture coordinate generation.
Cons:
GLU is old. I mean, really really old. The spec was last updated in 1998, and I suspect that the available implementations are just as old. This means that it's using immediate mode rendering (glBegin/glEnd) style, which is inefficient, and not available anymore in modern versions of OpenGL.
GLU support is starting to disappear from some platforms.
glutSolidCylinder
Pros:
As long as you're comfortable with using FreeGLUT, it's still supported, with source code available.
The FreeGLUT version seems to be able to use moderately modern rendering methods (VBOs), based on browsing the source code.
Cons:
Does not generate texture coordinates. This was definitely not supported for most solids in GLUT, and as far as I can tell is still not supported for cylinders in FreeGLUT.
self-made
Rendering a cylinder is very easy. Personally, I would just write it myself.
I agree with #Reto. I prefer implementing a cylinder myself too. Specially because it has a simple parametric form (a stack of circles). Interestingly, I was helping somebody else to dray cylinders. Maybe you find that interesting too:
Make a line thicker in 3D?
I am using Open GL 3.0
I am trying to update this example to modern OpenGL :
http://qt-project.org/doc/qt-4.8/opengl-hellogl-es.html
I am also looking at this example:
http://qt-project.org/doc/qt-5/qtopengl-cube-example.html
I am looking at the OpenGL ES examples, because they compiled and rendered easily on my machine, and the OpenGL ES 2 example uses some programmable pipelining.
I want to use the pipeline functions referenced in this tutorial:
http://www.opengl-tutorial.org/beginners-tutorials/tutorial-2-the-first-triangle/
For instance glGenBuffers()
However, this does not seem to come up in open Qt. If I try to compile a program that uses glGenBuffers, or glBindBuffer.
Why can I use some Open GL functions but not others?
Looking at the second example (OpenGL ES2) There is a type "QGLShaderProgram" which seems to wrap some of the shading functions, but I am at loss as to how to follow even a simple open GL tutorial with full access to the rendering functions.
For instance, the openGL tutorial references at least half a dozen functions I can't seem to use. I would be fine with this, but I can't seem to find where the Qt folks have explained what functions are wrapped, or covered up, or are absent.
Could I be missing an include or something?
I am including #QGLWidget and #QtOpenGL
See below for my answer to your question. However, it seems likely you are looking for a simpler OpenGL example with Qt like the triangle one you linked to. I also made an introductory post here where you can learn the basics of how Qt and OpenGL work together before you start an example.
First of all use Qt 5.5 now. It is configured with the -opengl dynamic option by default which might solve your problem. If you don't have -opengl desktop configure option set in your pre 5.5 build of Qt then you won't have access to modern OpenGL functions other than the subset of OpenGL ES 2 that is supported by all the platforms Qt supports.
Second, don't use the QGL* functions or classes as they are old/deprecated now. They were replaced by the QOpenGL* functions and classes.
As for includes, you will need a QOpenGLFunctions or QOpenGLFunctions_3_0 to know for sure which set of functions you are getting. You will also need any other classes like QOpenGLBuffer QOpenGLVertexArrayObject... or just include QtGui as that is where all the OpenGL functions and classes are now.
Why some GL Image functions requires using GL Load to initialize OpenGL context ? Is it possible to fully utilize GL Image using GLEW to initialize OpenGL context ?
If you are talking about the Unofficial SDK's GL Image system, the answer is no. The SDK is intended to be a package deal; if you're using one part of it, you ought to be using the rest. After all, if you can build and include GL Image, you could also use GL Load, since they're bundled together.
And GL Load does exactly what GLEW does; it's better in many ways, as it doesn't require that "experimental" thing to make it work on core contexts. Through the C interface, you could just swap out all of the #include <GL/glew.h> parts with #include <glload/gl_[Insert Version Here].h>. You wouldn't need to modify any code other than that (as well as the initialization code of course).
That being said, you ought to be able to use GL Load and GLEW simultaneously, as long as:
You initialize both of them. This means calling glewInit and LoadFunctions after creating the OpenGL context. Their variables shouldn't interact or anything.
You never try to include both of their non-system headers in the same file. GL Image's TextureGenerator.h is actually designed specifically to not require the inclusion of OpenGL headers (that is, it doesn't directly use GL types like GLint or GLenum).
It's obviously wasteful, as they do the exact same job. But it ought to work.
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).
When using SDL 1.2, what do I need to include to be able to use OpenGL Vertex Buffer Objects (VBOs)?
Currently, I only include SDL.h, SDL_opengl.h, SDL_image.h
And get the errors:
glGenBuffersARB, glBindBufferARB, glBufferDataARB not declared in this scope
If you want to use SDL_opengl.h define GL_GLEXT_PROTOTYPES before including it.
#define GL_GLEXT_PROTOTYPES
#include "SDL.h"
#include "SDL_opengl.h"
I may or might not work. If you want to do it the "proper" way, use something like glew.
You should include <GL/gl.h> and <GL/glext.h>. Sometimes OpenGl extension functions are not directly available and must be loaded using SDL_GL_GetProcAddress (this returns the function pointer or 0 if extension is not available). You may be interested to have a look to libglew which loads the extension functions.
Here is how you may do it (if not using glew):
extern PFNGLGENBUFFERSARBPROC glGenBuffers; // Function pointer declaration, in a header file.
// Function pointer initialization
glGenBuffers = 0;
// Get the function (you should have checked that extension is available)
glGenBuffers = (PFNGLGENBUFFERSARBPROC)SDL_GL_GetProcAddress("glGenBuffersARB");
It is possible to get the underdevelopment 1.3 version of SDL to open a OpenGL 3.2 context with a bit of work.
It's also worth checking out SFML, it's similar to SDL but is hardware accelerated for the 2D stuff, object orientated C++ and is much easier to use. OpenGL is particularly simple to use with it. Once again it's the development 2.0 version that supports OpenGL 3.2 contexts (although it's close to being released.)
You will probably need to use the non-ARB versions with the above.
I find the SDL_opengl.h file to be fairly useless. Personally, I recommend using GLEW or GLee. GLee is easier to add to your project but stops at OpenGL 3.0 (usually fine in SDL apps since SDL only enables an OpenGL 2.1 context). GLEW requires just a bit more work but enables stuff up through OpenGL 4.
I ran into this same problem regarding VBOs in SDL.