SDL 2 CreateRenderer Invalid

So I am running XCode 5 on OS X 10.9 with SDL 2.0.3. I picked up on a project I was working on a few months ago and found SDL 2 to not be working correctly. When I call CreateRenderer I get an SDL_Error for an “invalid renderer”. I dove down into the call stack and found that it was created from the CHECK_RENDERER_MAGIC macro being called inside the SDL_GetRendererOutputSize function. The renderer is being created fine and I get no crashes when I dereference it. When I try to render textures, I get the same error and they do not show up.

Here is the online source code: http://www.libsdl.org/tmp/SDL/src/render/SDL_render.c

The weird thing is that the texture renders about every other time I run the project. I have tried every combination of flags passing to the window and to the renderer with no changes. I have also tried passing my own OpenGL context with no success.

Here is my source for initialization.

    // init sdl
    if(SDL_Init(SDL_INIT_EVERYTHING) < 0)
    {
        fprintf(stderr, "Could not initiliaze SDL: %s\n", SDL_GetError());
        exit(-1);
    }

    // init the window
    window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, 0);
    if(!window)
    {
        fprintf(stderr, "Could not create the SDL window: %s\n", SDL_GetError());
        exit(-1);
    }

	// init the renderer
	renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
	if (!renderer)
	{
		fprintf(stderr, "Could not create the SDL renderer: %s\n", SDL_GetError());
		exit(-1);
	}
    printf("%s\n", SDL_GetError());

I initially had problems getting SDL 2.0.3 to even compile using the prebuilt framework provided by the site. I had to download the source and recompile the framework to even get SDL to run properly. I googled this problem and also found people had this issue.

My question is why the hell is the renderer not getting the correct magic and does it have anything to due with SDL 2.0.3 having issues with OS X 10.9 or Xcode 5.

Thanks

Silent
Code:

I too get that error message regardless of how I create the renderer, but
if SDL_CreateRenderer does not return NULL, it probably means its ok to use
it. I’m on Linux.

I only noticed the error message now that you mentioned it, actually. Your
error might be somewhere else and we need more code to help you.

2014-06-09 18:12 GMT-03:00 SilentDeath :> So I am running XCode 5 on OS X 10.9 with SDL 2.0.3. I picked up on a

project I was working on a few months ago and found SDL 2 to not be working
correctly. When I call CreateRenderer I get an SDL_Error for an “invalid
renderer”. I dove down into the call stack and found that it was created
from the CHECK_RENDERER_MAGIC macro being called inside the
SDL_GetRendererOutputSize function. The renderer is being created fine and
I get no crashes when I dereference it. When I try to render textures, I
get the same error and they do not show up.

Here is the online source code:
http://www.libsdl.org/tmp/SDL/src/render/SDL_render.c

The weird thing is that the texture renders about every other time I run
the project. I have tried every combination of flags passing to the
window and to the renderer with no changes. I have also tried passing my
own OpenGL context with no success.

Here is my source for initialization.

// init sdl
if(SDL_Init(SDL_INIT_EVERYTHING) < 0)
{
fprintf(stderr, “Could not initiliaze SDL: %s\n”, SDL_GetError());
exit(-1);
}

// init the window
window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED, width, height, 0);
if(!window)
{
fprintf(stderr, “Could not create the SDL window: %s\n”, SDL_GetError());
exit(-1);
}

// init the renderer
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED |
SDL_RENDERER_PRESENTVSYNC);
if (!renderer)
{
fprintf(stderr, “Could not create the SDL renderer: %s\n”, SDL_GetError());
exit(-1);
}
printf("%s\n", SDL_GetError());

I initially had problems getting SDL 2.0.3 to even compile using the
prebuilt framework provided by the site. I had to download the source and
recompile the framework to even get SDL to run properly. I googled this
problem and also found people had this issue.

My question is why the hell is the renderer not getting the correct magic
and does it have anything to due with SDL 2.0.3 having issues with OS X
10.9 or Xcode 5.

Thanks

Silent

Code:


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I really would not care or even notice those errors, like you said. The problem is my scene only renders every few times I build the project, obviously something that is not ideal and very annoying. As for code I am not doing anything special beyond what I posted. I just declared each SDL object. I just want to get a general idea of why it is not rendering. The magic being wrong is just a clue to something beyond what is in the SDL C code, or so I think.