templates/SDLOpenGL/code/main.c

65 lines
1.1 KiB
C

#include <stdio.h>
#include <assert.h>
#include <stdint.h>
#include <glad/glad.h>
#include <glad/glad.c>
#define SDL_MAIN_HANDLED
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#include "bitmaps.h"
#include "renderer.h"
#include "renderer.c"
#define true 1
#define false 0
int main(int argc, char *argv[])
{
/* Initialization */
SDL_Init(SDL_INIT_EVERYTHING);
init_info info = { .width = 800, .height = 600};
r_init(info);
v4 bg_color = extract_color_v4_from_u32(0x0C0C0CFF);
_Bool Running = true;
/* Main Loop */
while(Running)
{
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(bg_color.x, bg_color.y, bg_color.z, bg_color.w);
SDL_Event e;
while(SDL_PollEvent(&e))
{
switch(e.type)
{
case SDL_QUIT: Running = false; break;
case SDL_WINDOWEVENT:
{
if(e.window.event == SDL_WINDOWEVENT_RESIZED)
{
r_resize(e.window.data1, e.window.data2);
}
} break;
}
}
r_draw_text("Sample", -1, .1f, 0xFF00FFFF, 1.0f);
r_draw_text("colored", -1, 0.f, 0x00FFFFFF, 0.75f);
r_draw_text("text", -1, -.1f, 0xACACACFF, 0.5f);
r_present();
}
return 0;
}