Is there anyway to use the OpenGl API directly in Qt 5? - c++

We're using Qt 5.01. We're supposed to use OpenGl to write a visualizer. Even a simple function to draw a triangle returns the error: glBegin() not found, glVertex2f() not found/defined or something.
I learned this is because Qt 5 doesn't come with the regular OpenGl API but it has its own QOpenGl framework.
Is there anyway to eschew the QOpenGl framework and work with OpenGl directly?
I'm on a Windows system using MinGW if that's relevant.

Related

Don’t use QT OpenGL anymore?

I am new to C++, OpenGL, and QT. In fact, I’ve never even touched QT. The reason for this is the following; I’ve made games in a few other languages in the past (mostly C# with Unity). Now I want to get into games with c++. However, I want to use pure C++, not even Unreal (maybe one day ), for games. To do this I know that for graphics I should almost definitely be using OpenGL (which I’m currently learning). I also am going to need to make GUIs. When I looked up what to use, it looked like the best option would probably be QT. This means I need QT to work with OpenGL. So again I looked it up. I found QT OpenGL on this post: How to work with OpenGL and QT?. When I looked up Qt OpenGL (https://doc.qt.io/qt-5/qtopengl-index.html) it said:
Warning: This module should not be used anymore for new code. Please use the corresponding OpenGL classes in Qt GUI.
So what is QT GUI?
And, how easy it to use QT with OpenGL?
As the new features of Qt 5.4 point out, the Qt Opengl module has been declared deprecated.
Deprecated features
Qt OpenGL:
The Qt OpenGL module (which contain classes that start with "QGL") is now deprecated in favor of the Qt GUI module (which contain
classes that start with "QOpenGL"). QGLWidget can now be replaced by
QOpenGLWidget.
That does not imply that:
the module has been removed but at any time Qt could remove it without notice.
You cannot use opengl in Qt, only you should not use the QGLX classes that belong to the Qt OpenGL package but you must use the QOpenGLX classes of the Qt Gui module, for example replace QGLWidget with QOpenGLWidget.
You can also find several examples here.
Qt is probably not the right tool for you. For one you want to use GLFW, which would cross into the turf of Qt and vice versa. A much better choice for game UI stuff is Dear ImGUI which is far better suited for the needs of game development.

Use Unity3D as GUI to a Win32 c++ with OpenGL app

I have a Win32 app written in C++ that uses a lot of OpenGL code.
Right now we render all the GUI using OpenGL code, but I think using Unity3D as an interface layer would really simple things for us:
Is it possible to use our own c++ classes with OpenGL under a Unity3D app (in Windows?)
You should consider an alternative UI library that is capable of rendering directly to an OpenGL texture without imposing the burden of integrating with the entire Unity system.
I've played with QML, CEGUI, or libRocket.
QML is the most well designed of these three, although it's support for rendering directly to OpenGL textures is relatively recent, so there are some minor gotchas, but in general it's easy to use and the limitations can be worked around.

Embedding a GLFW window inside windows forms

I'm making an editor for 3d worlds in opengl using the windows forms UI. I'm developing on visual studio 2012 express and i would like to embed a GLFW window/context inside a windows form. just like done in this tutorial http://www.codeproject.com/Articles/16051/Creating-an-OpenGL-view-on-a-Windows-Form except working. And with GLFW for opengl context.
Is this possible? should i use Qt instead? and how would i got about doing this? I'm not bound to using windows forms i just need a simple good-looking functional UI for my project.
That are three different frameworks (Windows Forms, GLFW, Qt) which can all do the same thing, i.e. creating a window and an OpenGL context in it.
See here for an easy example how to create a window with OpenGL context with GLFW.
Or see here for the Qt example.
So, you have to choose between one of them. GLFW and Qt have the advantages that your code will also work on MacOSX and on Linux; with some work even on iPhone.
If you want to do the window creation and event handling and other stuff with GLFW but the GUI still with Qt, there is some way to do offline drawing (some ref here or here or here) the Qt widgets and then draw it onto some OpenGL texture. Or you might also be able to directly draw them via OpenGL (not exactly sure).

difference of freeglut vs glew?

I've recently started learning OpenGL (> 3.3) & I've noticed a lot of examples & tutorials use both freeglut & glew, but don't really explain the difference at all. The best description I've found, after googling & reading ad nauseum, has been this OpenGL Related toolkits and APIs but found it lacking. I've even read the tag info on SO.
As someone really new to OpenGL I'm still trying to get a grasp of the different concepts. I've gotten to the stage of creating a basic program that uses glew, create context (on windows, VS2010), & draw really basic shapes, all without the need for explicitly including freeglut. So I don't understand why I would need it.
So my question then is, what's the difference between:
-freeglut
-glew
-(& glfw)
What can one do that the other can't?
The OpenGL Extension Wrangler (GLEW) is used to access the modern OpenGL API functions(version 3.2 up to latest version).If we use an ancient version of OpenGL then we can access the OpenGL functions simply including as #include <GL/gl.h>.But in modern OpenGL, the API functions are determined at run time, not compile time. GLEW will handle the run time loading of the OpenGL API.About GLEW see here
GLFW or freeglut will allow us to create a window, and receive mouse and keyboard input in a cross-platform way. OpenGL does not handle window creation or input, so we have to use these library for handling window, keyboard, mouse, joysticks, input and other purpose.
GLFW and freeglut are alternative for us according to our need we can choose any one but GLEW is different from them which is used for run time loading of the OpenGL API.
I'm using both of them for some work at my university.
GLEW is a "cross-platform open-source C/C++ extension loading library" (from its website), while freeglut is a window manager that replaces the default OpenGL Utility Toolkit (GLUT) library.
So, as you see, both different have different purposes. The point of using freeglut is that it's still maintained, while the default GLUT isn't, so if you want bug fixes and new features you should use it :)

Combine WGL with GLUT for shapes under Windows 7 OpenGL. Missing GLUT INIT?

I'm working with OpenGL using Win32 API. Therefore I'm using wgl (Wiggle). Everything is fine. Except if I want to use some shapes from the FREEGLUT library. For example, the teapot. I was looking at the source code of freeglut, and it seems that when I issue a
glutSolidTeaPot(1.0); ,it exists the program because of the macro: FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidSphere" ); which calls fgerror, which has an exit(1).
Therefore, the symptom that I'm getting is obvious. When I ran the OPENGL program without any GLUT commands (like the teapot) it works great. If I use the teapot, it exits.
It is clear to me, that I'm missing initialization. The question is if I can initialize (and how) glut to be used for the shapes in my wgl context ... If this is not possible, I guess I could create the shapes myself. It is just faster to use those if possible.
All the examples that I have found so far point in how to initialize glut when you are working with glut only.
I'm using Windows 7 64, Visual Studio 2012, NVIDIA 330m , FreeGlut
FreeGLUT is not intended to be used in part. It is a system for creating and managing an OpenGL rendering context. It has utilities functions, but it's primary purpose is to create and manage a window. So if you're not using FreeGLUT to create and manage OpenGL, you don't get to use it for other things too.
While It seems that combining GLUT and WGL (Wiggle) is not possible (and rightly so), I have look at the code and it seems that this could be change to make it work. Of course, why make it work? Because of the additional utilties that GLUT (FreeGlut) has... like creating a sphere...
A better approach is to create a modern library to do all of this... Of course, you have some of the geometry libraries outthere, but I haven't check them.
I'm talking something more like the AUX library, but up to date.