Well if you don't know, there are multiple renderers in sdl, and on some don't work on certain computers, so people use a fallback ex: "accelerated renderer -> software renderer". Sadly, I haven't came across an example that I could copy and paste.
-Pretty please can you not lecture me how to do this, and just give me code <3
Reading the documentation https://wiki.libsdl.org/SDL_CreateRenderer it would appear you could just do renderer = SDL_CreateRenderer(win, -1, SDL_RENDERER_SOFTWARE | SDL_RENDERER_ACCELERATED);
Pretty please can you not lecture me how to do this, and just give me code <3
This is a terrible attitude, I only posted code because your question was about how to use a very specific feature of SDL.
Reading the documentation https://wiki.libsdl.org/SDL_CreateRenderer it would appear you could just do
renderer = SDL_CreateRenderer(win, -1, SDL_RENDERER_SOFTWARE | SDL_RENDERER_ACCELERATED);
Pretty please can you not lecture me how to do this, and just give me code <3
This is a terrible attitude, I only posted code because your question was about how to use a very specific feature of SDL.
Yea, but what about a complete one, using all the possible renderer's, with target texture and present sync?
|| is the logical or operator. It will treat both operands as bool values. Both SDL_RENDERER_SOFTWARE and SDL_RENDERER_ACCELERATED is different from zero so they will be treated as true.
true || true == true
The true value will be converted to the integer value 1 when it's passed to the function. The constant SDL_RENDERER_SOFTWARE is equal to 1 so that means passing SDL_RENDERER_SOFTWARE || SDL_RENDERER_ACCELERATED will have the same effect as passing just SDL_RENDERER_SOFTWARE.
Note: my post is conjecture and I don't really know how SDL works. Take this with a grain of salt:
It doesn't make much sense to create a renderer that is both HW and SW. SDL likely favors the Accelerated option when specified and uses the Software option only if you do no specify the accelerated option.
If you want to fall back to SW if HW fails, try creating HW first... then if that fails... create a SW renderer:
1 2 3 4 5 6 7 8 9 10 11
SDL_Renderer* rend = SDL_CreateRenderer(win,-1,SDL_RENDERER_ACCELERATED);
if(!rend)
{
rend = SDL_CreateRenderer(win,-1,SDL_RENDERER_SOFTWARE);
}
if(!rend)
{
// could not create either HW or SW renderer -- notify user
}
Note that the the function can impossibly know in which order you wrote SDL_RENDERER_SOFTWARE and SDL_RENDERER_ACCELERATED. The | operator simply produce a value where the bits are 1 if the corresponding bit is 1 in any of the two arguments.
It just goes strait for accelerated.
That's because your system supports accelerated. If it is not then it will fall back to software rendering. That's the point of having a fallback.
Thats messed up man... I think that I have a driver problem... When I open my game, the window is blank and glitched, and no sdl errors pop up when it checks if the renderer is equal to null... But I play videogames! Shouldn't I have renderer problems with them too? I even re-downloaded the accelerated driver from intel for my chip set... Any ideas?
Oh, sorry, I meant to say that all the sdl code that I compile with the renderer, gets the same bug, not error. As I said, you can take the rendering tutorial on lazy foo as an example, any code with sdl rendering has the same bug...
Find the smallest example that produces this error. And post it. You can use pastebin if it's a bit long. But I'm not going to go through six tutorials to put together code that may or may not be the same code causing issues for you.