JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
GLEventListener.java
Go to the documentation of this file.
1/**
2 * Copyright (c) 2010-2023 JogAmp Community. All rights reserved.
3 * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * - Redistribution of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistribution in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * Neither the name of Sun Microsystems, Inc. or the names of
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * This software is provided "AS IS," without a warranty of any kind. ALL
21 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
22 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
23 * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
24 * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
25 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
26 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
27 * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
28 * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
29 * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
30 * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
31 * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 *
33 * You acknowledge that this software is not designed or intended for use
34 * in the design, construction, operation or maintenance of any nuclear
35 * facility.
36 */
37
38package com.jogamp.opengl;
39
40import java.util.EventListener;
41
42/** Declares events which client code can use to manage OpenGL
43 rendering into a {@link GLAutoDrawable}. At the time any of these
44 methods is called, the drawable has made its associated OpenGL
45 context current, so it is valid to make OpenGL calls. */
46
47public interface GLEventListener extends EventListener {
48 /** Called by the drawable immediately after the OpenGL context is
49 initialized. Can be used to perform one-time OpenGL
50 initialization per GLContext, such as setup of lights and display lists.<p>
51
52 Note that this method may be called more than once if the underlying
53 OpenGL context for the GLAutoDrawable is destroyed and
54 recreated, for example if a GLCanvas is removed from the widget
55 hierarchy and later added again.
56 */
57 public void init(GLAutoDrawable drawable);
58
59 /** Notifies the listener to perform the release of all OpenGL
60 resources per GLContext, such as memory buffers and GLSL programs.<P>
61
62 Called by the drawable before the OpenGL context is
63 destroyed by an external event, like a reconfiguration of the
64 {@link GLAutoDrawable} closing an attached window,
65 but also manually by calling {@link GLAutoDrawable#destroy destroy}.<P>
66
67 Note that this event does not imply the end of life of the application.
68 It could be produced with a followup call to {@link #init(GLAutoDrawable)}
69 in case the GLContext has been recreated,
70 e.g. due to a pixel configuration change in a multihead environment.
71 */
72 public void dispose(GLAutoDrawable drawable);
73
74 /** Called by the drawable to initiate OpenGL rendering by the
75 client. After all GLEventListeners have been notified of a
76 display event, the drawable will swap its buffers if {@link
77 GLAutoDrawable#setAutoSwapBufferMode setAutoSwapBufferMode} is
78 enabled. */
79 public void display(GLAutoDrawable drawable);
80
81 /**
82 * Called by the drawable during the first repaint after the
83 * component has been resized.
84 * <p>
85 * The client can update it's viewport associated data
86 * and view volume of the window appropriately.
87 * </p>
88 * <p>
89 * For efficiency the GL viewport has already been updated
90 * via <code>glViewport(x, y, width, height)</code> when this method is called.
91 * </p>
92 *
93 * @param drawable the triggering {@link GLAutoDrawable}
94 * @param x lower left corner of the viewport rectangle in pixel units
95 * @param y lower left corner of the viewport rectangle in pixel units
96 * @param width width of the viewport rectangle in pixel units
97 * @param height height of the viewport rectangle in pixel units
98 */
99 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height);
100}
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
void dispose(GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
void display(GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void init(GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
Called by the drawable during the first repaint after the component has been resized.