I am working on a 3D game in C ++ and OpenGL 3.2 with SFML. I tried my best to implement point-by-point rendering of shadows. What I have done so far seems to be consistent with what I learned and the examples I saw, but still there are no shadows.
What I did was write a simplified list of all the code that I use, in the order in which I use it, but not as the complete source code, but only the corresponding code (because my project is divided into several classes):
Omnidirectional shadow mapping C++ - Initialization -- Use shadow pass shader program -- Generate + bind the shadow frame buffer glGenFramebuffers(1, &shadowFrameBuffer); glBindFramebuffer(GL_FRAMEBUFFER, shadowFrameBuffer); -- Generate a texture glGenTextures(1, &shadowMap); -- Bind texture as cubemap glBindTexture(GL_TEXTURE_CUBE_MAP); -- Set texture parameters glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); -- Generate empty 1024 x 1024 for every face of the cube for (int face = 0; face < 6; face++) glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, GL_DEPTH_COMPONENT32F , 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); -- Attach the cubemap to the framebuffer glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, shadowMap, 0); -- Only draw depth to framebuffer glDrawBuffer(GL_NONE); - Every frame -- Clear screen glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); -- Render shadow map --- Bind shadow frame buffer glBindFramebuffer(GL_FRAMEBUFFER, shadowFrameBuffer); --- Set the viewport to the size of the shadow map glViewport(0, 0, 1024, 1024); -- Cull front faces glCullFace(GL_FRONT); -- Use shadow mapping program --- Define projection matrix for rendering each face glm::mat4 depthProjectionMatrix = glm::perspective(90.0f, 1.0f, 1.0f, 10.0f); --- Define view matrices for all six faces std::vector<glm::mat4> depthViewMatrices; depthViewMatrices.push_back(glm::lookAt(lightInvDir, glm::vec3(1,0,0), glm::vec3(0,-1,0) ));
Here is an image of what my code is doing now:

This is a strange effect, but it seems to be close to what I had in mind. It seems that any surface exposed to light at 0, 0, 0 has an unpainted circle in the center of it, and everything else is not indicated.