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:net.minecraft.src.forge.ForgeHooksClient.java
License:Minecraft Forge Public License
protected static void unbindTexture() { if (inWorld) { Tessellator.instance = defaultTessellator; } else {//w w w . j a v a 2s . c om if (Tessellator.instance.isDrawing) { int mode = Tessellator.instance.drawMode; Tessellator.instance.draw(); if (unbindContext != null) { unbindContext.afterRenderContext(); unbindContext = null; } Tessellator.instance.startDrawing(mode); } GL11.glBindTexture(GL11.GL_TEXTURE_2D, ModLoader.getMinecraftInstance().renderEngine.getTexture("/terrain.png")); return; } }
From source file:net.minecraft.src.forge.ForgeHooksClient.java
License:Minecraft Forge Public License
public static void beforeRenderPass(int pass) { renderPass = pass;//from w w w .ja v a2 s . c om defaultTessellator = Tessellator.instance; Tessellator.renderingWorldRenderer = true; GL11.glBindTexture(GL11.GL_TEXTURE_2D, ModLoader.getMinecraftInstance().renderEngine.getTexture("/terrain.png")); renderTextures.clear(); inWorld = true; }
From source file:net.minecraft.src.forge.ForgeHooksClient.java
License:Minecraft Forge Public License
public static void afterRenderPass(int pass) { renderPass = -1;//from w ww. j a va 2s .co m inWorld = false; for (TesKey info : renderTextures) { IRenderContextHandler handler = renderHandlers.get(info); GL11.glBindTexture(GL11.GL_TEXTURE_2D, info.tex); Tessellator tess = tessellators.get(info); if (handler == null) { tess.draw(); } else { Tessellator.instance = tess; handler.beforeRenderContext(); tess.draw(); handler.afterRenderContext(); } } GL11.glBindTexture(GL11.GL_TEXTURE_2D, ModLoader.getMinecraftInstance().renderEngine.getTexture("/terrain.png")); Tessellator.renderingWorldRenderer = false; Tessellator.instance = defaultTessellator; }
From source file:net.minecraft.src.forge.ForgeHooksClient.java
License:Minecraft Forge Public License
public static void overrideTexture(Object obj) { if (obj instanceof ITextureProvider) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, ModLoader.getMinecraftInstance().renderEngine .getTexture(((ITextureProvider) obj).getTextureFile())); }// w w w. j a va2 s . c o m }
From source file:net.minecraft.src.GuiAchievement.java
public void updateAchievementWindow() { if (Minecraft.hasPaidCheckTime > 0L) { GL11.glDisable(2929 /*GL_DEPTH_TEST*/); GL11.glDepthMask(false);//from w w w. j a v a2s. c o m RenderHelper.disableStandardItemLighting(); this.updateAchievementWindowScale(); String var1 = "Minecraft Beta 1.7.3 Unlicensed Copy :("; String var2 = "(Or logged in from another location)"; String var3 = "Purchase at minecraft.net"; this.theGame.fontRenderer.drawStringWithShadow(var1, 2, 2, 16777215); this.theGame.fontRenderer.drawStringWithShadow(var2, 2, 11, 16777215); this.theGame.fontRenderer.drawStringWithShadow(var3, 2, 20, 16777215); GL11.glDepthMask(true); GL11.glEnable(2929 /*GL_DEPTH_TEST*/); } if (this.theAchievement != null && this.field_25083_f != 0L || customNotification) { //Spout //Spout Start double delayTime = 3000; if (customNotification) { if (time < 1) { delayTime = 7500; } else { delayTime = time; } } double var8 = (double) (System.currentTimeMillis() - this.field_25083_f) / delayTime; //Spout End if (!this.field_27103_i && !this.field_27103_i && (var8 < 0.0D || var8 > 1.0D)) { this.field_25083_f = 0L; } else { this.updateAchievementWindowScale(); GL11.glDisable(2929 /*GL_DEPTH_TEST*/); GL11.glDepthMask(false); double var9 = var8 * 2.0D; if (var9 > 1.0D) { var9 = 2.0D - var9; } var9 *= 4.0D; var9 = 1.0D - var9; if (var9 < 0.0D) { var9 = 0.0D; } var9 *= var9; var9 *= var9; int var5 = this.achievementWindowWidth - 160; int var6 = 0 - (int) (var9 * 36.0D); int var7 = this.theGame.renderEngine.getTexture("/achievement/bg.png"); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(3553 /*GL_TEXTURE_2D*/); GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, var7); GL11.glDisable(2896 /*GL_LIGHTING*/); this.drawTexturedModalRect(var5, var6, 96, 202, 160, 32); if (this.field_27103_i) { this.theGame.fontRenderer.func_27278_a(this.field_25084_e, var5 + 30, var6 + 7, 120, -1); } else { this.theGame.fontRenderer.drawString(this.field_25085_d, var5 + 30, var6 + 7, -256); this.theGame.fontRenderer.drawString(this.field_25084_e, var5 + 30, var6 + 18, -1); } GL11.glPushMatrix(); GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glPopMatrix(); GL11.glDisable(2896 /*GL_LIGHTING*/); GL11.glEnable('\u803a'); GL11.glEnable(2903 /*GL_COLOR_MATERIAL*/); GL11.glEnable(2896 /*GL_LIGHTING*/); //Spout Start ItemStack toRender = theAchievement != null ? theAchievement.theItemStack : null; if (customNotification) { if (data < 1) { toRender = new ItemStack(itemId, 1, 0); } else { toRender = new ItemStack(itemId, 1, data); } } if (toRender != null) { itemRender.renderItemIntoGUI(theGame.fontRenderer, theGame.renderEngine, toRender, var5 + 8, var6 + 8); } //Spout End GL11.glDisable(2896 /*GL_LIGHTING*/); GL11.glDepthMask(true); GL11.glEnable(2929 /*GL_DEPTH_TEST*/); } } }
From source file:net.minecraft.src.PaintWorld.java
License:Open Source License
public void getTextureForFace(int face) { PaintFace pface = renderBlock.paintedFaces[face]; if (textureBuffer == null) { textureBuffer = ByteBuffer.allocateDirect(ARRAY_SIZE); textureBuffer.order(ByteOrder.nativeOrder()); }/* www.j av a 2 s .c om*/ if (textureId <= 0) { textureId = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); 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); } GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); textureBuffer.clear(); textureBuffer.put(pface.points); textureBuffer.flip(); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, ROW, ROW, 0, GL11.GL_RGBA, GL11.GL_BYTE, textureBuffer); }
From source file:net.minecraft.src.wirelessredstone.presentation.GuiButtonBoolean.java
License:Open Source License
/** * Renders the button to the screen.//w ww . ja v a 2 s . co m * * @param minecraft * minecraft instance * @param i * mouse X coordinate * @param j * mouse Y coordinate */ @Override public void drawButton(Minecraft minecraft, int i, int j) { FontRenderer fontrenderer = minecraft.fontRenderer; if (state) { GL11.glBindTexture(3553 /* GL_TEXTURE_2D */, minecraft.renderEngine.getTexture("/gui/guiOn.png")); } else { GL11.glBindTexture(3553 /* GL_TEXTURE_2D */, minecraft.renderEngine.getTexture("/gui/guiOff.png")); } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); boolean flag = inBounds(i, j);// >= xPosition && j >= yPosition && i < // xPosition + width && j < yPosition + // height; int k = getHoverState(flag); drawTexturedModalRect(xPosition, yPosition, 0, 46 + k * 20, width / 2, height); drawTexturedModalRect(xPosition + width / 2, yPosition, 200 - width / 2, 46 + k * 20, width / 2, height); mouseDragged(minecraft, i, j); if (!enabled) { drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (height - 8) / 2, 0xffa0a0a0); } else if (flag) { drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (height - 8) / 2, 0xffffa0); } else { drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (height - 8) / 2, 0xe0e0e0); } }
From source file:net.minecraft.src.wirelessredstone.presentation.GuiButtonWirelessExit.java
License:Open Source License
/** * Renders the button to the screen.<br> * Uses gui/wifi_exit.png// www . j a va 2s . co m * * @param minecraft * minecraft instance * @param i * mouse X coordinate * @param j * mouse Y coordinate */ @Override public void drawButton(Minecraft minecraft, int i, int j) { FontRenderer fontrenderer = minecraft.fontRenderer; GL11.glBindTexture(3553 /* GL_TEXTURE_2D */, minecraft.renderEngine.getTexture("/gui/wifi_exit.png")); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); boolean flag = i >= xPosition && j >= yPosition && i < xPosition + width && j < yPosition + height; int k = getHoverState(flag); drawTexturedModalRect(xPosition, yPosition, 0, ((k - 1) * 13), 13, 13); drawTexturedModalRect(xPosition + width / 2, yPosition, 200 - width / 2, ((k - 1) * 13), width / 2, height); mouseDragged(minecraft, i, j); }
From source file:net.neilcsmith.praxis.video.opengl.internal.FrameBuffer.java
License:Apache License
private void build() { LOGGER.fine("Building FBO"); // ByteBuffer tmp = ByteBuffer.allocateDirect(4); // tmp.order(ByteOrder.nativeOrder()); // IntBuffer handle = tmp.asIntBuffer(); IntBuffer handle = BufferUtils.createIntBuffer(1); glGenFramebuffersEXT(handle);/*ww w . j av a 2 s . c o m*/ framebufferHandle = handle.get(0); if (hasDepth) { // gl.glGenRenderbuffers(1, handle); glGenRenderbuffersEXT(handle); depthbufferHandle = handle.get(0); } // GL11.glBindTexture(GL11.GL_TEXTURE_2D, colorTexture.getTextureObjectHandle()); colorTexture.bind(); if (hasDepth) { glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthbufferHandle); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL14.GL_DEPTH_COMPONENT16, colorTexture.getWidth(), colorTexture.getHeight()); } // gl.glBindFramebuffer(GL20.GL_FRAMEBUFFER, framebufferHandle); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebufferHandle); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, colorTexture.getTextureObjectHandle(), 0); if (hasDepth) { glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthbufferHandle); } int result = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); if (result != GL_FRAMEBUFFER_COMPLETE_EXT) { LOGGER.log(Level.WARNING, "Unable to build FBO"); colorTexture.dispose(); if (hasDepth) { handle.put(depthbufferHandle); handle.flip(); glDeleteRenderbuffersEXT(handle); } colorTexture.dispose(); handle.put(framebufferHandle); handle.flip(); glDeleteFramebuffersEXT(handle); if (result == GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT) { throw new IllegalStateException("frame buffer couldn't be constructed: incomplete attachment"); } if (result == GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT) { throw new IllegalStateException("frame buffer couldn't be constructed: incomplete dimensions"); } if (result == GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT) { throw new IllegalStateException("frame buffer couldn't be constructed: missing attachment"); } } }
From source file:net.neilcsmith.praxis.video.opengl.internal.GLRenderer.java
License:Apache License
private void activate() { if (active) { return;//from w ww. ja va2 s.c o m } GL11.glDepthMask(false); GL11.glEnable(GL11.GL_TEXTURE_2D); FrameBuffer fbo = null; boolean clear = false; target = null; if (surface != null) { GLSurfaceData data = surface.getData(); if (data == null) { LOGGER.finest("Setting up render to empty surface"); data = new GLSurfaceData(surface.getWidth(), surface.getHeight(), surface.hasAlpha()); data.texture = context.getTextureManager().acquire(data.width, data.height); surface.setData(data); clear = true; } else if (data.usage > 1) { LOGGER.finest("Setting up render to shared surface"); data.usage--; if (data.texture == null) { data.texture = context.getTextureManager().acquire(data.width, data.height); syncPixelsToTexture(data); } data.texture.getFrameBuffer().bind(); data = new GLSurfaceData(surface.getWidth(), surface.getHeight(), surface.hasAlpha()); data.texture = context.getTextureManager().acquire(data.width, data.height); data.texture.bind(); GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, data.width, data.height); surface.setData(data); } else if (data.texture == null) { LOGGER.finest("Setting up render to pixel backed surface"); data.texture = context.getTextureManager().acquire(data.width, data.height); syncPixelsToTexture(data); } data.pixels = null; target = data.texture; fbo = data.texture.getFrameBuffer(); } GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); if (fbo == null) { LOGGER.finest("Setting up render to screen"); int w = GLContext.getCurrent().getWidth(); int h = GLContext.getCurrent().getHeight(); FrameBuffer.unbind(); GL11.glViewport(0, 0, w, h); projectionMatrix.setToOrtho2D(0, 0, w, h); } else { LOGGER.finest("Setting up render to texture"); fbo.bind(); int w = surface.getWidth(); int h = surface.getHeight(); GL11.glViewport(0, 0, w, h); projectionMatrix.setToOrtho2D(0, h, w, -h); } if (customShader != null) { customShader.begin(); } else { shader.begin(); } setupMatrices(); active = true; if (clear) { clear(); } }