How to make GPU PerfStudio & GLEW play nicely? - c++

I have a basic application which runs just fine, uses OpenGL 4.3 core profile & GLEW 1.11.0.
However, when I run it through GPU PerfStudio, it crashes right on glewInit, yielding an error saying "Missing GL version".
The context is created before glewInit is called, of course (and as mentioned it runs perfectly fine on its own).
How can this problem be solved?
Update:
Win32 binaries work perfectly fine - this only happens with x64.

Related

Replicating environment from renderdoc to debug

I have a strange issue, a vulkan application I am writing seemingly runs fine when run from the terminal. But if run from renderdoc an assertion inside the official .hpp header triggers.
Since this only happens if the program is launched with renderdoc I am having a hard time trying to debug it.
Is there a way to get the exact environment configuration renderdoc is using to run the program so that I can replicate the bug?
It is quite bizarre it only happens if the new dynamic rendering extension is active too. If it is not requested renderdoc doesn;t seem to trigger the assertion. But I am on the latest version (1.18).
If anyone runs into something like this in teh future. The problem was that an old instance of renderdoc was installed in my system, this in turn created conflicts when loading the program onto renderdoc as vulkan wasn't properly configured.
Uninstalling the old version fixed it.

Can't load Cg shaders when RenderDoc is attached in OpenGL

I'm trying to debug my OpenGL game using RenderDoc, but if I launch from RenderDoc, then no graphics are shown and Cg outputs errors on startup. How can I get RenderDoc to work with my game?
I get a couple of errors:
cgGLGetLatestProfile(CG_GL_VERTEX) returns CG_PROFILE_ARBVP1 (a much lower profile than is returned when not launching from RenderDoc)
cgGLGetLatestProfile(CG_GL_FRAGMENT) returns CG_PROFILE_UNKNOWN
When trying to load a shader with this profile, or with a hardcoded newer one, it says The profile is not supported.
After that an additional error is output: fatal error C9999: InitHAL failed.
RenderDoc documentation mentions that dbghelp.dll shouldn't be used in combination with RenderDoc, so I removed our inclusion of dbghelp.lib and all references to the dll and the header from our code, so I think I'm not using dbghelp.dll anymore.
The GPU being used is a GeForce GTX 560 and on startup of the game GL_VERSION is reported as 4.6.0 NVIDIA 391.35. I've also tried running on a different computer with a newer videocard (Nvidia 1050ti) and I've tried installing the newest drivers but this didn't make any difference. This is all on Windows 10 64bit.
We also have a DirectX9 option in our engine. When I use this and launch the game from RenderDoc it starts fine and shows the RenderDoc overlay over the game. However, since RenderDoc doesn't actually support DirectX9 I can't capture a frame that way (which is as expected).

Access Violation on OpenGL functions, injected into existing context

I've been developing a hack for an older game adding shaders. The dll intercepts opengl calls and then modifies the rendering pipeline as needed. I use glew to load extension functions. For the first time, I am testing compiling and using the .dll on a computer different than the one I primarily developed on.
I've had a previous build of this dll that did work previously on this new machine, but now, when I've compiled the dll from a working source on this machine and attempt to use it, i receive access violations on many gl* function calls (glGenTextures, glBindTexture), that looks like:
Unhandled exception at 0x0C941CA3 in Game.exe: 0xC0000005: Access violation reading location 0xD8EBE92C. occurred
To initialize glew, I call glewInit when I intercept the first glSwapBuffers call. AFAIK this tells me the context already exists, and the gl calls are being called after this init step. I have attempted this with glewExperimental enabled as well. When i receive these errors, I have no indication that glew is not initializing correctly (glewInit() == GLEW_OK)
Am I missing something about OpenGL/glew availability between machines?
The primary development machine which it was working correctly on has a Nvidia Geforce GTX 660ti, running on Windows 10, compiling with VS2015
The secondary development machine which it is failing on, has a "AMD FirePro M6100 FireGL V", running on Windows 7, compiling with VS2017

