Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false);
- GLCapabilities caps = new GLCapabilities(GLProfile
- .get(GLProfile.GL2ES2));
- //caps.setAlphaBits(1);
- caps.setRedBits(8);
- caps.setGreenBits(8);
- caps.setBlueBits(8);
- caps.setOnscreen(false);
- caps.setPBuffer(true);
- Display display = NewtFactory.createDisplay(null);
- Screen screen = NewtFactory.createScreen(display, 0);
- Window window = NewtFactory.createWindow(screen, caps);
- GLWindow glWindow = GLWindow.create(window);
- glWindow.setSize(256, 256);
- glWindow.setVisible(true);
- glWindow.addGLEventListener(new GLEventListener() {
- @Override
- public void reshape(GLAutoDrawable drawable, int x, int y, int width,
- int height) {
- }
- @Override
- public void init(GLAutoDrawable drawable) {
- GL2ES2 gl = drawable.getGL().getGL2ES2();
- gl.glClearColor(0, 1, 0, 1);
- }
- @Override
- public void dispose(GLAutoDrawable drawable) {
- }
- @Override
- public void display(GLAutoDrawable drawable) {
- GL gl = drawable.getGL();
- gl.glClear(GL.GL_COLOR_BUFFER_BIT);
- gl.glFinish();
- if(screenshot.readPixels(gl, false)) {
- screenshot.write(new File("test.png"));
- }
- }
- });
- glWindow.display();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement