Java Code Examples for org.lwjgl.opengl.GL11#glTexParameterf()
The following examples show how to use
org.lwjgl.opengl.GL11#glTexParameterf() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FrameBufferContainer.java From LookingGlass with GNU General Public License v3.0 | 6 votes |
private void allocateFrameBuffer() { if (this.framebuffer != 0) return; this.framebuffer = EXTFramebufferObject.glGenFramebuffersEXT(); //Release via: EXTFramebufferObject.glDeleteFramebuffersEXT(framebuffer); this.depthBuffer = EXTFramebufferObject.glGenRenderbuffersEXT(); //Release via: EXTFramebufferObject.glDeleteRenderbuffersEXT(depthBuffer); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, this.framebuffer); EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, depthBuffer); if (MinecraftForgeClient.getStencilBits() == 0) EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, GL14.GL_DEPTH_COMPONENT24, width, height); else EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, org.lwjgl.opengl.EXTPackedDepthStencil.GL_DEPTH24_STENCIL8_EXT, width, height); EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, depthBuffer); if (MinecraftForgeClient.getStencilBits() != 0) EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_STENCIL_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, depthBuffer); this.texture = GL11.glGenTextures(); //Release via: GL11.glDeleteTextures(colorTexture); GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.texture); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, width, height, 0, GL11.GL_RGBA, GL11.GL_INT, (java.nio.ByteBuffer) null); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, this.texture, 0); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0); }
Example 2
Source File: TextureUtils.java From OpenGL-Animation with The Unlicense | 5 votes |
protected static int loadTextureToOpenGL(TextureData data, TextureBuilder builder) { int texID = GL11.glGenTextures(); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, data.getWidth(), data.getHeight(), 0, GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE, data.getBuffer()); if (builder.isMipmap()) { GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR); if (builder.isAnisotropic() && GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) { GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, 4.0f); } } else if (builder.isNearest()) { 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); } else { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); } if (builder.isClampEdges()) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); } else { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); } GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); return texID; }
Example 3
Source File: OffscreenBuffer.java From LWJGUI with MIT License | 4 votes |
/** * Resize the buffer to desired width/height * @param width * @param height * @return */ public boolean resize(int width, int height) { if (this.width == width && this.height == height) { return false; } this.width = width; this.height = height; // resize the texture if (texId != 0) { GL11.glDeleteTextures(texId); GL30.glDeleteFramebuffers(fboId); GL30.glDeleteRenderbuffers(renderId); texId = 0; fboId = 0; renderId = 0; } // Create texture if ( texId == 0 ) texId = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, 0); // Set default filtering GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); // update the framebuf if (fboId == 0) fboId = GL30.glGenFramebuffers(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fboId); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, texId, 0); // The depth buffer if ( renderId == 0 ) renderId = GL30.glGenRenderbuffers(); GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, renderId); GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL11.GL_DEPTH_COMPONENT, width, height); GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER, renderId); // remove the old quad quadDirty = true; GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); return true; }
Example 4
Source File: TileEntityNewBeaconRenderer.java From Et-Futurum with The Unlicense | 4 votes |
@Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTickTime) { TileEntityNewBeacon beacon = (TileEntityNewBeacon) tile; float f1 = beacon.func_146002_i(); OpenGLHelper.alphaFunc(GL11.GL_GREATER, 0.1F); if (f1 > 0.0F) { Tessellator tessellator = Tessellator.instance; List<BeamSegment> list = beacon.getSegments(); int j = 0; for (int i = 0; i < list.size(); i++) { BeamSegment beamsegment = list.get(i); int l = j + beamsegment.func_177264_c(); bindTexture(BEAM_TEXTURE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); OpenGLHelper.disableLighting(); OpenGLHelper.disableCull(); OpenGLHelper.disableBlend(); OpenGLHelper.depthMask(true); OpenGlHelper.glBlendFunc(770, 1, 1, 0); float f2 = tile.getWorldObj().getTotalWorldTime() + partialTickTime; float f3 = -f2 * 0.2F - MathHelper.floor_float(-f2 * 0.1F); double d3 = f2 * 0.025D * -1.5D; tessellator.startDrawingQuads(); double d4 = 0.2D; double d5 = 0.5D + Math.cos(d3 + 2.356194490192345D) * d4; double d6 = 0.5D + Math.sin(d3 + 2.356194490192345D) * d4; double d7 = 0.5D + Math.cos(d3 + Math.PI / 4D) * d4; double d8 = 0.5D + Math.sin(d3 + Math.PI / 4D) * d4; double d9 = 0.5D + Math.cos(d3 + 3.9269908169872414D) * d4; double d10 = 0.5D + Math.sin(d3 + 3.9269908169872414D) * d4; double d11 = 0.5D + Math.cos(d3 + 5.497787143782138D) * d4; double d12 = 0.5D + Math.sin(d3 + 5.497787143782138D) * d4; double d13 = 0.0D; double d14 = 1.0D; double d15 = -1.0F + f3; double d16 = beamsegment.func_177264_c() * f1 * (0.5D / d4) + d15; tessellator.setColorRGBA_F(beamsegment.func_177263_b()[0], beamsegment.func_177263_b()[1], beamsegment.func_177263_b()[2], 0.125F); tessellator.addVertexWithUV(x + d5, y + l, z + d6, d14, d16); tessellator.addVertexWithUV(x + d5, y + j, z + d6, d14, d15); tessellator.addVertexWithUV(x + d7, y + j, z + d8, d13, d15); tessellator.addVertexWithUV(x + d7, y + l, z + d8, d13, d16); tessellator.addVertexWithUV(x + d11, y + l, z + d12, d14, d16); tessellator.addVertexWithUV(x + d11, y + j, z + d12, d14, d15); tessellator.addVertexWithUV(x + d9, y + j, z + d10, d13, d15); tessellator.addVertexWithUV(x + d9, y + l, z + d10, d13, d16); tessellator.addVertexWithUV(x + d7, y + l, z + d8, d14, d16); tessellator.addVertexWithUV(x + d7, y + j, z + d8, d14, d15); tessellator.addVertexWithUV(x + d11, y + j, z + d12, d13, d15); tessellator.addVertexWithUV(x + d11, y + l, z + d12, d13, d16); tessellator.addVertexWithUV(x + d9, y + l, z + d10, d14, d16); tessellator.addVertexWithUV(x + d9, y + j, z + d10, d14, d15); tessellator.addVertexWithUV(x + d5, y + j, z + d6, d13, d15); tessellator.addVertexWithUV(x + d5, y + l, z + d6, d13, d16); tessellator.draw(); OpenGLHelper.enableBlend(); OpenGlHelper.glBlendFunc(770, 771, 1, 0); OpenGLHelper.depthMask(false); tessellator.startDrawingQuads(); tessellator.setColorRGBA_F(beamsegment.func_177263_b()[0], beamsegment.func_177263_b()[1], beamsegment.func_177263_b()[2], 0.125F); d3 = 0.2D; d4 = 0.2D; d5 = 0.8D; d6 = 0.2D; d7 = 0.2D; d8 = 0.8D; d9 = 0.8D; d10 = 0.8D; d11 = 0.0D; d12 = 1.0D; d13 = -1.0F + f3; d14 = beamsegment.func_177264_c() * f1 + d13; tessellator.addVertexWithUV(x + d3, y + l, z + d4, d12, d14); tessellator.addVertexWithUV(x + d3, y + j, z + d4, d12, d13); tessellator.addVertexWithUV(x + d5, y + j, z + d6, d11, d13); tessellator.addVertexWithUV(x + d5, y + l, z + d6, d11, d14); tessellator.addVertexWithUV(x + d9, y + l, z + d10, d12, d14); tessellator.addVertexWithUV(x + d9, y + j, z + d10, d12, d13); tessellator.addVertexWithUV(x + d7, y + j, z + d8, d11, d13); tessellator.addVertexWithUV(x + d7, y + l, z + d8, d11, d14); tessellator.addVertexWithUV(x + d5, y + l, z + d6, d12, d14); tessellator.addVertexWithUV(x + d5, y + j, z + d6, d12, d13); tessellator.addVertexWithUV(x + d9, y + j, z + d10, d11, d13); tessellator.addVertexWithUV(x + d9, y + l, z + d10, d11, d14); tessellator.addVertexWithUV(x + d7, y + l, z + d8, d12, d14); tessellator.addVertexWithUV(x + d7, y + j, z + d8, d12, d13); tessellator.addVertexWithUV(x + d3, y + j, z + d4, d11, d13); tessellator.addVertexWithUV(x + d3, y + l, z + d4, d11, d14); tessellator.draw(); OpenGLHelper.enableLighting(); OpenGLHelper.enableTexture2D(); OpenGLHelper.depthMask(true); j = l; } } }
Example 5
Source File: RenderCarvableBeacon.java From Chisel-2 with GNU General Public License v2.0 | 4 votes |
public void renderTileEntityAt(TileEntityCarvableBeacon beacon, double x, double y, double z, float partialTicks) { float f1 = beacon.func_146002_i(); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); if(f1 > 0.1F){ Color color = new Color(ItemDye.field_150922_c[beacon.getWorldObj().getBlockMetadata(beacon.xCoord, beacon.yCoord, beacon.zCoord)]); Tessellator tessellator = Tessellator.instance; this.bindTexture(texture); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); GL11.glDepthMask(true); OpenGlHelper.glBlendFunc(770, 1, 1, 0); float f2 = (float) beacon.getWorldObj().getTotalWorldTime() + partialTicks; float f3 = -f2 * 0.2F - (float) MathHelper.floor_float(-f2 * 0.1F); byte b0 = 1; double d3 = (double) f2 * 0.025D * (1.0D - (double) (b0 & 1) * 2.5D); tessellator.startDrawingQuads(); tessellator.setColorRGBA(color.getRed(), color.getGreen(), color.getBlue(), 32); double d5 = (double) b0 * 0.2D; double d7 = 0.5D + Math.cos(d3 + 2.356194490192345D) * d5; double d9 = 0.5D + Math.sin(d3 + 2.356194490192345D) * d5; double d11 = 0.5D + Math.cos(d3 + (Math.PI / 4D)) * d5; double d13 = 0.5D + Math.sin(d3 + (Math.PI / 4D)) * d5; double d15 = 0.5D + Math.cos(d3 + 3.9269908169872414D) * d5; double d17 = 0.5D + Math.sin(d3 + 3.9269908169872414D) * d5; double d19 = 0.5D + Math.cos(d3 + 5.497787143782138D) * d5; double d21 = 0.5D + Math.sin(d3 + 5.497787143782138D) * d5; double d23 = (double) (256.0F * f1); double d25 = 0.0D; double d27 = 1.0D; double d28 = (double) (-1.0F + f3); double d29 = (double) (256.0F * f1) * (0.5D / d5) + d28; tessellator.addVertexWithUV(x + d7, y + d23, z + d9, d27, d29); tessellator.addVertexWithUV(x + d7, y, z + d9, d27, d28); tessellator.addVertexWithUV(x + d11, y, z + d13, d25, d28); tessellator.addVertexWithUV(x + d11, y + d23, z + d13, d25, d29); tessellator.addVertexWithUV(x + d19, y + d23, z + d21, d27, d29); tessellator.addVertexWithUV(x + d19, y, z + d21, d27, d28); tessellator.addVertexWithUV(x + d15, y, z + d17, d25, d28); tessellator.addVertexWithUV(x + d15, y + d23, z + d17, d25, d29); tessellator.addVertexWithUV(x + d11, y + d23, z + d13, d27, d29); tessellator.addVertexWithUV(x + d11, y, z + d13, d27, d28); tessellator.addVertexWithUV(x + d19, y, z + d21, d25, d28); tessellator.addVertexWithUV(x + d19, y + d23, z + d21, d25, d29); tessellator.addVertexWithUV(x + d15, y + d23, z + d17, d27, d29); tessellator.addVertexWithUV(x + d15, y, z + d17, d27, d28); tessellator.addVertexWithUV(x + d7, y, z + d9, d25, d28); tessellator.addVertexWithUV(x + d7, y + d23, z + d9, d25, d29); tessellator.draw(); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); GL11.glDepthMask(false); tessellator.startDrawingQuads(); tessellator.setColorRGBA(color.getRed(), color.getGreen(), color.getBlue(), 32); double d30 = 0.2D; double d4 = 0.2D; double d6 = 0.8D; double d8 = 0.2D; double d10 = 0.2D; double d12 = 0.8D; double d14 = 0.8D; double d16 = 0.8D; double d18 = (double) (256.0F * f1); double d20 = 0.0D; double d22 = 1.0D; double d24 = (double) (-1.0F + f3); double d26 = (double) (256.0F * f1) + d24; tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d22, d26); tessellator.addVertexWithUV(x + d30, y, z + d4, d22, d24); tessellator.addVertexWithUV(x + d6, y, z + d8, d20, d24); tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d20, d26); tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d22, d26); tessellator.addVertexWithUV(x + d14, y, z + d16, d22, d24); tessellator.addVertexWithUV(x + d10, y, z + d12, d20, d24); tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d20, d26); tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d22, d26); tessellator.addVertexWithUV(x + d6, y, z + d8, d22, d24); tessellator.addVertexWithUV(x + d14, y, z + d16, d20, d24); tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d20, d26); tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d22, d26); tessellator.addVertexWithUV(x + d10, y, z + d12, d22, d24); tessellator.addVertexWithUV(x + d30, y, z + d4, d20, d24); tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d20, d26); tessellator.draw(); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDepthMask(true); } }