Java Code Examples for org.lwjgl.opengl.GL11#glGetInteger()
The following examples show how to use
org.lwjgl.opengl.GL11#glGetInteger() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlurPane.java From LWJGUI with MIT License | 6 votes |
private void blit(Context context) { // Source float ratio = window.getPixelRatio(); int srcfbo = GL11.glGetInteger(GL30.GL_FRAMEBUFFER_BINDING); GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, srcfbo); // Destination GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, bufferTemp.getFboId()); int destwid = bufferTemp.getWidth(); int desthei = bufferTemp.getHeight(); int sx1 = (int)(getX()*ratio); int sy1 = (int)(getY()*ratio); int sx2 = sx1 + (int) (destwid*ratio); int sy2 = sy1 + (int) (desthei*ratio); // Blit GL30.glBlitFramebuffer( sx1,sy1,sx2,sy2, 0,0, destwid,desthei, GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST); // Rebind source GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER,srcfbo); }
Example 2
Source File: Rendertarget.java From opsu-dance with GNU General Public License v3.0 | 6 votes |
/** * Creates a Rendertarget with a Texture that it renders the color buffer in * and a renderbuffer that it renders the depth to. * @param width the width * @param height the height * @return the newly created Rendertarget instance */ public static Rendertarget createRTTFramebuffer(int width, int height) { int old_framebuffer = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT); int old_texture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); Rendertarget buffer = new Rendertarget(width,height); buffer.bind(); int fboTexture = buffer.textureID; GL11.glBindTexture(GL11.GL_TEXTURE_2D, fboTexture); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, 4, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_INT, (ByteBuffer) null); 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); EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, buffer.depthBufferID); EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, GL11.GL_DEPTH_COMPONENT, width, height); EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, buffer.depthBufferID); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, fboTexture, 0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, old_texture); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, old_framebuffer); return buffer; }
Example 3
Source File: RenderState.java From OpenPeripheral-Addons with MIT License | 6 votes |
public void readState() { this.lighting = GL11.glIsEnabled(GL11.GL_LIGHTING); this.alphaTest = GL11.glIsEnabled(GL11.GL_ALPHA_TEST); this.texture = GL11.glIsEnabled(GL11.GL_TEXTURE_2D); this.depthTest = GL11.glIsEnabled(GL11.GL_DEPTH_TEST); this.blend = GL11.glIsEnabled(GL11.GL_BLEND); this.blendSrc = GL11.glGetInteger(GL11.GL_BLEND_SRC); this.blendDst = GL11.glGetInteger(GL11.GL_BLEND_DST); this.cullFace = GL11.glIsEnabled(GL11.GL_CULL_FACE); this.lineWidth = GL11.glGetFloat(GL11.GL_LINE_WIDTH); this.pointSize = GL11.glGetFloat(GL11.GL_POINT_SIZE); GL11.glGetFloat(GL11.GL_CURRENT_COLOR, colors); float r = colors.get(); float g = colors.get(); float b = colors.get(); float a = colors.get(); this.color = (((int)(255 * r) & 0xFF) << 24) + (((int)(255 * g) & 0xFF) << 16) + (((int)(255 * b) & 0xFF) << 8) + (((int)(255 * a) & 0xFF) << 0); colors.clear(); }
Example 4
Source File: FEResources.java From FEMultiplayer with GNU General Public License v3.0 | 6 votes |
public static void loadResources() { try { //Load bitmap fonts loadBitmapFonts(); // Textures textures.put("whoops", new AnimationData("res/whoops.png")); loadTextures(); //load audio audio.put("miss", AudioLoader.getAudio("WAV", ResourceLoader.getResourceAsStream("res/sfx/miss.wav"))); } catch (IOException e) { int max = GL11.glGetInteger(GL11.GL_MAX_TEXTURE_SIZE); System.out.println(max); e.printStackTrace(); } System.gc(); }
Example 5
Source File: CurveRenderState.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Backup the current state of the relevant OpenGL state and change it to * what's needed to draw the curve. */ private RenderState saveRenderState() { 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.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, GL12.GL_CLAMP_TO_EDGE); GL20.glUseProgram(0); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); return state; }
Example 6
Source File: LegacyCurveRenderState.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Backup the current state of the relevant OpenGL state and change it to * what's needed to draw the curve. */ private RenderState saveRenderState() { 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.glDisable(GL11.GL_BLEND); 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; }
Example 7
Source File: CurveRenderState.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
/** * Backup the current state of the relevant OpenGL state and change it to * what's needed to draw the curve. */ private RenderState saveRenderState() { 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.glDisable(GL11.GL_BLEND); 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; }
Example 8
Source File: BlenderKey.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * @return maximum texture size (width/height) */ public int getMaxTextureSize() { if (maxTextureSize <= 0) { try { maxTextureSize = GL11.glGetInteger(GL11.GL_MAX_TEXTURE_SIZE); } catch (Exception e) { // this is in case this method was called before openGL initialization return 8192; } } return maxTextureSize; }
Example 9
Source File: GuiHelper.java From NotEnoughItems with MIT License | 5 votes |
public static void restoreMatrixStack() { if (modelviewDepth >= 0) { for (int i = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH); i > modelviewDepth; i--) { GlStateManager.popMatrix(); } } }
Example 10
Source File: LegacyCurveRenderState.java From opsu with GNU General Public License v3.0 | 4 votes |
/** * Draw a curve to the screen that's tinted with `color`. The first time * this is called this caches the image result of the curve and on subsequent * runs it just draws the cached copy to the screen. * @param color tint of the curve * @param borderColor the curve border color * @param from index to draw from * @param to index to draw to (exclusive) */ public void draw(Color color, Color borderColor, int from, int to) { float alpha = color.a; if (fbo == null) initFBO(); if (lastPointDrawn != to || firstPointDrawn != from) { int oldFb = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT); int oldTex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); //glGetInteger requires a buffer of size 16, even though just 4 //values are returned in this specific case IntBuffer oldViewport = BufferUtils.createIntBuffer(16); GL11.glGetInteger(GL11.GL_VIEWPORT, oldViewport); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, fbo.getID()); GL11.glViewport(0, 0, fbo.width, fbo.height); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); this.renderCurve(color, borderColor, from, to, firstPointDrawn != from); lastPointDrawn = to; firstPointDrawn = from; color.a = 1f; GL11.glBindTexture(GL11.GL_TEXTURE_2D, oldTex); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, oldFb); GL11.glViewport(oldViewport.get(0), oldViewport.get(1), oldViewport.get(2), oldViewport.get(3)); } // draw a fullscreen quad with the texture that contains the curve GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_1D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.getTextureID()); GL11.glBegin(GL11.GL_QUADS); GL11.glColor4f(1.0f, 1.0f, 1.0f, alpha); GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex2i(fbo.width, 0); GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex2i(0, 0); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex2i(0, fbo.height); GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex2i(fbo.width, fbo.height); GL11.glEnd(); }
Example 11
Source File: ProjectionHelper.java From OpenModsLib with MIT License | 4 votes |
public void updateMatrices() { GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview); GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection); GL11.glGetInteger(GL11.GL_VIEWPORT, viewport); }
Example 12
Source File: Render.java From mapwriter with MIT License | 4 votes |
public static int getMaxTextureSize() { return GL11.glGetInteger(GL11.GL_MAX_TEXTURE_SIZE); }
Example 13
Source File: GuiContainerManager.java From NotEnoughItems with MIT License | 4 votes |
public static boolean checkMatrixStack() { return modelviewDepth < 0 || GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH) == modelviewDepth; }
Example 14
Source File: GuiContainerManager.java From NotEnoughItems with MIT License | 4 votes |
public static void enableMatrixStackLogging() { modelviewDepth = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH); }
Example 15
Source File: GLUtils.java From tribaltrouble with GNU General Public License v2.0 | 4 votes |
public final static int getGLInteger(int gl_enum) { GL11.glGetInteger(gl_enum, int_buf); return int_buf.get(0); }
Example 16
Source File: GuiHelper.java From NotEnoughItems with MIT License | 4 votes |
public static void enableMatrixStackLogging() { modelviewDepth = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH); }
Example 17
Source File: StructureManager.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
/** * Will not draw the structure if it is not already baked. Resource reloading will re-bake if required. * * @param alpha The transparency of the rendered structure. * @param location The ResourceLocation of the structure to look up. */ @SideOnly(Side.CLIENT) public void draw(ResourceLocation location, float alpha) { HashMap<Integer, int[]> cache = vboCache.get(location); if (cache == null || cache.isEmpty()) { bake(location); return; } GlStateManager.pushMatrix(); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.enablePolygonOffset(); GlStateManager.doPolygonOffset(1f, -0.05f); // GlStateManager.disableDepth(); int alphaFunc = GL11.glGetInteger(GL11.GL_ALPHA_TEST_FUNC); float alphaRef = GL11.glGetFloat(GL11.GL_ALPHA_TEST_REF); GlStateManager.alphaFunc(GL11.GL_ALWAYS, 1); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Tessellator tes = Tessellator.getInstance(); BufferBuilder buffer = tes.getBuffer(); for (int layerID : cache.keySet()) { buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); buffer.addVertexData(cache.get(layerID)); for (int i = 0; i < buffer.getVertexCount(); i++) { buffer.putColorRGBA(buffer.getColorIndex(i), 255, 255, 255, (int) (alpha * 255)); } tes.draw(); } GlStateManager.alphaFunc(alphaFunc, alphaRef); // GlStateManager.enableDepth(); GlStateManager.disablePolygonOffset(); GlStateManager.color(1F, 1F, 1F, 1F); GlStateManager.popMatrix(); }
Example 18
Source File: Render.java From mapwriter with MIT License | 4 votes |
public static int getBoundTextureId() { return GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); }
Example 19
Source File: ImmediateModeOGLRenderer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * @see org.newdawn.slick.opengl.renderer.SGL#glGetInteger(int, java.nio.IntBuffer) */ public void glGetInteger(int id, IntBuffer ret) { GL11.glGetInteger(id, ret); }
Example 20
Source File: WorldSceneRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
private BlockPos handleMouseHit(Vec2f mousePosition) { //read depth of pixel under mouse GL11.glReadPixels((int) mousePosition.x, (int) mousePosition.y, 1, 1, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, PIXEL_DEPTH_BUFFER); //rewind buffer after write by glReadPixels PIXEL_DEPTH_BUFFER.rewind(); //retrieve depth from buffer (0.0-1.0f) float pixelDepth = PIXEL_DEPTH_BUFFER.get(); //rewind buffer after read PIXEL_DEPTH_BUFFER.rewind(); //read current rendering parameters GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, MODELVIEW_MATRIX_BUFFER); GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, PROJECTION_MATRIX_BUFFER); GL11.glGetInteger(GL11.GL_VIEWPORT, VIEWPORT_BUFFER); //rewind buffers after write by OpenGL glGet calls MODELVIEW_MATRIX_BUFFER.rewind(); PROJECTION_MATRIX_BUFFER.rewind(); VIEWPORT_BUFFER.rewind(); //call gluUnProject with retrieved parameters GLU.gluUnProject(mousePosition.x, mousePosition.y, pixelDepth, MODELVIEW_MATRIX_BUFFER, PROJECTION_MATRIX_BUFFER, VIEWPORT_BUFFER, OBJECT_POS_BUFFER); //rewind buffers after read by gluUnProject VIEWPORT_BUFFER.rewind(); PROJECTION_MATRIX_BUFFER.rewind(); MODELVIEW_MATRIX_BUFFER.rewind(); //rewind buffer after write by gluUnProject OBJECT_POS_BUFFER.rewind(); //obtain absolute position in world float posX = OBJECT_POS_BUFFER.get(); float posY = OBJECT_POS_BUFFER.get(); float posZ = OBJECT_POS_BUFFER.get(); //rewind buffer after read OBJECT_POS_BUFFER.rewind(); //System.out.println(String.format("%f %f %f %f", pixelDepth, posX, posY, posZ)); //if we didn't hit anything, just return null //also return null if hit is too far from us if (posY < -100.0f) { return null; //stop execution at that point } BlockPos pos = new BlockPos(posX, posY, posZ); if (world.isAirBlock(pos)) { //if block is air, then search for nearest adjacent block //this can happen under extreme rotation angles for (EnumFacing offset : EnumFacing.VALUES) { BlockPos relative = pos.offset(offset); if (world.isAirBlock(relative)) continue; pos = relative; break; } } if (world.isAirBlock(pos)) { //if we didn't found any other block, return null return null; } return pos; }