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.def.iss.vd2.lib_v3d.element.V3DCircle.java
License:Open Source License
private void drawExternCircle() { float step = 2f * (float) Math.PI / (float) quality; if (customColor) { GL11.glPushAttrib(GL11.GL_CURRENT_BIT); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }/*from w w w. j a v a 2 s.c om*/ GL11.glBegin(GL11.GL_TRIANGLE_STRIP); for (int i = 0; i <= quality; i++) { if (customColor) { GL11.glColor4f(innerColor.r, innerColor.g, innerColor.b, innerColor.a); } GL11.glVertex3f((float) (innerRadius * Math.cos(step * i)), (float) (innerRadius * Math.sin(step * i)), 0f); if (customColor) { GL11.glColor4f(outerColor.r, outerColor.g, outerColor.b, outerColor.a); } GL11.glVertex3f((float) (radius * Math.cos(step * i)), (float) (radius * Math.sin(step * i)), 0f); } GL11.glEnd(); if (customColor) { GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glPopAttrib(); } }
From source file:fr.def.iss.vd2.lib_v3d.element.V3DSprite.java
License:Open Source License
@Override protected void doDisplay(V3DCamera camera) { if (!enableColor) { GL11.glPushAttrib(GL11.GL_CURRENT_BIT); GL11.glColor4f(1, 1, 1, opacity); }/*from w w w . ja v a 2 s.co m*/ GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1f); GL11.glEnable(GL11.GL_ALPHA_TEST); if (disableRotation) { camera.disableRotation(); } float w = 0.5f * size.x * image.getWidth(); float h = 0.5f * size.y * image.getHeight(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getID()); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(-w, -h, 0.0f); GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(w, -h, 0.0f); GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(w, h, 0.0f); GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(-w, h, 0.0f); GL11.glEnd(); if (disableRotation) { camera.enableRotation(); } GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_TEXTURE_2D); if (!enableColor) { GL11.glPopAttrib(); } }
From source file:fr.def.iss.vd2.lib_v3d.V3DCanvas.java
License:Open Source License
/** * Sets up the screen.//from w ww.ja va2 s.co m * * @see javax.media.openGL11.GLEventListener#init(javax.media.openGL11.GLAutoDrawable) */ public void init() { try { frame = new JFrame("Space agencies"); //frame.setSize(width,height); //frame.setUndecorated(true); //here frame.setVisible(true); //frame.setAlwaysOnTop(true); frame.setLocation(0, 0); Canvas canvas = new Canvas(); canvas.setMinimumSize(new Dimension(800, 600)); canvas.setPreferredSize(new Dimension(width, height)); frame.add(canvas); frame.pack(); frame.addWindowListener(generateWindowListener()); frame.getContentPane().addHierarchyBoundsListener(new HierarchyBoundsListener() { @Override public void ancestorMoved(HierarchyEvent e) { } @Override public void ancestorResized(HierarchyEvent e) { width = frame.getContentPane().getWidth(); height = frame.getContentPane().getHeight(); reshape(0, 0, width, height); } }); Display.setDisplayMode(new DisplayMode(width, height)); //Display.setFullscreen(true); Display.setVSyncEnabled(false); Display.setTitle("Space agencies"); Display.setParent(canvas); Display.create(); canvas.requestFocus(); } catch (Exception e) { System.out.println("Error setting up display" + e); System.exit(0); } // Enable z- (depth) buffer for hidden surface removal. GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glEnable(GL11.GL_POINT_SMOOTH); if (polygonOffset) { GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); GL11.glPolygonOffset(1.0f, 1.0f); } GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST); GL11.glClearDepth(1.0); // Enables Clearing Of The Depth Buffer GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_BLEND); // Enable smooth shading. GL11.glShadeModel(GL11.GL_SMOOTH); // Define "clear" color. GL11.glClearColor(0f, 0f, 0.4f, 0f); // We want a nice perspective. GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glFlush(); TextureManager.clearCache(); initied = true; // new LWJGLBinding(); }
From source file:fr.def.iss.vd2.lib_v3d.v3draw.V3DrawReader.java
License:Open Source License
private void enableTexture() { int textureIndex = buffer.getInt(); GL11.glEnable(GL11.GL_TEXTURE_2D);/* w w w . j av a 2 s . c om*/ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1f); GL11.glEnable(GL11.GL_ALPHA_TEST); // GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureList.get(textureIndex).getID()); }
From source file:fr.guillaume.prive.viper.core.graphic.GraphicMotor.java
public static void draw() { GraphicMotor.checkInstance();//from w w w . ja va2s .c om GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL20.glUseProgram(instance.shipShaderId); GL20.glUniform1i(instance.useTextureLocation, instance.drawPolygonFrame ? 0 : 1); int drawStyle = instance.drawPolygonFrame ? GL11.GL_LINE_LOOP : GL11.GL_TRIANGLES; GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, instance.shipTextureId); GL30.glBindVertexArray(instance.shipVaoId); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); GL20.glEnableVertexAttribArray(3); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, instance.shipVboiId); GL11.glDrawElements(drawStyle, instance.shipVboiLenght, GL11.GL_UNSIGNED_INT, 0); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); GL20.glDisableVertexAttribArray(3); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); GL20.glUseProgram(0); }
From source file:fr.ign.cogit.geoxygene.appli.render.DisplayableTextRenderer.java
License:Open Source License
private void drawText() throws GLException { if (this.program == null || this.textImage == null) { Logger.getRootLogger().debug("The GeoxGLTextRenderer " + this.hashCode() + "is not ready yet"); return;/*from w w w .j av a 2 s .com*/ } this.textImage.getRGB(0, 0, width, height, this.pixels, 0, width); this.buffer.rewind(); for (int y = height - 1; y >= 0; y--) { for (int x = 0; x < width; x++) { int pixel = this.pixels[y * width + x]; this.buffer.put((byte) (pixel >> 16 & 0xFF)); // Red component this.buffer.put((byte) (pixel >> 8 & 0xFF)); // Green component this.buffer.put((byte) (pixel >> 0 & 0xFF)); // Blue component this.buffer.put((byte) (pixel >> 24 & 0xFF)); // Alpha component } } this.buffer.rewind(); glEnable(GL_TEXTURE_2D); GL13.glActiveTexture(GL13.GL_TEXTURE0 + 2); glBindTexture(GL_TEXTURE_2D, this.getTextTextureId()); // Setup texture scaling filtering GL11.glTexParameteri(GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexImage2D(GL_TEXTURE_2D, 0, GL11.GL_RGBA8, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, this.buffer); Integer fbow = (Integer) GLContext.getActiveGlContext() .getSharedUniform(GeoxygeneConstants.GL_VarName_FboWidth); Integer fboh = (Integer) GLContext.getActiveGlContext() .getSharedUniform(GeoxygeneConstants.GL_VarName_FboHeight); GL11.glViewport(0, 0, fbow, fboh); glDisable(GL11.GL_POLYGON_SMOOTH); GLContext.getActiveGlContext().setCurrentProgram(program); program.setUniform1i("colorTexture2", 2); GLTools.glCheckError("texture binding"); GL11.glDepthMask(false); glDisable(GL11.GL_DEPTH_TEST); GL30.glBindVertexArray(LayerViewGLPanel.getScreenQuad().getVaoId()); GLTools.glCheckError("before drawing textured quad VAO binding"); program.setUniform(GeoxygeneConstants.GL_VarName_ObjectOpacityVarName, 1f); program.setUniform(GeoxygeneConstants.GL_VarName_GlobalOpacityVarName, 1f); glEnable(GL_BLEND); GL11.glBlendFunc(GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GLTools.glCheckError("blending set for textured quad"); LwjglLayerRenderer.drawComplex(LayerViewGLPanel.getScreenQuad()); GLTools.glCheckError("Drawing textured quad"); GL30.glBindVertexArray(0); // unbind VAO GLTools.glCheckError("exiting Text rendering"); glBindTexture(GL_TEXTURE_2D, 0); // unbind texture }
From source file:fr.mcnanotech.kevin_68.nanotechmod.city.client.renderer.tileentity.TileEntityFountainRender.java
License:Creative Commons License
public void renderTileEntitySpotLightAt(TileEntityFountain tileentity, double x, double y, double z, float par8) { float f1 = tileentity.func_82125_v_(); if (f1 > 0.0F) { 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);/*from ww w . j a v a 2s . c o m*/ GL11.glDepthMask(true); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); tessellator.setColorRGBA(255, 255, 255, 32); float f2 = (float) (tileentity.getWorldObj().getTotalWorldTime() / 2) + par8; float f22; if (tileentity.rotate) { f22 = ((f2 - par8) * 2) + par8; } else { f22 = 1.0F; } float f3 = -f2 * 0.2F - (float) MathHelper.floor_float(-f2 * 0.1F); byte b0 = 1; double d3 = (double) f22 * 0.025D * (1.0D - (double) (b0 & 1) * 2.5D); tessellator.startDrawingQuads(); double d4 = (double) b0 * tileentity.getWidth(); 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; d13 = (double) (tileentity.f * f1); double d14 = 0.0D; double d15 = 1.0D; double d16 = (double) (-1.0F + f3); double d17 = (double) (tileentity.f * f1) * (0.5D / d4) + d16; tessellator.addVertexWithUV(x + d7, y, z + d8, d14, d16); tessellator.addVertexWithUV(x + d7, y + d13, z + d8, d14, d17); tessellator.addVertexWithUV(x + d9, y, z + d10, d14, d16); tessellator.addVertexWithUV(x + d9, y + d13, z + d10, d14, d17); tessellator.addVertexWithUV(x + d7, y + d13, z + d8, d15, d17); tessellator.addVertexWithUV(x + d7, y, z + d8, d15, d16); tessellator.addVertexWithUV(x + d9, y + d13, z + d10, d15, d17); tessellator.addVertexWithUV(x + d9, y, z + d10, d15, d16); tessellator.addVertexWithUV(x + d5, y + d13, z + d6, d15, d17); tessellator.addVertexWithUV(x + d5, y, z + d6, d15, d16); tessellator.addVertexWithUV(x + d11, y + d13, z + d12, d15, d17); tessellator.addVertexWithUV(x + d11, y, z + d12, d15, d16); tessellator.addVertexWithUV(x + d11, y, z + d12, d14, d16); tessellator.addVertexWithUV(x + d11, y + d13, z + d12, d14, d17); tessellator.addVertexWithUV(x + d5, y, z + d6, d14, d16); tessellator.addVertexWithUV(x + d5, y + d13, z + d6, d14, d17); tessellator.draw(); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDepthMask(true); } }
From source file:fr.mcnanotech.kevin_68.nanotechmod.main.client.renderer.RenderCreeperDriller.java
License:Creative Commons License
protected int renderMobCreeperDrillerPassModel(MobCreeperDriller mob, int par2, float par3) { if (mob.getPowered()) { if (par2 == 1) { float var4 = (float) mob.ticksExisted + par3; this.bindTexture(new ResourceLocation("textures/entity/creeper/creeper_armor.png")); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity();//w ww . jav a 2s . c om float var5 = var4 * 0.01F; float var6 = var4 * 0.01F; GL11.glTranslatef(var5, var6, 0.0F); this.setRenderPassModel(this.model); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_BLEND); float var7 = 0.5F; GL11.glColor4f(var7, var7, var7, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); return 1; } if (par2 == 2) { GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); } } return -1; }
From source file:fr.mcnanotech.kevin_68.nanotechmod.main.client.renderer.RenderFlyingCreeper.java
License:Creative Commons License
protected int renderMobFlyingCreeperPassModel(MobFlyingCreeper mob, int par2, float par3) { if (mob.getPowered()) { if (par2 == 1) { float var4 = (float) mob.ticksExisted + par3; this.bindTexture(new ResourceLocation("textures/entity/creeper/creeper_armor.png")); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity();/*ww w. jav a2 s. c om*/ float var5 = var4 * 0.01F; float var6 = var4 * 0.01F; GL11.glTranslatef(var5, var6, 0.0F); this.setRenderPassModel(this.model); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_BLEND); float var7 = 0.5F; GL11.glColor4f(var7, var7, var7, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); return 1; } if (par2 == 2) { GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); } } return -1; }
From source file:fr.mcnanotech.kevin_68.nanotechmod.main.client.renderer.RenderSuperCreeper.java
License:Creative Commons License
protected int renderMobSuperCreeperPassModel(MobSuperCreeper mob, int par2, float par3) { if (mob.getPowered()) { if (par2 == 1) { float var4 = (float) mob.ticksExisted + par3; this.bindTexture(new ResourceLocation("textures/entity/creeper/creeper_armor.png")); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity();/*from w w w . ja va 2 s .com*/ float var5 = var4 * 0.01F; float var6 = var4 * 0.01F; GL11.glTranslatef(var5, var6, 0.0F); this.setRenderPassModel(this.model); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_BLEND); float var7 = 0.5F; GL11.glColor4f(var7, var7, var7, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); return 1; } if (par2 == 2) { GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); } } return -1; }