JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
ReadBufferBase.java
Go to the documentation of this file.
1/**
2 * Copyright 2010 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.opengl.test.junit.jogl.offscreen;
30
31import com.jogamp.opengl.*;
32
33import com.jogamp.opengl.util.GLReadBufferUtil;
34
35public class ReadBufferBase implements GLEventListener {
36 public boolean glDebug = false ;
37 public boolean glTrace = false ;
38
40
41 GLReadBufferUtil readBufferUtil;
42
43 public ReadBufferBase (final GLDrawable externalRead, final boolean write2Texture) {
44 this.externalRead = externalRead ;
45 this.readBufferUtil = new GLReadBufferUtil(false, write2Texture);
46 }
47
48 public void init(final GLAutoDrawable drawable) {
49 GL _gl = drawable.getGL();
50
51 _gl.glGetError(); // flush error ..
52
53 if(glDebug) {
54 try {
55 _gl = _gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Debug", null, _gl, null) );
56 } catch (final Exception e) {
57 throw new RuntimeException("can not set debug pipeline", e);
58 }
59 }
60
61 if(glTrace) {
62 try {
63 _gl = _gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Trace", null, _gl, new Object[] { System.err } ) );
64 } catch (final Exception e) {
65 throw new RuntimeException("can not set trace pipeline", e);
66 }
67 }
68
69 System.out.println(_gl);
70
72 if(_gl.isGL2GL3()) {
74 }
75 System.out.println("---------------------------");
76 System.out.println(_gl.getContext());
77 System.out.println("---------------------------");
78 }
79
80 public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
81 }
82
83 public void dispose(final GLAutoDrawable drawable) {
84 readBufferUtil.dispose(drawable.getGL());
85 }
86
87 public void display(final GLAutoDrawable drawable) {
88 readBufferUtil.readPixels(drawable.getGL(), false);
89 }
90
91}
92
abstract GL setGL(GL gl)
Sets the GL pipeline object for this GLContext.
abstract GLDrawable setGLReadDrawable(GLDrawable read)
Set the read-Drawable for read framebuffer operations.
Factory for pipelining GL instances.
static final GL create(final String pipelineClazzBaseName, final Class<?> reqInterface, final GL downstream, final Object[] additionalArgs)
Creates a pipelined GL instance using the given downstream downstream and optional arguments addition...
void init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
ReadBufferBase(final GLDrawable externalRead, final boolean write2Texture)
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height)
Called by the drawable during the first repaint after the component has been resized.
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
Utility to read out the current FB to TextureData, optionally writing the data back to a texture obje...
boolean readPixels(final GL gl, final boolean mustFlipVertically)
Read the drawable's pixels to TextureData and Texture, if requested at construction.
void glReadBuffer(int mode)
Entry point to C language function: void {@native glReadBuffer}(GLenum mode) Part of GL_ES_VERSION...
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
boolean isGL2GL3()
Indicates whether this GL object conforms to a GL2GL3 compatible profile.
GLContext getContext()
Returns the GLContext associated which this GL object.
GL2GL3 getGL2GL3()
Casts this object to the GL2GL3 interface.
An abstraction for an OpenGL rendering target.
Definition: GLDrawable.java:51
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
int glGetError()
Entry point to C language function: GLenum {@native glGetError}() Part of GL_ES_VERSION_2_0,...
static final int GL_FRONT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_FRONT" with expressio...
Definition: GL.java:597