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:io.github.minecraftgui.models.fonts.UnicodeFont.java
License:Open Source License
@Override public void drawString(String text, double y, double x, int size, Color color) { org.newdawn.slick.UnicodeFont unicodeFonts[] = fonts.get(size + "-" + color.getRGB()); if (unicodeFonts != null) { GL11.glEnable(GL11.GL_BLEND);//ww w . j a v a2s . co m GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glScaled(1f / screen.getScaleFactor(), 1f / screen.getScaleFactor(), 1); unicodeFonts[screen.getScaleFactor()].drawString((float) (x * screen.getScaleFactor()), (float) (y * screen.getScaleFactor()), text); GL11.glScaled(1f * screen.getScaleFactor(), 1f * screen.getScaleFactor(), 1); } }
From source file:io.root.gfx.glutils.GL.java
License:Apache License
public static void glBlendFunc(int sfactor, int dfactor) { GL11.glBlendFunc(sfactor, dfactor); }
From source file:ion2d.INDirector.java
License:Open Source License
public static void setAlphaBlending(boolean blending) { if (Display.isCreated() == false) return;// w w w . j a v a 2 s .com if (blending) { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(INTypes.BLEND_SRC, INTypes.BLEND_DST); } else { GL11.glDisable(GL11.GL_BLEND); } }
From source file:ion2d.INLabelMap.java
License:Open Source License
/** * Draws the sprite sheet to screen// w w w .ja v a 2 s. c o m */ public void draw() { //If there are no quads do nothing if (this.atlas.getTotalQuads() == 0 || this.atlas.getTotalVisibleQuads() == 0) return; boolean newBlend = false; if (this.blend.source != GL11.GL_SRC_ALPHA || this.blend.destination != GL11.GL_ONE_MINUS_SRC_ALPHA) { GL11.glBlendFunc(this.blend.source, this.blend.destination); newBlend = true; } this.atlas.drawQuads(); if (newBlend) GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }
From source file:ion2d.INSprite.java
License:Open Source License
/** * Draws the sprite/*w ww. ja v a 2 s . c o m*/ * Only used if self rendering */ public void draw() { //If the sprite is using a sprite sheet then do not draw via //The sprite and let the sprite sheet handle the drawing instead if (this.useSpriteSheet) return; //This is pretty obvious, if the sprite isn't visible then //Do not draw the sprite! if (!this.visible) return; //If the sprites quad is off the screen there is no point in //Drawing the sprite if (this.isQuadOffScreen(this.quad)) return; boolean newBlend = false; if (this.blend.source != GL11.GL_SRC_ALPHA || this.blend.destination != GL11.GL_ONE_MINUS_SRC_ALPHA) { newBlend = true; GL11.glBlendFunc(this.blend.source, this.blend.destination); } this.texture.bind(); this.updateColorBuffer(); this.updateTextureBuffer(); this.updateVertexBuffer(); //Color GL11.glColorPointer(4, 0, this.colorBuffer); //Texture GL11.glTexCoordPointer(2, 0, this.textureBuffer); //Vertex GL11.glVertexPointer(3, 0, this.verticeBuffer); GL11.glDrawArrays(GL11.GL_QUADS, 0, 4); if (newBlend) { GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } }
From source file:ion2d.INSpriteSheet.java
License:Open Source License
/** * Draws the sprite sheet to screen//from www . java 2s . co m */ public void draw() { //If there are no quads do nothing if (this.textureAtlas.getTotalQuads() == 0 || this.textureAtlas.getTotalVisibleQuads() == 0) return; for (INNode child : this.children) { INSprite sprite = (INSprite) child; if (sprite.isDirty()) { sprite.updateTransform(); } } boolean newBlend = false; if (this.blend.source != GL11.GL_SRC_ALPHA || this.blend.destination != GL11.GL_ONE_MINUS_SRC_ALPHA) { GL11.glBlendFunc(this.blend.source, this.blend.destination); newBlend = true; } this.textureAtlas.drawQuads(); if (newBlend) GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }
From source file:itdelatrisu.opsu.render.CurveRenderState.java
License:Open Source License
/** * Backup the current state of the relevant OpenGL state and change it to * what's needed to draw the curve./*from w ww . j a va2 s.co m*/ */ private RenderState startRender() { RenderState state = new RenderState(); state.smoothedPoly = GL11.glGetBoolean(GL11.GL_POLYGON_SMOOTH); state.blendEnabled = GL11.glGetBoolean(GL11.GL_BLEND); state.depthEnabled = GL11.glGetBoolean(GL11.GL_DEPTH_TEST); state.depthWriteEnabled = GL11.glGetBoolean(GL11.GL_DEPTH_WRITEMASK); state.texEnabled = GL11.glGetBoolean(GL11.GL_TEXTURE_2D); state.texUnit = GL11.glGetInteger(GL13.GL_ACTIVE_TEXTURE); state.oldProgram = GL11.glGetInteger(GL20.GL_CURRENT_PROGRAM); state.oldArrayBuffer = GL11.glGetInteger(GL15.GL_ARRAY_BUFFER_BINDING); GL11.glDisable(GL11.GL_POLYGON_SMOOTH); GL11.glEnable(GL11.GL_BLEND); GL14.glBlendEquation(GL14.GL_FUNC_ADD); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_TEXTURE_1D); GL11.glBindTexture(GL11.GL_TEXTURE_1D, staticState.gradientTexture); GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); GL20.glUseProgram(0); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); return state; }
From source file:ivorius.ivtoolkit.models.ModelRenderer.java
License:Apache License
private static void renderNodePart(Tessellator tessellator, NodePart nodePart) { MeshPart meshPart = nodePart.meshPart; Material material = nodePart.material; Matrix4f[] bones = nodePart.bones;//from w ww. j a va 2 s.com Mesh mesh = meshPart.mesh; IndexData indexData = mesh.getIndices(); ShortBuffer indexBuf = indexData.getBuffer(); VertexData vertexData = mesh.getVertices(); FloatBuffer vertexBuf = vertexData.getBuffer(); VertexAttributes vertexAttributes = vertexData.getAttributes(); VertexAttribute posAttr = vertexAttributes.findByUsage(VertexAttributes.Usage.Position); int vertexLengthInFloats = vertexAttributes.vertexSize >> 2; VertexAttribute textureCoordAttr = null; float[] rgb = WHITE; Texture texture = null; float[] uvs = null; if (material.has(TextureAttribute.Diffuse)) { TextureAttribute textureAttr = material.get(TextureAttribute.class, TextureAttribute.Diffuse); texture = textureAttr.texture; textureCoordAttr = vertexAttributes.findByUsageAndUnit(VertexAttributes.Usage.TextureCoordinates, 0); if (textureCoordAttr == null) uvs = guessUVs(meshPart.primitiveType, texture, meshPart.numVertices); } else if (material.has(ColorAttribute.Diffuse)) { // Note that a texture replaces the color diffuse ColorAttribute diffuse = material.get(ColorAttribute.class, ColorAttribute.Diffuse); rgb = new float[] { diffuse.color.getRed() / 255.0f, diffuse.color.getGreen() / 255.0f, diffuse.color.getBlue() / 255.0f }; } BlendingAttribute blend = material.get(BlendingAttribute.class, BlendingAttribute.Type); if (blend != null) { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(blend.sourceFunction, blend.destFunction); GL11.glColor4f(rgb[0], rgb[1], rgb[2], blend.opacity); } else GL11.glColor3f(rgb[0], rgb[1], rgb[2]); if (texture != null) texture.bindTexture(); else GL11.glDisable(GL11.GL_TEXTURE_2D); List<VertexAttribute> boneWeightAttributes = new ArrayList<>(); for (VertexAttribute attribute : vertexAttributes) { if (attribute.usage == VertexAttributes.Usage.BoneWeight) boneWeightAttributes.add(attribute); } tessellator.startDrawing(meshPart.primitiveType); for (int i = meshPart.indexOffset; i < meshPart.numVertices + meshPart.indexOffset; i++) { int vertexIndex = indexBuf.get(i) * vertexLengthInFloats; if (texture != null) { if (textureCoordAttr != null) { int textureIndex = vertexIndex + (textureCoordAttr.offset >> 2); tessellator.setTextureUV( MathUtils.mix(texture.minU(), texture.maxU(), vertexBuf.get(textureIndex)), MathUtils.mix(texture.minV(), texture.maxV(), vertexBuf.get(textureIndex + 1))); } else if (uvs != null) tessellator.setTextureUV(uvs[i * 2], uvs[i * 2 + 1]); } int posIndex = vertexIndex + (posAttr.offset >> 2); float vertexX = vertexBuf.get(posIndex); float vertexY = vertexBuf.get(posIndex + 1); float vertexZ = vertexBuf.get(posIndex + 2); if (boneWeightAttributes.size() > 0) { buildMatrix(TEMP_MATRIX, boneWeightAttributes, vertexBuf, vertexIndex, bones); TEMP_VEC.set(vertexX, vertexY, vertexZ, 1.0f); Matrix4f.transform(TEMP_MATRIX, TEMP_VEC, TEMP_VEC); tessellator.addVertex(TEMP_VEC.x, TEMP_VEC.y, TEMP_VEC.z); } else tessellator.addVertex(vertexX, vertexY, vertexZ); } tessellator.draw(); if (texture == null) GL11.glEnable(GL11.GL_TEXTURE_2D); if (blend != null) GL11.glDisable(GL11.GL_BLEND); }
From source file:jake2.desktop.LWJGLAdapter.java
License:Open Source License
@Override public void glBlendFunc(int sfactor, int dfactor) { GL11.glBlendFunc(sfactor, dfactor); }
From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java
License:Open Source License
@Override public void setBlendFunc(int src, int dst) { try {//from w w w . j a v a 2 s. c om GL11.glBlendFunc(blendSrcToGL[src], blendDstToGL[dst]); } catch (IllegalStateException e) { log.warn("VideoEngine: " + e.getMessage()); } }