Skip to content

Instantly share code, notes, and snippets.

@l-t-m-f
Created February 13, 2026 20:07
Show Gist options
  • Select an option

  • Save l-t-m-f/1b82aeda196d7a11373cc9f7a136e7ae to your computer and use it in GitHub Desktop.

Select an option

Save l-t-m-f/1b82aeda196d7a11373cc9f7a136e7ae to your computer and use it in GitHub Desktop.
Example - Gestion des images
#include <SDL3/SDL.h>
#include <SDL3_image/SDL_image.h>
SDL_Window *win = nullptr;
SDL_Renderer *rend = nullptr;
SDL_Texture *sprites = nullptr;
int main(int argc, char *argv[])
{
/* Initialisation. */
SDL_Init(SDL_INIT_VIDEO);
win = SDL_CreateWindow("Gestion des images", 480, 480, 0);
rend = SDL_CreateRenderer(win, nullptr);
/* Chargement de l'image. */
sprites = IMG_LoadTexture(rend, "sheet.png");
if (sprites == nullptr)
{
SDL_LogWarn(0, "Failed to load image! %s", SDL_GetError());
}
SDL_SetTextureScaleMode(sprites, SDL_SCALEMODE_NEAREST);
/* Game loop pattern. */
while (1)
{
/* Event queue. */
SDL_Event e;
while (SDL_PollEvent(&e) == true)
{
if (e.type == SDL_EVENT_QUIT)
{
return 1;
}
}
SDL_SetRenderDrawColor(rend, 0, 255, 0, 255);
SDL_RenderClear(rend);
SDL_RenderTexture(rend, sprites, nullptr, nullptr);
SDL_RenderPresent(rend);
}
SDL_Log("hello, SDL");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment