Last active
March 9, 2019 15:43
-
-
Save aqiank/efa6eefcc81157982acc to your computer and use it in GitHub Desktop.
SDL2 DropEvent minimal example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SDL2/SDL.h> | |
int main() { | |
SDL_Init(SDL_INIT_EVERYTHING); | |
SDL_Window *window = SDL_CreateWindow("Drag-and-Drop", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_SHOWN); | |
int running = 1; | |
while (running) { | |
SDL_Event event; | |
while (SDL_PollEvent(&event)) { | |
switch (event.type) { | |
case SDL_DROPFILE: | |
printf("Dropped file: %s\n", event.drop.file); | |
break; | |
case SDL_QUIT: | |
running = 0; | |
break; | |
} | |
} | |
} | |
SDL_DestroyWindow(window); | |
SDL_Quit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fun fact: if said free requirement is correct, the majority of SDL2 applications have in-built memory leaks regarding dropped files
(EDIT: Note: I'm agreeing. The API implies this is most likely the case. It's quite horrifying.)