velage/engine/rendering.hpp

79 lines
No EOL
1.7 KiB
C++

#ifndef __RENDERING_H__
#define __RENDERING_H__
#include <GL/glew.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#include <SDL2/SDL_video.h>
#include <functional>
#include <vector>
#include <iostream>
#include <fstream>
#include <json/json.h>
#include <json/value.h>
#include <json/reader.h>
#include "light.hpp"
#include "shader.hpp"
#include "object.hpp"
#include "multipass.hpp"
//contains the context for the window and stuff for setting up the renderer to render stuff
class rendering {
public:
// init SDL2 (create window after)
bool SDLinit();
// init gl (after sdl init)
bool GLinit(SDL_Window *window);
//grab manifest and get shaders
bool Shaderinit();
SDL_GLContext context;
std::vector<GLuint> vertex_shaders;
std::vector<GLuint> fragment_shaders;
std::vector<GLuint> geometry_shaders;
std::vector<shader> shaders;
std::vector< std::reference_wrapper<gameobject> > objects;
std::vector<light> lights;
GLuint quadVBO;
GLuint quadVAO=0;
GLuint rboDepth;
GLint width;
GLint height;
GLuint depthCubemap;
GLuint depthFBO;
GLfloat farClipPlane=100;
const GLuint SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
//temporary
void render(camera cam, shader *depthshd, shader *shadowcalc, Gbuffer *gbuf);
void renderlighting(GLuint pos, GLuint txc);
/* sets up the textures for defered shading
* tex 0 position
* tex 1 normals
* tex 2 diffuse (albedo)
* tex 3 texcoord
*/
void setupTextureDS(Gbuffer gbuf);
/* copies the depth buffer to the main one
*
*/
void cpyDepthBuffer(GLuint buffer);
void mkDepthBuffer();
void mkShadowCubemap();
private:
SDL_Window *window;
};
#endif