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"
|
2021-08-09 15:49:05 +01:00
|
|
|
#include "random.h"
|
2023-03-01 00:55:04 +00:00
|
|
|
#include "clock.h"
|
2021-07-04 02:53:37 +01:00
|
|
|
|
2021-08-12 21:16:45 +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!
|
2021-08-12 21:16:45 +01:00
|
|
|
// 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
|
2021-08-12 21:16:45 +01:00
|
|
|
GLuint g0;
|
2021-08-13 20:03:19 +01:00
|
|
|
// x albedo x
|
|
|
|
// y albedo y
|
|
|
|
// z albedo z
|
|
|
|
// w -
|
|
|
|
GLuint g1;
|
2021-08-12 21:16:45 +01:00
|
|
|
};
|
|
|
|
|
2021-07-10 16:16:01 +01:00
|
|
|
SDL_Window* gfxInit(int width, int height);
|
|
|
|
|
2021-08-12 21:16:45 +01:00
|
|
|
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
|
|
|
|
2021-08-12 21:16:45 +01:00
|
|
|
int createTextures(int width, int height, struct Shaders shaders, struct Textures* textures);
|
2021-08-09 15:49:05 +01:00
|
|
|
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);
|
2021-08-12 21:16:45 +01:00
|
|
|
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
|
|
|
|
2021-08-12 21:16:45 +01:00
|
|
|
// quad initialisation
|
2021-07-09 01:00:19 +01:00
|
|
|
void setVertexAttributes();
|
|
|
|
void initBuffers();
|
|
|
|
|