JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
Bug427GLJPanelTest1.java
Go to the documentation of this file.
1package com.jogamp.opengl.test.bugs;
2
3import javax.swing.*;
4
5import java.awt.*;
6
7import com.jogamp.opengl.*;
8import com.jogamp.opengl.awt.*;
9import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
10
11public class Bug427GLJPanelTest1 extends JFrame implements GLEventListener {
12
14 super("Bug427GLJPanelTest1");
15
16 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
17 setLayout(new BorderLayout());
18
19 try {
20 javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
21 public void run() {
22 setSize(600, 600);
23 setLocation(40, 40);
24 setVisible(true);
25 } } );
26 } catch(final Exception ex) {
27 throw new RuntimeException(ex);
28 }
29
30 final GLProfile glp = GLProfile.get(GLProfile.GL2);
31 final GLCapabilities caps = new GLCapabilities(glp);
32 caps.setDoubleBuffered(true);
33 caps.setHardwareAccelerated(true);
34
35 final GLJPanel panel = new GLJPanel(caps);
36 panel.addGLEventListener(this);
37
38 add(panel, BorderLayout.CENTER);
39 }
40
41 public static void main(final String[] args) {
43 try {
44 javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
45 public void run() {
46 demo.setVisible(true);
47 } } );
48 } catch(final Exception ex) {
49 throw new RuntimeException(ex);
50 }
51 }
52
53 public void display(final GLAutoDrawable drawable) {
54 final GL2 gl = drawable.getGL().getGL2();
55
58
59 gl.glColor3f(1, 0, 0);
60 gl.glVertex3f(0.25f, 0.25f, 0);
61
62 gl.glColor3f(0, 1, 0);
63 gl.glVertex3f(0.5f, 0.25f, 0);
64
65 gl.glColor3f(0, 0, 1);
66 gl.glVertex3f(0.25f, 0.5f, 0);
67
68 gl.glEnd();
69 gl.glFlush();
70 }
71
72 public void init(final GLAutoDrawable drawable) {
73 final GL2 gl = drawable.getGL().getGL2();
74
75 gl.glClearColor(0, 0, 0, 0);
77 gl.glLoadIdentity();
78 gl.glOrtho(0, 1, 0, 1, -1, 1);
79 }
80
81 public void reshape(final GLAutoDrawable glDrawable, final int x, final int y, final int w, final int h) {
82 }
83
84 public void displayChanged(final GLAutoDrawable drawable, final boolean modeChanged, final boolean deviceChanged) {
85 }
86
87 public void dispose(final GLAutoDrawable drawable) {
88 }
89}
Specifies a set of OpenGL capabilities.
void setDoubleBuffered(final boolean enable)
Enables or disables double buffering.
void setHardwareAccelerated(final boolean enable)
Enables or disables hardware acceleration.
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static final String GL2
The desktop OpenGL profile 1.x up to 3.0.
Definition: GLProfile.java:579
A lightweight Swing component which provides OpenGL rendering support.
Definition: GLJPanel.java:189
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Definition: GLJPanel.java:989
void init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
void displayChanged(final GLAutoDrawable drawable, final boolean modeChanged, final boolean deviceChanged)
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void reshape(final GLAutoDrawable glDrawable, final int x, final int y, final int w, final int h)
Called by the drawable during the first repaint after the component has been resized.
void glOrtho(double left, double right, double bottom, double top, double near_val, double far_val)
void glBegin(int mode)
Entry point to C language function: void {@native glBegin}(GLenum mode) Part of GL_VERSION_1_0
void glVertex3f(float x, float y, float z)
Entry point to C language function: void {@native glVertex3f}(GLfloat x, GLfloat y,...
void glEnd()
Entry point to C language function: void {@native glEnd}() Part of GL_VERSION_1_0
void glColor3f(float red, float green, float blue)
Entry point to C language function: void {@native glColor3f}(GLfloat red, GLfloat green,...
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
GL2 getGL2()
Casts this object to the GL2 interface.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
static final int GL_TRIANGLES
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_TRIANGLES" with expre...
Definition: GL.java:145
static final int GL_COLOR_BUFFER_BIT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_COLOR_BUFFER_BIT" wit...
Definition: GL.java:390
void glClearColor(float red, float green, float blue, float alpha)
Entry point to C language function: void {@native glClearColor}(GLfloat red, GLfloat green,...
void glClear(int mask)
Entry point to C language function: void {@native glClear}(GLbitfield mask) Part of GL_ES_VERSION_...
void glFlush()
Entry point to C language function: void {@native glFlush}() Part of GL_ES_VERSION_2_0,...
Subset of OpenGL fixed function pipeline's matrix operations.
static final int GL_PROJECTION
Matrix mode projection.
void glLoadIdentity()
Load the current matrix with the identity matrix.
void glMatrixMode(int mode)
Sets the current matrix mode.