List of usage examples for org.lwjgl.opengl GL11 glEnable
public static void glEnable(@NativeType("GLenum") int target)
From source file:com.oneofthesevenbillion.ziah.ZiahsClient.gui.GuiScrollingList.java
License:Open Source License
public void drawScreen(int mouseX, int mouseY, float tick) { this.mouseX = mouseX; this.mouseY = mouseY; this.drawBackground(); int listLength = this.getSize(); int scrollBarXStart = this.left + this.listWidth - 6; int scrollBarXEnd = scrollBarXStart + 6; int boxLeft = this.left; int boxRight = scrollBarXStart - 1; int var10; int var11; int var13; int var19; if (Mouse.isButtonDown(0)) { if (this.initialMouseClickY == -1.0F) { boolean var7 = true; if (mouseY >= this.top && mouseY <= this.bottom) { var10 = mouseY - this.top - this.field_27261_r + (int) this.scrollDistance - 4; var11 = var10 / this.slotHeight; if (mouseX >= boxLeft && mouseX <= boxRight && var11 >= 0 && var10 >= 0 && var11 < listLength) { boolean var12 = var11 == this.selectedIndex && System.currentTimeMillis() - this.lastClickTime < 250L; this.elementClicked(var11, var12); this.selectedIndex = var11; this.lastClickTime = System.currentTimeMillis(); } else if (mouseX >= boxLeft && mouseX <= boxRight && var10 < 0) { this.func_27255_a(mouseX - boxLeft, mouseY - this.top + (int) this.scrollDistance - 4); var7 = false; }//from ww w . jav a2s .com if (mouseX >= scrollBarXStart && mouseX <= scrollBarXEnd) { this.scrollFactor = -1.0F; var19 = this.getContentHeight() - (this.bottom - this.top - 4); if (var19 < 1) { var19 = 1; } var13 = (int) ((float) ((this.bottom - this.top) * (this.bottom - this.top)) / (float) this.getContentHeight()); if (var13 < 32) { var13 = 32; } if (var13 > this.bottom - this.top - 8) { var13 = this.bottom - this.top - 8; } this.scrollFactor /= (float) (this.bottom - this.top - var13) / (float) var19; } else { this.scrollFactor = 1.0F; } if (var7) { this.initialMouseClickY = mouseY; } else { this.initialMouseClickY = -2.0F; } } else { this.initialMouseClickY = -2.0F; } } else if (this.initialMouseClickY >= 0.0F) { this.scrollDistance -= (mouseY - this.initialMouseClickY) * this.scrollFactor; this.initialMouseClickY = mouseY; } } else { while (Mouse.next()) { int var16 = Mouse.getEventDWheel(); if (var16 != 0) { if (var16 > 0) { var16 = -1; } else if (var16 < 0) { var16 = 1; } this.scrollDistance += var16 * this.slotHeight / 2; } } this.initialMouseClickY = -1.0F; } this.applyScrollLimits(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_FOG); Tessellator var18 = Tessellator.instance; try { ((TextureManager) ModLoader.getPrivateValue(Minecraft.class, this.client, 7)) .func_110577_a(Gui.field_110325_k); } catch (Exception e) { e.printStackTrace(); } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); float var17 = 32.0F; var18.startDrawingQuads(); var18.setColorOpaque_I(2105376); var18.addVertexWithUV(this.left, this.bottom, 0.0D, this.left / var17, (this.bottom + (int) this.scrollDistance) / var17); var18.addVertexWithUV(this.right, this.bottom, 0.0D, this.right / var17, (this.bottom + (int) this.scrollDistance) / var17); var18.addVertexWithUV(this.right, this.top, 0.0D, this.right / var17, (this.top + (int) this.scrollDistance) / var17); var18.addVertexWithUV(this.left, this.top, 0.0D, this.left / var17, (this.top + (int) this.scrollDistance) / var17); var18.draw(); // boxRight = this.listWidth / 2 - 92 - 16; var10 = this.top + 4 - (int) this.scrollDistance; if (this.field_27262_q) { this.func_27260_a(boxRight, var10, var18); } int var14; for (var11 = 0; var11 < listLength; ++var11) { var19 = var10 + var11 * this.slotHeight + this.field_27261_r; var13 = this.slotHeight - 4; if (var19 <= this.bottom && var19 + var13 >= this.top) { if (this.field_25123_p && this.isSelected(var11)) { var14 = boxLeft; int var15 = boxRight; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_TEXTURE_2D); var18.startDrawingQuads(); var18.setColorOpaque_I(8421504); var18.addVertexWithUV(var14, var19 + var13 + 2, 0.0D, 0.0D, 1.0D); var18.addVertexWithUV(var15, var19 + var13 + 2, 0.0D, 1.0D, 1.0D); var18.addVertexWithUV(var15, var19 - 2, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV(var14, var19 - 2, 0.0D, 0.0D, 0.0D); var18.setColorOpaque_I(0); var18.addVertexWithUV(var14 + 1, var19 + var13 + 1, 0.0D, 0.0D, 1.0D); var18.addVertexWithUV(var15 - 1, var19 + var13 + 1, 0.0D, 1.0D, 1.0D); var18.addVertexWithUV(var15 - 1, var19 - 1, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV(var14 + 1, var19 - 1, 0.0D, 0.0D, 0.0D); var18.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } this.drawSlot(var11, boxRight, var19, var13, var18); } } GL11.glDisable(GL11.GL_DEPTH_TEST); byte var20 = 4; this.overlayBackground(0, this.top, 255, 255); this.overlayBackground(this.bottom, this.listHeight, 255, 255); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_TEXTURE_2D); var18.startDrawingQuads(); var18.setColorRGBA_I(0, 0); var18.addVertexWithUV(this.left, this.top + var20, 0.0D, 0.0D, 1.0D); var18.addVertexWithUV(this.right, this.top + var20, 0.0D, 1.0D, 1.0D); var18.setColorRGBA_I(0, 255); var18.addVertexWithUV(this.right, this.top, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV(this.left, this.top, 0.0D, 0.0D, 0.0D); var18.draw(); var18.startDrawingQuads(); var18.setColorRGBA_I(0, 255); var18.addVertexWithUV(this.left, this.bottom, 0.0D, 0.0D, 1.0D); var18.addVertexWithUV(this.right, this.bottom, 0.0D, 1.0D, 1.0D); var18.setColorRGBA_I(0, 0); var18.addVertexWithUV(this.right, this.bottom - var20, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV(this.left, this.bottom - var20, 0.0D, 0.0D, 0.0D); var18.draw(); var19 = this.getContentHeight() - (this.bottom - this.top - 4); if (var19 > 0) { var13 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight(); if (var13 < 32) { var13 = 32; } if (var13 > this.bottom - this.top - 8) { var13 = this.bottom - this.top - 8; } var14 = (int) this.scrollDistance * (this.bottom - this.top - var13) / var19 + this.top; if (var14 < this.top) { var14 = this.top; } var18.startDrawingQuads(); var18.setColorRGBA_I(0, 255); var18.addVertexWithUV(scrollBarXStart, this.bottom, 0.0D, 0.0D, 1.0D); var18.addVertexWithUV(scrollBarXEnd, this.bottom, 0.0D, 1.0D, 1.0D); var18.addVertexWithUV(scrollBarXEnd, this.top, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV(scrollBarXStart, this.top, 0.0D, 0.0D, 0.0D); var18.draw(); var18.startDrawingQuads(); var18.setColorRGBA_I(8421504, 255); var18.addVertexWithUV(scrollBarXStart, var14 + var13, 0.0D, 0.0D, 1.0D); var18.addVertexWithUV(scrollBarXEnd, var14 + var13, 0.0D, 1.0D, 1.0D); var18.addVertexWithUV(scrollBarXEnd, var14, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV(scrollBarXStart, var14, 0.0D, 0.0D, 0.0D); var18.draw(); var18.startDrawingQuads(); var18.setColorRGBA_I(12632256, 255); var18.addVertexWithUV(scrollBarXStart, var14 + var13 - 1, 0.0D, 0.0D, 1.0D); var18.addVertexWithUV(scrollBarXEnd - 1, var14 + var13 - 1, 0.0D, 1.0D, 1.0D); var18.addVertexWithUV(scrollBarXEnd - 1, var14, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV(scrollBarXStart, var14, 0.0D, 0.0D, 0.0D); var18.draw(); } this.func_27257_b(mouseX, mouseY); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_BLEND); }
From source file:com.oneofthesevenbillion.ziah.ZiahsClient.util.Utils.java
License:Open Source License
/** * Draws a solid color rectangle with the specified coordinates and color. Args: x1, y1, x2, y2, color *///from w w w .ja v a 2s . c o m public static void drawRect(int x1, int y1, int x2, int y2, int color, float zLevel) { int var5; if (x1 < x2) { var5 = x1; x1 = x2; x2 = var5; } if (y1 < y2) { var5 = y1; y1 = y2; y2 = var5; } float var10 = (color >> 24 & 255) / 255.0F; float var6 = (color >> 16 & 255) / 255.0F; float var7 = (color >> 8 & 255) / 255.0F; float var8 = (color & 255) / 255.0F; Tessellator var9 = Tessellator.instance; GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(var6, var7, var8, var10); var9.startDrawingQuads(); var9.addVertex(x1, y2, zLevel); var9.addVertex(x2, y2, zLevel); var9.addVertex(x2, y1, zLevel); var9.addVertex(x1, y1, zLevel); var9.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); }
From source file:com.oneofthesevenbillion.ziah.ZiahsClient.util.Utils.java
License:Open Source License
/** * Draws a rectangle with a vertical gradient between the specified colors. *//*from w w w .j a v a 2 s .c om*/ public static void drawGradientRect(int x, int y, int x1, int y2, int color1, int color2, float zLevel) { float var7 = (color1 >> 24 & 255) / 255.0F; float var8 = (color1 >> 16 & 255) / 255.0F; float var9 = (color1 >> 8 & 255) / 255.0F; float var10 = (color1 & 255) / 255.0F; float var11 = (color2 >> 24 & 255) / 255.0F; float var12 = (color2 >> 16 & 255) / 255.0F; float var13 = (color2 >> 8 & 255) / 255.0F; float var14 = (color2 & 255) / 255.0F; GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glShadeModel(GL11.GL_SMOOTH); Tessellator var15 = Tessellator.instance; var15.startDrawingQuads(); var15.setColorRGBA_F(var8, var9, var10, var7); var15.addVertex(x1, y, zLevel); var15.addVertex(x, y, zLevel); var15.setColorRGBA_F(var12, var13, var14, var11); var15.addVertex(x, y2, zLevel); var15.addVertex(x1, y2, zLevel); var15.draw(); GL11.glShadeModel(GL11.GL_FLAT); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); }
From source file:com.onkiup.minedroid.gui.betterfonts.StringCache.java
License:Open Source License
/** * Render a single-line string to the screen using the current OpenGL color. The (x,y) coordinates are of the uppet-left * corner of the string's bounding box, rather than the baseline position as is typical with fonts. This function will also * add the string to the cache so the next renderString() call with the same string is faster. * * @param str the string being rendered; it can contain color codes * @param startX the x coordinate to draw at * @param startY the y coordinate to draw at * @param initialColor the initial RGBA color to use when drawing the string; embedded color codes can override the RGB component * @param shadowFlag if true, color codes are replaces by a darker version used for drop shadows * @return the total advance (horizontal distance) of this string * @todo Add optional NumericShaper to replace ASCII digits with locale specific ones * @todo Add support for the "k" code which randomly replaces letters on each render (used only by splash screen) * @todo Pre-sort by texture to minimize binds; can store colors per glyph in string cache * @todo Optimize the underline/strikethrough drawing to draw a single line for each run *///from w w w . j a v a 2 s.c o m public Entry renderString(String str, int startX, int startY, int initialColor, boolean shadowFlag) { /* Check for invalid arguments */ if (str == null || str.isEmpty()) { return null; } View.resetBlending(); GlStateManager.enableTexture2D(); float scale = GuiManager.getDisplayScale(); float f = GuiManager.getScale().getScaleFactor(); /* Make sure the entire string is cached before rendering and return its glyph representation */ Entry entry = cacheString(str); /* Adjust the baseline of the string because the startY coordinate in Minecraft is for the top of the string */ startY += entry.getScaledBase(); /* Color currently selected by color code; reapplied to Tessellator instance after glBindTexture() */ int color = initialColor; /* Track which texture is currently bound to minimize the number of glBindTexture() and Tessellator.draw() calls needed */ int boundTextureName = 0; /* * This color change will have no effect on the actual text (since colors are included in the Tessellator vertex * array), however GuiEditSign of all things depends on having the current color set to white when it renders its * "Edit sign message:" text. Otherwise, the sign which is rendered underneath would look too dark. */ GL11.glColor3f(color >> 16 & 0xff, color >> 8 & 0xff, color & 0xff); /* * Enable GL_BLEND in case the font is drawn anti-aliased because Minecraft itself only enables blending for chat text * (so it can fade out), but not GUI text or signs. Minecraft uses multiple blend functions so it has to be specified here * as well for consistent blending. To reduce the overhead of OpenGL state changes and making native LWJGL calls, this * function doesn't try to save/restore the blending state. Hopefully everything else that depends on blending in Minecraft * will set its own state as needed. */ if (antiAliasEnabled) { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } /* Using the Tessellator to queue up data in a vertex array and then draw all at once should be faster than immediate mode */ Tessellator tessellator = Tessellator.getInstance(); tessellator.getWorldRenderer().startDrawingQuads(); tessellator.getWorldRenderer().setColorRGBA(color >> 16 & 0xff, color >> 8 & 0xff, color & 0xff, color >> 24 & 0xff); /* The currently active font syle is needed to select the proper ASCII digit style for fast replacement */ int fontStyle = Font.PLAIN; for (int glyphIndex = 0, colorIndex = 0; glyphIndex < entry.glyphs.length; glyphIndex++) { /* * If the original string had a color code at this glyph's position, then change the current GL color that gets added * to the vertex array. Note that only the RGB component of the color is replaced by a color code; the alpha component * of the original color passed into this function will remain. The while loop handles multiple consecutive color codes, * in which case only the last such color code takes effect. */ while (colorIndex < entry.colors.length && entry.glyphs[glyphIndex].stringIndex >= entry.colors[colorIndex].stringIndex) { color = applyColorCode(entry.colors[colorIndex].colorCode, initialColor, shadowFlag); fontStyle = entry.colors[colorIndex].fontStyle; colorIndex++; } /* Select the current glyph's texture information and horizontal layout position within this string */ Glyph glyph = entry.glyphs[glyphIndex]; GlyphCache.Entry texture = glyph.texture; int glyphX = glyph.x; /* * Replace ASCII digits in the string with their respective glyphs; strings differing by digits are only cached once. * If the new replacement glyph has a different width than the original placeholder glyph (e.g. the '1' glyph is often * narrower than other digits), re-center the new glyph over the placeholder's position to minimize the visual impact * of the width mismatch. */ char c = str.charAt(glyph.stringIndex); if (c >= '0' && c <= '9') { int oldWidth = texture.width; texture = digitGlyphs[fontStyle][c - '0'].texture; int newWidth = texture.width; glyphX += (oldWidth - newWidth) >> 1; } /* * Make sure the OpenGL texture storing this glyph's image is bound (if not already bound). All pending glyphs in the * Tessellator's vertex array must be drawn before switching textures, otherwise they would erroneously use the new * texture as well. */ if (boundTextureName != texture.textureName) { tessellator.draw(); tessellator.getWorldRenderer().startDrawingQuads(); tessellator.getWorldRenderer().setColorRGBA(color >> 16 & 0xff, color >> 8 & 0xff, color & 0xff, color >> 24 & 0xff); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.textureName); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); boundTextureName = texture.textureName; } /* The divide by 2.0F is needed to align with the scaled GUI coordinate system; startX/startY are already scaled */ float x1 = startX + (glyphX) / f; float x2 = startX + (glyphX + texture.width) / f; float y1 = startY + (glyph.y) / f; float y2 = startY + (glyph.y + texture.height) / f; tessellator.getWorldRenderer().addVertexWithUV(x1, y1, 0, texture.u1, texture.v1); tessellator.getWorldRenderer().addVertexWithUV(x1, y2, 0, texture.u1, texture.v2); tessellator.getWorldRenderer().addVertexWithUV(x2, y2, 0, texture.u2, texture.v2); tessellator.getWorldRenderer().addVertexWithUV(x2, y1, 0, texture.u2, texture.v1); } /* Draw any remaining glyphs in the Tessellator's vertex array (there should be at least one glyph pending) */ tessellator.draw(); /* Draw strikethrough and underlines if the string uses them anywhere */ if (entry.specialRender) { int renderStyle = 0; /* Use initial color passed to renderString(); disable texturing to draw solid color lines */ color = initialColor; GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.getWorldRenderer().startDrawingQuads(); tessellator.getWorldRenderer().setColorRGBA(color >> 16 & 0xff, color >> 8 & 0xff, color & 0xff, color >> 24 & 0xff); for (int glyphIndex = 0, colorIndex = 0; glyphIndex < entry.glyphs.length; glyphIndex++) { /* * If the original string had a color code at this glyph's position, then change the current GL color that gets added * to the vertex array. The while loop handles multiple consecutive color codes, in which case only the last such * color code takes effect. */ while (colorIndex < entry.colors.length && entry.glyphs[glyphIndex].stringIndex >= entry.colors[colorIndex].stringIndex) { color = applyColorCode(entry.colors[colorIndex].colorCode, initialColor, shadowFlag); renderStyle = entry.colors[colorIndex].renderStyle; colorIndex++; } /* Select the current glyph within this string for its layout position */ Glyph glyph = entry.glyphs[glyphIndex]; /* The strike/underlines are drawn beyond the glyph's width to include the extra space between glyphs */ int glyphSpace = glyph.advance - glyph.texture.width; /* Draw underline under glyph if the style is enabled */ if ((renderStyle & ColorCode.UNDERLINE) != 0) { /* The divide by 2.0F is needed to align with the scaled GUI coordinate system; startX/startY are already scaled */ float x1 = startX + (glyph.x - glyphSpace) / f; float x2 = startX + (glyph.x + glyph.advance) / f; float y1 = startY + (UNDERLINE_OFFSET) / f; float y2 = startY + (UNDERLINE_OFFSET + UNDERLINE_THICKNESS) / f; tessellator.getWorldRenderer().addVertex(x1, y1, 0); tessellator.getWorldRenderer().addVertex(x1, y2, 0); tessellator.getWorldRenderer().addVertex(x2, y2, 0); tessellator.getWorldRenderer().addVertex(x2, y1, 0); } /* Draw strikethrough in the middle of glyph if the style is enabled */ if ((renderStyle & ColorCode.STRIKETHROUGH) != 0) { /* The divide by 2.0F is needed to align with the scaled GUI coordinate system; startX/startY are already scaled */ float x1 = startX + (glyph.x - glyphSpace) / f; float x2 = startX + (glyph.x + glyph.advance) / f; float y1 = startY + (STRIKETHROUGH_OFFSET) / f; float y2 = startY + (STRIKETHROUGH_OFFSET + STRIKETHROUGH_THICKNESS) / f; tessellator.getWorldRenderer().addVertex(x1, y1, 0); tessellator.getWorldRenderer().addVertex(x1, y2, 0); tessellator.getWorldRenderer().addVertex(x2, y2, 0); tessellator.getWorldRenderer().addVertex(x2, y1, 0); } } /* Finish drawing the last strikethrough/underline segments */ tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } /* Return total horizontal advance (slightly wider than the bounding box, but close enough for centering strings) */ return entry; }
From source file:com.opengrave.og.base.RenderableBoneAnimated.java
License:Open Source License
@Override public void render(Matrix4f matrix, RenderStyle style) { // if (!visible) { // return;//from w w w . j ava 2 s.c o m // } GL11.glDisable(GL11.GL_CULL_FACE); // TODO Enable Face Culling, and be // absolutely sure that all tris are // facing the correct way dealWithChange(); int pID = Resources.loadShader("animmodel.vs", "animmodel.fs").getProgram(); GL20.glUseProgram(pID); int texture = GL20.glGetUniformLocation(pID, "texture"); int shadow = GL20.glGetUniformLocation(pID, "shadowMap"); GL20.glUniform1i(texture, 0); GL20.glUniform1i(shadow, 1); GL30.glBindVertexArray(vao_ID); GL20.glBindAttribLocation(pID, 0, "in_Position"); GL20.glBindAttribLocation(pID, 1, "in_Normal"); GL20.glBindAttribLocation(pID, 2, "in_TextureCoord"); GL20.glBindAttribLocation(pID, 3, "in_BoneID"); GL20.glBindAttribLocation(pID, 4, "in_BoneWeight"); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); GL20.glEnableVertexAttribArray(3); GL20.glEnableVertexAttribArray(4); if (matList != null && matList.valid()) { matList.bind(pID, GL13.GL_TEXTURE0); Util.loadMaterials(matList, pID); } setBonesUniform(pID); getContext().setMatrices(pID, matrix); getContext().bindShadowData(GL13.GL_TEXTURE2); getContext().bindLights(pID, GL13.GL_TEXTURE3); Util.setRenderStyle(pID, style); // GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertCount); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vbo_index_ID); GL11.glDrawElements(GL11.GL_TRIANGLES, indexCount, GL11.GL_UNSIGNED_INT, 0); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); getContext().unbindLights(); getContext().unbindShadowData(); if (matList != null && matList.valid()) { matList.unbind(); } GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); GL20.glDisableVertexAttribArray(3); GL20.glDisableVertexAttribArray(4); GL20.glUseProgram(0); GL30.glBindVertexArray(0); GL11.glEnable(GL11.GL_CULL_FACE); }
From source file:com.opengrave.og.base.RenderableLines.java
License:Open Source License
@Override public void render(Matrix4f matrix, RenderStyle style) { dealWithChange();// ww w . j av a 2 s .c o m if (!visible) { return; } if (vertCount == 0) { return; } GL11.glPointSize(3f); int pID = Resources.loadShader("lines.vs", "lines.fs").getProgram(); GL20.glUseProgram(pID); if (pID == 0) { return; } GL30.glBindVertexArray(vaoID); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); Util.checkErr(); getContext().setMatrices(pID, matrix); Util.checkErr(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDrawArrays(GL11.GL_LINES, 0, vertCount); GL11.glEnable(GL11.GL_DEPTH_TEST); Util.checkErr(); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(0); Util.checkErr(); GL30.glBindVertexArray(0); GL20.glUseProgram(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); Util.checkErr(); }
From source file:com.opengrave.og.base.RenderableParticles.java
License:Open Source License
@Override public void render(Matrix4f matrix, RenderStyle style) { dealWithChange();//from w w w . j a v a2 s.co m if (matList == null || !matList.valid()) { return; } GL30.glBindVertexArray(idVao); int pID = Resources.loadShader("particle.vs", "particle.fs").getProgram(); GL20.glUseProgram(pID); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); GL20.glBindAttribLocation(pID, 0, "in_Position"); GL20.glBindAttribLocation(pID, 1, "in_Colour"); GL20.glBindAttribLocation(pID, 2, "in_Scale"); Util.checkErr(); int texture = GL20.glGetUniformLocation(pID, "tex"); GL20.glUniform1i(texture, 0); int wSS = GL20.glGetUniformLocation(pID, "windowSizeScale"); GL20.glUniform1f(wSS, getContext().width / 1024f); getContext().setMatrices(pID, matrix); if (matList != null && matList.valid()) { matList.bind(pID, GL13.GL_TEXTURE0); } GL11.glEnable(GL20.GL_POINT_SPRITE); GL11.glEnable(GL20.GL_VERTEX_PROGRAM_POINT_SIZE); GL11.glDepthMask(false); GL11.glDrawArrays(GL11.GL_POINTS, 0, size); GL11.glDepthMask(true); GL11.glDisable(GL20.GL_POINT_SPRITE); GL11.glDisable(GL20.GL_VERTEX_PROGRAM_POINT_SIZE); if (matList != null && matList.valid()) { matList.unbind(); } Util.checkErr(); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); Util.checkErr(); GL20.glUseProgram(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); Util.checkErr(); }
From source file:com.opengrave.og.base.RenderableParticles.java
License:Open Source License
@Override public void renderForPicking(Matrix4f matrix, Pickable object) { dealWithChange();//from w w w . j a v a 2 s.c om GL30.glBindVertexArray(idVao); int pID = Resources.loadShader("particle.vs", "pickingmodel.fs").getProgram(); GL20.glUseProgram(pID); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(2); GL20.glBindAttribLocation(pID, 0, "in_Position"); GL20.glBindAttribLocation(pID, 2, "in_Scale"); Util.checkErr(); int wSS = GL20.glGetUniformLocation(pID, "windowSizeScale"); GL20.glUniform1f(wSS, MainThread.lastW / 1024f); getContext().setMatrices(pID, matrix); GL11.glEnable(GL20.GL_POINT_SPRITE); GL11.glEnable(GL20.GL_VERTEX_PROGRAM_POINT_SIZE); Picking.registerObject(pID, getContext(), object); GL11.glDrawArrays(GL11.GL_POINTS, 0, size); GL11.glDisable(GL20.GL_POINT_SPRITE); GL11.glDisable(GL20.GL_VERTEX_PROGRAM_POINT_SIZE); Util.checkErr(); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(2); Util.checkErr(); GL20.glUseProgram(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); Util.checkErr(); }
From source file:com.opengrave.og.base.RenderablePoints.java
License:Open Source License
@Override public void render(Matrix4f matrix, RenderStyle style) { Util.checkErr();/*from w w w. j a va2s . c om*/ dealWithChange(); if (!visible) { return; } if (vertCount == 0) { return; } Util.checkErr(); GL11.glDisable(GL11.GL_DEPTH_TEST); Util.checkErr(); GL11.glPointSize(3f); Util.checkErr(); int pID = Resources.loadShader("particle.vs", "particle.fs").getProgram(); Util.checkErr(); GL20.glUseProgram(pID); Util.checkErr(); if (pID == 0) { return; } Util.checkErr(); GL30.glBindVertexArray(vaoID); Util.checkErr(); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); Util.checkErr(); int wSS = GL20.glGetUniformLocation(pID, "windowSizeScale"); GL20.glUniform1f(wSS, MainThread.lastW / 1024f); getContext().setMatrices(pID, matrix); Util.checkErr(); if (tex != null) { tex.bind(GL13.GL_TEXTURE0); } GL11.glEnable(GL20.GL_POINT_SPRITE); GL11.glEnable(GL20.GL_VERTEX_PROGRAM_POINT_SIZE); GL11.glDrawArrays(GL11.GL_POINTS, 0, vertCount); GL11.glDisable(GL20.GL_POINT_SPRITE); GL11.glDisable(GL20.GL_VERTEX_PROGRAM_POINT_SIZE); if (tex != null) { tex.unbind(); } Util.checkErr(); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); Util.checkErr(); GL30.glBindVertexArray(0); GL20.glUseProgram(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); Util.checkErr(); GL11.glEnable(GL11.GL_DEPTH_TEST); }
From source file:com.opengrave.og.engine.Node.java
License:Open Source License
public void renderSemiTransparent(Matrix4f matrix) { Util.checkErr();// w w w.ja v a2 s . co m doRenderSemiTransparent(matrix); if (MainThread.main.input.getLastHovered() != null) { Pickable lr = MainThread.main.input.getLastHovered().getRenderable(); if (this instanceof BaseObject && lr instanceof BaseObject) { if (lr == this) { BaseObject notThis = (BaseObject) this; if (notThis.drawOutline) { // Setup for outline draw GL11.glDepthFunc(GL11.GL_LESS); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_LINE); GL11.glLineWidth(10f); GL11.glCullFace(GL11.GL_FRONT); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // Draw RenderStyle rs = notThis.getRenderStyle(); notThis.setRenderStyle(RenderStyle.HALO); doRender(matrix); notThis.setRenderStyle(rs); // Return to correct state GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_FILL); GL11.glLineWidth(1f); GL11.glCullFace(GL11.GL_BACK); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_BLEND); } } } } Util.checkErr(); for (Node node : children) { Matrix4f childMatrix = matrix.mult(node.getMatrix(), null); node.renderSemiTransparent(childMatrix); Util.checkErr(); } }