mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-09-09 23:41:14 -04:00
Simplify exception handling
This commit is contained in:
parent
78ccebea38
commit
8636fb651f
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
using namespace SDL2pp;
|
using namespace SDL2pp;
|
||||||
|
|
||||||
int Run() {
|
int main() try {
|
||||||
SDL sdl(SDL_INIT_AUDIO);
|
SDL sdl(SDL_INIT_AUDIO);
|
||||||
|
|
||||||
const int samplerate = 48000;
|
const int samplerate = 48000;
|
||||||
@ -54,14 +54,7 @@ int Run() {
|
|||||||
SDL_Delay(1000);
|
SDL_Delay(1000);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} catch (std::exception& e) {
|
||||||
|
|
||||||
int main() {
|
|
||||||
try {
|
|
||||||
return Run();
|
|
||||||
} catch (std::exception& e) {
|
|
||||||
std::cerr << "Error: " << e.what() << std::endl;
|
std::cerr << "Error: " << e.what() << std::endl;
|
||||||
}
|
return 1;
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
using namespace SDL2pp;
|
using namespace SDL2pp;
|
||||||
|
|
||||||
int Run() {
|
int main() try {
|
||||||
SDL sdl(SDL_INIT_AUDIO);
|
SDL sdl(SDL_INIT_AUDIO);
|
||||||
|
|
||||||
Wav wav(TESTDATA_DIR "/test.wav");
|
Wav wav(TESTDATA_DIR "/test.wav");
|
||||||
@ -64,14 +64,7 @@ int Run() {
|
|||||||
SDL_Delay(5000);
|
SDL_Delay(5000);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} catch (std::exception& e) {
|
||||||
|
|
||||||
int main() {
|
|
||||||
try {
|
|
||||||
return Run();
|
|
||||||
} catch (std::exception& e) {
|
|
||||||
std::cerr << "Error: " << e.what() << std::endl;
|
std::cerr << "Error: " << e.what() << std::endl;
|
||||||
}
|
return 1;
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
using namespace SDL2pp;
|
using namespace SDL2pp;
|
||||||
|
|
||||||
int Run() {
|
int main() try {
|
||||||
SDL sdl(SDL_INIT_VIDEO);
|
SDL sdl(SDL_INIT_VIDEO);
|
||||||
SDLImage image(IMG_INIT_PNG); // optional
|
SDLImage image(IMG_INIT_PNG); // optional
|
||||||
Window window("libSDL2pp demo: loading", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE);
|
Window window("libSDL2pp demo: loading", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE);
|
||||||
@ -76,14 +76,7 @@ int Run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} catch (std::exception& e) {
|
||||||
|
|
||||||
int main() {
|
|
||||||
try {
|
|
||||||
return Run();
|
|
||||||
} catch (std::exception& e) {
|
|
||||||
std::cerr << "Error: " << e.what() << std::endl;
|
std::cerr << "Error: " << e.what() << std::endl;
|
||||||
}
|
return 1;
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
using namespace SDL2pp;
|
using namespace SDL2pp;
|
||||||
|
|
||||||
int Run() {
|
int main() try {
|
||||||
SDL sdl(SDL_INIT_VIDEO);
|
SDL sdl(SDL_INIT_VIDEO);
|
||||||
Window window("libSDL2pp demo: sprites", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE);
|
Window window("libSDL2pp demo: sprites", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE);
|
||||||
Renderer render(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
Renderer render(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
||||||
@ -88,14 +88,7 @@ int Run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} catch (std::exception& e) {
|
||||||
|
|
||||||
int main() {
|
|
||||||
try {
|
|
||||||
return Run();
|
|
||||||
} catch (std::exception& e) {
|
|
||||||
std::cerr << "Error: " << e.what() << std::endl;
|
std::cerr << "Error: " << e.what() << std::endl;
|
||||||
}
|
return 1;
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ enum {
|
|||||||
MY_RENDERTARGET_SIZE = 512,
|
MY_RENDERTARGET_SIZE = 512,
|
||||||
};
|
};
|
||||||
|
|
||||||
int Run() {
|
int main() try {
|
||||||
SDL sdl(SDL_INIT_VIDEO);
|
SDL sdl(SDL_INIT_VIDEO);
|
||||||
Window window("libSDL2pp demo: sprites", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, MY_SCREEN_WIDTH, MY_SCREEN_HEIGHT, SDL_WINDOW_RESIZABLE);
|
Window window("libSDL2pp demo: sprites", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, MY_SCREEN_WIDTH, MY_SCREEN_HEIGHT, SDL_WINDOW_RESIZABLE);
|
||||||
Renderer render(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
Renderer render(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
||||||
@ -114,14 +114,7 @@ int Run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} catch (std::exception& e) {
|
||||||
|
|
||||||
int main() {
|
|
||||||
try {
|
|
||||||
return Run();
|
|
||||||
} catch (std::exception& e) {
|
|
||||||
std::cerr << "Error: " << e.what() << std::endl;
|
std::cerr << "Error: " << e.what() << std::endl;
|
||||||
}
|
return 1;
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ unsigned char pixels[4 * 4 * 4] = {
|
|||||||
RGBA(0x80, 0x00, 0xff, 0xff), RGBA(0x00, 0x00, 0xff, 0xff), RGBA(0x00, 0x80, 0xff, 0xff), RGBA(0x00, 0xff, 0xff, 0xff),
|
RGBA(0x80, 0x00, 0xff, 0xff), RGBA(0x00, 0x00, 0xff, 0xff), RGBA(0x00, 0x80, 0xff, 0xff), RGBA(0x00, 0xff, 0xff, 0xff),
|
||||||
};
|
};
|
||||||
|
|
||||||
int Run() {
|
int main() try {
|
||||||
SDL sdl(SDL_INIT_VIDEO);
|
SDL sdl(SDL_INIT_VIDEO);
|
||||||
Window window("libSDL2pp demo: sprites", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE);
|
Window window("libSDL2pp demo: sprites", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE);
|
||||||
Renderer render(window, -1, SDL_RENDERER_ACCELERATED);
|
Renderer render(window, -1, SDL_RENDERER_ACCELERATED);
|
||||||
@ -87,14 +87,7 @@ int Run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} catch (std::exception& e) {
|
||||||
|
|
||||||
int main() {
|
|
||||||
try {
|
|
||||||
return Run();
|
|
||||||
} catch (std::exception& e) {
|
|
||||||
std::cerr << "Error: " << e.what() << std::endl;
|
std::cerr << "Error: " << e.what() << std::endl;
|
||||||
}
|
return 1;
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
using namespace SDL2pp;
|
using namespace SDL2pp;
|
||||||
|
|
||||||
int Run() {
|
int main() try {
|
||||||
SDL sdl(SDL_INIT_VIDEO);
|
SDL sdl(SDL_INIT_VIDEO);
|
||||||
SDLTTF ttf;
|
SDLTTF ttf;
|
||||||
Window window("libSDL2pp demo: font", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE);
|
Window window("libSDL2pp demo: font", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE);
|
||||||
@ -81,14 +81,7 @@ int Run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} catch (std::exception& e) {
|
||||||
|
|
||||||
int main() {
|
|
||||||
try {
|
|
||||||
return Run();
|
|
||||||
} catch (std::exception& e) {
|
|
||||||
std::cerr << "Error: " << e.what() << std::endl;
|
std::cerr << "Error: " << e.what() << std::endl;
|
||||||
}
|
return 1;
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user