List of usage examples for org.lwjgl.opengl GL11 glBlendFunc
public static void glBlendFunc(@NativeType("GLenum") int sfactor, @NativeType("GLenum") int dfactor)
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 . j a v a2 s . c o m*/ 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
private void render(CameraProjective camera) { if (this._models == null) { return;/*from 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); 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.world.particles.ParticleRenderer.java
/** render every quad particles */ private void renderBillboardedParticles(World world, CameraProjectiveWorld camera) { if (this._billboarded_particles.size() == 0) { return;//from w ww . j a v a 2s . co m } 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._program_billboarded_particle.useStart(); this.getParent().getDefaultVAO().bind(); this._program_billboarded_particle.loadGlobalUniforms(camera); this._billboarded_particles.sort(this._particle_comparator); int i = 0; while (i < this._billboarded_particles.size()) { ParticleBillboarded particle = this._billboarded_particles.get(i); float radius = Maths.max(particle.getScale().x, particle.getScale().y); if (particle != null && particle.getCameraSquareDistance() < camera.getSquaredRenderDistance() && camera.isSphereInFrustum(particle.getPosition(), radius)) { this._program_billboarded_particle.loadInstanceUniforms(particle); this.getParent().getDefaultVAO().draw(GL11.GL_POINTS, 0, 1); } ++i; } }
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 ww w . j a v a2s . c om*/ } 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); }
From source file:com.grillecube.engine.renderer.world.particles.ProgramParticleBillboarded.java
/** load particle instance uniforms */ public void loadInstanceUniforms(ParticleBillboarded particle) { particle.getSprite().getTexture().bind(GL13.GL_TEXTURE0, GL11.GL_TEXTURE_2D); if (particle.isGlowing()) { GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); } else {/*www . j av a2 s .co m*/ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } super.loadUniformInteger(this._lines, particle.getSprite().getLines()); super.loadUniformInteger(this._cols, particle.getSprite().getCols()); super.loadUniformInteger(this._maxhealth, particle.getMaxHealth()); super.loadUniformInteger(this._health, particle.getHealth()); super.loadUniformVec(this._color, particle.getColor()); super.loadUniformVec(this._position, particle.getPosition()); super.loadUniformVec(this._scale, particle.getScale()); }
From source file:com.grillecube.engine.renderer.world.terrain.TerrainRenderer.java
@Override public void render() { if (!this._can_render) { return;/* w w w . ja v a2 s .c om*/ } GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); if (this.getParent().getGLFWWindow().isKeyPressed(GLFW.GLFW_KEY_F)) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); } this.render(super.getCamera()); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_CULL_FACE); }
From source file:com.itszuvalex.femtocraft.research.gui.GuiResearch.java
License:Open Source License
protected void genAchievementBackground(int par1, int par2, float par3) { int k = MathHelper.floor_double(field_74117_m + (guiMapX - field_74117_m) * (double) par3); int l = MathHelper.floor_double(field_74115_n + (guiMapY - field_74115_n) * (double) par3); if (k < guiMapTop) { k = guiMapTop;//from ww w . j a va2 s . c om } if (l < guiMapLeft) { l = guiMapLeft; } if (k >= guiMapBottom) { k = guiMapBottom - 1; } if (l >= guiMapRight) { l = guiMapRight - 1; } int i1 = (this.width - this.researchPaneWidth) / 2; int j1 = (this.height - this.researchPaneHeight) / 2; int k1 = i1 + 16; int l1 = j1 + 17; this.zLevel = 0.0F; GL11.glDepthFunc(GL11.GL_GEQUAL); GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 0.0F, -200.0F); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_COLOR_MATERIAL); int i2 = k + 288 >> 4; int j2 = l + 288 >> 4; int k2 = (k + 288) % 16; int l2 = (l + 288) % 16; Random random = new Random(); int i3; int j3; int k3; // Make background for (i3 = 0; i3 * 16 - l2 < 155; ++i3) { float f1 = 0.6F - (float) (j2 + i3) / 25.0F * 0.3F; GL11.glColor4f(f1, f1, f1, 1.0F); for (k3 = 0; k3 * 16 - k2 < 224; ++k3) { random.setSeed((long) (1234 + i2 + k3)); random.nextInt(); j3 = random.nextInt(1 + j2 + i3) + (j2 + i3) / 2; IIcon icon = Blocks.sand.getIcon(0, 0); if (j3 <= 37 && j2 + i3 != 35) { if (j3 == 22) { if (random.nextInt(2) == 0) { icon = Femtocraft.blockOrePlatinum().getIcon(0, 0); } else { icon = Femtocraft.blockOreFarenite().getIcon(0, 0); } } else if (j3 == 10) { icon = Femtocraft.blockOreTitanium().getIcon(0, 0); } else if (j3 == 8) { icon = Femtocraft.blockOreThorium().getIcon(0, 0); } else if (j3 > 4) { icon = Blocks.stone.getIcon(0, 0); } else if (j3 > 0) { icon = Blocks.dirt.getIcon(0, 0); } } else { icon = Blocks.bedrock.getIcon(0, 0); } Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); this.drawTexturedModelRectFromIcon(k1 + k3 * 16 - k2, l1 + i3 * 16 - l2, icon, 16, 16); } } GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); // GL11.glDisable(GL11.GL_TEXTURE_2D); int l3; int i4; int j4; for (ITechnology tech : Femtocraft.researchManager().getTechnologies()) { ResearchStatus rs = researchStatus.getTechnology(tech.getName()); if (rs == null) { continue; } if (tech.getPrerequisites() != null) { for (String cr : tech.getPrerequisites()) { TechNode node = Femtocraft.researchManager().getNode(tech); for (IGraphNode parent : node.getParents()) { IGraphNode next = parent; IGraphNode prev = node; while (next instanceof DummyTechNode) { k3 = prev.getDisplayX() * 24 - k + 11 + k1; j3 = prev.getDisplayY() * 24 - l + 11 + l1 - 11; j4 = next.getDisplayX() * 24 - k + 11 + k1; l3 = next.getDisplayY() * 24 - l + 11 + l1 + 11; boolean flag6 = !rs.researched(); i4 = Math.sin( (double) (Minecraft.getSystemTime() % 600L) / 600.0D * Math.PI * 2.0D) > 0.6D ? 255 : 130; int color = tech.getLevel().getColor(); if (flag6) { color += (i4 << 24); } else { color += (255 << 24); } // this.drawHorizontalLine(k3, j4, j3, color); // this.drawVerticalLine(j4, j3, l3, color); RenderUtils.drawLine(k3, j4, j3, l3, 1, color); RenderUtils.drawLine(j4, j4, l3 - 22, l3, 1, color); // Dummy nodes should only have 1 parent prev = next; next = next.getParents().get(0); } k3 = prev.getDisplayX() * 24 - k + 11 + k1; j3 = prev.getDisplayY() * 24 - l + 11 + l1 - 11; j4 = next.getDisplayX() * 24 - k + 11 + k1; l3 = next.getDisplayY() * 24 - l + 11 + l1 + 11; boolean flag6 = !rs.researched(); i4 = Math.sin((double) (Minecraft.getSystemTime() % 600L) / 600.0D * Math.PI * 2.0D) > 0.6D ? 255 : 130; int color = tech.getLevel().getColor(); if (flag6) { color += (i4 << 24); } else { color += (255 << 24); } // this.drawHorizontalLine(k3, j4, j3, color); // this.drawVerticalLine(j4, j3, l3, color); RenderUtils.drawLine(k3, j4, j3, l3, 1, color); } } } } ITechnology tooltipTech = null; RenderItem renderitem = new RenderItem(); RenderHelper.enableGUIStandardItemLighting(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_COLOR_MATERIAL); int l4; int i5; for (ITechnology tech : Femtocraft.researchManager().getTechnologies()) { ResearchStatus ts = researchStatus.getTechnology(tech.getName()); if (ts == null) { continue; } TechNode node = Femtocraft.researchManager().getNode(tech); j4 = node.getDisplayX() * 24 - k; l3 = node.getDisplayY() * 24 - l; if (j4 >= -24 && l3 >= -24 && j4 <= 224 && l3 <= 155) { float f2; if (ts.researched()) { f2 = 1.0F; GL11.glColor4f(f2, f2, f2, 1.0F); } else { f2 = Math.sin((double) (Minecraft.getSystemTime() % 600L) / 600.0D * Math.PI * 2.0D) < 0.6D ? 0.6F : 0.8F; GL11.glColor4f(f2, f2, f2, 1.0F); } // else { // f2 = 0.3F; // GL11.glColor4f(f2, f2, f2, 1.0F); // } Minecraft.getMinecraft().getTextureManager().bindTexture(achievementTextures); i5 = k1 + j4; l4 = l1 + l3; GL11.glEnable(GL11.GL_BLEND);// Forge: Specifically enable blend because it is needed here. And we // fix Generic RenderItem's leakage of it. if (tech.isKeystone()) { this.drawTexturedModalRect(i5 - 2, l4 - 2, 26, 202, 26, 26); } else { this.drawTexturedModalRect(i5 - 2, l4 - 2, 0, 202, 26, 26); } GL11.glDisable(GL11.GL_BLEND); //Forge: Cleanup states we set. // // if (!this.statFileWriter.canUnlockAchievement(achievement2)) // { // float f3 = 0.1F; // GL11.glColor4f(f3, f3, f3, 1.0F); // renderitem.renderWithColor = false; // } GL11.glDisable(GL11.GL_LIGHTING); //Forge: Make sure Lighting is disabled. Fixes MC-33065 GL11.glEnable(GL11.GL_CULL_FACE); RenderHelper.enableGUIStandardItemLighting(); // GL11.glDisable(GL11.GL_LIGHTING); // GL11.glBlendFunc(GL11.GL_DST_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // GL11.glEnable(GL12.GL_RESCALE_NORMAL); // GL11.glEnable(GL11.GL_COLOR_MATERIAL); // GL11.glEnable(GL11.GL_LIGHTING); // GL11.glEnable(GL11.GL_CULL_FACE); renderitem.renderItemAndEffectIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), tech.getDisplayItem(), i5 + 3, l4 + 3); RenderHelper.disableStandardItemLighting(); // GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // GL11.glDisable(GL11.GL_LIGHTING); // GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_LIGHTING); // if (!this.statFileWriter.canUnlockAchievement(achievement2)) // { // renderitem.renderWithColor = true; // } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); if (par1 >= k1 && par2 >= l1 && par1 < k1 + 224 && par2 < l1 + 155 && par1 >= i5 && par1 <= i5 + 22 && par2 >= l4 && par2 <= l4 + 22) { tooltipTech = tech; } } } GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glPopMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().getTextureManager().bindTexture(achievementTextures); this.drawTexturedModalRect(i1, j1, 0, 0, this.researchPaneWidth, this.researchPaneHeight); // GL11.glPopMatrix(); this.zLevel = 0.0F; GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); super.drawScreen(par1, par2, par3); if (tooltipTech != null) { ResearchStatus status = researchStatus.getTechnology(tooltipTech.getName()); String s = tooltipTech.getName(); String s1 = tooltipTech.getShortDescription(); j4 = par1 + 12; l3 = par2 - 4; i5 = Math.max(this.fontRendererObj.getStringWidth(s), 120); l4 = this.fontRendererObj.splitStringWidth(s1, i5); if (status.researched()) { l4 += 12; } this.drawGradientRect(j4 - 3, l3 - 3, j4 + i5 + 3, l3 + l4 + 3 + 12, -1073741824, -1073741824); this.fontRendererObj.drawSplitString(s1, j4, l3 + 12, i5, -6250336); if (status.researched()) { this.fontRendererObj.drawStringWithShadow("Researched!", j4, l3 + l4 + 4, -7302913); } // Keep Commented // else { // i5 = Math.max(this.fontRenderer.getStringWidth(s), 120); // String s2 = I18n.getStringParams("achievement.requires", // new Object[] { I18n // .getString(tooltipTech.parentAchievement // .getName()) }); // i4 = this.fontRenderer.splitStringWidth(s2, i5); // this.drawGradientRect(j4 - 3, l3 - 3, j4 + i5 + 3, l3 + i4 + 12 // + 3, -1073741824, -1073741824); // this.fontRenderer // .drawSplitString(s2, j4, l3 + 12, i5, -9416624); // } this.fontRendererObj.drawStringWithShadow(s, j4, l3, status.researched() ? (tooltipTech.isKeystone() ? -128 : -1) : (tooltipTech.isKeystone() ? -8355776 : -8355712)); } GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_LIGHTING); RenderHelper.disableStandardItemLighting(); }
From source file:com.itszuvalex.femtocraft.research.gui.GuiResearchConsole.java
License:Open Source License
@Override protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().getTextureManager().bindTexture(texture); int k = (this.width - xSize) / 2; int l = (this.height - ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, xSize, ySize); int progress = console.getResearchProgressScaled(78); this.drawTexturedModalRect(k + 64, l + 65, 0, 166, progress, 6); if (console.displayTech() != null || console.isResearching()) { String name;//from w w w . j a v a 2 s .com if (console.isResearching()) { name = console.getResearchingName(); } else { name = console.displayTech(); } ITechnology tech = Femtocraft.researchManager().getTechnology(name); if (tech != null) { String s = tech.getName(); this.fontRendererObj.drawString(s, k + 71 + (165 - 71 - this.fontRendererObj.getStringWidth(s)) / 2, l + 20, FemtocraftUtils.colorFromARGB(255, 255, 255, 255)); if (console.isResearching()) { s = String.format("%d%s", console.getResearchProgressScaled(100), "%"); this.fontRendererObj.drawString(s, k + 168 - this.fontRendererObj.getStringWidth(s), l + 40, FemtocraftUtils.colorFromARGB(255, 255, 255, 255)); } else { s = "Begin"; this.fontRendererObj.drawString(s, k + 85 - this.fontRendererObj.getStringWidth(s) / 2, l + 36 + (52 - 36 - this.fontRendererObj.FONT_HEIGHT) / 2, FemtocraftUtils.colorFromARGB(255, 255, 255, 255)); } RenderItem render = new RenderItem(); GL11.glDisable(GL11.GL_BLEND); //Forge: Cleanup states we set. GL11.glDisable(GL11.GL_LIGHTING); //Forge: Make sure Lighting is disabled. Fixes MC-33065 GL11.glEnable(GL11.GL_CULL_FACE); RenderHelper.enableGUIStandardItemLighting(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_COLOR_MATERIAL); render.renderItemAndEffectIntoGUI(fontRendererObj, Minecraft.getMinecraft().getTextureManager(), tech.getDisplayItem(), k + 110, l + 33); RenderHelper.disableStandardItemLighting(); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_LIGHTING); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } } }
From source file:com.kauridev.lunarfever.Lunar.java
License:Open Source License
private void initOpenGL() { try {// w w w . j a v a 2 s .c o m Display.setDisplayMode(new DisplayMode(TARGET_WIDTH, TARGET_HEIGHT)); Display.setTitle("Lunar Fever"); Display.setFullscreen(false); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); } GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, TARGET_WIDTH, 0, TARGET_HEIGHT, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:com.kauridev.lunarfever.particle.ExplosionParticleEmitter.java
License:Open Source License
@Override public void render(double elapsed, Camera camera) { ////from w ww . java 2 s.c om // TODO - configure this somehow? GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); super.render(elapsed, camera); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }