Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Using SDL2, is there a way to determine at runtime whether the application is using OpenGL, OpenGLES, or DirectX?

EDIT: If there is a way to figure it out without using the SDL2 API, I'm willing to throw that code into my project.

share|improve this question
    
Posting this as a comment, as I'm not 100% sure this is correct. But I think I saw in the code that it is decided at compile time what renderer is used so this information might not be available at run-time. –  Roy T. yesterday
    
@RoyT. Yeah, I saw that. I believe it was meant for SDL2's internal use. I've edited the answer to allow for ways without using SDL's API. –  147ofthem yesterday
    
SDL just creates a window for you. Whether you use OpenGL(ES) or DirectX with it is up to you. Or are you asking about SDL renderers that use that window? In that case SDL_GetRendererInfo might be for you. –  kolrabi yesterday

1 Answer 1

Once upon a time there was Google.

Now this seems to be what you are looking for:

const char* SDL_GetCurrentVideoDriver(void)

Returns the name of the current video driver or NULL if no driver has been initialized.

share|improve this answer
2  
Tested it on two computers: SDL_GetCurrentVideoDriver() returns string windows. When I tried to print all avalible "drivers", I got these three: windows, dummy and ` ` (empty string). –  HolyBlackCat 2 days ago
    
Try going to the implementation of that function. See how it decides what to return. It's possible that you can find some clues there. –  Eejin 2 days ago
    
I knew about this, but @HolyBlackCat is right. The title is misleading. There are a lot of functions that sound like they'd get what I need, but I can only find functions to get platform stuff and whether or not SDL is using software rendering or hardware accelerated rendering. –  147ofthem 2 days ago
    
@HolyBlackCat Maybe "windows" is a code for "DirectX". Have you tried to test this line on a Linux machine? Maybe the result will vary. –  AlphSpirit yesterday
    
I have not any PC with linux nor installed virtual machine. I can't test it. –  HolyBlackCat yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.