diff --git a/.clang-format b/.clang-format index 41e7b1a..927dad4 100644 --- a/.clang-format +++ b/.clang-format @@ -2,7 +2,16 @@ BasedOnStyle: LLVM IndentWidth: 4 # Use 4 spaces for indentation TabWidth: 4 # Tab width is also 4 spaces UseTab: Never # Always use spaces instead of tabs -ColumnLimit: 80 # Wrap lines after 80 characters +ColumnLimit: 120 # Wrap lines after 80 characters AllowShortLoopsOnASingleLine: true +AllowShortFunctionsOnASingleLine: false AlwaysBreakTemplateDeclarations: true BreakConstructorInitializers: BeforeComma +AlignConsecutiveDeclarations: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveMacros: true diff --git a/break.c b/break.c index 38828a3..3c39b67 100644 --- a/break.c +++ b/break.c @@ -2,6 +2,7 @@ #include #include // mmap and friends #include +#include int main(void) { /* diff --git a/sdldemo/Makefile b/sdldemo/Makefile new file mode 100644 index 0000000..e62fac0 --- /dev/null +++ b/sdldemo/Makefile @@ -0,0 +1,12 @@ +CC ?= gcc +CFLAGS ?= -Wall -O2 -lSDL2 + +TARGET = main.elf +SRC = main.c + +$(TARGET): $(SRC) + @echo CC $@ + @$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) + +clean: + rm -f $(TARGET) diff --git a/sdldemo/main.c b/sdldemo/main.c new file mode 100644 index 0000000..382417d --- /dev/null +++ b/sdldemo/main.c @@ -0,0 +1,40 @@ +#include +#include + +int main() { + if (SDL_Init(SDL_INIT_VIDEO) != 0) { + printf("SDL_Init Error: %s\n", SDL_GetError()); + return 1; + } + + SDL_Window *win = SDL_CreateWindow("Simple Window", 100, 100, 640, 480, SDL_WINDOW_SHOWN); + if (!win) { + printf("SDL_CreateWindow Error: %s\n", SDL_GetError()); + SDL_Quit(); + return 1; + } + + SDL_Renderer *renderer = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED); + if (!renderer) { + SDL_DestroyWindow(win); + printf("SDL_CreateRenderer Error: %s\n", SDL_GetError()); + SDL_Quit(); + return 1; + } + + SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255); // Blue background + SDL_RenderClear(renderer); + + SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); // Red rectangle + SDL_Rect rect = {100, 100, 200, 150}; + SDL_RenderFillRect(renderer, &rect); + + SDL_RenderPresent(renderer); + + SDL_Delay(3000); // Wait 3 seconds + + SDL_DestroyRenderer(renderer); + SDL_DestroyWindow(win); + SDL_Quit(); + return 0; +}