summaryrefslogblamecommitdiffstats
path: root/src/RendererSection.hpp
blob: 12a169e625f8b6e719910326bb3a42ef729829b7 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                     



                                    
                                  




                                                              
                       








                                 
        
                                          
 

                      

                                                           
       
                                              


                                             
                           
 
                                              
 
                         
 
                     
 


                                                                 
 
#pragma once

#include <GL/glew.h>
#include <glm/detail/type_mat.hpp>
#include <glm/vec2.hpp>
#include <glm/detail/type_mat4x4.hpp>
#include <glm/gtx/transform.hpp>
#include <easylogging++.h>

#include "AssetManager.hpp"
#include "Section.hpp"
#include "World.hpp"
#include "Vector.hpp"
#include "Renderer.hpp"

struct RendererSectionData {
    std::vector<glm::mat4> models;
    std::vector<glm::vec4> textures;
    std::vector<glm::vec3> colors;
    std::vector<glm::vec2> lights;
    size_t hash;
    Vector sectionPos;

    RendererSectionData(World *world, Vector sectionPosition);
};
class RendererSection {
    enum Vbos {
        MODELS = 0,
        TEXTURES,
        COLORS,
        LIGHTS,
        VBOCOUNT,
    };
    GLuint Vao = { 0 };
    GLuint Vbo[VBOCOUNT] = { 0 };
	
	static GLuint VboVertices, VboUvs;

	size_t hash;
    Vector sectionPos;

    RendererSection(const RendererSection &other) = delete;
public:
    RendererSection(RendererSectionData data);

    RendererSection(RendererSection &&other);

	~RendererSection();

	void Render(RenderState &renderState);

    Vector GetPosition();

    size_t GetHash();

    size_t numOfFaces;

    friend void swap(RendererSection &lhs, RendererSection &rhs);
};