29package com.jogamp.opengl.test.junit.jogl.acore;
31import java.nio.FloatBuffer;
32import java.nio.ShortBuffer;
34import com.jogamp.common.nio.Buffers;
35import com.jogamp.opengl.test.junit.util.MiscUtils;
36import com.jogamp.opengl.test.junit.util.UITestCase;
37import com.jogamp.opengl.util.GLBuffers;
39import com.jogamp.opengl.GL;
40import com.jogamp.opengl.GL2;
41import com.jogamp.opengl.GL2ES2;
42import com.jogamp.opengl.GLAutoDrawable;
43import com.jogamp.opengl.GLCapabilities;
44import com.jogamp.opengl.GLDrawableFactory;
45import com.jogamp.opengl.GLEventListener;
46import com.jogamp.opengl.GLException;
47import com.jogamp.opengl.GLOffscreenAutoDrawable;
48import com.jogamp.opengl.GLProfile;
50import org.junit.Assert;
52import org.junit.FixMethodOrder;
53import org.junit.runners.MethodSorters;
60@FixMethodOrder(MethodSorters.NAME_ASCENDING)
62 static long duration = 500;
65 private final static float[] vertexColorData =
new float[]{
66 0.0f, 0.75f, 0.0f, 1,0,0,
67 -0.5f, -0.75f, 0.0f, 0,1,0,
68 0.9f, -0.75f, 0.0f, 0,0,1
70 private final FloatBuffer vertexColorDataBuffer =
GLBuffers.newDirectFloatBuffer(vertexColorData);
72 private final short[] indices =
new short[]{0, 1, 2};
73 private final ShortBuffer indicesBuffer =
GLBuffers.newDirectShortBuffer(indices);
76 private int vertID = -1;
77 private int fragID = -1;
78 private int progID = -1;
80 private static int createShader(
final GL2ES2 gl,
final int type,
81 final String[] srcLines){
84 final int[] lengths =
new int[srcLines.length];
85 for (
int i = 0; i < srcLines.length; i++) {
86 lengths[i] = srcLines[i].length();
88 gl.
glShaderSource(shaderID, srcLines.length, srcLines, lengths, 0);
93 private void initShaders(
final GL2ES2 gl) {
94 final String[] vertSrc =
new String[]{
96 "in vec4 vPosition;\n",
100 " pColor = vColor;\n",
101 " gl_Position = vPosition;\n",
106 final String[] fragSrc =
new String[]{
110 " gl_FragColor = pColor;\n",
146 private void displayCPUSourcing(
final GL2 gl) {
152 final int stride = 6 * Buffers.SIZEOF_FLOAT;
155 vertexColorDataBuffer.position(3);
157 vertexColorDataBuffer.position(0);
174 displayCPUSourcing((
GL2) gl);
180 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int w,
final int h) {
184 private void testImpl(
final GLProfile profile)
throws InterruptedException {
189 final Demo vaoTest =
new Demo();
199 System.err.println(
"GL2 n/a");
209 System.err.println(
"No GL core profile available, got "+glp);
217 System.err.println(
"Expected Exception: "+exp.getMessage());
219 Assert.assertNotNull(
"Excpected GLException missing due to CPU Sourcing w/ GL3 core context", exp);
222 public static void main(
final String args[]) {
223 for(
int i=0; i<args.length; i++) {
224 if(args[i].equals(
"-time")) {
Specifies a set of OpenGL capabilities.
abstract GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice device, GLCapabilitiesImmutable caps, GLCapabilitiesChooser chooser, int width, int height)
Creates a realized GLOffscreenAutoDrawable incl it's offscreen NativeSurface with the given capabilit...
static GLDrawableFactory getFactory(final GLProfile glProfile)
Returns the sole GLDrawableFactory instance.
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
Specifies the the OpenGL profile.
static boolean isAvailable(final AbstractGraphicsDevice device, final String profile)
Returns the availability of a profile on a device.
final boolean isGL2ES2()
Indicates whether this profile is capable of GL2ES2.
final boolean isGL3ES3()
Indicates whether this profile is capable of GL3ES3.
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.
static GLProfile getMaxProgrammableCore(final AbstractGraphicsDevice device, final boolean favorHardwareRasterizer)
Returns the highest profile, implementing the programmable shader core pipeline only.
CPU sourced data API entry not allowed on ES3 and GL core >= 3.0.
void test02GL3CPUSource()
void test01GL2CPUSource()
static void main(final String args[])
static long atol(final String str, final long def)
Utility routines for dealing with direct buffers.
void glDrawElements(int mode, int count, int type, Buffer indices)
Entry point to C language function: void {@native glDrawElements}(GLenum mode, GLsizei count,...
static final int GL_VERTEX_SHADER
GL_ES_VERSION_2_0, GL_VERSION_2_0, GL_EXT_vertex_shader, GL_ARB_vertex_shader Alias for: GL_VERTEX_SH...
void glEnableVertexAttribArray(int index)
Entry point to C language function: void {@native glEnableVertexAttribArray}(GLuint index) Part of...
void glCompileShader(int shader)
Entry point to C language function: void {@native glCompileShader}(GLuint shader) Part of GL_ES_VE...
void glDeleteShader(int shader)
Entry point to C language function: void {@native glDeleteShader}(GLuint shader) Part of GL_ES_VER...
void glValidateProgram(int program)
Entry point to C language function: void {@native glValidateProgram}(GLuint program) Part of GL_ES...
void glDetachShader(int program, int shader)
Entry point to C language function: void {@native glDetachShader}(GLuint program,...
int glGetAttribLocation(int program, String name)
Entry point to C language function: GLint {@native glGetAttribLocation}(GLuint program,...
int glCreateProgram()
Entry point to C language function: GLuint {@native glCreateProgram}() Part of GL_ES_VERSION_2_0,...
void glUseProgram(int program)
Entry point to C language function: void {@native glUseProgram}(GLuint program) Part of GL_ES_VERS...
void glReleaseShaderCompiler()
Start: GL_ARB_ES2_compatibility functions, which are part of ES2 core as well.
void glDisableVertexAttribArray(int index)
Entry point to C language function: void {@native glDisableVertexAttribArray}(GLuint index) Part o...
void glShaderSource(int shader, int count, String[] string, IntBuffer length)
Entry point to C language function: void {@native glShaderSource}(GLuint shader, GLsizei count,...
void glAttachShader(int program, int shader)
Entry point to C language function: void {@native glAttachShader}(GLuint program,...
void glDeleteProgram(int program)
Entry point to C language function: void {@native glDeleteProgram}(GLuint program) Part of GL_ES_V...
int glCreateShader(int type)
Entry point to C language function: GLuint {@native glCreateShader}(GLenum type) Part of GL_ES_VER...
void glLinkProgram(int program)
Entry point to C language function: void {@native glLinkProgram}(GLuint program) Part of GL_ES_VER...
static final int GL_FRAGMENT_SHADER
GL_ES_VERSION_2_0, GL_VERSION_2_0, GL_ATI_fragment_shader, GL_ARB_fragment_shader Alias for: GL_FRAGM...
void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride, Buffer ptr)
Entry point to C language function: void {@native glVertexAttribPointer}(GLuint indx,...
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
GL2ES2 getGL2ES2()
Casts this object to the GL2ES2 interface.
void setSwapInterval(int interval)
Set the swap interval of the current context and attached onscreen GLDrawable.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
Platform-independent GLAutoDrawable specialization, exposing offscreen functionality.
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...
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...
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_UNSIGNED_SHORT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_UNSIGNED_SHORT" with ...
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...
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,...
static final int GL_DEPTH_TEST
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_TEST" with expr...
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...
static final int GL_CULL_FACE
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_CULL_FACE" with expre...