SDL_Surface* myFunction() {
/* code for creating the surface...
*********
*/
int tryOnce = 0;
if(tempSurface != nullptr) {
// all is good
return tempSurface;
} else if(tryOnce < 1) {
++tryOnce;
myFunction();
} else {
SDL_Log("log error");
throw "caught error... exiting";
}
Hello,
I wrote a simple program.
It returns surfaces in several functions , but I want to check to see the surface is not a nullptr before returning it and if it is ,
call the same function once more to try to load the image to the surface or whatever, and if that fails to throw an exception which
will exit the game.
Is this a bad way to do it , it seems to excessive to end the game but I'm a beginner and really don't want to get too deep into everything yet.
?
thanks