| 5 | #include "ShadowMapRenderer.h" |
| 6 | |
| 7 | ShadowMapRenderer::ShadowMapRenderer(const shared_ptr<ONFSTrack> &activeTrack): track(activeTrack) { |
| 8 | // ----------------------- |
| 9 | // Configure depth map FBO |
| 10 | // ----------------------- |
| 11 | glGenFramebuffers(1, &depthMapFBO); |
| 12 | // create depth texture |
| 13 | glGenTextures(1, &depthTextureID); |
| 14 | glBindTexture(GL_TEXTURE_2D, depthTextureID); |
| 15 | glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, SHADOW_WIDTH, SHADOW_HEIGHT, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); |
| 16 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 17 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 18 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
| 19 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
| 20 | /*glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); |
| 21 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); |
| 22 | float borderColor[] = { 1.0f, 1.0f, 1.0f, 1.0f }; |
| 23 | glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);*/ |
| 24 | // attach depth texture as FBO's depth buffer |
| 25 | glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); |
| 26 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTextureID, 0); |
| 27 | glDrawBuffer(GL_NONE); |
| 28 | glReadBuffer(GL_NONE); |
| 29 | |
| 30 | // Always check that our framebuffer is ok |
| 31 | ASSERT(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, "Depth FBO is nae good."); |
| 32 | |
| 33 | glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 34 | } |
| 35 | |
| 36 | void ShadowMapRenderer::renderShadowMap(const glm::mat4 &lightViewMatrix, std::vector<int> activeTrackBlockIDs, const std::shared_ptr<Car> &car){ |
| 37 | /* ------- SHADOW MAPPING ------- */ |
nothing calls this directly
no outgoing calls
no test coverage detected