List of usage examples for org.lwjgl.opengl GL11 glBindTexture
public static void glBindTexture(@NativeType("GLenum") int target, @NativeType("GLuint") int texture)
From source file:eu.over9000.veya.util.TextureLoader.java
License:Open Source License
public static int loadBlockTexture(final int textureUnit) { final InputStream in = TextureLoader.class.getResourceAsStream("/textures/blocks.png"); ByteBuffer convertedBuffer = null; int sourceTexWidth = 0; int sourceTexHeight = 0; int texCount = 0; try {/* w ww . j a v a 2 s .c o m*/ // Link the PNG decoder to this stream final PNGDecoder decoder = new PNGDecoder(in); // Get the width and height of the texture sourceTexWidth = decoder.getWidth(); sourceTexHeight = decoder.getHeight(); texCount = sourceTexWidth / TextureLoader.TEXTURE_WIDTH * (sourceTexHeight / TextureLoader.TEXTURE_WIDTH); // Decode the PNG file in a ByteBuffer final ByteBuffer buf = ByteBuffer.allocateDirect(4 * decoder.getWidth() * decoder.getHeight()); decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA); buf.flip(); convertedBuffer = TextureLoader.convertBuffer(buf, sourceTexWidth, sourceTexHeight); in.close(); } catch (final IOException e) { e.printStackTrace(); System.exit(-1); } // Create a new texture object in memory and bind it final int texId = GL11.glGenTextures(); GL13.glActiveTexture(textureUnit); GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, texId); // All RGB bytes are aligned to each other and each component is 1 byte GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); // Upload the texture model and generate mip maps (for scaling) // GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, tWidth, tHeight, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buf); GL12.glTexImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, GL11.GL_RGBA, TextureLoader.TEXTURE_WIDTH, TextureLoader.TEXTURE_HEIGHT, texCount, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, convertedBuffer); GL30.glGenerateMipmap(GL30.GL_TEXTURE_2D_ARRAY); // Setup the ST coordinate system GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); // Setup what to do when the texture has to be scaled GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); org.lwjgl.opengl.Util.checkGLError(); System.out .println("loading block texture, id=" + texId + ", w=" + sourceTexWidth + ", h=" + sourceTexHeight); GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, 0); return texId; }
From source file:fi.conf.ae.gl.core.GLCore.java
License:LGPL
public void renderToTexture(int textureID, int width, int height) { GL11.glViewport(0, 0, width, height); glLoop();/*from w w w .j a v a 2s. c o m*/ GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); // Bind and copy texture GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 0, 0, width, height, 0); GL11.glViewport(0, 0, GLValues.screenWidth, GLValues.screenHeight); //GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear The Screen And Depth Buffer }
From source file:fi.conf.ae.gl.GLGraphicRoutines.java
License:LGPL
public static void drawLineCircle(float radius, float segments, float lineWidth) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, -1); GL11.glLineWidth(lineWidth);//w w w . j av a 2s . co m GL11.glBegin(GL11.GL_LINE_LOOP); for (float a = 0; a < 2 * Math.PI; a += (2.0f * Math.PI) / segments) { GL11.glVertex3d(Math.sin(a) * radius, Math.cos(a) * radius, 0); } GL11.glEnd(); }
From source file:fi.conf.ae.gl.GLGraphicRoutines.java
License:LGPL
public static void drawLineRect(float w, float x0, float y0, float x1, float y1, float z) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, -1); GL11.glLineWidth(w);//from ww w. java2s. c o m GL11.glBegin(GL11.GL_LINE_LOOP); GL11.glVertex3d(x0, y1, z); GL11.glVertex3d(x1, y1, z); GL11.glVertex3d(x1, y0, z); GL11.glVertex3d(x0, y0, z); GL11.glEnd(); }
From source file:fi.conf.ae.gl.texture.GLTextureManager.java
License:LGPL
public void bindTexture(String identifier) { //S.funcArgs(identifier); Integer textureID;//from w w w .ja va2s. c o m synchronized (idMap) { textureID = idMap.get(identifier); } if (textureID == null) { //S.debug("Cannot bind texture '%s', no matching identifier found. Binding placeholder texture instead.", identifier); GL11.glBindTexture(GL11.GL_TEXTURE_2D, placeholderTextureID); } else { GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); } }
From source file:fi.conf.ae.gl.texture.GLTextureManager.java
License:LGPL
public static void unbindTexture() { GL11.glBindTexture(GL11.GL_TEXTURE_2D, -1); }
From source file:fi.conf.ae.gl.texture.GLTextureRoutines.java
License:LGPL
public static int bindTexture(int glTextureID) { int prevTextureID = getBoundTextureID(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, glTextureID); return prevTextureID; }
From source file:forestry.apiculture.render.EntityBeeFX.java
License:Open Source License
public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) { tessellator.draw();/*from ww w .j a v a 2s.c om*/ GL11.glPushMatrix(); GL11.glDepthMask(false); GL11.glEnable(3042); GL11.glBlendFunc(770, blendmode); Proxies.common.bindTexture(texture); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); float f10 = 0.1F * particleScale; float f11 = (float) ((prevPosX + (posX - prevPosX) * f) - interpPosX); float f12 = (float) ((prevPosY + (posY - prevPosY) * f) - interpPosY); float f13 = (float) ((prevPosZ + (posZ - prevPosZ) * f) - interpPosZ); // GL11.glRotatef(this.rand.nextFloat(), 0.0F, 1.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.setBrightness(0x0000f0); tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, 1.0F); tessellator.addVertexWithUV(f11 - f1 * f10 - f4 * f10, f12 - f2 * f10, f13 - f3 * f10 - f5 * f10, 0, 1); tessellator.addVertexWithUV((f11 - f1 * f10) + f4 * f10, f12 + f2 * f10, (f13 - f3 * f10) + f5 * f10, 1, 1); tessellator.addVertexWithUV(f11 + f1 * f10 + f4 * f10, f12 + f2 * f10, f13 + f3 * f10 + f5 * f10, 1, 0); tessellator.addVertexWithUV((f11 + f1 * f10) - f4 * f10, f12 - f2 * f10, (f13 + f3 * f10) - f5 * f10, 0, 0); tessellator.draw(); GL11.glDisable(3042); GL11.glDepthMask(true); GL11.glPopMatrix(); GL11.glBindTexture(3553 /* GL_TEXTURE_2D *//* GL_TEXTURE_2D */, Proxies.common.getClientInstance().renderEngine.getTexture("/particles.png")); tessellator.startDrawingQuads(); }
From source file:forestry.core.render.EntitySnowFX.java
License:Open Source License
public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) { tessellator.draw();/*from ww w. ja va 2s . c o m*/ GL11.glPushMatrix(); GL11.glDepthMask(false); GL11.glEnable(3042); GL11.glBlendFunc(770, blendmode); Proxies.common.bindTexture(texture); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); float f10 = 0.1F * particleScale; float f11 = (float) ((prevPosX + (posX - prevPosX) * f) - interpPosX); float f12 = (float) ((prevPosY + (posY - prevPosY) * f) - interpPosY); float f13 = (float) ((prevPosZ + (posZ - prevPosZ) * f) - interpPosZ); GL11.glRotatef((float) motionY, 0.0F, 1.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.setBrightness(0x0000f0); tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, 1.0F); tessellator.addVertexWithUV(f11 - f1 * f10 - f4 * f10, f12 - f2 * f10, f13 - f3 * f10 - f5 * f10, 0, 1); tessellator.addVertexWithUV((f11 - f1 * f10) + f4 * f10, f12 + f2 * f10, (f13 - f3 * f10) + f5 * f10, 1, 1); tessellator.addVertexWithUV(f11 + f1 * f10 + f4 * f10, f12 + f2 * f10, f13 + f3 * f10 + f5 * f10, 1, 0); tessellator.addVertexWithUV((f11 + f1 * f10) - f4 * f10, f12 - f2 * f10, (f13 + f3 * f10) - f5 * f10, 0, 0); tessellator.draw(); GL11.glDisable(3042); GL11.glDepthMask(true); GL11.glPopMatrix(); GL11.glBindTexture(3553 /* GL_TEXTURE_2D *//* GL_TEXTURE_2D */, Proxies.common.getClientInstance().renderEngine.getTexture("/particles.png")); tessellator.startDrawingQuads(); }
From source file:fr.def.iss.vd2.lib_v3d.element.TextureHandler.java
License:Open Source License
@Override public void bind() { GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getGlId()); }