OpenGL code runs perfectly from IDE, CodeXL and GPU PerfStudio, but gives blank screen if started from Windows

I have been improving an OpenGL code of my own since some days, and now I got a terrible surprise: My code works properly if run from inside CodeBlocks IDE (by Menu-> Build -> Run), but if I open it from the Windows Explorer, the program will still open and issue messages on the console as if it would be running properly, but I just get a blank screen.
I have trying re-building the code to see if the problem disappears from Windows, or to see if it also affects the run from inside CodeBlocks, but the outcome is still the same.
Some days ago (before much of the code change), I could start the program from both Windows and CodeBlocks and run perfectly in both cases, so this is totally surprising for me now.
I use GLFW3 and GLEW and I am linking to the following libraries:
C:\msys64\mingw64\lib\libglew32.dll.a
C:\msys64\mingw64\lib\libglfw3.a
opengl32
C:\msys64\mingw64\lib\libsfml-system.dll.a (I use the clock of this library)
gdi32
On the meantime I have deinstalled and installed msys64, but this didnt affect my other OpenGL projects linking the same libraries, so I suppose this is not the source of the problem
How would I proceed to debug such an issue? I have no clue about how to start troubleshooting this, so any comment on what extra info I should post is welcome.
Update: If I open the application from the GPU PerfStudio and CodeXL, everything works just fine, but not when I open via Windows Explorer.
How would I proceed to debug such an issue?
When I deal with bugs like this I use a tool called CodeXL. You can download the latest version here. It automatically breaks on any OpenGL error and shows you which of your OpenGL function calls caused it.
It is free and it works also with non-AMD GPUs.
It should not take you long time to learn how to use it: you just create a new project, give it path to your project folder and .exe and hit run. (make sure that Debug->Breakpoints->Break on OpenGL error is checked)
//Moreover, it visualizes your buffers, shows you your loaded textures, etc.. Definitely check it if you plan to program more Windows+OpenGL in the future.

How to build and run examples in OpenGL Superbible 6th edition?

My system is Win 8.1 64-bit and using VS2013 Express. I can verify my video cards support the latest OpenGL and OpenCL. I used the latest code and media files from authors github and site: https://github.com/openglsuperbible/sb6code and http://www.openglsuperbible.com/example-code/ respectively.
I am able to make debug and release builds of the project(s) successfully but cannot correctly run it either via debug mode or the .exe in the bin folder. A white window will show up and then exit. I was able to step through and found that glfwOpenWindow will return false causing the exit but I cannot step further and see why it is returning so. I found some solutions that suggested changing
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
to
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, 0);
but this does not change my results. I can verify also that major version is 4 and minor is 3 for the book code. I have found a few other people having the same problem but no resolution. Another possible solution (but to a different problem it seems) was changing the project subsystem to Console from Windows but this throws an error regarding main and so it may not be what I'm looking for.
For reference, this book is using glfw version 2.7.6 when (currently) the latest is 3.0.4. I tried swapping this too but it understandably blew up due to all of the changes.
Any further ideas would be great and very helpful!
I have discovered that while my GPU does support the latest OpenGL, my computer was instead using the integrated Intel HD 4600! By switching my computer to use the dedicated GPU by default, I am able to run the latest OpenGL.
If it successfully compiled, then please do following:
Ensure that you do have the latest graphic card drivers installed (eg. if you have nVIDIA card, go to www.nvidia.com and get newest drivers).
Ensure that files which these examples are trying to load (I guess jpg/tga/png files, maybe some obj/fbx/3ds files for geometry, whatever else these examples need) are present at expected path (relative path to exe).
Run it as a debug, place breakpoints in app initialization, see that OpenGL is initialized correctly and that required files are loaded. I think you will find that required files are not in expected path(s).
P.S.
I think the best practice for learning OpenGL is not to rely on some library to open window and initalize OpenGL for you - it's better you learn it all step by step - how to open an application window, how to initialize gl render context associated with device context etc. You'd also avoid things like this when you don't know where the problem could be.