I'm trying to use gDEBugger to debug my OpenGL application, but the problem is that when I use normal GLFW libraries, gDEBugger runs the program and stops at specified breakpoints, but when I use Qt's QOpenGLWidget, although I'm calling native OpenGL API calls, when I try to step through the program, it seems that gDEBugger runs the program and the program exits, without any stop on breakpoints.
Does anybody know how to use gDEBugger to step through OpenGL code in Qt? Are there other debugger tools available I can use?
Thank you in advance
I've had similar problems using Nvidia Nsight and QOpenGLWidget. In nsight I'd only see the draw calls of QOpenGLWidget and not my own.
The problem for me was that I was setting the default QSurfaceFormat explicitly myself to the desired OpenGL version.
When I commented it out and not longer set that, it worked fine. And I could now see both contexts, mine and the one used by the qopenglwidget.
Not sure why this happens. Probably worth looking into the source to see how the widget renders to texture and then calls your rendering functions.
Let me know if it works for u?
Related
Recently I tried to compile my Qt static libraries with both -no-angle and -no-opengl. I first thought that it would not compile. But unexpectedly, Qt (5.7) compiled just fine. I could also compile my application (using many QtWidgets).
To my surprise I could not see any difference with my Angle based Qt app. No lags, no glitches, my QtCharts were displaying as always.
I could not find any definitive answer on the web. but I have two guesses:
I was not really using any hardware acceleration after all.
There is a mysterious fallback mechanism.
What is going on here ?
What happens? In your case nothing. Qt widgets don't use OpenGL behind your back. You have to explicitly force its use in a given widget stack by using the QOpenGlWidget as the top level widget. By default, you're using the CPU-based raster rendering backend - as you noted, it performs quite well.
Compiling Qt without angle and OpenGL support is a good way to make your application smaller if you don't use OpenGL :)
How do I set the number of samples in the default framebuffer, given by Windows?
I found this page, but although I use glew, there is no available wglChoosePixelFormatARB function in my context. What could be the cause of this?
With WGL, you can only set the pixel format for a window once when you create the context, and you can only call the wglChoosePixelFormatARB() function once the client driver is loaded, and the client driver is only loaded once you have an OpenGL context. Yes, that's circular. So, this means you have to do the following:
Create a window with an OpenGL context.
Get the function pointer for wglChoosePixelFormatARB().
Destroy the window, and create a new window with the desired pixel format.
If you've got any sense in you, you'll use SDL or GLFW to do this for you, because it's just a bunch of plumbing you have to write, there's no value in learning how to do it, and you probably want to get some real work done. SDL/GLFW/etc. is how 99% of the OpenGL game devs out there do it.
If you really want to do this yourself and get stuck, look at the SDL or GLFW source code to see how they do it.
In SDL, the src/video/windows/SDL_windowsopengl.c file has a function WIN_GL_ChoosePixelFormatARB() which does what you want. Also note the function WIN_GL_LoadLibrary().
In GLFW, the src/win32_window.c file has a function _glfwPlatformCreateWindow() which does what you want.
P.S. GLEW is a bit broken with core contexts and modern cards, so watch out. There are other GL loaders out there.
For a while I've been using SDL to write my 3D engine,and have recently been implementing an editor that can export an optimized format for the type of engine Im building. Right now the editor is fairly simple, objects can just be moved around and their textures and models can be changed. As of right now, I'm using SDL with OpenGL to render everything, but I want to use Qt for the GUI part of the editor, that way it looks native on every platform. I've got it working great so far, I'm running a QApplication inside of the SDL application, so it basically just opens 2 windows, one that uses SDL and OpenGL, and the other using Qt. Doing a bit of research, I've found that you can manually update a QApplication, which totally removes any threading problems, and everything works. Just in case you're having a hard time visualizing this, heres a picture:
What my goal is to merge these windows into one, because on smaller screens (like my laptop's) it makes it really hard to keep track of all the different windows that I would eventually have. I know theres a way to render to Qt with OpenGL, but can this be integrated with SDL? Am I going to need to move away from using an SDL window and use a QT one if the editor is enabled? Just to clarify, when the engine isn't in editor mode, it won't use and Qt, just SDL, so optimally I wouldn't need to do this.
Drop the SDL part. You have Qt, which does everything SDL does as well. Just subclass a QGLWidget and use that.
You can keep your game and editor separate processes and still make them part of the same app.
Just spawn the window where you want the game to run as part of Qt, and at least in windows, you can then pass the window handle to your game, and make sure when your game is setting up, instead of creating the window yourself in SDL and binding the opengl context to it, you can actually bind to the existing handle.
There are some gotchas with this technique to watch out for such as input focus I believe (I tested with directX, but it might be similar with SDL). The problem is that the foreground mode does some dumb checks on the "root" window which for me was not the window that owned the opengl context, so it failed to initialize. However background mode worked. I think that was for a joystick now that I think about it, but anyway, that's how you can merge everything together.
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.
I'm working on a 2D engine, it's written in C++ and I use Microsoft Visual Studio 2010 on Windows 7 64 bit.
I use OpenGL for hardware acceleration, and am now experimenting with framebuffers for using textures as canvas. (For things like allowing the user to paint on the screen)
Now this framebuffer works fine, as long as I start the program with the debugger attached (F5)
If I start the program from outside the IDE, or start it without the debugger (CTRL+F5), I can't paint to the texture, but get flickering and OpenGL stack underflow errors every frame.
I really don't know where to start searching for the problem, can you please help me?
I can't be sure, but it could be one of several things:
uninitialized variables that a debugger (sometimes) initializes to 0
race conditions that don't show since the timing is now all different