Start building main compositor application
This commit is contained in:
parent
ea3aceeaf8
commit
150ada41b2
8
include/compositor.h
Normal file
8
include/compositor.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef COMPOSITOR_H
|
||||
#define COMPOSITOR_H
|
||||
|
||||
#include "aliases/aliases.h"
|
||||
|
||||
i32 run_main_loop(void);
|
||||
|
||||
#endif // !COMPOSITOR_H
|
59
src/compositor.c
Normal file
59
src/compositor.c
Normal file
@ -0,0 +1,59 @@
|
||||
#include "aliases/aliases.h"
|
||||
#include "window.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_events.h>
|
||||
#include <SDL2/SDL_render.h>
|
||||
#include <SDL2/SDL_video.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define MAX_WINDOWS 2
|
||||
|
||||
#define WINDOW_WIDTH 800
|
||||
#define WINDOW_HEIGHT 600
|
||||
|
||||
typedef struct compositor compositor_t;
|
||||
struct compositor {
|
||||
window_t windows[MAX_WINDOWS];
|
||||
bool running;
|
||||
SDL_Event event;
|
||||
};
|
||||
|
||||
i32 run_main_loop(void) {
|
||||
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
compositor_t comp = {0};
|
||||
|
||||
window_t *main_window = &(comp.windows[0]);
|
||||
|
||||
if (!init_window(main_window, "Compositor", WINDOW_WIDTH, WINDOW_HEIGHT)) {
|
||||
SDL_Quit();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
comp.running = true;
|
||||
|
||||
colour_t bg_colour = {.abgr = 0xffffffff};
|
||||
colour_t fg_colour = {.abgr = 0xff000000};
|
||||
|
||||
while (comp.running) {
|
||||
while (SDL_PollEvent(&(comp.event))) {
|
||||
switch (comp.event.type) {
|
||||
case SDL_QUIT:
|
||||
comp.running = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
clear_window(main_window, bg_colour);
|
||||
|
||||
swap_buffers(main_window);
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Reference in New Issue
Block a user