The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL2, OpenGL 3.2 Core and Steam-Overlay: Black Screenshots
moe


Joined: 08 Aug 2016
Posts: 3
Hi,

I am a hobbyist game developer and new to this forum.

I recently upgraded my work-in-progress game engine to SDL 2 and OpenGL 3.2 Core Profile. Also, I imported my game to my Steam library as a non-steam game, mainly for taking screenshots.

The upgrade took place in several steps and I checked that my engine was still working after ever step.

Before upgrading to OpenGL 3.2 Core Profile, taking screenshots in Steam worked as expected. But after the upgrade all screenshots turned out black. I could verify that this has something to do with choosing Core Profile while setting up my rendering context. As long as I explicitly request a compatible OpenGL 3.2 context, screenshots are working fine. Since Steam ships its own version of SDL2.dll I also tried to put the version I downloaded from libsdl.org in the same directory as my game, but that didn't make any difference. I verified that the correct library was loaded by launching my game from steam and attaching to the process with my debugger afterwards. The path VisualStudio listed for the library was my local path, not the Steam one, but the screenshots were still black.

I don't know if it is of any use, but taking screenshots in Steam seems to happen somewhere down in SDL_GL_SwapWindow(), which makes sense, since only at this point it can be sure the frame is complete.

The way I set up OpenGL in SDL2 basically is:

Code:

m_win = SDL_CreateWindow( caption, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, SDL_WINDOW_OPENGL );

const int glmajor = 3, glminor = 2;

SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, glmajor );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, glminor );
[color=green]// to allow steam screenshots, use compatibility mode[/color]
SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY );
// SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );

m_glctx = SDL_GL_CreateContext( m_win );

// begin main loop
// ... do stuff
SDL_GL_SwapWindow( m_win );
// end main loop

I also checked if any of my OpenGL commands fails in Core, but all return with GL_NO_ERROR.

I am aware that this might not be the right place to ask a questions that might be specific to OpenGL and Steam, but maybe someone else has encountered this problem and can suggest a solution to get a pure OpenGL 3.2 Core Profile or other things to check or try.

Of course, since I already found a workaround myself by not requesting Core Profile this is more a question out of curiosity.

The SDL version I am using is 2.0.4, but the problem was the same with 2.0.3. My compiler is VisualStudio Express 2013 (native C++, tested on Windows 7 and 10). My video card is an AMD R9 270 with the latest drivers.

Marc
SDL2, OpenGL 3.2 Core and Steam-Overlay: Black Screenshots
Andreas
Guest

Hi,

On Sun, Sep 04, 2016 at 05:24:45PM +0000, moe wrote:
Quote:
Before upgrading to OpenGL 3.2 Core Profile, taking screenshots in
Steam worked as expected. But after the upgrade all screenshots turned
out black. I could verify that this has something to do with choosing
Core Profile while setting up my rendering context. As long as I
explicitly request a compatible OpenGL 3.2 context, screenshots are
working fine. Since Steam ships its own version of SDL2.dll I also
tried to put the version I downloaded from libsdl.org in the same
directory as my game, but that didn't make any difference. I verified
that the correct library was loaded by launching my game from steam
and attaching to the process with my debugger afterwards. The path
VisualStudio listed for the library was my local path, not the Steam
one, but the screenshots were still black.

When using Core profile you need to use Vertex Arrays (VAO) too. That
could be the reason why you're seeing black screen.

Here's some documentation to read:
https://www.opengl.org/sdk/docs/man/html/glGenVertexArrays.xhtml
https://www.opengl.org/sdk/docs/man/html/glBindVertexArray.xhtml
https://www.opengl.org/sdk/docs/man/html/glDeleteVertexArrays.xhtml

--
Regards,
Andreas
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL2, OpenGL 3.2 Core and Steam-Overlay: Black Screenshots
Sik


Joined: 26 Nov 2011
Posts: 905
2016-09-11 3:48 GMT-03:00, Andreas:
Quote:
When using Core profile you need to use Vertex Arrays (VAO) too. That
could be the reason why you're seeing black screen.

If I'm reading right though the problem is with screenshots only, not
what's actually visible on screen?
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Re: SDL2, OpenGL 3.2 Core and Steam-Overlay: Black Screensho
moe


Joined: 08 Aug 2016
Posts: 3
Andreas wrote:

When using Core profile you need to use Vertex Arrays (VAO) too. That
could be the reason why you're seeing black screen.


Hi Andreas,

I already converted my engine to only use VAO and none of my GL commands sets an error state, which would be the case if I was using commands that are not allowed in Core. The main reason I moved to 3.2 Core was to be able to use renderdoc for debugging my engine, which only supports OpenGL 3.2 Core and above.

The engine is working fine in both Core and Compatibilty Profile. It's only the screenshots that turn out black in Core.

Marc
Re: SDL2, OpenGL 3.2 Core and Steam-Overlay: Black Screensho
moe


Joined: 08 Aug 2016
Posts: 3
Sik wrote:

If I'm reading right though the problem is with screenshots only, not
what's actually visible on screen?


Hi Sik,

yes, it is only the screenshots that turn out black. Each frame gets drawn to the screen as expected.

Btw, I just noticed taking screenshots the old-fashioned way (Alt+PrintScreen) works fine.

Marc