We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1140

Summary: SDL_CreateRenderer returns null renderer after SDL_GetRenderDriverInfo called
Product: SDL Reporter: Trent M <thm99>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED INVALID QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: x86   
OS: Mac OS X 10.6   
Attachments: Failing

Description Trent M 2011-02-21 13:19:06 UTC
Created attachment 584 [details]
Failing

I was trying to loop through the renderers,

	int renderCount = SDL_GetNumRenderDrivers();
	SDL_RendererInfo *info;
	
	for (int i=0; i<renderCount; i++) {
		SDL_GetRenderDriverInfo(i, info);
		if (info->name == "opengles") {
			renderer = SDL_CreateRenderer(window, i, 0);
			break;
		}
	}
	
    //renderer = SDL_CreateRenderer(window, -1, 0);


	
renderer is always null although I verify the renderer exists at the 'i' ordinal passed. 
Note, the commented line above was working fine and getting a valid renderer but when I uncomment this line it always returns a null renderer? 

The problem appears to be when I call SDL_GetRenderDriver I always get a null renderer after no matter if I pass a valid ordinal or even the -1 hint.

This will work now:

	int renderCount = SDL_GetNumRenderDrivers();
	SDL_RendererInfo *info;
	
	for (int i=0; i<renderCount; i++) {
		//SDL_GetRenderDriverInfo(i, info);
		if (info->name == "opengles") {
			renderer = SDL_CreateRenderer(window, i, 0);
			break;
		}
	}
	
    renderer = SDL_CreateRenderer(window, -1, 0);
Comment 1 Sam Lantinga 2011-02-21 15:12:27 UTC
This isn't valid C code:
if (info->name == "opengles")

What you want is:
if (SDL_strcmp(info->name, "opengles") == 0)

Cheers!