oglc/src/gfx.h

64 lines
1.4 KiB
C
Raw Normal View History

2021-07-04 02:53:37 +01:00
#pragma once
#define GLEW_STATIC
#include "GL/glew.h"
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
2023-03-01 00:12:15 +00:00
#include <cglm/vec2.h>
2021-07-04 02:53:37 +01:00
#include "io.h"
#include "random.h"
2023-03-01 00:55:04 +00:00
#include "clock.h"
2021-07-04 02:53:37 +01:00
struct Shaders
{
GLuint quad;
GLuint prepass;
GLuint lighting;
};
struct Textures
{
// texture that ultimately gets drawn to the framebuffer
GLuint target;
// TODO: blue noise, pink noise!
// noise texture to help with randomness
GLuint noise;
2021-08-13 20:03:19 +01:00
// TODO: replace these with an actual array!
// additional view space information
//
2021-08-13 20:03:19 +01:00
// x surface normal x
// y surface normal y
// z surface normal z
// w depth
GLuint g0;
2021-08-13 20:03:19 +01:00
// x albedo x
// y albedo y
// z albedo z
// w -
GLuint g1;
};
2021-07-10 16:16:01 +01:00
SDL_Window* gfxInit(int width, int height);
int compileShaders(struct Shaders *shaders);
GLuint compileQuadShaderProgram(const char* vsPath, const char* fsPath);
GLuint compileComputeShaderProgram(const char* csPath);
2021-07-04 02:53:37 +01:00
int createTextures(int width, int height, struct Shaders shaders, struct Textures* textures);
GLuint createNoiseTexture(int width, int height);
2021-08-13 20:03:19 +01:00
GLuint createTextureUnit(int width, int height, int unit);
2021-07-10 16:16:01 +01:00
GLuint createWriteOnlyTexture(int width, int height);
GLuint compileShader(const char* path, GLenum type);
2021-07-10 16:16:01 +01:00
void printWorkGroupLimits();
2021-07-05 01:05:37 +01:00
// quad initialisation
2021-07-09 01:00:19 +01:00
void setVertexAttributes();
void initBuffers();