54 lines
1.1 KiB
C
54 lines
1.1 KiB
C
/**
|
|
* Copyright (c) 2021 Dominic Msters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "render.h"
|
|
|
|
render_t * renderInit(char *name) {
|
|
// Initialize the renderer
|
|
render_t *render = malloc(sizeof(render_t));
|
|
if(!render) return NULL;
|
|
// render->width = WINDOW_WIDTH_DEFAULT;
|
|
// render->height = WINDOW_HEIGHT_DEFAULT;
|
|
|
|
//GLEnable Things
|
|
glEnable(GL_BLEND);
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
glEnable(GL_DEPTH_TEST);
|
|
glDepthMask(GL_TRUE);
|
|
glDepthFunc(GL_LEQUAL);
|
|
|
|
return render;
|
|
}
|
|
|
|
void renderFrame(render_t *render) {
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
float z = 0.0f;
|
|
|
|
glBegin(GL_TRIANGLES);
|
|
glColor3f(1, 0, 0);
|
|
glVertex3f(-1, -1, z);
|
|
|
|
glColor3f(0, 1, 0);
|
|
glVertex3f(0, 1, z);
|
|
|
|
glColor3f(0, 0, 1);
|
|
glVertex3f(1, -1, z);
|
|
glEnd();
|
|
}
|
|
|
|
bool renderDispose(render_t *render) {
|
|
// Free up the renderer
|
|
free(render);
|
|
return true;
|
|
}
|
|
|
|
void renderSetResolution(render_t *render, uint32_t width, uint32_t height) {
|
|
render->width = width;
|
|
render->height = height;
|
|
glViewport(0, 0, width, height);
|
|
} |