List of usage examples for org.lwjgl.opengl GL11 glDisable
public static void glDisable(@NativeType("GLenum") int target)
From source file:com.grillecube.client.renderer.particles.ParticleRenderer.java
/** render every cube particles */ public final void renderCubeParticles(CameraProjective camera, ArrayList<ParticleCube> particles) { if (particles.size() == 0) { return;//from w w w. j ava 2 s . c o m } // get the number of cube particle alive int cube_count = Maths.min(particles.size(), ParticleRenderer.MAX_CUBE_PARTICLES); if (cube_count == ParticleRenderer.MAX_CUBE_PARTICLES) { Logger.get().log(Logger.Level.WARNING, "Max number of cube particle reached! " + particles.size() + "/" + ParticleRenderer.MAX_CUBE_PARTICLES); } // create a buffer to hold them all ByteBuffer floats = BufferUtils.createByteBuffer(cube_count * CubeMesh.FLOATS_PER_CUBE_INSTANCE * 4); int cubesInBuffer = 0; for (int i = 0; i < cube_count; i++) { ParticleCube particle = particles.get(i); // if not in frustum, do not render it if (!camera.isBoxInFrustum(particle, particle)) { continue; } Matrix4f mat = particle.getTransfMatrix(); Vector4f color = particle.getColor(); float health = particle.getHealthRatio(); floats.putFloat(mat.m00); floats.putFloat(mat.m01); floats.putFloat(mat.m02); floats.putFloat(mat.m03); floats.putFloat(mat.m10); floats.putFloat(mat.m11); floats.putFloat(mat.m12); floats.putFloat(mat.m13); floats.putFloat(mat.m20); floats.putFloat(mat.m21); floats.putFloat(mat.m22); floats.putFloat(mat.m23); floats.putFloat(mat.m30); floats.putFloat(mat.m31); floats.putFloat(mat.m32); floats.putFloat(mat.m33); floats.putFloat(color.x); floats.putFloat(color.y); floats.putFloat(color.z); floats.putFloat(color.w); floats.putFloat(health); ++cubesInBuffer; } floats.flip(); this.cubeInstancesVBO.bind(GL15.GL_ARRAY_BUFFER); int buffersize = cubesInBuffer * CubeMesh.FLOATS_PER_CUBE_INSTANCE * 4; this.cubeInstancesVBO.bufferDataUpdate(GL15.GL_ARRAY_BUFFER, floats, buffersize); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); this.programCube.useStart(); this.programCube.loadGlobalUniforms(camera); this.cubeMesh.bind(); this.cubeMesh.drawInstanced(cubesInBuffer); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_BLEND); }
From source file:com.grillecube.client.renderer.sky.SkyRenderer.java
public void render(CameraProjective camera, Sky sky) { // GL11.glEnable(GL11.GL_CULL_FACE); // GL11.glCullFace(GL11.GL_BACK); this.programSky.useStart(); this.programSky.loadUniforms(sky, camera); this.vao.bind(); this.vao.draw(GL11.GL_TRIANGLES, 0, Sphere.getVertexCount(SKYDOME_PRECISION)); this.programSky.useStop(); GL11.glDisable(GL11.GL_CULL_FACE); }
From source file:com.grillecube.client.renderer.world.TerrainMesh.java
@Override protected void preDraw() { if (this.cull()) { GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK);/*w w w . j a va 2 s.co m*/ } else { GL11.glDisable(GL11.GL_CULL_FACE); } }
From source file:com.grillecube.client.renderer.world.TerrainMesh.java
@Override protected void postDraw() { if (this.cull()) { GL11.glDisable(GL11.GL_CULL_FACE); } }
From source file:com.grillecube.client.renderer.world.TerrainRenderer.java
public void render(CameraProjective camera, WorldFlat world, ArrayList<TerrainMesh> opaqueMeshes, ArrayList<TerrainMesh> transparentMeshes) { GL11.glEnable(GL11.GL_DEPTH_TEST);/*from w w w .j a v a 2s.c o m*/ if (this.getMainRenderer().getGLFWWindow().isKeyPressed(GLFW.GLFW_KEY_F)) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); } this.terrainProgram.useStart(); this.terrainProgram.loadUniforms(camera, world); if (opaqueMeshes != null && opaqueMeshes.size() > 0) { this.drawMeshes(camera, opaqueMeshes, ProgramTerrain.MESH_TYPE_OPAQUE); } if (transparentMeshes != null && transparentMeshes.size() > 0) { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // bind textures this.drawMeshes(camera, transparentMeshes, ProgramTerrain.MESH_TYPE_TRANSPARENT); GL11.glDisable(GL11.GL_BLEND); } GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); }
From source file:com.grillecube.engine.renderer.gui.GuiRenderer.java
@Override public void preRender() { GL11.glDisable(GL11.GL_DEPTH_TEST); }
From source file:com.grillecube.engine.renderer.model.ModelRenderer.java
/** render world terrains */ @Override/*from w ww . j a v a2s . c o m*/ public void render() { GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK); this.render(super.getCamera()); GL11.glDisable(GL11.GL_CULL_FACE); }
From source file:com.grillecube.engine.renderer.model.ModelRenderer.java
private void render(CameraProjective camera) { if (this._models == null) { return;/*w w w. java 2 s.c o m*/ } GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_DEPTH_TEST); if (this.getParent().getGLFWWindow().isKeyPressed(GLFW.GLFW_KEY_F)) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); } // enable model program this._program_model.useStart(); { // load global uniforms this._program_model.loadUniforms(camera); // for each model instance to render for (ModelInstance instance : this._models) { // the skin to use ModelSkin skin = instance.getModel().getSkin(instance.getSkinID()); if (skin == null) { continue; } // render each of it parts ModelPartInstance[] instances = instance.getPartInstances(); for (int i = 0; i < instances.length; i++) { ModelPartInstance part = instances[i]; // load uniforms this._program_model.loadInstanceUniforms(part.getTransformationMatrix()); // bind the part part.getModelPart().bind(); // unable skin ModelPartSkin partskin = skin.getPart(i); part.getModelPart().toggleSkin(partskin); // render part.getModelPart().render(); // } // // render equipment // if (instance.getEntity() instanceof EntityModeledLiving) { // EntityModeledLiving entity = (EntityModeledLiving) // instance.getEntity(); // Item[] items = entity.getEquipments(); // // // if the entity actually has equipmment // if (items != null) { // // for each of it equipments // for (Item item : items) { // // get it model // Model model = item.getModel(); // // unable the skin // // model.toggleSkin(item.getSkinID()); // // // TODO RENDER IT // } // } // } } } this._program_model.useStop(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_BLEND); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); }
From source file:com.grillecube.engine.renderer.model.ModelRenderer.java
@Override public void renderShadow(ShadowCamera shadow_camera) { if (this._models == null) { return;/*ww w . j a va2 s.c o m*/ } GL11.glEnable(GL11.GL_DEPTH_TEST); if (this.getParent().getGLFWWindow().isKeyPressed(GLFW.GLFW_KEY_F)) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); } // enable model program this._program_model_shadow.useStart(); { // load global uniforms this._program_model_shadow.loadUniforms(shadow_camera); // for each model instance to render for (ModelInstance instance : this._models) { // the skin to use ModelSkin skin = instance.getModel().getSkin(instance.getSkinID()); if (skin == null) { continue; } // render each of it parts for (int i = 0; i < instance.getPartInstances().length; i++) { ModelPartInstance part = instance.getPartInstances()[i]; // load uniforms this._program_model_shadow.loadInstanceUniforms(part); // bind the part part.getModelPart().bind(); // unable skin ModelPartSkin partskin = skin.getPart(i); part.getModelPart().toggleSkin(partskin); // render part.getModelPart().render(); } // render equipment if (instance.getEntity() instanceof EntityModeledLiving) { EntityModeledLiving entity = (EntityModeledLiving) instance.getEntity(); Item[] items = entity.getEquipments(); // if the entity actually has equipmment if (items != null) { // for each of it equipments for (Item item : items) { // get it model Model model = item.getModel(); // unable the skin // model.toggleSkin(item.getSkinID()); // TODO RENDER IT } } } } } this._program_model_shadow.useStop(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_BLEND); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); }
From source file:com.grillecube.engine.renderer.world.particles.ParticleRenderer.java
/** render every cube particles */ private void renderCubeParticles(World world, CameraProjectiveWorld camera) { if (this._cube_particles.size() == 0) { return;//from w ww. j av a 2s . c o m } GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); this._program_cube.useStart(); this._vao_cube.bind(); this._program_cube.loadGlobalUniforms(camera); this._vao_cube.drawInstanced(GL11.GL_TRIANGLES, 0, 36, this._cubes_in_buffer); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_BLEND); }