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:org.ajgl.graphics.Immediate.java
License:Open Source License
/** * Draws a shape using glBegin / Primitive mode. Adds color and texture to it. * Note that {@code colorValues} should have four values per vertex. * @param beginMode - OpenGL begin mode//w w w. j a v a2 s.c o m * @param textureID - The texture id to be used * @param vertexValues - Array of vertices * @param colorValues - Array of color vertices * @param textureValues - Array of local texture vertices */ @OpenGLInfo(fwdCompatible = false, openGLVersion = "1.1", status = "Deprecated") public static void threePointdraw(@BeginMode int beginMode, int textureID, float[] vertexValues, float[] colorValues, float[] textureValues) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glBegin(beginMode); for (int i = 0, j = 0, k = 0; i < vertexValues.length - 2; i += 3, j += 4, k += 2) { GL11.glColor4f(colorValues[j], colorValues[j + 1], colorValues[j + 2], colorValues[j + 3]); GL11.glTexCoord2f(textureValues[k], textureValues[k + 1]); GL11.glVertex3f(vertexValues[i], vertexValues[i + 1], vertexValues[i + 2]); } GL11.glEnd(); }
From source file:org.ajgl.graphics.Immediate.java
License:Open Source License
/** * Draws a shape using glBegin / Primitive mode. Adds color and texture to it. * Note that {@code colorValues} should have four values per vertex. * @param beginMode - OpenGL begin mode//from ww w . ja v a 2 s. c om * @param textureID - The texture id to be used * @param vertexValues - Array of vertices * @param colorValues - Array of color vertices * @param textureValues - Array of local texture vertices */ @OpenGLInfo(fwdCompatible = false, openGLVersion = "1.1", status = "Deprecated") public static void fourPointdraw(@BeginMode int beginMode, int textureID, float[] vertexValues, float[] colorValues, float[] textureValues) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glBegin(beginMode); for (int i = 0, j = 0, k = 0; i < vertexValues.length - 3; i += 4, j += 4, k += 2) { GL11.glColor4f(colorValues[j], colorValues[j + 1], colorValues[j + 2], colorValues[j + 3]); GL11.glTexCoord2f(textureValues[k], textureValues[k + 1]); GL11.glVertex4f(vertexValues[i], vertexValues[i + 1], vertexValues[i + 2], vertexValues[i + 3]); } GL11.glEnd(); }
From source file:org.free.jake2.render.lwjgl.Image.java
License:Open Source License
void GL_Bind(int texnum) { if ((gl_nobind.value != 0) && (draw_chars != null)) { // performance evaluation option texnum = draw_chars.texnum;/*from w ww .j a va 2 s .c om*/ } if (gl_state.currenttextures[gl_state.currenttmu] == texnum) { return; } gl_state.currenttextures[gl_state.currenttmu] = texnum; GL11.glBindTexture(GL11.GL_TEXTURE_2D, texnum); }
From source file:org.fusfoundation.kranion.ImageLabel.java
License:Open Source License
private void buildTexture(String resource) { BufferedImage img = null;// w w w . j a v a 2 s. c om try { InputStream rstm = this.getClass().getResourceAsStream(resource); img = ImageIO.read(rstm); } catch (IOException e) { return; } try { //Create the PNGDecoder object and decode the texture to a buffer int width = img.getWidth(), height = img.getHeight(); bounds.width = width; bounds.height = height; byte buf[] = (byte[]) img.getRaster().getDataElements(0, 0, width, height, null); ByteBuffer pixelData = ByteBuffer.allocateDirect(buf.length); pixelData.put(buf, 0, buf.length); pixelData.flip(); if (texName != 0) { deleteTexture(); } //Generate and bind the texture texName = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texName); //Upload the buffer's content to the VRAM GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, pixelData); //Apply filters 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.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.glBindTexture(GL11.GL_TEXTURE_2D, 0); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.geekygoblin.nedetlesmaki.game.systems.DrawSystem.java
License:Open Source License
private void drawLevel(LevelBackground level) { GL11.glPushMatrix();/*from w w w . j av a 2 s . c om*/ GL11.glLoadIdentity(); IPlay backgroundAnimationPlay = level.getBackground(); backgroundAnimationPlay.update((long) (world.getDelta() * 1000L)); final IAnimationFrame currentFrame = backgroundAnimationPlay.getCurrentFrame(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, (Integer) currentFrame.getImage().getId()); float x1 = -VirtualResolution.WIDTH / 2.0f; float x2 = VirtualResolution.WIDTH / 2.0f; float y1 = VirtualResolution.HEIGHT / 2.0f; float y2 = -VirtualResolution.HEIGHT / 2.0f; float u1 = currentFrame.getU1(); float u2 = currentFrame.getU2(); float v1 = currentFrame.getV2(); float v2 = currentFrame.getV1(); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(u1, v1); GL11.glVertex2f(x1, y2); GL11.glTexCoord2f(u2, v1); GL11.glVertex2f(x2, y2); GL11.glTexCoord2f(u2, v2); GL11.glVertex2f(x2, y1); GL11.glTexCoord2f(u1, v2); GL11.glVertex2f(x1, y1); GL11.glEnd(); GL11.glPopMatrix(); }
From source file:org.getspout.spout.config.MipMapUtils.java
License:Open Source License
public static void initalizeTexture(int textureId) { GL11.glBindTexture(3553, textureId); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); int textureWidth = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH); int tileWidth = textureWidth / 16; setMipmapLevels(textureId, (int) Math.round(Math.log((double) tileWidth) / Math.log(2D))); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, getMipmapLevels(textureId)); ContextCapabilities capabilities = GLContext.getCapabilities(); if (capabilities.OpenGL30) { MipMapUtils.mode = 1;//w w w . j a va 2 s . c om } else if (capabilities.GL_EXT_framebuffer_object) { MipMapUtils.mode = 2; } else if (capabilities.OpenGL14) { MipMapUtils.mode = 3; GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL14.GL_GENERATE_MIPMAP, GL11.GL_TRUE); } }
From source file:org.getspout.spout.config.MipMapUtils.java
License:Open Source License
public static void update(int texture) { GL11.glPushMatrix();/*from w w w .ja va 2 s .c om*/ if (MipMapUtils.mode == 3) { MipMapUtils.updateTerrain = ConfigReader.mipmapsPercent > 0F; GL11.glBindTexture(3553, texture); if (ConfigReader.mipmapsPercent > 0F) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); } else { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); } GL11.glPopMatrix(); return; } if (ConfigReader.mipmapsPercent > 0F) { MipMapUtils.updateTerrain = true; GL11.glBindTexture(3553, texture); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); } GL11.glPopMatrix(); }
From source file:org.getspout.spout.config.MipMapUtils.java
License:Open Source License
public static void onTick(int texture, float targetFade, float currentFade) { GL11.glPushMatrix();/*from ww w .j a v a2 s . co m*/ GL11.glBindTexture(3553, texture); if (targetFade != currentFade) { if (targetFade < currentFade) { currentFade -= 0.01f; if (currentFade <= targetFade) { currentFade = targetFade; } } else { currentFade += 0.01f; if (currentFade >= targetFade) { currentFade = targetFade; } } if (currentFade <= 0.0f) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glAlphaFunc(GL11.GL_GREATER, 0.01F); //default blend state updateTerrain = false; GL11.glPopMatrix(); return; } else { GL11.glTexEnvf(GL14.GL_TEXTURE_FILTER_CONTROL, GL14.GL_TEXTURE_LOD_BIAS, getMipmapLevels(texture) * (currentFade - 1.0f)); } } switch (mode) { case 1: GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); break; case 2: EXTFramebufferObject.glGenerateMipmapEXT(GL11.GL_TEXTURE_2D); break; } GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.3F); //more strict blend state GL11.glPopMatrix(); }
From source file:org.getspout.spout.entity.RenderTexture.java
License:Open Source License
@Override public void doRender(Entity entity, double x, double y, double z, float yaw, float pitch) { EntityTexture entityT = (EntityTexture) entity; if (entityT.texture == null) { entityT.texture = CustomTextureManager.getTextureFromUrl(entityT.getUrl()); if (entityT.texture == null) { return; }/*w w w .ja v a 2s .c o m*/ } GL11.glPushMatrix(); RenderHelper.disableStandardItemLighting(); yaw = entityT.isRotateWithPlayer() ? -this.renderManager.playerViewY : yaw; GL11.glTranslated(x, y, z); GL11.glRotatef(yaw, 0, 1.0F, 0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glBindTexture(GL11.GL_TEXTURE_2D, entityT.texture.getTextureID()); Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); double h = entityT.height * 0.014; double w = entityT.width * 0.014; tessellator.addVertexWithUV(w / 2, -h / 2, 0, 0.0D, 0.0D); //draw corners tessellator.addVertexWithUV(-w / 2, -h / 2, 0, entityT.texture.getWidth(), 0.0D); tessellator.addVertexWithUV(-w / 2, h / 2, 0, entityT.texture.getWidth(), entityT.texture.getHeight()); tessellator.addVertexWithUV(w / 2, h / 2, 0, 0.0D, entityT.texture.getHeight()); tessellator.draw(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); RenderHelper.enableStandardItemLighting(); GL11.glPopMatrix(); }
From source file:org.getspout.spout.gui.about.GuiAbout.java
License:LGPL
@Override public void drawScreen(int x, int y, float z) { super.drawBackground(0); GL11.glDisable(2896 /*GL_LIGHTING*/); GL11.glDisable(2912 /*GL_FOG*/); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); bg.setTopColor(background1);//w w w . j a va2s. c om bg.setBottomColor(background2); bg.setY(30); bg.setHeight(this.height - 50); bg.setX(0); bg.setWidth(this.width - 12); bg.render(); scrollArea.setY(30); scrollArea.setHeight(this.height - 50); scrollArea.setX(this.width - 12); scrollArea.setWidth(16); scrollArea.setTopColor(scrollBarColor); scrollArea.setBottomColor(scrollBarColor2); scrollArea.render(); drawScaledString("What is Spoutcraft?", this.width / 2 - 200, this.height, 0xffffff); drawScaledString("Spoutcraft is a modified Minecraft client", this.width / 2 - 200, this.height + 10, 0x808080); drawScaledString("that plays exactly like the official game.", this.width / 2 - 200, this.height + 20, 0x808080); drawScaledString("Its goal is to give modders an easy to", this.width / 2 - 200, this.height + 30, 0x808080); drawScaledString("use development platform for building", this.width / 2 - 200, this.height + 40, 0x808080); drawScaledString("and distributing mods, as well as a ", this.width / 2 - 200, this.height + 50, 0x808080); drawScaledString("providing a rich experience for players.", this.width / 2 - 200, this.height + 60, 0x808080); drawScaledString("What is Spout?", this.width / 2 - 200, this.height + 90, 0xffffff); drawScaledString("Spout is a Bukkit plugin that gives ", this.width / 2 - 200, this.height + 100, 0x808080); drawScaledString("developers an advanced server", this.width / 2 - 200, this.height + 110, 0x808080); drawScaledString("development platform that allows previouly ", this.width / 2 - 200, this.height + 120, 0x808080); drawScaledString("impossible tasks, such as custom items,", this.width / 2 - 200, this.height + 130, 0x808080); drawScaledString("blocks, mobs, animals, and vehicles. ", this.width / 2 - 200, this.height + 140, 0x808080); drawScaledString("Who is SpoutDev?", this.width / 2 - 200, this.height + 170, 0xffffff); drawScaledString("SpoutDev is the team behind Spout, ", this.width / 2 - 200, this.height + 180, 0x808080); drawScaledString("SpoutAPI, Spoutcraft and SpoutcraftAPI.", this.width / 2 - 200, this.height + 190, 0x808080); drawScaledString("Sponsors", this.width / 2 + 30, this.height, 0xffffff); drawScaledString("Team", this.width / 2 + 30, this.height + 90, 0xffffff); drawScaledString("Afforess - Lead Developer", this.width / 2 + 30, this.height + 100, 0x808080); drawScaledString("Wulfspider - Co-Lead & Support", this.width / 2 + 30, this.height + 110, 0x808080); drawScaledString("alta189 - Co-Lead & Developer", this.width / 2 + 30, this.height + 120, 0x808080); drawScaledString("Top_Cat - Developer", this.width / 2 + 30, this.height + 130, 0x808080); drawScaledString("Raphfrk - Developer", this.width / 2 + 30, this.height + 140, 0x808080); drawScaledString("narrowtux - Developer", this.width / 2 + 30, this.height + 150, 0x808080); drawScaledString("Olloth - Developer", this.width / 2 + 30, this.height + 160, 0x808080); drawScaledString("Email: dev@getspout.org", this.width / 2 + 30, this.height + 170, 0x808080); drawScaledString("Website: getspout.org", this.width / 2 + 30, this.height + 180, 0x808080); drawScaledString("IRC: #spout in Esper.net", this.width / 2 + 30, this.height + 190, 0x808080); drawScaledString("Move along, nothing to see here.", 40, this.height * 5, 0x808080); GL11.glDisable(2896 /*GL_LIGHTING*/); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int var11 = this.mc.renderEngine.getTexture("/gui/allitems.png"); this.mc.renderEngine.bindTexture(var11); RenderUtil.drawTexturedModalRectangle(this.width - 14, getInvertedScaledHeight(this.height - 5), 0, 208, 16, 16, 0f); GL11.glDisable(2912 /*GL_FOG*/); GL11.glDisable(2929 /*GL_DEPTH_TEST*/); this.overlayBackground(0, 30, 255, 255); this.overlayBackground(this.height - 50, this.height, 255, 255); drawCenteredString(this.fontRenderer, "About", this.width / 2, 16, 0xffffff); GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, this.mc.renderEngine.getTexture("/title/mclogo.png")); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glScalef(0.4f, 0.4f, 0.4f); this.drawTexturedModalRect((int) (0.23f * this.width), (int) (this.height * 2.1f), 0, 0, 155, 44); this.drawTexturedModalRect((int) (0.23f * this.width) + 155, (int) (this.height * 2.1f), 0, 45, 155, 44); GL11.glScalef(1 / .4f, 1 / .4f, 1 / .4f); //undo scale above if (textureBinding != null) { GL11.glPushMatrix(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_BLEND); GL11.glDepthMask(false); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef((0.685f * this.width), (this.height * 0.83f), 0); // moves texture into place GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureBinding.getTextureID()); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.addVertexWithUV(0.0D, 32, -90, 0.0D, 0.0D); // draw corners tessellator.addVertexWithUV(128, 32, -90, textureBinding.getWidth(), 0.0D); tessellator.addVertexWithUV(128, 0.0D, -90, textureBinding.getWidth(), textureBinding.getHeight()); tessellator.addVertexWithUV(0.0D, 0.0D, -90, 0.0D, textureBinding.getHeight()); tessellator.draw(); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glPopMatrix(); } drawString(this.fontRenderer, "Beta 1.8.1", (int) (this.width * 0.097f), this.height - 20, 0xffffff); drawString(this.fontRenderer, "Copyright Mojang AB", (int) (this.width * 0.097f), this.height - 10, 0x808080); drawString(this.fontRenderer, SpoutClient.getClientVersion().toString(), (int) (this.width * 0.8713f), this.height - 20, 0xffffff); drawString(this.fontRenderer, "Licensed under LGPLv3", (int) (this.width * 0.695f), this.height - 10, 0x808080); getControlList().get(0).xPosition = this.width / 2 - 45; getControlList().get(0).yPosition = this.height - 25; getControlList().get(0).drawButton(this.mc, x, y); //super.drawScreen(x, x, z); //Shadow magic GL11.glEnable(3042 /*GL_BLEND*/); GL11.glBlendFunc(770, 771); GL11.glDisable(3008 /*GL_ALPHA_TEST*/); GL11.glShadeModel(7425 /*GL_SMOOTH*/); GL11.glDisable(3553 /*GL_TEXTURE_2D*/); Tessellator var16 = Tessellator.instance; byte var19 = 4; var16.startDrawingQuads(); var16.setColorRGBA_I(0, 0); var16.addVertexWithUV(0, (double) (30 + var19), 0.0D, 0.0D, 1.0D); var16.addVertexWithUV(this.width - 12, (double) (30 + var19), 0.0D, 1.0D, 1.0D); var16.setColorRGBA_I(0, 255); var16.addVertexWithUV(this.width - 12, 30, 0.0D, 1.0D, 0.0D); var16.addVertexWithUV(0, 30, 0.0D, 0.0D, 0.0D); var16.draw(); var16.startDrawingQuads(); var16.setColorRGBA_I(0, 255); var16.addVertexWithUV(0, this.height - 50, 0.0D, 0.0D, 1.0D); var16.addVertexWithUV(this.width - 12, this.height - 50, 0.0D, 1.0D, 1.0D); var16.setColorRGBA_I(0, 0); var16.addVertexWithUV(this.width - 12, (double) (this.height - 50 - var19), 0.0D, 1.0D, 0.0D); var16.addVertexWithUV(0, (double) (this.height - 50 - var19), 0.0D, 0.0D, 0.0D); var16.draw(); }