Skip to content

Commit

Permalink
SDL3/SDL_GetDisplayName: Updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
mariobadr authored and SDLWikiBot committed Nov 5, 2024
1 parent 2f79da6 commit 68eb4d3
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions SDL3/SDL_GetDisplayName.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,37 @@ const char * SDL_GetDisplayName(SDL_DisplayID displayID);
This function is available since SDL 3.1.3.
## Code Examples
```c
// Example program
// Use SDL3 to log the name of every display found
#include <SDL3/SDL_log.h>
#include <SDL3/SDL_main.h>
#include <SDL3/SDL_video.h>
int
main(int argc, char** argv)
{
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_Log("Unable to initialize SDL: %s", SDL_GetError());
return 0;
}
int num_displays;
SDL_DisplayID *displays = SDL_GetDisplays(&num_displays);
for(int i = 0; i < num_displays; i++) {
SDL_Log("Found display named '%s'", SDL_GetDisplayName(displays[i]));
}
SDL_free(displays);
return 0;
}
```

## See Also

- [SDL_GetDisplays](SDL_GetDisplays)
Expand Down

0 comments on commit 68eb4d3

Please sign in to comment.