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 - SDL_CreateRenderer returns null renderer after SDL_GetRenderDriverInfo called
Summary: SDL_CreateRenderer returns null renderer after SDL_GetRenderDriverInfo called
Status: RESOLVED INVALID
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86 Mac OS X 10.6
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-21 13:19 UTC by Trent M
Modified: 2011-02-21 15:12 UTC (History)
0 users

See Also:


Attachments
Failing (2.20 KB, application/octet-stream)
2011-02-21 13:19 UTC, Trent M
Details

Note You need to log in before you can comment on or make changes to this bug.
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!