Compare commits

..

3 commits

Author SHA1 Message Date
Imbus
12e5f22929 Includes 2025-08-12 03:23:15 +02:00
Imbus
6e7e2858d3 New formatting config 2025-08-08 05:14:36 +02:00
Imbus
4b26278543 SDLdemo 2025-08-08 05:14:17 +02:00
4 changed files with 63 additions and 1 deletions

View file

@ -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

View file

@ -2,6 +2,7 @@
#include <stdio.h>
#include <sys/mman.h> // mmap and friends
#include <unistd.h>
#include <stdbool.h>
int main(void) {
/*

12
sdldemo/Makefile Normal file
View file

@ -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)

40
sdldemo/main.c Normal file
View file

@ -0,0 +1,40 @@
#include <SDL2/SDL.h>
#include <stdio.h>
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;
}