List of usage examples for org.lwjgl.opengl GL11 glEnable
public static void glEnable(@NativeType("GLenum") int target)
From source file:com.grillecube.client.renderer.gui.font.FontModel.java
/** render this font model */ public void render() { if (this.hasState(FontModel.STATE_TEXT_UP_TO_DATE) == false) { this.updateText(); }// www. j a va 2 s.co m if (this.vertexCount == 0 || this.font == null) { return; } GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); this.vao.bind(); this.font.getTexture().bind(GL13.GL_TEXTURE0, GL11.GL_TEXTURE_2D); this.vao.draw(GL11.GL_TRIANGLES, 0, this.vertexCount); }
From source file:com.grillecube.client.renderer.gui.GuiRenderer.java
@Override public void render() { GL11.glDisable(GL11.GL_DEPTH_TEST);/*w w w . j av a2 s .c o m*/ GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // render them in the correct order for (Gui gui : this.renderingList) { gui.render(this); } GL11.glDisable(GL11.GL_BLEND); }
From source file:com.grillecube.client.renderer.model.ModelRenderer.java
/** render world terrains */ public void render(CameraProjective camera, HashMap<Model, ArrayList<ModelInstance>> renderingList) { if (this.getMainRenderer().getGLFWWindow().isKeyPressed(GLFW.GLFW_KEY_F)) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); }// www . j a v a2 s. com GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_DEPTH_TEST); // enable model program this.programModel.useStart(); { // load global uniforms this.programModel.loadCamera(camera); // for each entity to render for (ArrayList<ModelInstance> models : renderingList.values()) { if (models.size() > 0) { Model model = models.get(0).getModel(); model.bind(); this.programModel.loadModel(model); for (ModelInstance instance : models) { this.programModel.loadModelInstance(instance); model.draw(); } } } } this.programModel.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.client.renderer.particles.ParticleRenderer.java
/** * render every given billoaded particles with the given camera (billboarded * = textured quad facing the camera)//from w ww .jav a 2s.c om */ public final void renderBillboardedParticles(CameraProjective camera, ArrayList<ParticleBillboarded> particles) { if (particles.size() == 0) { return; } GL13.glActiveTexture(GL13.GL_TEXTURE0 + 0); // Texture unit 0 GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); this.programBillboardedParticles.useStart(); this.getMainRenderer().getDefaultVAO().bind(); this.programBillboardedParticles.loadGlobalUniforms(camera); HashMap<ParticleBillboarded, Double> distances = new HashMap<ParticleBillboarded, Double>( particles.size() * 4); for (ParticleBillboarded particle : particles) { distances.put(particle, Vector3f.distanceSquare(particle.getPosition(), camera.getPosition())); } particles.sort(new Comparator<ParticleBillboarded>() { @Override public int compare(ParticleBillboarded a, ParticleBillboarded b) { double da = distances.get(a); double db = distances.get(b); if (da < db) { return (1); } else if (da > db) { return (-1); } return (0); } }); int i = 0; while (i < particles.size()) { ParticleBillboarded particle = particles.get(i); float radius = Maths.max(Maths.max(particle.getSizeX(), particle.getSizeY()), particle.getSizeZ()); if (particle != null && distances.get(particle) < camera.getSquaredRenderDistance() && camera.isSphereInFrustum(particle.getPosition(), radius)) { this.programBillboardedParticles.loadInstanceUniforms(particle); this.getMainRenderer().getDefaultVAO().draw(GL11.GL_POINTS, 0, 1); } ++i; } }
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 ww . j a v a2s .c om*/ } // 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.world.TerrainMesh.java
@Override protected void preDraw() { if (this.cull()) { GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK);/* w ww . j a va 2 s . c o m*/ } else { 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); if (this.getMainRenderer().getGLFWWindow().isKeyPressed(GLFW.GLFW_KEY_F)) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); }/*w w w . j a v a2 s. c o m*/ 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.font.FontModel.java
/** render this font model */ public void render() { if (this.hasState(FontModel.STATE_INITIALIZED) == false) { this.initialize(); }/*from w w w . ja va 2 s.c om*/ if (this.hasState(FontModel.STATE_TEXT_UP_TO_DATE) == false) { this.updateText(); } if (this._vertex_count == 0 || this._font == null) { return; } GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); this._vao.bind(); this._font.getTexture().bind(GL13.GL_TEXTURE0, GL11.GL_TEXTURE_2D); this._vao.draw(GL11.GL_TRIANGLES, 0, this._vertex_count); }
From source file:com.grillecube.engine.renderer.model.ModelRenderer.java
/** render world terrains */ @Override//from w ww. ja v a2s . c om 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;/*from w ww. j av a 2s.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); }