Additional cleanup.
This commit is contained in:
parent
dcfc8cca97
commit
136999f701
19
graphics.cc
19
graphics.cc
@ -66,28 +66,12 @@ void Graphics::init(Level* level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
framebuffer_cube = SharedFrameBufferObject(new FrameBufferObject());
|
framebuffer_cube = SharedFrameBufferObject(new FrameBufferObject());
|
||||||
|
|
||||||
depthTexture_cube = SharedTexture2D( new Texture2D(windowSize, GL_DEPTH_COMPONENT16));
|
|
||||||
depthTexture_cube->setMinFilter(GL_NEAREST);
|
|
||||||
depthTexture_cube->setMagFilter(GL_NEAREST);
|
|
||||||
depthTexture_cube->setWrapS(GL_CLAMP_TO_EDGE);
|
|
||||||
depthTexture_cube->setWrapT(GL_CLAMP_TO_EDGE);
|
|
||||||
depthTexture_cube->setCompareMode(GL_COMPARE_REF_TO_TEXTURE);
|
|
||||||
|
|
||||||
framebuffer_cube_mirror = SharedFrameBufferObject(new FrameBufferObject());
|
|
||||||
framebuffer_cube_mirror->setDepthTexture(depthTexture_cube);
|
|
||||||
|
|
||||||
saveDepthBufferBool = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::uvec2 Graphics::getWindowSize() {
|
glm::uvec2 Graphics::getWindowSize() {
|
||||||
return windowSize;
|
return windowSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::saveDepthBuffer() {
|
|
||||||
saveDepthBufferBool = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Graphics::render(double time)
|
void Graphics::render(double time)
|
||||||
{
|
{
|
||||||
// At first render shadows
|
// At first render shadows
|
||||||
@ -106,9 +90,6 @@ void Graphics::render(double time)
|
|||||||
for (unsigned int i_pointlight = 0; i_pointlight<1 && i_pointlight<level->getLights()->size(); i_pointlight++) {
|
for (unsigned int i_pointlight = 0; i_pointlight<1 && i_pointlight<level->getLights()->size(); i_pointlight++) {
|
||||||
// render each side of the cube
|
// render each side of the cube
|
||||||
for (int i_face = 0; i_face<6; i_face++) {
|
for (int i_face = 0; i_face<6; i_face++) {
|
||||||
framebuffer_cube_mirror->bind();
|
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
|
||||||
framebuffer_cube->bind();
|
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i_face, depth_cubeMaps.at(i_pointlight)->getObjectName(), 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i_face, depth_cubeMaps.at(i_pointlight)->getObjectName(), 0);
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
glm::mat4 viewMatrix = glm::lookAt(level->getLights()->at(i_pointlight).getPosition(),
|
glm::mat4 viewMatrix = glm::lookAt(level->getLights()->at(i_pointlight).getPosition(),
|
||||||
|
@ -18,9 +18,7 @@ class Graphics {
|
|||||||
glm::uvec2 getWindowSize();
|
glm::uvec2 getWindowSize();
|
||||||
void resize(glm::uvec2 windowSize);
|
void resize(glm::uvec2 windowSize);
|
||||||
float getFarPlane();
|
float getFarPlane();
|
||||||
void saveDepthBuffer();
|
|
||||||
private:
|
private:
|
||||||
bool saveDepthBufferBool;
|
|
||||||
void updateLights();
|
void updateLights();
|
||||||
void saveDepthBufferToDisk(int face, std::string);
|
void saveDepthBufferToDisk(int face, std::string);
|
||||||
double lastUpdate;
|
double lastUpdate;
|
||||||
@ -33,8 +31,6 @@ class Graphics {
|
|||||||
ACGL::OpenGL::SharedFrameBufferObject framebuffer;
|
ACGL::OpenGL::SharedFrameBufferObject framebuffer;
|
||||||
std::vector<ACGL::OpenGL::SharedTextureCubeMap> depth_cubeMaps;
|
std::vector<ACGL::OpenGL::SharedTextureCubeMap> depth_cubeMaps;
|
||||||
ACGL::OpenGL::SharedFrameBufferObject framebuffer_cube;
|
ACGL::OpenGL::SharedFrameBufferObject framebuffer_cube;
|
||||||
ACGL::OpenGL::SharedFrameBufferObject framebuffer_cube_mirror;
|
|
||||||
ACGL::OpenGL::SharedTexture2D depthTexture_cube;
|
|
||||||
static const int cube_size;
|
static const int cube_size;
|
||||||
Level* level;
|
Level* level;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user