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:nova.core.wrapper.mc.forge.v18.wrapper.entity.forward.FWEntityRenderer.java
License:Open Source License
public static void render(Entity wrapper, nova.core.entity.Entity entity, double x, double y, double z) { Optional<DynamicRenderer> opRenderer = entity.components.getOp(DynamicRenderer.class); if (opRenderer.isPresent()) { BWModel model = new BWModel(); model.matrix.translate(x, y, z).scale(entity.scale()).translate(entity.pivot()) .rotate(entity.rotation()).translate(entity.pivot().negate()); opRenderer.get().onRender.accept(model); if (model.blendSFactor > 0 && model.blendDFactor > 0) { glShadeModel(GL_SMOOTH);/*from ww w .j ava 2 s . c om*/ glEnable(GL_BLEND); GL11.glBlendFunc(model.blendSFactor, model.blendDFactor); } Tessellator.getInstance().getWorldRenderer().startDrawingQuads(); model.render(Optional.of(Minecraft.getMinecraft().getRenderManager())); Tessellator.getInstance().draw(); if (model.blendSFactor > 0 && model.blendDFactor > 0) { RenderUtility.disableBlending(); } } }
From source file:ocelot.mods.qp2.client.RenderRefinery.java
License:Open Source License
private void render(TileRefineryPlus tile, double x, double y, double z) { FluidStack liquid1 = null, liquid2 = null, liquidResult = null; float anim = 0; int angle = 0; ModelRenderer theMagnet = this.magnet[0]; if (tile != null) { liquid1 = tile.src1;//from ww w . j a v a 2s . c om liquid2 = tile.src2; liquidResult = tile.res; anim = tile.getAnimationStage(); angle = 0; switch (tile.worldObj.getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord)) { case 2: angle = 90; break; case 3: angle = 270; break; case 4: angle = 180; break; case 5: angle = 0; break; } if (tile.animationSpeed <= 1) { theMagnet = this.magnet[0]; } else if (tile.animationSpeed <= 2.5) { theMagnet = this.magnet[1]; } else if (tile.animationSpeed <= 4.5) { theMagnet = this.magnet[2]; } else { theMagnet = this.magnet[3]; } } GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F); GL11.glScalef(0.99F, 0.99F, 0.99F); GL11.glRotatef(angle, 0, 1, 0); bindTexture(TEXTURE); GL11.glPushMatrix(); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); GL11.glTranslatef(-4F * pixel, 0, -4F * pixel); this.tank.render(pixel); GL11.glTranslatef(4F * pixel, 0, 4F * pixel); GL11.glTranslatef(-4F * pixel, 0, 4F * pixel); this.tank.render(pixel); GL11.glTranslatef(4F * pixel, 0, -4F * pixel); GL11.glTranslatef(4F * pixel, 0, 0); this.tank.render(pixel); GL11.glTranslatef(-4F * pixel, 0, 0); GL11.glPopMatrix(); float trans1, trans2; if (anim <= 100) { trans1 = 12F * pixel * anim / 100F; trans2 = 0; } else if (anim <= 200) { trans1 = 12F * pixel - (12F * pixel * (anim - 100F) / 100F); trans2 = 12F * pixel * (anim - 100F) / 100F; } else { trans1 = 12F * pixel * (anim - 200F) / 100F; trans2 = 12F * pixel - (12F * pixel * (anim - 200F) / 100F); } GL11.glPushMatrix(); GL11.glScalef(0.99F, 0.99F, 0.99F); GL11.glTranslatef(-0.51F, trans1 - 0.5F, -0.5F); theMagnet.render(pixel); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(0.99F, 0.99F, 0.99F); GL11.glTranslatef(-0.51F, trans2 - 0.5F, 12F * pixel - 0.5F); theMagnet.render(pixel); GL11.glPopMatrix(); if (tile != null) { GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); GL11.glScalef(0.5F, 1, 0.5F); if (liquid1 != null && liquid1.amount > 0) { int[] list1 = FluidRenderer.getFluidDisplayLists(liquid1, tile.worldObj, false); if (list1 != null) { bindTexture(FluidRenderer.getFluidSheet(liquid1)); FluidRenderer.setColorForFluidStack(liquid1); GL11.glCallList( list1[(int) (liquid1.amount / (float) tile.buf * (FluidRenderer.DISPLAY_STAGES - 1))]); } } if (liquid2 != null && liquid2.amount > 0) { int[] list2 = FluidRenderer.getFluidDisplayLists(liquid2, tile.worldObj, false); if (list2 != null) { GL11.glPushMatrix(); GL11.glTranslatef(0, 0, 1); bindTexture(FluidRenderer.getFluidSheet(liquid2)); FluidRenderer.setColorForFluidStack(liquid2); GL11.glCallList( list2[(int) (liquid2.amount / (float) tile.buf * (FluidRenderer.DISPLAY_STAGES - 1))]); GL11.glPopMatrix(); } } if (liquidResult != null && liquidResult.amount > 0) { int[] list3 = FluidRenderer.getFluidDisplayLists(liquidResult, tile.worldObj, false); if (list3 != null) { GL11.glPushMatrix(); GL11.glTranslatef(1, 0, 0.5F); bindTexture(FluidRenderer.getFluidSheet(liquidResult)); FluidRenderer.setColorForFluidStack(liquidResult); GL11.glCallList(list3[(int) (liquidResult.amount / (float) tile.buf * (FluidRenderer.DISPLAY_STAGES - 1))]); GL11.glPopMatrix(); } } GL11.glPopAttrib(); } GL11.glPopAttrib(); GL11.glPopMatrix(); }
From source file:org.blockartistry.mod.DynSurround.client.fx.particle.EntityTextPopOffFX.java
License:MIT License
@Override public void renderParticle(final WorldRenderer renderer, final Entity entity, final float x, final float y, final float z, final float dX, final float dY, final float dZ) { this.rotationYaw = (-Minecraft.getMinecraft().thePlayer.rotationYaw); this.rotationPitch = Minecraft.getMinecraft().thePlayer.rotationPitch; final float locX = ((float) (this.prevPosX + (this.posX - this.prevPosX) * x - interpPosX)); final float locY = ((float) (this.prevPosY + (this.posY - this.prevPosY) * y - interpPosY)); final float locZ = ((float) (this.prevPosZ + (this.posZ - this.prevPosZ) * z - interpPosZ)); GL11.glPushMatrix();/* ww w.j a v a 2s. c o m*/ if (this.shouldOnTop) { GL11.glDepthFunc(519); } else { GL11.glDepthFunc(515); } GL11.glTranslatef(locX, locY, locZ); GL11.glRotatef(this.rotationYaw, 0.0F, 1.0F, 0.0F); GL11.glRotatef(this.rotationPitch, 1.0F, 0.0F, 0.0F); GL11.glScalef(-1.0F, -1.0F, 1.0F); GL11.glScaled(this.particleScale * 0.008D, this.particleScale * 0.008D, this.particleScale * 0.008D); GL11.glScaled(this.scale, this.scale, this.scale); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 0.003662109F); GL11.glEnable(3553); GL11.glDisable(3042); GL11.glDepthMask(true); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(3553); GL11.glEnable(2929); GL11.glDisable(2896); GL11.glBlendFunc(770, 771); GL11.glEnable(3042); GL11.glEnable(3008); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; fontRenderer.drawStringWithShadow(this.text, -MathHelper.floor_float(fontRenderer.getStringWidth(this.text) / 2.0F) + 1, -MathHelper.floor_float(fontRenderer.FONT_HEIGHT / 2.0F) + 1, this.renderColor.rgb()); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDepthFunc(515); GL11.glPopMatrix(); if (this.grow) { this.particleScale *= 1.08F; if (this.particleScale > SIZE * 3.0D) { this.grow = false; } } else { this.particleScale *= 0.96F; } }
From source file:org.blockartistry.mod.DynSurround.client.fx.particle.ParticleTextPopOff.java
License:MIT License
@Override public void renderParticle(VertexBuffer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { this.rotationYaw = (-Minecraft.getMinecraft().thePlayer.rotationYaw); this.rotationPitch = Minecraft.getMinecraft().thePlayer.rotationPitch; final float locX = ((float) (this.prevPosX + (this.posX - this.prevPosX) * partialTicks - interpPosX)); final float locY = ((float) (this.prevPosY + (this.posY - this.prevPosY) * partialTicks - interpPosY)); final float locZ = ((float) (this.prevPosZ + (this.posZ - this.prevPosZ) * partialTicks - interpPosZ)); GL11.glPushMatrix();/* ww w .jav a2 s . c om*/ if (this.showOnTop) { GL11.glDepthFunc(519); } else { GL11.glDepthFunc(515); } GL11.glTranslatef(locX, locY, locZ); GL11.glRotatef(this.rotationYaw, 0.0F, 1.0F, 0.0F); GL11.glRotatef(this.rotationPitch, 1.0F, 0.0F, 0.0F); GL11.glScalef(-1.0F, -1.0F, 1.0F); GL11.glScaled(this.particleScale * 0.008D, this.particleScale * 0.008D, this.particleScale * 0.008D); GL11.glScaled(this.scale, this.scale, this.scale); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 0.003662109F); GL11.glEnable(3553); GL11.glDisable(3042); GL11.glDepthMask(true); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(3553); GL11.glEnable(2929); GL11.glDisable(2896); GL11.glBlendFunc(770, 771); GL11.glEnable(3042); GL11.glEnable(3008); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; fontRenderer.drawStringWithShadow(this.text, -MathHelper.floor_float(fontRenderer.getStringWidth(this.text) / 2.0F) + 1, -MathHelper.floor_float(fontRenderer.FONT_HEIGHT / 2.0F) + 1, this.renderColor.rgb()); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDepthFunc(515); GL11.glPopMatrix(); if (this.grow) { this.particleScale *= 1.08F; if (this.particleScale > SIZE * 3.0D) { this.grow = false; } } else { this.particleScale *= 0.96F; } }
From source file:org.cogaen.lwjgl.scene.CommandLineVisual.java
License:Open Source License
@Override public void prolog() { GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }
From source file:org.cogaen.lwjgl.scene.RectangleVisual.java
License:Open Source License
@Override public void prolog() { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }
From source file:org.cogaen.lwjgl.scene.SceneService.java
License:Open Source License
public void renderScene() { // quite and dirty frame counter this.clock.tick(); this.fpsSum += this.clock.getDelta(); if (++this.fpsCnt >= this.fpsAvg) { this.fpsCnt = 0; this.fps = String.format("FPS: %2.2f", (1.0 / (this.fpsSum / this.fpsAvg))); this.fpsSum = 0.0; }//from w w w . j ava2s.c o m // Clear the screen and depth buffer GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); // render layers in each camera for (Camera camera : cameras) { if (!camera.isActive()) { continue; } camera.applyTransform(); for (int i = this.layers.size() - 1; i >= 0; --i) { this.layers.get(i).render(camera.getMask()); } for (RenderSubsystem rs : this.subSystems) { rs.render(camera.getMask()); } } // draw overlays GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, 1.0, 0, 1.0 / getAspectRatio(), 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glViewport(0, 0, this.config.getWidth(), this.config.getHeight()); this.overlayRoot.renderWithAspectRatio(0xFFFFFFFF, getAspectRatio()); // this.overlayRoot.render(0xFFFFFFFF); // render frame counter GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, this.config.getWidth(), this.config.getHeight(), 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4d(1, 0, 1, 1); font.drawString(5, this.config.getHeight() - 20, this.fps); Display.update(); if (Display.isCloseRequested()) { this.evtSrv.dispatchEvent(new SimpleEvent(WINDOW_CLOSE_REQUEST)); } }
From source file:org.cogaen.lwjgl.scene.SpriteFxVisual.java
License:Open Source License
@Override public void prolog() { GL11.glEnable(GL11.GL_TEXTURE_2D);/*from w ww . java 2s .c o m*/ GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, this.blendMode); texture.bind(); // or GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getTextureID()); }
From source file:org.craftmania.rendering.GLFont.java
License:Apache License
/** * Render a text string in 2D over the scene, using the character set * created by this GLFont object.// w w w .ja va 2s . c o m * * @see makeFont() */ public void print(int x, int y, String msg) { if (msg != null) { GL11.glPushMatrix(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // enable the charset texture GL11.glEnable(GL11.GL_TEXTURE_2D); texture.bind(); // draw the text GL11.glTranslatef(x, y, 0); // Position The Text (in pixel coords) IntBuffer buffer = BufferUtils.createIntBuffer(msg.length()); for (int i = 0; i < msg.length(); i++) { buffer.put(fontListBase + (msg.charAt(i) - 32)); } buffer.flip(); GL11.glCallLists(buffer); GL11.glPopMatrix(); } }
From source file:org.fenggui.binding.render.lwjgl.LWJGLOpenGL.java
License:Open Source License
public void setupStateVariables(boolean depthTestEnabled) { GL11.glEnable(GL11.GL_BLEND);//from w ww .j av a 2s . co m // GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); if (depthTestEnabled) GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_FOG); GL11.glDisable(GL11.GL_DITHER); GL11.glEnable(GL11.GL_SCISSOR_TEST); //GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GL11.glDisable(GL11.GL_LINE_STIPPLE); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_DECAL); //GL11.glDisable(GL11.GL_TEXTURE_GEN_S); GL11.glDisable(GL11.GL_CULL_FACE); // GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_NORMALIZE); GL11.glFrontFace(GL11.GL_CW); GL11.glCullFace(GL11.GL_BACK); // disabling textures after setting state values. They would // be ignored otherwise (i think) GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_1D); }