Skip to content

Commit 00778f4

Browse files
committed
SDL_Init returns 0 on success but any negative number can be
returned on failure, not just -1
1 parent 60beb1e commit 00778f4

File tree

9 files changed

+9
-9
lines changed

9 files changed

+9
-9
lines changed

Diff for: Lesson0/src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Lesson 0: Test to make sure SDL is setup properly
1010
*/
1111
int main(int argc, char **argv){
12-
if (SDL_Init(SDL_INIT_EVERYTHING) == -1){
12+
if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
1313
std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
1414
return 1;
1515
}

Diff for: Lesson1/src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
int main(int argc, char** argv){
1212
//First we need to start up SDL, and make sure it went ok
13-
if (SDL_Init(SDL_INIT_EVERYTHING) == -1){
13+
if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
1414
std::cout << SDL_GetError() << std::endl;
1515
return 1;
1616
}

Diff for: Lesson2/src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void ApplySurface(int x, int y, SDL_Texture *tex, SDL_Renderer *rend){
6161

6262
int main(int argc, char** argv){
6363
//Start up SDL and make sure it went ok
64-
if (SDL_Init(SDL_INIT_EVERYTHING) == -1){
64+
if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
6565
std::cout << SDL_GetError() << std::endl;
6666
return 1;
6767
}

Diff for: Lesson3/src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void ApplySurface(int x, int y, SDL_Texture *tex, SDL_Renderer *rend){
5656

5757
int main(int argc, char** argv){
5858
//Start up SDL and make sure it went ok
59-
if (SDL_Init(SDL_INIT_EVERYTHING) == -1){
59+
if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
6060
std::cout << SDL_GetError() << std::endl;
6161
return 1;
6262
}

Diff for: Lesson4/src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void ApplySurface(int x, int y, SDL_Texture *tex, SDL_Renderer *rend){
5656

5757
int main(int argc, char** argv){
5858
//Start up SDL and make sure it went ok
59-
if (SDL_Init(SDL_INIT_EVERYTHING) == -1){
59+
if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
6060
std::cout << SDL_GetError() << std::endl;
6161
return 1;
6262
}

Diff for: Lesson5/src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void ApplySurface(int x, int y, SDL_Texture *tex, SDL_Renderer *rend, SDL_Rect *
6262

6363
int main(int argc, char** argv){
6464
//Start up SDL and make sure it went ok
65-
if (SDL_Init(SDL_INIT_EVERYTHING) == -1){
65+
if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
6666
std::cout << SDL_GetError() << std::endl;
6767
return 1;
6868
}

Diff for: Lesson6/src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void ApplySurface(int x, int y, SDL_Texture *tex, SDL_Renderer *rend){
8484

8585
int main(int argc, char** argv){
8686
//Start up SDL and make sure it went ok
87-
if (SDL_Init(SDL_INIT_EVERYTHING) == -1){
87+
if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
8888
std::cout << SDL_GetError() << std::endl;
8989
return 1;
9090
}

Diff for: Lesson7/src/window.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ SDL_Rect Window::mBox;
2828

2929
void Window::Init(std::string title){
3030
//initialize all SDL subsystems
31-
if (SDL_Init(SDL_INIT_EVERYTHING) == -1)
31+
if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
3232
throw std::runtime_error("SDL Init Failed");
3333
if (TTF_Init() == -1)
3434
throw std::runtime_error("TTF Init Failed");

Diff for: Lesson8/src/window.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Window::~Window(){
3232
}
3333
void Window::Init(std::string title){
3434
//initialize all SDL subsystems
35-
if (SDL_Init(SDL_INIT_EVERYTHING) == -1)
35+
if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
3636
throw std::runtime_error("SDL Init Failed");
3737
if (TTF_Init() == -1)
3838
throw std::runtime_error("TTF Init Failed");

0 commit comments

Comments
 (0)