Conclusion my problem isnt here my problem is that course is old and many fonctions does not exist anymore so i need a documentation on sdl2 in c language
Like I said, it is literally copy pasting library, importing headers and writing the Code. (Since the C++ code in most tutorials for SDL2 are C styled since SDL2 is a C API)
For example,
main.c
// SDL2 Hello, World!
// This should display a white screen for 2 seconds
// compile with: clang main.cpp -o hello_sdl2 -lSDL2
// run with: ./hello_sdl2
#include <SDL2/SDL.h>
#include <stdio.h>
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
int main(int argc, char* args[]){
SDL_Window* window = NULL;
SDL_Surface* screenSurface = NULL;
if
(SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "could not initialize sdl2: %s\n", SDL_GetError()); return 1; }
window = SDL_CreateWindow( "hello_sdl2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
if (window == NULL) {
fprintf(stderr, "could not create window: %s\n", SDL_GetError()); return 1;
}
screenSurface = SDL_GetWindowSurface(window); SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));
SDL_UpdateWindowSurface(window);
SDL_Delay(2000);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;}
Here, I just changed main.cc to main.c since the tutorial literally uses C styled Cpp or basically a C program.
https://gist.github.com/fschr/92958222e35a823e738bb181fe045274