Skip to content

Commit

Permalink
Some more SDL3 changes for renderers.
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Odetti <[email protected]>
  • Loading branch information
audetto committed Jun 14, 2024
1 parent fb25307 commit 77dbd0a
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions source/frontends/sdl/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@

#define INDENT '\t'

namespace
{

#if SDL_VERSION_ATLEAST(3, 0, 0)
void processProperty(void *userdata, SDL_PropertiesID props, const char *name)
{
std::ostream & os = *reinterpret_cast<std::ostream *>(userdata);
const char * value = SDL_GetStringProperty(props, name, nullptr);
if (value)
{

os << INDENT << name << ": " << value << std::endl;
}
}
#endif

}

namespace sa2
{

Expand Down Expand Up @@ -58,11 +76,8 @@ namespace sa2
const SDL_PixelFormatEnum pixelFormat,
const int selectedDriver)
{
SDL_RendererInfo info;
SDL_GetRendererInfo(ren.get(), &info);

const size_t n = SDL_GetNumRenderDrivers();
os << "SDL Render driver:" << std::endl;
os << "SDL Render drivers:" << std::endl;
for(size_t i = 0; i < n; ++i)
{
#if SDL_VERSION_ATLEAST(3, 0, 0)
Expand All @@ -74,15 +89,19 @@ namespace sa2
#endif
}

os << "Active driver (" << selectedDriver << "): ";
#if SDL_VERSION_ATLEAST(3, 0, 0)
os << SDL_GetRendererName(ren.get()) << std::endl;
SDL_EnumerateProperties(SDL_GetRendererProperties(ren.get()), processProperty, &os);
#else
SDL_RendererInfo info;
if (SDL_GetRendererInfo(ren.get(), &info) == 0)
{
os << "Active driver (" << selectedDriver << "): " << info.name << std::endl;
#if !SDL_VERSION_ATLEAST(3, 0, 0)
os << info.name << std::endl;
os << INDENT << "SDL_RENDERER_PRESENTVSYNC: " << ((info.flags & SDL_RENDERER_PRESENTVSYNC) > 0) << std::endl;
os << INDENT << "SDL_RENDERER_SOFTWARE: " << ((info.flags & SDL_RENDERER_SOFTWARE) > 0) << std::endl;
os << INDENT << "SDL_RENDERER_ACCELERATED: " << ((info.flags & SDL_RENDERER_ACCELERATED) > 0) << std::endl;
os << INDENT << "SDL_RENDERER_TARGETTEXTURE: " << ((info.flags & SDL_RENDERER_TARGETTEXTURE) > 0) << std::endl;
#endif
os << "Pixel format: " << SDL_GetPixelFormatName(pixelFormat) << std::endl;
for (size_t i = 0; i < info.num_texture_formats; ++i)
{
Expand All @@ -91,8 +110,9 @@ namespace sa2
}
else
{
os << "No Renderinfo" << std::endl;
os << "#NA" << std::endl;
}
#endif
}

bool show_yes_no_dialog(const std::shared_ptr<SDL_Window> & win,
Expand Down

0 comments on commit 77dbd0a

Please sign in to comment.