public Texture getTexture(String path) throws Exception { Texture texture = texturesMap.get(path); if ( texture == null ) { texture = new Texture(path); texturesMap.put(path, texture); } return texture; } }
public void cleanup() { glDeleteFramebuffers(depthMapFBO); depthMap.cleanup(); } }
public Particle(Mesh mesh, Vector3f speed, long ttl, long updateTextureMillis) { super(mesh); this.speed = new Vector3f(speed); this.ttl = ttl; this.updateTextureMillis = updateTextureMillis; this.currentAnimTimeMillis = 0; Texture texture = this.getMesh().getMaterial().getTexture(); this.animFrames = texture.getNumCols() * texture.getNumRows(); }
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 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, 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 Texture(String fileName) throws Exception { this(loadTexture(fileName)); }
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 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); }
public Texture(String fileName) throws Exception { this(loadTexture(fileName)); }
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 void cleanup() { glDeleteFramebuffers(depthMapFBO); depthMap.cleanup(); } }
public Texture getTexture(String path) throws Exception { Texture texture = texturesMap.get(path); if ( texture == null ) { texture = new Texture(path); texturesMap.put(path, texture); } return texture; } }
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); } }
public Particle(Mesh mesh, Vector3f speed, long ttl, long updateTextureMillis) { super(mesh); this.speed = new Vector3f(speed); this.ttl = ttl; this.updateTextureMillis = updateTextureMillis; this.currentAnimTimeMillis = 0; Texture texture = this.getMesh().getMaterial().getTexture(); this.animFrames = texture.getNumCols() * texture.getNumRows(); }
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 Texture(String fileName) throws Exception { this(loadTexture(fileName)); }
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 void cleanup() { glDeleteFramebuffers(depthMapFBO); depthMap.cleanup(); } }