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:fr.mcnanotech.kevin_68.nanotechmod.main.client.renderer.RenderSuperEnderman.java
License:Creative Commons License
protected int renderEyes(MobSuperEnderman mob, int par2, float par3) { if (par2 != 0) { return -1; } else {/*from ww w . java 2 s .c o m*/ this.bindTexture(new ResourceLocation("textures/entity/enderman/enderman_eyes.png")); float var4 = 1.0F; GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); GL11.glDisable(GL11.GL_LIGHTING); char var5 = 61680; int var6 = var5 % 65536; int var7 = var5 / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) var6 / 1.0F, (float) var7 / 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_LIGHTING); GL11.glColor4f(1.0F, 1.0F, 1.0F, var4); return 1; } }
From source file:fr.mcnanotech.kevin_68.nanotechmod.main.event.RenderEvent.java
License:Creative Commons License
@SubscribeEvent public void onRenderGameOverlay(RenderGameOverlayEvent event) { if (event.isCancelable() || event.type != ElementType.EXPERIENCE) { return;/* www . ja va 2 s . com*/ } else { ItemStack stack = this.mc.thePlayer.inventory.armorItemInSlot(3); if (this.mc.gameSettings.thirdPersonView == 0 && stack != null && stack.getItem().equals(NanotechItem.crazyGlasses)) { int k = event.resolution.getScaledWidth(); int l = event.resolution.getScaledHeight(); GL11.glEnable(GL11.GL_BLEND); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); this.mc.renderEngine.bindTexture(texture); Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.addVertexWithUV(0.0D, (double) l, -90.0D, 0.0D, 1.0D); tessellator.addVertexWithUV((double) k, (double) l, -90.0D, 1.0D, 1.0D); tessellator.addVertexWithUV((double) k, 0.0D, -90.0D, 1.0D, 0.0D); tessellator.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D); tessellator.draw(); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } } }
From source file:fr.theshark34.sharkengine.ui.components.Button.java
License:Apache License
/** * Draw the button/*from w w w . jav a 2s.c om*/ */ @Override public void draw() { // Enabling blending GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // Being sure that texturing is disabled GL11.glDisable(GL11.GL_TEXTURE_2D); // Check if the mouse is on the button if (Mouse.getX() > this.x && Mouse.getX() < this.x + this.width && Mouse.getY() < Display.getHeight() - this.y && Mouse.getY() > Display.getHeight() - this.y - this.height) { // Changing button color to colorHover GL11.glColor4f((float) colorHover.getRed() / 255, (float) colorHover.getGreen() / 255, (float) colorHover.getBlue() / 255, (float) colorHover.getAlpha() / 255); // If the mouse clicked and clicked is false, executing action // and setting clicked to true, then the action will not be // repeated if (Mouse.isButtonDown(0)) { if (!clicked) { clicked = true; action.buttonClicked(); } } else // If mouse isn't on it, setting clicked to false clicked = false; } else // Else, setting the color to the base color GL11.glColor4f((float) color.getRed() / 255, (float) color.getGreen() / 255, (float) color.getBlue() / 255, (float) color.getAlpha() / 255); // Drawing the button base (a rectangle) GL11.glBegin(GL11.GL_QUADS); { GL11.glVertex2f(x, y); GL11.glVertex2f(x + width, y); GL11.glVertex2f(x + width, y + height); GL11.glVertex2f(x, y + height); } GL11.glEnd(); // Drawing the text this.font.drawString(x + (this.width - this.font.getWidth(text)) / 2, y + (this.height - this.font.getHeight(text)) / 2, text); // Disabling blending GL11.glDisable(GL11.GL_BLEND); }
From source file:fr.theshark34.sharkengine.ui.components.Checkbox.java
License:Apache License
/** * Draw the checkbox/*w ww. ja va2 s.c o m*/ */ public void draw() { // Enabling blending GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // Being sure that texturing is disabled GL11.glDisable(GL11.GL_TEXTURE_2D); // Picking white color GL11.glColor3f(1.0F, 1.0F, 1.0F); // Drawing the checkbox GL11.glBegin(GL11.GL_QUADS); { GL11.glVertex2f(x, y); GL11.glVertex2f(x + width, y); GL11.glVertex2f(x + width, y + height); GL11.glVertex2f(x, y + height); } GL11.glEnd(); // Drawing the text this.font.drawString(x + 25, y + (this.height - this.font.getHeight(text)) / 2, text); // Being sure that texturing is enabled GL11.glEnable(GL11.GL_TEXTURE_2D); // If the mouse is on the checkbox if (Mouse.getX() > this.x && Mouse.getX() < this.x + this.width && Mouse.getY() < Display.getHeight() - this.y && Mouse.getY() > Display.getHeight() - this.y - this.height) // If the mouse clicked and clicked is false, setting coched // to its oposite and setting clicked to true, so it will do // it one time if (Mouse.isButtonDown(0)) { if (!clicked) { clicked = true; coched = !coched; } } else // If mouse isn't on it, setting clicked to false clicked = false; // Checking if the checkbox is coched if (coched) { // Drawing coched checkbox texture GL11.glBindTexture(GL11.GL_TEXTURE_2D, cochedcb.getTextureID()); // Drawing the image GL11.glBegin(GL11.GL_QUADS); { GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex2f(x, y); GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex2f(x + width, y); GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex2f(x + width, y + height); GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex2f(x, y + height); } GL11.glEnd(); } // Disabling texture GL11.glDisable(GL11.GL_TEXTURE_2D); // Disabling blending GL11.glDisable(GL11.GL_BLEND); }
From source file:fr.theshark34.sharkengine.ui.components.HorizontalSlider.java
License:Apache License
/** * Draw the slider//from ww w . j av a 2 s.com */ @Override public void draw() { // Enabling blending GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // Being sure that texturing is disabled GL11.glDisable(GL11.GL_TEXTURE_2D); // Check if the mouse is on the slider if (Mouse.getX() > this.x + this.sliderX && Mouse.getX() < this.x + this.sliderX + this.sliderWidth && Mouse.getY() < Display.getHeight() - this.y && Mouse.getY() > Display.getHeight() - this.y - this.height) { // If the mouse clicked and clicked is false, settings clicked to // true and saving mouse initial click if (Mouse.isButtonDown(0)) { if (!clicked) { clicked = true; mouseClick = Mouse.getX(); } } else // If mouse isn't on it, setting clicked to false clicked = false; } // Setting clicked to false only when the mouse stop clicking else if (!Mouse.isButtonDown(0)) clicked = false; // If mouse clicked if (clicked) { // If slider isn't on the minimum / maximum if (sliderX >= 0 && sliderX + sliderWidth <= width) if (sliderX + Mouse.getX() - mouseClick >= 0) if (sliderX + sliderWidth + Mouse.getX() - mouseClick <= width) { sliderX += Mouse.getX() - mouseClick; mouseClick = Mouse.getX(); } else sliderX = width - sliderWidth; else sliderX = 0; } // Picking the background color GL11.glColor4f((float) color.getRed() / 255, (float) color.getGreen() / 255, (float) color.getBlue() / 255, (float) color.getAlpha() / 255); // Drawing the slider background GL11.glBegin(GL11.GL_QUADS); { GL11.glVertex2f(x, y); GL11.glVertex2f(x + width, y); GL11.glVertex2f(x + width, y + height); GL11.glVertex2f(x, y + height); } GL11.glEnd(); // Picking the slider color GL11.glColor4f((float) sliderColor.getRed() / 255, (float) sliderColor.getGreen() / 255, (float) sliderColor.getBlue() / 255, (float) sliderColor.getAlpha() / 255); // Drawing the slider GL11.glBegin(GL11.GL_QUADS); { GL11.glVertex2f(x + sliderX, y); GL11.glVertex2f(x + sliderX + sliderWidth, y); GL11.glVertex2f(x + sliderX + sliderWidth, y + height); GL11.glVertex2f(x + sliderX, y + height); } GL11.glEnd(); }
From source file:fr.theshark34.sharkengine.ui.components.Image.java
License:Apache License
/** * Draw it/*from w w w .ja v a 2 s .c om*/ */ @Override public void draw() { // Without this, image can render strangely GL11.glColor3f(1.0F, 1.0F, 1.0F); // Enabling blend and texture GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getTextureID()); // Drawing the image GL11.glBegin(GL11.GL_QUADS); { GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex2f(x, y); GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex2f(x + width, y); GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex2f(x + width, y + height); GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex2f(x, y + height); } GL11.glEnd(); // Disabling blend and texture GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); }
From source file:fr.theshark34.sharkengine.ui.components.ProgressBar.java
License:Apache License
/** * Draw the bar//from w w w. j a v a2 s .co m */ @Override public void draw() { // Enabling blending GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // Being sure that texture is disabled GL11.glDisable(GL11.GL_TEXTURE_2D); // Picking the base color GL11.glColor4f((float) color.getRed() / 255, (float) color.getGreen() / 255, (float) color.getBlue() / 255, (float) color.getAlpha() / 255); // Drawing the base GL11.glBegin(GL11.GL_QUADS); { GL11.glVertex2f(x, y); GL11.glVertex2f(x + width, y); GL11.glVertex2f(x + width, y + height); GL11.glVertex2f(x, y + height); } GL11.glEnd(); if (value != 0 && maximum != 0) { // Picking the foreground color GL11.glColor4f((float) fgColor.getRed() / 255, (float) fgColor.getGreen() / 255, (float) fgColor.getBlue() / 255, (float) fgColor.getAlpha() / 255); int fgWidth = (int) (width / ((float) maximum / (float) value)); // Drawing the foreground GL11.glBegin(GL11.GL_QUADS); { GL11.glVertex2f(x, y); GL11.glVertex2f(x + fgWidth, y); GL11.glVertex2f(x + fgWidth, y + height); GL11.glVertex2f(x, y + height); } GL11.glEnd(); } // Drawing the text this.font.drawString(x + (this.width - this.font.getWidth(string)) / 2, y + (this.height - this.font.getHeight(string)) / 2, string); // Disabling blending GL11.glDisable(GL11.GL_BLEND); }
From source file:fr.theshark34.sharkengine.ui.components.VerticalSlider.java
License:Apache License
/** * Draw the slider/*from w w w . j a v a2 s.c o m*/ */ @Override public void draw() { // Enabling blending GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // Being sure that texturing is disabled GL11.glDisable(GL11.GL_TEXTURE_2D); // Check if the mouse is on the slider if (Mouse.getX() > this.x && Mouse.getX() < this.x + width && Mouse.getY() < Display.getHeight() - this.y + this.sliderY && Mouse.getY() > Display.getHeight() - this.y - this.sliderY - this.sliderHeight) { // If the mouse clicked and clicked is false, settings clicked to // true and saving mouse initial click if (Mouse.isButtonDown(0)) { if (!clicked) { clicked = true; mouseClick = Display.getHeight() - Mouse.getY(); } } else // If mouse isn't on it, setting clicked to false clicked = false; } // Setting clicked to false only when the mouse stop clicking else if (!Mouse.isButtonDown(0)) clicked = false; // If mouse clicked if (clicked) { // If slider isn't on the minimum / maximum if (sliderY >= 0 && sliderY + sliderHeight <= height) if (sliderY + Display.getHeight() - Mouse.getY() - mouseClick >= 0) if (sliderY + sliderHeight + Display.getHeight() - Mouse.getY() - mouseClick <= height) { sliderY += Display.getHeight() - Mouse.getY() - mouseClick; mouseClick = Display.getHeight() - Mouse.getY(); } else sliderY = height - sliderHeight; else sliderY = 0; } // Picking the background color GL11.glColor4f((float) color.getRed() / 255, (float) color.getGreen() / 255, (float) color.getBlue() / 255, (float) color.getAlpha() / 255); // Drawing the slider background GL11.glBegin(GL11.GL_QUADS); { GL11.glVertex2f(x, y); GL11.glVertex2f(x + width, y); GL11.glVertex2f(x + width, y + height); GL11.glVertex2f(x, y + height); } GL11.glEnd(); // Picking the slider color GL11.glColor4f((float) sliderColor.getRed() / 255, (float) sliderColor.getGreen() / 255, (float) sliderColor.getBlue() / 255, (float) sliderColor.getAlpha() / 255); // Drawing the slider GL11.glBegin(GL11.GL_QUADS); { GL11.glVertex2f(x, y + sliderY); GL11.glVertex2f(x + width, y + sliderY); GL11.glVertex2f(x + width, y + sliderY + sliderHeight); GL11.glVertex2f(x, y + sliderY + sliderHeight); } GL11.glEnd(); }
From source file:game.engine.game.Scene.java
License:Open Source License
/** * Draws the screen contents using OpenGL. *//*from w w w. j ava 2 s . com*/ public void draw() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, getScreenWidthUnits(), getScreenHeightUnits(), 0, -1, 1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(-screenX, -screenY, 0.0f); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); for (GameObject gameObject : gameObjects) { gameObject.draw(); } }
From source file:game.states.State_PREFAB_EDITOR.java
License:Open Source License
@Override protected void Init() { ButtonGUILayer = new GUI_Layer(); ButtonGUILayer.SetEnabled(true);//from w w w . ja v a 2 s .c o m MenuGUILayer = new GUI_Layer(); MenuGUILayer.SetEnabled(false); int ButtonStartX = 712; int ButtonStartY = 600; float xScale = 1.5f; float yScale = 1.5f; int Spacing = 145; int menuButtonStartX = 640 - 128; int menuButtonStartY = 150; float menuXScale = 1f; float menuYScale = 1f; int menuSpacing = 110; try { GL11.glEnable(GL11.GL_TEXTURE_2D); BackGroundImage = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/GUIPrefab.png")); Texture button1 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/SaveIconButton.png"), false, GL11.GL_NEAREST); ButtonGUILayer.AddButton(ButtonStartX + Spacing * 0, ButtonStartY, (int) (button1.getImageWidth() * xScale), (int) (button1.getImageHeight() * yScale), button1); Texture button2 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/LoadIconButton.png"), false, GL11.GL_NEAREST); ButtonGUILayer.AddButton(ButtonStartX + Spacing * 1, ButtonStartY, (int) (button2.getImageWidth() * xScale), (int) (button2.getImageHeight() * yScale), button2); Texture button3 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/OptionsIconButton.png"), false, GL11.GL_NEAREST); ButtonGUILayer.AddButton(ButtonStartX + Spacing * 2, ButtonStartY, (int) (button3.getImageWidth() * xScale), (int) (button3.getImageHeight() * yScale), button3); Texture button4 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/HelpIconButton.png"), false, GL11.GL_NEAREST); ButtonGUILayer.AddButton(ButtonStartX + Spacing * 3, ButtonStartY, (int) (button4.getImageWidth() * xScale), (int) (button4.getImageHeight() * yScale), button4); Texture mButton0 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/ReturnButton.png"), false, GL11.GL_NEAREST); MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 0, (int) (mButton0.getImageWidth() * menuXScale), (int) (mButton0.getImageHeight() * menuYScale), mButton0); Texture mButton1 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/LoadButton.png"), false, GL11.GL_NEAREST); MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 1, (int) (mButton1.getImageWidth() * menuXScale), (int) (mButton1.getImageHeight() * menuYScale), mButton1); Texture mButton2 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/SaveButton.png"), false, GL11.GL_NEAREST); MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 2, (int) (mButton2.getImageWidth() * menuXScale), (int) (mButton2.getImageHeight() * menuYScale), mButton2); Texture mButton3 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/BackButton.png"), false, GL11.GL_NEAREST); MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 3, (int) (mButton3.getImageWidth() * menuXScale), (int) (mButton3.getImageHeight() * menuYScale), mButton3); } catch (IOException e) { e.printStackTrace(); } GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GLU.gluPerspective(45.0f, (float) Display.getWidth() / (float) Display.getHeight(), 0.1f, 600.0f); GLU.gluLookAt(0, 20, 50, 0, -2, -100, 0, -1, 0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }