fork download
  1.  
  2. int main() {
  3. int scale = 2;
  4. int width = 320, height = 240;
  5.  
  6. SDL_Window *sdlwindow;
  7. SDL_Renderer *sdlrenderer;
  8.  
  9. if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
  10. fprintf(stderr, "failed to init SDL");
  11. return 1;
  12. }
  13.  
  14. if(SDL_CreateWindowAndRenderer(scale*width, scale*height, SDL_WINDOW_SHOWN, &sdlwindow, &sdlrenderer)) {
  15. fprintf(stderr, "failed to open window");
  16. SDL_Quit();
  17. return 1;
  18. }
  19.  
  20. SDL_Texture *sdltexture = SDL_CreateTexture(sdlrenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, width, height);
  21. uint32_t *pixels;
  22. int pitch;
  23.  
  24. while(running) {
  25. SDL_Event event;
  26. while(SDL_PollEvent(&event)) {
  27. switch(event.type) {
  28. case SDL_KEYDOWN:
  29. if(event.key.keysym.sym == SDLK_ESCAPE) {
  30. running = 0;
  31. }
  32. break;
  33. }
  34. }
  35.  
  36. SDL_LockTexture(sdltexture, NULL, (void*)&pixels, &pitch);
  37.  
  38. // put shit into pixels
  39.  
  40. SDL_UnlockTexture(sdltexture);
  41. SDL_RenderCopy(sdlrenderer, sdltexture, NULL, NULL);
  42. SDL_RenderPresent(sdlrenderer);
  43.  
  44. }
  45.  
  46. SDL_DestroyTexture(sdltexture);
  47.  
  48. SDL_DestroyWindow(sdlwindow);
  49. SDL_Quit();
  50. return 0;
  51. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:6:5: error: unknown type name ‘SDL_Window’
     SDL_Window *sdlwindow;
     ^
prog.c:7:5: error: unknown type name ‘SDL_Renderer’
     SDL_Renderer *sdlrenderer;
     ^
prog.c:9:5: error: implicit declaration of function ‘SDL_Init’ [-Werror=implicit-function-declaration]
     if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
     ^
prog.c:9:17: error: ‘SDL_INIT_VIDEO’ undeclared (first use in this function)
     if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
                 ^
prog.c:9:17: note: each undeclared identifier is reported only once for each function it appears in
prog.c:9:34: error: ‘SDL_INIT_EVENTS’ undeclared (first use in this function)
     if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
                                  ^
prog.c:10:9: error: implicit declaration of function ‘fprintf’ [-Werror=implicit-function-declaration]
         fprintf(stderr, "failed to init SDL");
         ^
prog.c:10:9: error: incompatible implicit declaration of built-in function ‘fprintf’ [-Werror]
prog.c:10:17: error: ‘stderr’ undeclared (first use in this function)
         fprintf(stderr, "failed to init SDL");
                 ^
prog.c:14:5: error: implicit declaration of function ‘SDL_CreateWindowAndRenderer’ [-Werror=implicit-function-declaration]
     if(SDL_CreateWindowAndRenderer(scale*width, scale*height, SDL_WINDOW_SHOWN, &sdlwindow, &sdlrenderer)) {
     ^
prog.c:14:63: error: ‘SDL_WINDOW_SHOWN’ undeclared (first use in this function)
     if(SDL_CreateWindowAndRenderer(scale*width, scale*height, SDL_WINDOW_SHOWN, &sdlwindow, &sdlrenderer)) {
                                                               ^
prog.c:15:9: error: incompatible implicit declaration of built-in function ‘fprintf’ [-Werror]
         fprintf(stderr, "failed to open window");
         ^
prog.c:16:9: error: implicit declaration of function ‘SDL_Quit’ [-Werror=implicit-function-declaration]
         SDL_Quit();
         ^
prog.c:20:5: error: unknown type name ‘SDL_Texture’
     SDL_Texture *sdltexture = SDL_CreateTexture(sdlrenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, width, height);
     ^
prog.c:20:5: error: implicit declaration of function ‘SDL_CreateTexture’ [-Werror=implicit-function-declaration]
prog.c:20:62: error: ‘SDL_PIXELFORMAT_ARGB8888’ undeclared (first use in this function)
     SDL_Texture *sdltexture = SDL_CreateTexture(sdlrenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, width, height);
                                                              ^
prog.c:20:88: error: ‘SDL_TEXTUREACCESS_STREAMING’ undeclared (first use in this function)
     SDL_Texture *sdltexture = SDL_CreateTexture(sdlrenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, width, height);
                                                                                        ^
prog.c:21:5: error: unknown type name ‘uint32_t’
     uint32_t *pixels;
     ^
prog.c:24:11: error: ‘running’ undeclared (first use in this function)
     while(running) {
           ^
prog.c:25:9: error: unknown type name ‘SDL_Event’
         SDL_Event event;
         ^
prog.c:26:9: error: implicit declaration of function ‘SDL_PollEvent’ [-Werror=implicit-function-declaration]
         while(SDL_PollEvent(&event)) {
         ^
prog.c:27:25: error: request for member ‘type’ in something not a structure or union
             switch(event.type) {
                         ^
prog.c:28:22: error: ‘SDL_KEYDOWN’ undeclared (first use in this function)
                 case SDL_KEYDOWN:
                      ^
prog.c:29:29: error: request for member ‘key’ in something not a structure or union
                     if(event.key.keysym.sym == SDLK_ESCAPE) {
                             ^
prog.c:29:48: error: ‘SDLK_ESCAPE’ undeclared (first use in this function)
                     if(event.key.keysym.sym == SDLK_ESCAPE) {
                                                ^
prog.c:36:9: error: implicit declaration of function ‘SDL_LockTexture’ [-Werror=implicit-function-declaration]
         SDL_LockTexture(sdltexture, NULL, (void*)&pixels, &pitch);
         ^
prog.c:36:37: error: ‘NULL’ undeclared (first use in this function)
         SDL_LockTexture(sdltexture, NULL, (void*)&pixels, &pitch);
                                     ^
prog.c:40:9: error: implicit declaration of function ‘SDL_UnlockTexture’ [-Werror=implicit-function-declaration]
         SDL_UnlockTexture(sdltexture);
         ^
prog.c:41:9: error: implicit declaration of function ‘SDL_RenderCopy’ [-Werror=implicit-function-declaration]
         SDL_RenderCopy(sdlrenderer, sdltexture, NULL, NULL);
         ^
prog.c:42:9: error: implicit declaration of function ‘SDL_RenderPresent’ [-Werror=implicit-function-declaration]
         SDL_RenderPresent(sdlrenderer);
         ^
prog.c:46:5: error: implicit declaration of function ‘SDL_DestroyTexture’ [-Werror=implicit-function-declaration]
     SDL_DestroyTexture(sdltexture);
     ^
prog.c:48:5: error: implicit declaration of function ‘SDL_DestroyWindow’ [-Werror=implicit-function-declaration]
     SDL_DestroyWindow(sdlwindow);
     ^
cc1: all warnings being treated as errors
stdout
Standard output is empty