JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
MultisampleDemoES1.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
3 * Copyright (c) 2010 JogAmp Community. 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 * Sun gratefully acknowledges that this software was originally authored
38 * and developed by Kenneth Bradley Russell and Christopher John Kline.
39 */
40
41package com.jogamp.opengl.test.junit.jogl.demos.es1;
42
43import com.jogamp.opengl.GL;
44import com.jogamp.opengl.GL2ES1;
45import com.jogamp.opengl.GLAutoDrawable;
46import com.jogamp.opengl.GLEventListener;
47import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
48
49import com.jogamp.opengl.util.ImmModeSink;
50
51public class MultisampleDemoES1 implements GLEventListener {
52
53 boolean multisample;
54 ImmModeSink immModeSink;
55
56 public MultisampleDemoES1(final boolean multisample) {
57 this.multisample = multisample;
58 }
59
60 public void init(final GLAutoDrawable drawable) {
61 System.err.println();
62 System.err.println("Requested: " + drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities());
63 System.err.println();
64 System.err.println("Chosen : " + drawable.getChosenGLCapabilities());
65 System.err.println();
66 final GL2ES1 gl = drawable.getGL().getGL2ES1();
67 if (multisample) {
69 }
70 gl.glClearColor(0, 0, 0, 0);
71 // gl.glEnable(GL.GL_DEPTH_TEST);
72 // gl.glDepthFunc(GL.GL_LESS);
74 gl.glLoadIdentity();
76 gl.glLoadIdentity();
77 gl.glOrtho(-1, 1, -1, 1, -1, 1);
78 if (multisample) {
80 }
81 immModeSink = ImmModeSink.createFixed(40,
82 3, GL.GL_FLOAT, // vertex
83 0, GL.GL_FLOAT, // color
84 0, GL.GL_FLOAT, // normal
85 0, GL.GL_FLOAT, // texCoords
87 final int numSteps = 20;
88 final double increment = Math.PI / numSteps;
89 final double radius = 1;
90 immModeSink.glBegin(GL.GL_LINES);
91 for (int i = numSteps - 1; i >= 0; i--) {
92 immModeSink.glVertex3f((float) (radius * Math.cos(i * increment)),
93 (float) (radius * Math.sin(i * increment)),
94 0f);
95 immModeSink.glVertex3f((float) (-1.0 * radius * Math.cos(i * increment)),
96 (float) (-1.0 * radius * Math.sin(i * increment)),
97 0f);
98 }
99 immModeSink.glEnd(gl, false);
100 }
101
102 public void dispose(final GLAutoDrawable drawable) {
103 immModeSink.destroy(drawable.getGL());
104 immModeSink = null;
105 }
106
107 public void display(final GLAutoDrawable drawable) {
108 final GL2ES1 gl = drawable.getGL().getGL2ES1();
109 if (multisample) {
111 }
113 immModeSink.draw(gl, true);
114 if (multisample) {
116 }
117 }
118
119 // Unused routines
120 public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
121 }
122
123 public void displayChanged(final GLAutoDrawable drawable, final boolean modeChanged, final boolean deviceChanged) {
124 }
125}
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
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 displayChanged(final GLAutoDrawable drawable, final boolean modeChanged, final boolean deviceChanged)
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
final void glVertex3f(final float x, final float y, final float z)
static ImmModeSink createFixed(final int initialElementCount, final int vComps, final int vDataType, final int cComps, final int cDataType, final int nComps, final int nDataType, final int tComps, final int tDataType, final int glBufferUsage)
Uses a GL2ES1, or ES2 fixed function emulation immediate mode sink.
void draw(final GL gl, final boolean disableBufferAfterDraw)
final void glEnd(final GL gl)
CapabilitiesImmutable getRequestedCapabilities()
Return the capabilities used to choose this graphics configuration.
AbstractGraphicsConfiguration getGraphicsConfiguration()
Returns the graphics configuration corresponding to this window.
void glOrtho(double left, double right, double bottom, double top, double near_val, double far_val)
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
GL2ES1 getGL2ES1()
Casts this object to the GL2ES1 interface.
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...
NativeSurface getNativeSurface()
Returns the associated NativeSurface of this NativeSurfaceHolder.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
static final int GL_MULTISAMPLE
Common in ES1, GL2 and GL3.
Definition: GL.java:1249
static final int GL_STATIC_DRAW
GL_VERSION_1_5, GL_ES_VERSION_2_0, GL_VERSION_ES_1_0, GL_ARB_vertex_buffer_object Alias for: GL_STATI...
Definition: GL.java:673
static final int GL_FLOAT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_FLOAT" with expressio...
Definition: GL.java:786
void glDisable(int cap)
Entry point to C language function: void {@native glDisable}(GLenum cap) Part of GL_ES_VERSION_2_0...
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 glEnable(int cap)
Entry point to C language function: void {@native glEnable}(GLenum cap) Part of GL_ES_VERSION_2_0,...
void glClear(int mask)
Entry point to C language function: void {@native glClear}(GLbitfield mask) Part of GL_ES_VERSION_...
static final int GL_DEPTH_BUFFER_BIT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_BUFFER_BIT" wit...
Definition: GL.java:738
static final int GL_LINES
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_LINES" with expressio...
Definition: GL.java:430
Subset of OpenGL fixed function pipeline's matrix operations.
static final int GL_PROJECTION
Matrix mode projection.
static final int GL_MODELVIEW
Matrix mode modelview.
void glLoadIdentity()
Load the current matrix with the identity matrix.
void glMatrixMode(int mode)
Sets the current matrix mode.