ref: 9be8b9a493e0607a506a7fed098ca9466153b23e
parent: 53e2b715d45f7e55b77f71f9f88975f77ffe2985
author: Gabriel Ravier <gabravier@gmail.com>
date: Sat Apr 11 22:26:51 EDT 2020
Backends: Added init/de-init messages for backends Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
--- a/src/Backends/Audio/SDL2.cpp
+++ b/src/Backends/Audio/SDL2.cpp
@@ -65,6 +65,7 @@
BOOL AudioBackend_Init(void)
{+ Backend_PrintInfo("Initializing SDL2 audio backend...");if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
{ std::string errorMessage = std::string("'SDL_InitSubSystem(SDL_INIT_AUDIO)' failed: ") + SDL_GetError();@@ -101,14 +102,17 @@
Backend_PrintInfo("Selected SDL audio driver: %s", SDL_GetCurrentAudioDriver());+ Backend_PrintInfo("Succesfully initialized SDL2 audio backend");return TRUE;
}
void AudioBackend_Deinit(void)
{+ Backend_PrintInfo("De-initializing SDL2 audio backend...");SDL_CloseAudioDevice(device_id);
SDL_QuitSubSystem(SDL_INIT_AUDIO);
+ Backend_PrintInfo("Finished de-initializing SDL2 audio backend");}
AudioBackend_Sound* AudioBackend_CreateSound(unsigned int frequency, const unsigned char *samples, size_t length)
--- a/src/Backends/Audio/miniaudio.cpp
+++ b/src/Backends/Audio/miniaudio.cpp
@@ -73,6 +73,7 @@
BOOL AudioBackend_Init(void)
{+ Backend_PrintInfo("Initializing miniaudio audio backend...");ma_device_config config = ma_device_config_init(ma_device_type_playback);
config.playback.pDeviceID = NULL;
config.playback.format = ma_format_f32;
@@ -99,6 +100,7 @@
Mixer_Init(device.sampleRate);
+ Backend_PrintInfo("Successfully initialized miniaudio audio backend");return TRUE;
}
else
@@ -133,6 +135,7 @@
void AudioBackend_Deinit(void)
{+ Backend_PrintInfo("De-initializing miniaudio audio backend...");ma_result return_value;
return_value = ma_device_stop(&device);
@@ -144,6 +147,7 @@
ma_mutex_uninit(&mutex);
ma_device_uninit(&device);
+ Backend_PrintInfo("Finished de-initializing miniaudio audio backend...");}
AudioBackend_Sound* AudioBackend_CreateSound(unsigned int frequency, const unsigned char *samples, size_t length)
--- a/src/Backends/GLFW3/Controller.cpp
+++ b/src/Backends/GLFW3/Controller.cpp
@@ -71,6 +71,7 @@
BOOL ControllerBackend_Init(void)
{+ Backend_PrintInfo("Initializing GLFW controller backend...");// Connect joysticks that are already plugged-in
for (int i = GLFW_JOYSTICK_1; i < GLFW_JOYSTICK_LAST; ++i)
if (glfwJoystickPresent(i) == GLFW_TRUE)
@@ -79,11 +80,13 @@
// Set-up the callback for future (dis)connections
glfwSetJoystickCallback(JoystickCallback);
+ Backend_PrintInfo("Sucessfully initialized GLFW controller backend");return TRUE;
}
void ControllerBackend_Deinit(void)
{+ Backend_PrintInfo("De-initializing GLFW controller backend...");glfwSetJoystickCallback(NULL);
joystick_connected = FALSE;
@@ -91,6 +94,7 @@
free(axis_neutrals);
axis_neutrals = NULL;
+ Backend_PrintInfo("Finished de-initializing GLFW controller backend");}
BOOL ControllerBackend_GetJoystickStatus(JOYSTICK_STATUS *status)
--- a/src/Backends/GLFW3/Misc.cpp
+++ b/src/Backends/GLFW3/Misc.cpp
@@ -159,10 +159,14 @@
BOOL Backend_Init(void)
{+ Backend_PrintInfo("Initializing GLFW platform backend...");glfwSetErrorCallback(ErrorCallback);
if (glfwInit() == GL_TRUE)
+ {+ Backend_PrintInfo("Successfully initialized GLFW platform backend");return TRUE;
+ }
Backend_ShowMessageBox("Fatal error", "Could not initialise GLFW3");@@ -171,10 +175,12 @@
void Backend_Deinit(void)
{+ Backend_PrintInfo("De-initializing GLFW platform backend...");if (cursor != NULL)
glfwDestroyCursor(cursor);
glfwTerminate();
+ Backend_PrintInfo("Finished de-initializing GLFW platform backend ");}
void Backend_PostWindowCreation(void)
--- a/src/Backends/Rendering/OpenGL3.cpp
+++ b/src/Backends/Rendering/OpenGL3.cpp
@@ -583,7 +583,10 @@
RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen)
{#ifndef USE_OPENGLES2
+ Backend_PrintInfo("Initializing OpenGL3 rendering backend...");glad_set_post_callback(PostGLCallCallback);
+#else
+ Backend_PrintInfo("Initializing OpenGLES2 rendering backend...");#endif
actual_screen_width = screen_width;
@@ -668,6 +671,12 @@
config.delete_texture_callback = GlyphBatch_DestroyTexture;
spritebatch_init(&glyph_batcher, &config, NULL);
+#ifndef USE_OPENGLES2
+ Backend_PrintInfo("Successfully initialized OpenGL3 rendering backend");+#else
+ Backend_PrintInfo("Successfully initialized OpenGLES2 rendering backend");+#endif
+
return &framebuffer;
}
@@ -694,6 +703,11 @@
void RenderBackend_Deinit(void)
{+#ifndef USE_OPENGLES2
+ Backend_PrintInfo("De-initializing OpenGL3 rendering backend...");+#else
+ Backend_PrintInfo("De-initializing OpenGLES2 rendering backend...");+#endif
free(local_vertex_buffer);
spritebatch_term(&glyph_batcher);
@@ -710,6 +724,12 @@
#endif
WindowBackend_OpenGL_DestroyWindow();
+
+#ifndef USE_OPENGLES2
+ Backend_PrintInfo("Finished de-initializing OpenGL3 rendering backend");+#else
+ Backend_PrintInfo("Finished de-initializing OpenGLES2 rendering backend");+#endif
}
void RenderBackend_DrawScreen(void)
--- a/src/Backends/Rendering/SDLSurface.cpp
+++ b/src/Backends/Rendering/SDLSurface.cpp
@@ -47,6 +47,7 @@
RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen)
{+ Backend_PrintInfo("Initializing SDLSurface rendering backend...");window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screen_width, screen_height, 0);
if (window != NULL)
@@ -66,6 +67,7 @@
{Backend_PostWindowCreation();
+ Backend_PrintInfo("Successfully initialized SDLSurface rendering backend");return &framebuffer;
}
@@ -91,8 +93,10 @@
void RenderBackend_Deinit(void)
{+ Backend_PrintInfo("De-initializing SDLSurface rendering backend...");SDL_FreeSurface(framebuffer.sdlsurface);
SDL_DestroyWindow(window);
+ Backend_PrintInfo("Finished de-initializing SDLSurface rendering backend");}
void RenderBackend_DrawScreen(void)
--- a/src/Backends/Rendering/SDLTexture.cpp
+++ b/src/Backends/Rendering/SDLTexture.cpp
@@ -128,6 +128,7 @@
RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen)
{+ Backend_PrintInfo("Initializing SDLTexture rendering backend..."); Backend_PrintInfo("Available SDL render drivers:");for (int i = 0; i < SDL_GetNumRenderDrivers(); ++i)
@@ -185,6 +186,7 @@
{Backend_PostWindowCreation();
+ Backend_PrintInfo("Successfully initialized SDLTexture rendering backend");return &framebuffer;
}
else
@@ -220,10 +222,12 @@
void RenderBackend_Deinit(void)
{+ Backend_PrintInfo("De-initializing SDLTexture rendering backend...");spritebatch_term(&glyph_batcher);
SDL_DestroyTexture(framebuffer.texture);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
+ Backend_PrintInfo("Finished de-initializing SDLTexture rendering backend...");}
void RenderBackend_DrawScreen(void)
--- a/src/Backends/Rendering/Software.cpp
+++ b/src/Backends/Rendering/Software.cpp
@@ -35,6 +35,7 @@
RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen)
{+ Backend_PrintInfo("Initializing Software rendering backend...");size_t pitch;
framebuffer.pixels = WindowBackend_Software_CreateWindow(window_title, screen_width, screen_height, fullscreen, &pitch);
framebuffer.width = screen_width;
@@ -41,12 +42,22 @@
framebuffer.height = screen_height;
framebuffer.pitch = pitch;
- return &framebuffer;
+ if (framebuffer.pixels)
+ {+ Backend_PrintInfo("Successfully initialized Software rendering backend");+ return &framebuffer;
+ }
+ else
+ {+ Backend_PrintError("Failed to create window");+ }
}
void RenderBackend_Deinit(void)
{+ Backend_PrintInfo("De-initializing Software rendering backend...");WindowBackend_Software_DestroyWindow();
+ Backend_PrintInfo("Finished de-initializing Software rendering backend");}
void RenderBackend_DrawScreen(void)
--- a/src/Backends/SDL2/Controller.cpp
+++ b/src/Backends/SDL2/Controller.cpp
@@ -17,6 +17,7 @@
BOOL ControllerBackend_Init(void)
{+ Backend_PrintInfo("Initializing SDL2 controller backend...");if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0)
{ Backend_PrintError("Couldn't initialise joystick SDL subsystem: %s", SDL_GetError());@@ -23,11 +24,13 @@
return FALSE;
}
+ Backend_PrintInfo("Successfully initialized SDL2 controller backend");return TRUE;
}
void ControllerBackend_Deinit(void)
{+ Backend_PrintInfo("De-initializing SDL2 controller backend...");if (joystick != NULL)
{SDL_JoystickClose(joystick);
@@ -35,6 +38,7 @@
}
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
+ Backend_PrintInfo("Finished de-initializing SDL2 controller backend");}
BOOL ControllerBackend_GetJoystickStatus(JOYSTICK_STATUS *status)
--- a/src/Backends/SDL2/Misc.cpp
+++ b/src/Backends/SDL2/Misc.cpp
@@ -33,6 +33,7 @@
BOOL Backend_Init(void)
{+ Backend_PrintInfo("Initializing SDL2 platform backend...");if (SDL_Init(SDL_INIT_EVENTS) == 0)
{if (SDL_InitSubSystem(SDL_INIT_VIDEO) == 0)
@@ -49,6 +50,7 @@
else
Backend_PrintError("No SDL video driver initialized !");+ Backend_PrintInfo("Successfully initialized SDL2 platform backend");return TRUE;
}
@@ -67,6 +69,7 @@
void Backend_Deinit(void)
{+ Backend_PrintInfo("De-initializing SDL2 platform backend...");if (cursor != NULL)
SDL_FreeCursor(cursor);
@@ -76,6 +79,7 @@
free(cursor_surface_pixels);
SDL_Quit();
+ Backend_PrintInfo("Finished de-initializing SDL2 platform backend...");}
void Backend_PostWindowCreation(void)
--
⑨