Add debug prints for listing SDL2 drivers
These list what video/render/audio backends are available, and which are currently being used. SDL2 allows you to choose a specific video/audio driver with the SDL_VIDEODRIVER and SDL_AUDIODRIVER environment variables, respectively, but there's no such option for the render driver.
This commit is contained in:
parent
1cf5df2d72
commit
79886f5ae4
3 changed files with 43 additions and 0 deletions
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#ifndef NDEBUG
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -155,6 +158,13 @@ BOOL AudioBackend_Init(void)
|
||||||
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
|
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
puts("Available SDL2 audio drivers:");
|
||||||
|
|
||||||
|
for (int i = 0; i < SDL_GetNumAudioDrivers(); ++i)
|
||||||
|
puts(SDL_GetAudioDriver(i));
|
||||||
|
#endif
|
||||||
|
|
||||||
SDL_AudioSpec specification;
|
SDL_AudioSpec specification;
|
||||||
specification.freq = 44100;
|
specification.freq = 44100;
|
||||||
specification.format = AUDIO_F32;
|
specification.format = AUDIO_F32;
|
||||||
|
@ -172,6 +182,10 @@ BOOL AudioBackend_Init(void)
|
||||||
|
|
||||||
SDL_PauseAudioDevice(device_id, 0);
|
SDL_PauseAudioDevice(device_id, 0);
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
printf("Selected SDL2 audio driver: %s\n", SDL_GetCurrentAudioDriver());
|
||||||
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#include "../Rendering.h"
|
#include "../Rendering.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#ifndef NDEBUG
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
@ -58,11 +61,28 @@ SDL_Window* Backend_CreateWindow(const char *title, int width, int height)
|
||||||
|
|
||||||
Backend_Surface* Backend_Init(SDL_Window *window)
|
Backend_Surface* Backend_Init(SDL_Window *window)
|
||||||
{
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
|
puts("Available SDL2 render drivers:");
|
||||||
|
|
||||||
|
for (int i = 0; i < SDL_GetNumRenderDrivers(); ++i)
|
||||||
|
{
|
||||||
|
SDL_RendererInfo info;
|
||||||
|
SDL_GetRenderDriverInfo(i, &info);
|
||||||
|
puts(info.name);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
||||||
|
|
||||||
if (renderer == NULL)
|
if (renderer == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
SDL_RendererInfo info;
|
||||||
|
SDL_GetRendererInfo(renderer, &info);
|
||||||
|
printf("Selected SDL2 render driver: %s\n", info.name);
|
||||||
|
#endif
|
||||||
|
|
||||||
int width, height;
|
int width, height;
|
||||||
SDL_GetRendererOutputSize(renderer, &width, &height);
|
SDL_GetRendererOutputSize(renderer, &width, &height);
|
||||||
framebuffer.texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, width, height);
|
framebuffer.texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, width, height);
|
||||||
|
|
|
@ -88,6 +88,15 @@ BOOL Flip_SystemTask(void)
|
||||||
|
|
||||||
SDL_Window* CreateWindow(const char *title, int width, int height)
|
SDL_Window* CreateWindow(const char *title, int width, int height)
|
||||||
{
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
|
puts("Available SDL2 video drivers:");
|
||||||
|
|
||||||
|
for (int i = 0; i < SDL_GetNumVideoDrivers(); ++i)
|
||||||
|
puts(SDL_GetVideoDriver(i));
|
||||||
|
|
||||||
|
printf("Selected SDL2 video driver: %s\n", SDL_GetCurrentVideoDriver());
|
||||||
|
#endif
|
||||||
|
|
||||||
return Backend_CreateWindow(title, width, height);
|
return Backend_CreateWindow(title, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue