List of usage examples for org.lwjgl.opengl GL11 glReadBuffer
public static void glReadBuffer(@NativeType("GLenum") int src)
From source file:com.opengrave.og.light.Depth2DFramebuffer.java
License:Open Source License
public Depth2DFramebuffer(int size) { framebufferSize = size;//from w ww .ja va 2 s . c o m framebuffer = GL30.glGenFramebuffers(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer); shadowMap = new Texture2DShadowMap(framebufferSize); shadowMap.bindToFrameBuffer(); // GL11.glDrawBuffer(GL30.GL_COLOR_ATTACHMENT0); GL11.glDrawBuffer(GL11.GL_NONE); Util.checkErr(); GL11.glReadBuffer(GL11.GL_NONE); int i = GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER); if (i != GL30.GL_FRAMEBUFFER_COMPLETE) { throw new RuntimeException("Framebuffer creation failed with code: " + i); } GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); // TESTING STUFF count = 2; FloatBuffer pos = BufferUtils.createFloatBuffer(3 * 3 * count); FloatBuffer tex = BufferUtils.createFloatBuffer(2 * 3 * count); pos.put(0.75f).put(0.75f).put(0f); pos.put(0.75f).put(0.25f).put(0f); pos.put(0.25f).put(0.75f).put(0f); pos.put(0.25f).put(0.25f).put(0f); pos.put(0.75f).put(0.25f).put(0f); pos.put(0.25f).put(0.75f).put(0f); pos.flip(); tex.put(1f).put(1f); tex.put(1f).put(0f); tex.put(0f).put(1f); tex.put(0f).put(0f); tex.put(1f).put(0f); tex.put(0f).put(1f); tex.flip(); vao_ID = GL30.glGenVertexArrays(); GL30.glBindVertexArray(vao_ID); int vbo_pos_ID = GL15.glGenBuffers(); int vbo_tex_ID = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo_pos_ID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, pos, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo_tex_ID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, tex, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, 0, 0); }
From source file:com.opengrave.og.light.DepthCubeFramebuffer.java
License:Open Source License
public DepthCubeFramebuffer(int size) { framebufferSize = size;//from w w w. j av a2s . co m framebuffer = GL30.glGenFramebuffers(); // System.out.println("Creating Pointlight Framebuffer : " + // framebuffer); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer); shadowMap = new TextureCubeShadowMap(framebufferSize); // shadowMap.bindToFrameBuffer(); shadowMap.bindToFrameBuffer(0); // GL11.glDrawBuffer(GL30.GL_COLOR_ATTACHMENT0); GL11.glDrawBuffer(GL11.GL_NONE); Util.checkErr(); GL11.glReadBuffer(GL11.GL_NONE); int i = GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER); if (i != GL30.GL_FRAMEBUFFER_COMPLETE) { throw new RuntimeException("Framebuffer creation failed with code: " + i); } GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); Util.checkErr(); }
From source file:com.samrj.devil.gl.FBO.java
License:Open Source License
/** * Specifies which color buffer to read from for this frame buffer. * /*from w w w. j a v a2s .c o m*/ * @param buffer The buffer to read from. */ public void readBuffer(int buffer) { ensureBound(); GL11.glReadBuffer(buffer); }
From source file:eu.over9000.veya.rendering.Shadow.java
License:Open Source License
public void init() { depthMap = GL11.glGenTextures();//from w w w. ja v a2 s.c om GL11.glBindTexture(GL11.GL_TEXTURE_2D, depthMap); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_DEPTH_COMPONENT, SHADOW_WIDTH, SHADOW_HEIGHT, 0, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (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); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL13.GL_CLAMP_TO_BORDER); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL13.GL_CLAMP_TO_BORDER); shadowFBO = GL30.glGenFramebuffers(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, shadowFBO); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL11.GL_TEXTURE_2D, depthMap, 0); GL11.glDrawBuffer(GL11.GL_NONE); GL11.glReadBuffer(GL11.GL_NONE); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); }
From source file:io.root.gfx.glutils.GL.java
License:Apache License
public static void glReadBuffer(int mode) { GL11.glReadBuffer(mode); }
From source file:itdelatrisu.opsu.Utils.java
License:Open Source License
/** * Takes a screenshot./*from w ww . j av a 2s . com*/ * @author http://wiki.lwjgl.org/index.php?title=Taking_Screen_Shots */ public static void takeScreenShot() { // create the screenshot directory File dir = Options.getScreenshotDir(); if (!dir.isDirectory()) { if (!dir.mkdir()) { ErrorHandler.error("Failed to create screenshot directory.", null, false); return; } } // create file name SimpleDateFormat date = new SimpleDateFormat("yyyyMMdd_HHmmss"); final File file = new File(dir, String.format("screenshot_%s.%s", date.format(new Date()), Options.getScreenshotFormat())); SoundController.playSound(SoundEffect.SHUTTER); // copy the screen to file final int width = Display.getWidth(); final int height = Display.getHeight(); final int bpp = 3; // assuming a 32-bit display with a byte each for red, green, blue, and alpha final ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * bpp); GL11.glReadBuffer(GL11.GL_FRONT); GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); GL11.glReadPixels(0, 0, width, height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, buffer); new Thread() { @Override public void run() { try { BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int i = (x + (width * y)) * bpp; int r = buffer.get(i) & 0xFF; int g = buffer.get(i + 1) & 0xFF; int b = buffer.get(i + 2) & 0xFF; image.setRGB(x, height - (y + 1), (0xFF << 24) | (r << 16) | (g << 8) | b); } } ImageIO.write(image, Options.getScreenshotFormat(), file); } catch (Exception e) { ErrorHandler.error("Failed to take a screenshot.", e, true); } } }.start(); }
From source file:jeiexporter.render.RenderHelper.java
public static BufferedImage readPixels(int width, int height) { /*/* w w w .j a v a 2s .c om*/ * Make sure we're reading from the back buffer, not the front buffer. * The front buffer is what is currently on-screen, and is useful for * screenshots. */ GL11.glReadBuffer(GL11.GL_BACK); // Allocate a native data array to fit our pixels ByteBuffer buf = BufferUtils.createByteBuffer(width * height * 4); // And finally read the pixel data from the GPU... GL11.glReadPixels(0, Minecraft.getMinecraft().displayHeight - height, width, height, GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE, buf); // ...and turn it into a Java object we can do things to. BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); int[] pixels = new int[width * height]; buf.asIntBuffer().get(pixels); img.setRGB(0, 0, width, height, pixels, 0, width); return img; }
From source file:mss.View.java
License:Open Source License
private void saveScreenshot() { final File f = new File(View.class.getProtectionDomain().getCodeSource().getLocation().getPath()); GL11.glReadBuffer(GL11.GL_FRONT); int width = Display.getWidth(); int height = Display.getHeight(); ByteBuffer byteBuffer = BufferUtils.createByteBuffer(width * height * 4); GL11.glReadPixels(0, 0, width, height, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, byteBuffer); ScreenshotSaver saver = new ScreenshotSaver(byteBuffer, f.getParent(), width, height); saver.start();//ww w .j av a 2 s .c o m }
From source file:mwisbest.openbase.opengl.UtilsGL.java
License:Open Source License
public static void takeScreenshot(String filename) { GL11.glReadBuffer(GL11.GL_FRONT); int width = Display.getDisplayMode().getWidth(); int height = Display.getDisplayMode().getHeight(); int bpp = 4;/*from w w w. ja v a 2s.com*/ ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * bpp); GL11.glReadPixels(0, 0, width, height, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer); File file = new File(filename); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int i = (x + width * y) * bpp; int r = buffer.get(i) & 0xFF; int g = buffer.get(i + 1) & 0xFF; int b = buffer.get(i + 2) & 0xFF; image.setRGB(x, height - (y + 1), 0xFF << 24 | r << 16 | g << 8 | b); } } try { ImageIO.write(image, "PNG", file); } catch (IOException e) { e.printStackTrace(); } }
From source file:net.smert.frameworkgl.opengl.helpers.FrameBufferObjectHelper.java
License:Apache License
public void disableBuffers() { GL11.glDrawBuffer(GL11.GL_NONE); GL11.glReadBuffer(GL11.GL_NONE); }