Package panamagl.offscreen
Class AOffscreenRenderer
java.lang.Object
panamagl.offscreen.AOffscreenRenderer
- All Implemented Interfaces:
OffscreenRenderer
Base class for offscreen rendering, handling most of the coordination between
a canvas and the GPU.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected GLContextprotected booleanprotected Stringprotected ExecutorServiceOnly used to export debug images if a debug file is givenprotected PanamaGLFactoryprotected FBOprotected GLprotected static final intprotected static final intprotected booleanprotected FBOReaderprotected ThreadRedirect -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddestroyContext(GLCanvas drawable, GLEventListener listener) getFBO()getGL()protected RunnablegetTask_destroyContext(GLCanvas drawable, GLEventListener listener) protected RunnablegetTask_initContext(GLCanvas drawable, GLEventListener listener) protected RunnablegetTask_renderGLToImage(GLCanvas drawable, GLEventListener listener) protected RunnablegetTask_renderGLToImage(GLCanvas drawable, GLEventListener listener, int width, int height) protected voidinitContext(GLCanvas drawable, GLEventListener listener) In general, you should initialize any resources that are needed for rendering or other functionality in the JPanel after the JPanel has been added to the Swing hierarchy, but before it is made visible.booleanIndicates if the renderer has already been initialized.voidonDestroy(GLCanvas drawable, GLEventListener listener) voidonDisplay(GLCanvas drawable, GLEventListener listener) voidonInit(GLCanvas drawable, GLEventListener listener) voidonResize(GLCanvas drawable, GLEventListener listener, int x, int y, int width, int height) protected voidreadImageAndPaintInCanvas(GLCanvas canvas) protected voidrenderGLToImage(GLCanvas canvas, GLEventListener listener) This method will render in FBO and then query a component repaint to ensure it is repainted ONCE the image is available.protected voidrenderGLToImage(GLCanvas canvas, GLEventListener listener, int width, int height) This method will resize the FBO and then update the componentvoidsetDebugFile(String debugFile) If not null, the input pattern will be used to save offscreen generated image to disk.voidvoidsetThreadRedirect(ThreadRedirect threadRedirect)
-
Field Details
-
INIT_FBO_WIDTH
protected static final int INIT_FBO_WIDTH- See Also:
-
INIT_FBO_HEIGHT
protected static final int INIT_FBO_HEIGHT- See Also:
-
debug
protected boolean debug -
factory
-
gl
-
context
-
fbo
-
reader
-
threadRedirect
-
initialized
protected boolean initialized -
debugFile
-
exec
Only used to export debug images if a debug file is given
-
-
Constructor Details
-
AOffscreenRenderer
-
-
Method Details
-
onInit
- Specified by:
onInitin interfaceOffscreenRenderer
-
onDisplay
- Specified by:
onDisplayin interfaceOffscreenRenderer
-
onResize
public void onResize(GLCanvas drawable, GLEventListener listener, int x, int y, int width, int height) - Specified by:
onResizein interfaceOffscreenRenderer
-
onDestroy
- Specified by:
onDestroyin interfaceOffscreenRenderer
-
initContext
In general, you should initialize any resources that are needed for rendering or other functionality in the JPanel after the JPanel has been added to the Swing hierarchy, but before it is made visible. This ensures that the JPanel has a valid parent container and can be properly displayed on the screen. On macOS, this should be performed in the main thread- By using -XstartOnMainThread (but warning with Swing and JavaFX that may be hanging)
- By having the context initialization performed by the AWT thread (through the GLPanel+GLEventListener)
-
destroyContext
-
renderGLToImage
This method will resize the FBO and then update the component -
renderGLToImage
This method will render in FBO and then query a component repaint to ensure it is repainted ONCE the image is available. This method can potentially execute in a separate thread (namely the main macOS thread). -
readImageAndPaintInCanvas
-
getFBO
- Specified by:
getFBOin interfaceOffscreenRenderer
-
setFBO
- Specified by:
setFBOin interfaceOffscreenRenderer
-
getDebugFile
- Specified by:
getDebugFilein interfaceOffscreenRenderer
-
isInitialized
public boolean isInitialized()Indicates if the renderer has already been initialized.- Specified by:
isInitializedin interfaceOffscreenRenderer
-
getGL
- Specified by:
getGLin interfaceOffscreenRenderer
-
getContext
- Specified by:
getContextin interfaceOffscreenRenderer
-
getThreadRedirect
- Specified by:
getThreadRedirectin interfaceOffscreenRenderer
-
setThreadRedirect
- Specified by:
setThreadRedirectin interfaceOffscreenRenderer
-
setDebugFile
If not null, the input pattern will be used to save offscreen generated image to disk. Example setDebugFile("target/glpanel"); Creates images in target/ folder under anme glpanel-1.png, glpanel-2.png, etc.- Specified by:
setDebugFilein interfaceOffscreenRenderer
-
getTask_renderGLToImage
protected Runnable getTask_renderGLToImage(GLCanvas drawable, GLEventListener listener, int width, int height) -
getTask_renderGLToImage
-
getTask_initContext
-
getTask_destroyContext
-