private void renderInstancedMeshes(Scene scene, boolean depthMap, ShaderProgram shader, Matrix4f viewMatrix, Matrix4f lightViewMatrix) { shader.setUniform("isInstanced", 1); // Render each mesh with the associated game Items Map<InstancedMesh, List<GameItem>> mapMeshes = scene.getGameInstancedMeshes(); for (InstancedMesh mesh : mapMeshes.keySet()) { if (!depthMap) { shader.setUniform("material", mesh.getMaterial()); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, shadowMap.getDepthMapTexture().getId()); } mesh.renderListInstanced(mapMeshes.get(mesh), depthMap, transformation, viewMatrix, lightViewMatrix); } }
public ShadowMap() throws Exception { // Create a FBO to render the depth map depthMapFBO = glGenFramebuffers(); // Create the depth map texture depthMap = new Texture(SHADOW_MAP_WIDTH, SHADOW_MAP_HEIGHT, GL_DEPTH_COMPONENT); // Attach the the depth map texture to the FBO glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap.getId(), 0); // Set only depth glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { throw new Exception("Could not create FrameBuffer"); } // Unbind glBindFramebuffer(GL_FRAMEBUFFER, 0); }
public ShadowMap() throws Exception { // Create a FBO to render the depth map depthMapFBO = glGenFramebuffers(); // Create the depth map texture depthMap = new Texture(SHADOW_MAP_WIDTH, SHADOW_MAP_HEIGHT, GL_DEPTH_COMPONENT); // Attach the the depth map texture to the FBO glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap.getId(), 0); // Set only depth glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { throw new Exception("Could not create FrameBuffer"); } // Unbind glBindFramebuffer(GL_FRAMEBUFFER, 0); }
public ShadowMap() throws Exception { // Create a FBO to render the depth map depthMapFBO = glGenFramebuffers(); // Create the depth map texture depthMap = new Texture(SHADOW_MAP_WIDTH, SHADOW_MAP_HEIGHT, GL_DEPTH_COMPONENT); // Attach the the depth map texture to the FBO glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap.getId(), 0); // Set only depth glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { throw new Exception("Could not create FrameBuffer"); } // Unbind glBindFramebuffer(GL_FRAMEBUFFER, 0); }
public ShadowMap() throws Exception { // Create a FBO to render the depth map depthMapFBO = glGenFramebuffers(); // Create the depth map texture depthMap = new Texture(SHADOW_MAP_WIDTH, SHADOW_MAP_HEIGHT, GL_DEPTH_COMPONENT); // Attach the the depth map texture to the FBO glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap.getId(), 0); // Set only depth glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { throw new Exception("Could not create FrameBuffer"); } // Unbind glBindFramebuffer(GL_FRAMEBUFFER, 0); }
public ShadowMap() throws Exception { // Create a FBO to render the depth map depthMapFBO = glGenFramebuffers(); // Create the depth map texture depthMap = new Texture(SHADOW_MAP_WIDTH, SHADOW_MAP_HEIGHT, GL_DEPTH_COMPONENT); // Attach the the depth map texture to the FBO glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap.getId(), 0); // Set only depth glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { throw new Exception("Could not create FrameBuffer"); } // Unbind glBindFramebuffer(GL_FRAMEBUFFER, 0); }
public ShadowMap() throws Exception { // Create a FBO to render the depth map depthMapFBO = glGenFramebuffers(); // Create the depth map texture depthMap = new Texture(SHADOW_MAP_WIDTH, SHADOW_MAP_HEIGHT, GL_DEPTH_COMPONENT); // Attach the the depth map texture to the FBO glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap.getId(), 0); // Set only depth glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { throw new Exception("Could not create FrameBuffer"); } // Unbind glBindFramebuffer(GL_FRAMEBUFFER, 0); }
public ShadowMap() throws Exception { // Create a FBO to render the depth map depthMapFBO = glGenFramebuffers(); // Create the depth map texture depthMap = new Texture(SHADOW_MAP_WIDTH, SHADOW_MAP_HEIGHT, GL_DEPTH_COMPONENT); // Attach the the depth map texture to the FBO glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap.getId(), 0); // Set only depth glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { throw new Exception("Could not create FrameBuffer"); } // Unbind glBindFramebuffer(GL_FRAMEBUFFER, 0); }
public ShadowMap() throws Exception { // Create a FBO to render the depth map depthMapFBO = glGenFramebuffers(); // Create the depth map texture depthMap = new Texture(SHADOW_MAP_WIDTH, SHADOW_MAP_HEIGHT, GL_DEPTH_COMPONENT); // Attach the the depth map texture to the FBO glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap.getId(), 0); // Set only depth glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { throw new Exception("Could not create FrameBuffer"); } // Unbind glBindFramebuffer(GL_FRAMEBUFFER, 0); }
public ShadowMap() throws Exception { // Create a FBO to render the depth map depthMapFBO = glGenFramebuffers(); // Create the depth map texture depthMap = new Texture(SHADOW_MAP_WIDTH, SHADOW_MAP_HEIGHT, GL_DEPTH_COMPONENT); // Attach the the depth map texture to the FBO glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap.getId(), 0); // Set only depth glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { throw new Exception("Could not create FrameBuffer"); } // Unbind glBindFramebuffer(GL_FRAMEBUFFER, 0); }
public ShadowMap() throws Exception { // Create a FBO to render the depth map depthMapFBO = glGenFramebuffers(); // Create the depth map texture depthMap = new Texture(SHADOW_MAP_WIDTH, SHADOW_MAP_HEIGHT, GL_DEPTH_COMPONENT); // Attach the the depth map texture to the FBO glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap.getId(), 0); // Set only depth glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { throw new Exception("Could not create FrameBuffer"); } // Unbind glBindFramebuffer(GL_FRAMEBUFFER, 0); }
public ShadowMap() throws Exception { // Create a FBO to render the depth map depthMapFBO = glGenFramebuffers(); // Create the depth map texture depthMap = new Texture(SHADOW_MAP_WIDTH, SHADOW_MAP_HEIGHT, GL_DEPTH_COMPONENT); // Attach the the depth map texture to the FBO glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap.getId(), 0); // Set only depth glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { throw new Exception("Could not create FrameBuffer"); } // Unbind glBindFramebuffer(GL_FRAMEBUFFER, 0); }
private void initRender() { Texture texture = material.getTexture(); if (texture != null) { // Activate firs texture bank glActiveTexture(GL_TEXTURE0); // Bind the texture glBindTexture(GL_TEXTURE_2D, texture.getId()); } // Draw the mesh glBindVertexArray(getVaoId()); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); }
private void initRender() { Texture texture = material.getTexture(); if (texture != null) { // Activate firs texture bank glActiveTexture(GL_TEXTURE0); // Bind the texture glBindTexture(GL_TEXTURE_2D, texture.getId()); } // Draw the mesh glBindVertexArray(getVaoId()); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); }
private void renderInstancedMeshes(Scene scene, ShaderProgram shader, Matrix4f viewMatrix, Matrix4f lightViewMatrix) { shader.setUniform("isInstanced", 1); // Render each mesh with the associated game Items Map<InstancedMesh, List<GameItem>> mapMeshes = scene.getGameInstancedMeshes(); for (InstancedMesh mesh : mapMeshes.keySet()) { Texture text = mesh.getMaterial().getTexture(); if (text != null) { sceneShaderProgram.setUniform("numCols", text.getNumCols()); sceneShaderProgram.setUniform("numRows", text.getNumRows()); } if (viewMatrix != null) { shader.setUniform("material", mesh.getMaterial()); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, shadowMap.getDepthMapTexture().getId()); } mesh.renderListInstanced(mapMeshes.get(mesh), transformation, viewMatrix, lightViewMatrix); } }
private void renderInstancedMeshes(Scene scene, ShaderProgram shader, Matrix4f viewMatrix, Matrix4f lightViewMatrix) { shader.setUniform("isInstanced", 1); // Render each mesh with the associated game Items Map<InstancedMesh, List<GameItem>> mapMeshes = scene.getGameInstancedMeshes(); for (InstancedMesh mesh : mapMeshes.keySet()) { Texture text = mesh.getMaterial().getTexture(); if (text != null) { sceneShaderProgram.setUniform("numCols", text.getNumCols()); sceneShaderProgram.setUniform("numRows", text.getNumRows()); } if (viewMatrix != null) { shader.setUniform("material", mesh.getMaterial()); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, shadowMap.getDepthMapTexture().getId()); } mesh.renderListInstanced(mapMeshes.get(mesh), transformation, viewMatrix, lightViewMatrix); } }
private void initRender() { Texture texture = material.getTexture(); if (texture != null) { // Activate firs texture bank glActiveTexture(GL_TEXTURE0); // Bind the texture glBindTexture(GL_TEXTURE_2D, texture.getId()); } // Draw the mesh glBindVertexArray(getVaoId()); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); }
private void initRender() { Texture texture = material.getTexture(); if (texture != null) { // Activate firs texture bank glActiveTexture(GL_TEXTURE0); // Bind the texture glBindTexture(GL_TEXTURE_2D, texture.getId()); } // Draw the mesh glBindVertexArray(getVaoId()); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); }
public void render() { // Activate firs texture bank glActiveTexture(GL_TEXTURE0); // Bind the texture glBindTexture(GL_TEXTURE_2D, texture.getId()); // Draw the mesh glBindVertexArray(getVaoId()); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glDrawElements(GL_TRIANGLES, getVertexCount(), GL_UNSIGNED_INT, 0); // Restore state glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); glBindVertexArray(0); }
public void render() { // Activate firs texture bank glActiveTexture(GL_TEXTURE0); // Bind the texture glBindTexture(GL_TEXTURE_2D, texture.getId()); // Draw the mesh glBindVertexArray(getVaoId()); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glDrawElements(GL_TRIANGLES, getVertexCount(), GL_UNSIGNED_INT, 0); // Restore state glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); glBindVertexArray(0); }