summaryrefslogtreecommitdiff
path: root/tests/sdl.c
blob: a3c3d8fd6a33e847de54076cffd459f979120711 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#define SDL_DISABLE_IMMINTRIN_H
#include <SDL2/SDL.h>
#include <GL/glcorearb.h>
#include <stdio.h>
#include <stdbool.h>

int main(void) {
	SDL_Init(SDL_INIT_EVERYTHING);
	SDL_Window *window = SDL_CreateWindow("hi", 0, 0, 1280, 720, SDL_WINDOW_SHOWN|SDL_WINDOW_OPENGL);
	SDL_GLContext ctx = SDL_GL_CreateContext(window);
	PFNGLCLEARPROC glClear = SDL_GL_GetProcAddress("glClear");
	PFNGLCLEARCOLORPROC glClearColor = SDL_GL_GetProcAddress("glClearColor");
	SDL_GL_SetSwapInterval(1);
	while (true) {
		SDL_Event event;
		while (SDL_PollEvent(&event)) {
			if (event.type == SDL_QUIT) {
				return 0;
			}
		}
		glClearColor(1, 1, 1, 1);
		glClear(GL_COLOR_BUFFER_BIT);
		SDL_GL_SwapWindow(window);
	}
	(void)ctx;
}

void entry(void) {
	exit(main());
}