What is difference between OpenGL programing with GLUT and Without GLUT - opengl

I want to start developing graphic programing using OpenGl
To kick start I am following OpenGL
I came across programing with GLUT and without GLUT but as being new to OpenGL in am even more confuse how to go with it?

GLUT is the OpenGL Utility Toolkit
It does stuff like this:
Multiple windows for OpenGL rendering
Callback driven event processing
Sophisticated input devices
An 'idle' routine and timers
A simple, cascading pop-up menu facility
Utility routines to generate various solid and wire frame objects
Support for bitmap and stroke fonts
Miscellaneous window management functions
You can find more about it here.

GLUT was designed as a lib for simple demos and tutorials. Maybe one cannot create full AAA game title using it... but for learning/teaching it is a great tool.
GLUT is very old right now, so look for FreeGlut which is an alternative that handles not only basic GLUT features but also gives some more advanced features: like fullscreen game mode, etc.
http://freeglut.sourceforge.net/

Related

Is there a performance difference in using an OpenGL window like GLFW or a surrounding window like GTK or SDL?

vlc has an impressive example showing how to integrate with gtk:
https://git.videolan.org/?p=vlc.git;a=blob;f=doc/libvlc/gtk_player.c
but we are using glfw and C++. If we were to create a wrapper window using a windowing toolkit like gtk, is there any performance penalty in terms of the OpenGL operating within it?
Is it possible to open a video window within the GTKGL component, or does OpenGL interfere with video even if it is not rendering?
If you pass the window handle to libvlc, I don't see why there would be performance differences.

Query about opengl, glut, glew

Is there not a simple sdk for opengl why there are glut or glew and what are the written using? Which one should I use? There are so many frameworks out there that it is so confusing? Why there isn't just one sdk for opengl?
why there are glut or glew and what are the written using?
GLUT, GLFW and similar frameworks exist, because the system level interfaces to create a window and a OpenGL context are extremely versatile in what they can do, but it also takes a lot of code, just to create a window and them some more to create the OpenGL context. …and then some lots more of code to also do things like UI event management and so on.
These system level APIs are that verbose, because on a system level, you don't want to pin down what you can and can not do with these APIs.
So the three calls
glutInitDisplayMode(…);
glutCreateWindow(…);
glutMainLoop();
encapsulate about 1.5k lines of code dealing with just the system. But then with GLUT you don't get nice buttons, menu bars and the likes. For that you'd use a different framework, like Qt, which has even more code, but uses the same system level APIs as GLUT does. Same goes for GLFW and so on.
GLEW we have, because OpenGL can be extended and the system level interface for extending it is again down for minimalism and flexibility.
Why there isn't just one sdk for opengl?
Because in the end OpenGL is a system level API and the "SDK" comes ready-to-use with your regular system default compiler.
If you want to, you can create OpenGL programs without GLEW, GLUT and so on. But it is tedious.

How to use OpenGL in a project that has no main function (e.g. MFC / Qt), and without using GLUT?

I mainly follow the Red Book 7th edition to learn OpenGL which is based on glut. Other references such as the blue OpenGL bible and online tutorials are based on glut as well. And they all need to put codes in a main function. I wonder how to use OpenGL in a project that has no main function, such as a MFC or Qt project, without using glut?
The basic answer is that GLUT makes life much easier for you than rolling your own games loop that looks after updates and monitors event listeners. I wrote a game some years ago using OpenGL that avoided GLUT - see here.
It put me through a lot of headache having to employ DirectInput for instance to handle keyboard events for instance, but I did have a lot more control over everything.
As a last note, GLUT is very old and lacks some very important functionality that allows you to exit the game loop cleanly. FreeGLUT is about as good as it gets if you really want to focus on learning OpenGL without all the other worrisome stuff I just described.
Regarding Qt specifics, that might help you out.

Alternative to GLUT

GLUT is a very old framework for OpenGL, and there seems to be a lot of negative attitude towards it. I hear SDL is an alternative, though to my understanding it does not handle the 3d component of OpenGL. What is a good option (which preferably has good documentation so it is easily learnable) that can do what GLUT does and provide more functionality, eg. to make a complete 3d game? I prefer not to use pre-made game engines, I'd much rather build my own code from scratch.
orginal GLUT is very old and I would not recommend it. But the new version of it: http://freeglut.sourceforge.net/ is quite interesting framework. Is is as simple as GLUT but adds more features: mouse scroll, new geometry objects, etc, etc.
last version of this library is from January 2012
here is a useful link with several frameworks for opengl: http://www.opengl.org/resources/libraries/windowtoolkits/
If you want to make w "whole" project I suggest combining more libraries:
http://www.opengl.org/wiki/Related_toolkits_and_APIs#Context.2FWindow_Toolkits
http://glsdk.sourceforge.net/docs/html/index.html
SOIL for texture loading
If you are to use modern OpenGL GLFW is the best option out there to manage context, window creation, user input. The lib is very active with constant new releases.
Just wanted to add that my consideration to move from GLUT and from FREEGLUT was the lack of ability to define color, stencil, depth bits and MSAA samples for created context. GLFW allows you doing this.
SDL can create windows with OpenGL context (see the SDL_WINDOW_OPENGL window flag), so you can use the OpenGL functions. So can SFML, and probably Allegro too.
I personally recommend SFML, especially version 2 (which is in development), as I find it very easy to set-up and start using, both generally and for OpenGL.

what's the relationship between SDL and OpenGL?

Anyone can tell me what's the relationship between SDL library and OpenGL library?
OpenGL is a graphics library that doesn't provide any feature in addition to drawing. It is neither able to embed an OpenGL view inside a window of any modern OS.
That's where SDL comes right into place and provides all the required functions needed to create an OpenGL window in a cross-platform manner in which you then draw by using OpenGL library itself. SDL also has a lot of facilities that are almost always necessary when working with games or graphical applications like timers, management of keyboard and mouse and whatever.
In any case you could use any other OpenGL wrapper like GLUT library or GLFW to achieve the same thing: creating an OpenGL view inside an application.