From 2483c0c147aa338dd002bf85a78d158be7b2aff8 Mon Sep 17 00:00:00 2001
From: toruwest
Date: Wed, 15 Oct 2014 23:27:19 +0900
Subject: Create IView.java
---
.../opengl/test/junit/jogl/demos/gl4/IView.java | 33 ++++++++++++++++++++++
1 file changed, 33 insertions(+)
create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/IView.java
(limited to 'src')
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/IView.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/IView.java
new file mode 100644
index 000000000..934416693
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/IView.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+ package com.jogamp.opengl.test.junit.jogl.demos.gl4;
+
+public interface IView {
+ float getScale();
+}
--
cgit v1.2.3
From 05fe522ae328177d0dfe64b6ca93e1f5e8c16d9b Mon Sep 17 00:00:00 2001
From: toruwest
Date: Wed, 15 Oct 2014 23:28:44 +0900
Subject: Added.
---
.../jogl/demos/gl4/IInstancedRenderingView.java | 33 +++
.../opengl/test/junit/jogl/demos/gl4/IView.java | 33 ---
.../TriangleInstancedRendererWithShaderState.java | 269 +++++++++++++++++++
.../gl4/TrianglesInstancedRendererHardcoded.java | 285 +++++++++++++++++++++
.../demos/gl4/awt/TestInstancedReneringGL4AWT.java | 244 ++++++++++++++++++
.../gl4/newt/TestInstancedReneringGL4NEWT.java | 108 ++++++++
.../test/junit/jogl/demos/gl4/shader/triangles.fp | 15 ++
.../test/junit/jogl/demos/gl4/shader/triangles.vp | 17 ++
8 files changed, 971 insertions(+), 33 deletions(-)
create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/IInstancedRenderingView.java
delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/IView.java
create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TriangleInstancedRendererWithShaderState.java
create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TrianglesInstancedRendererHardcoded.java
create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/awt/TestInstancedReneringGL4AWT.java
create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/newt/TestInstancedReneringGL4NEWT.java
create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/triangles.fp
create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/triangles.vp
(limited to 'src')
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/IInstancedRenderingView.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/IInstancedRenderingView.java
new file mode 100644
index 000000000..e76db6ab5
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/IInstancedRenderingView.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+ package com.jogamp.opengl.test.junit.jogl.demos.gl4;
+
+public interface IInstancedRenderingView {
+ float getScale();
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/IView.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/IView.java
deleted file mode 100644
index 934416693..000000000
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/IView.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Copyright 2014 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
- package com.jogamp.opengl.test.junit.jogl.demos.gl4;
-
-public interface IView {
- float getScale();
-}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TriangleInstancedRendererWithShaderState.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TriangleInstancedRendererWithShaderState.java
new file mode 100644
index 000000000..9ba0c8d59
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TriangleInstancedRendererWithShaderState.java
@@ -0,0 +1,269 @@
+package com.jogamp.opengl.test.junit.jogl.demos.gl4;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.nio.FloatBuffer;
+import java.util.Random;
+
+import javax.media.opengl.DebugGL4;
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GL4;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLUniformData;
+import javax.media.opengl.TraceGL4;
+
+import com.jogamp.opengl.math.Matrix4;
+import com.jogamp.opengl.util.GLArrayDataClient;
+import com.jogamp.opengl.util.GLArrayDataServer;
+import com.jogamp.opengl.util.PMVMatrix;
+import com.jogamp.opengl.util.glsl.ShaderCode;
+import com.jogamp.opengl.util.glsl.ShaderProgram;
+import com.jogamp.opengl.util.glsl.ShaderState;
+
+public class TriangleInstancedRendererWithShaderState implements GLEventListener {
+ private float aspect;
+
+ private static final String shaderBasename = "triangles";
+// private static final boolean useInterleaved = false;
+ private static final boolean useInterleaved = true;
+
+ private ShaderState st;
+ private PMVMatrix projectionMatrix;
+ private GLUniformData projectionMatrixUniform;
+ private GLUniformData transformMatrixUniform;
+
+ private GLArrayDataServer interleavedVBO;
+ private GLArrayDataClient verticesVBO;
+ private GLArrayDataClient colorsVBO;
+
+ private static final int NO_OF_INSTANCE = 30;
+ private final FloatBuffer triangleTransform = FloatBuffer.allocate(16 * NO_OF_INSTANCE);
+ private final Matrix4[] mat = new Matrix4[NO_OF_INSTANCE];
+ private final float[] rotationSpeed = new float[NO_OF_INSTANCE];
+
+ private static final boolean useTraceGL = false;
+ private PrintStream stream;
+ private final IInstancedRenderingView view;
+
+ private boolean isInitialized = false;
+
+ public TriangleInstancedRendererWithShaderState(IInstancedRenderingView view) {
+ this.view = view;
+
+ if(useTraceGL) {
+ try {
+ stream = new PrintStream(new FileOutputStream(new File("instanced-with-st.txt")));
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ initTransform();
+ }
+
+ private void initTransform() {
+ Random rnd = new Random();
+ for(int i = 0; i < NO_OF_INSTANCE; i++) {
+ rotationSpeed[i] = 0.3f * rnd.nextFloat();
+ mat[i] = new Matrix4();
+ mat[i].loadIdentity();
+ float scale = 1f + 4 * rnd.nextFloat();
+ mat[i].scale(scale, scale, scale);
+ //setup initial position of each triangle
+ mat[i].translate(20f * rnd.nextFloat() - 10f,
+ 10f * rnd.nextFloat() - 5f,
+ 0f);
+ }
+ }
+
+ @Override
+ public void init(GLAutoDrawable drawable) {
+ GL4 gl = drawable.getGL().getGL4();
+ drawable.setGL(new DebugGL4(gl));
+ if(useTraceGL) {
+ drawable.setGL(new TraceGL4(gl, stream));
+ }
+
+ gl.glClearColor(1, 1, 1, 1); //white background
+// gl.glClearColor(0, 0, 0, 1); //black background
+ gl.glClearDepth(1.0f);
+
+ System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
+ System.err.println("INIT GL IS: " + gl.getClass().getName());
+ System.err.println("GL_VENDOR: " + gl.glGetString(GL4.GL_VENDOR));
+ System.err.println("GL_RENDERER: " + gl.glGetString(GL4.GL_RENDERER));
+ System.err.println("GL_VERSION: " + gl.glGetString(GL4.GL_VERSION));
+
+ initShader(gl);
+ projectionMatrix = new PMVMatrix();
+ projectionMatrixUniform = new GLUniformData("mgl_PMatrix", 4, 4, projectionMatrix.glGetPMatrixf());
+ st.ownUniform(projectionMatrixUniform);
+ if(!st.uniform(gl, projectionMatrixUniform)) {
+ throw new GLException("Error setting mgl_PMatrix in shader: " + st);
+ }
+
+ transformMatrixUniform = new GLUniformData("mgl_MVMatrix", 4, 4, triangleTransform);
+
+ st.ownUniform(transformMatrixUniform);
+ if(!st.uniform(gl, transformMatrixUniform)) {
+ throw new GLException("Error setting mgl_MVMatrix in shader: " + st);
+ }
+
+ if(useInterleaved) {
+ initVBO_interleaved(gl);
+ } else {
+ initVBO_nonInterleaved(gl);
+ }
+
+ isInitialized = true;
+ }
+
+ @Override
+ public void display(GLAutoDrawable drawable) {
+ if(!isInitialized ) return;
+
+ GL4 gl = drawable.getGL().getGL4();
+ gl.glClear(GL4.GL_COLOR_BUFFER_BIT | GL4.GL_DEPTH_BUFFER_BIT);
+
+ st.useProgram(gl, true);
+ projectionMatrix.glMatrixMode(GL2.GL_PROJECTION);
+ projectionMatrix.glPushMatrix();
+
+ float winScale = 0.1f;
+ if(view != null) winScale = view.getScale();
+ projectionMatrix.glScalef(winScale, winScale, winScale);
+ projectionMatrix.update();
+ st.uniform(gl, projectionMatrixUniform);
+ projectionMatrix.glPopMatrix();
+
+ generateTriangleTransform();
+ st.uniform(gl, transformMatrixUniform);
+ if(useInterleaved) {
+ interleavedVBO.enableBuffer(gl, true);
+ } else {
+ verticesVBO.enableBuffer(gl, true);
+ colorsVBO.enableBuffer(gl, true);
+ }
+ //gl.glVertexAttribDivisor() is not required since each instance has the same attribute (color).
+ gl.glDrawArraysInstanced(GL4.GL_TRIANGLES, 0, 3, NO_OF_INSTANCE);
+ if(useInterleaved) {
+ interleavedVBO.enableBuffer(gl, false);
+ } else {
+ verticesVBO.enableBuffer(gl, false);
+ colorsVBO.enableBuffer(gl, false);
+ }
+ st.useProgram(gl, false);
+ }
+
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ GL4 gl3 = drawable.getGL().getGL4();
+ gl3.glViewport(0, 0, width, height);
+ aspect = (float) width / (float) height;
+
+ projectionMatrix.glMatrixMode(GL2.GL_PROJECTION);
+ projectionMatrix.glLoadIdentity();
+ projectionMatrix.gluPerspective(45, aspect, 0.001f, 20f);
+ projectionMatrix.gluLookAt(0, 0, -10, 0, 0, 0, 0, 1, 0);
+ }
+
+ @Override
+ public void dispose(GLAutoDrawable drawable){
+ GL4 gl = drawable.getGL().getGL4();
+ st.destroy(gl);
+ }
+
+ private void generateTriangleTransform() {
+ triangleTransform.clear();
+ for(int i = 0; i < NO_OF_INSTANCE; i++) {
+ mat[i].rotate(rotationSpeed[i], 0, 0, 1);
+ triangleTransform.put(mat[i].getMatrix());
+ }
+ triangleTransform.rewind();
+ }
+
+ private void initVBO_nonInterleaved(GL4 gl) {
+ int VERTEX_COUNT = 3;
+
+ verticesVBO = GLArrayDataClient.createGLSL("mgl_Vertex", 3, GL4.GL_FLOAT, false, VERTEX_COUNT);
+ FloatBuffer verticeBuf = (FloatBuffer)verticesVBO.getBuffer();
+ verticeBuf.put(vertices);
+ verticesVBO.seal(gl, true);
+
+ colorsVBO = GLArrayDataClient.createGLSL("mgl_Color", 4, GL4.GL_FLOAT, false, VERTEX_COUNT);
+ FloatBuffer colorBuf = (FloatBuffer)colorsVBO.getBuffer();
+ colorBuf.put(colors);
+ colorsVBO.seal(gl, true);
+
+ verticesVBO.enableBuffer(gl, false);
+ colorsVBO.enableBuffer(gl, false);
+
+ st.ownAttribute(verticesVBO, true);
+ st.ownAttribute(colorsVBO, true);
+ st.useProgram(gl, false);
+ }
+
+ private void initVBO_interleaved(GL4 gl) {
+ int VERTEX_COUNT = 3;
+ interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3 + 4, GL.GL_FLOAT, false, VERTEX_COUNT, GL.GL_STATIC_DRAW);
+ interleavedVBO.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER);
+ interleavedVBO.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER);
+
+ FloatBuffer ib = (FloatBuffer)interleavedVBO.getBuffer();
+
+ for(int i = 0; i < VERTEX_COUNT; i++) {
+ ib.put(vertices, i*3, 3);
+ ib.put(colors, i*4, 4);
+ }
+ interleavedVBO.seal(gl, true);
+ interleavedVBO.enableBuffer(gl, false);
+ st.ownAttribute(interleavedVBO, true);
+ st.useProgram(gl, false);
+ }
+
+ private void initShader(GL4 gl) {
+ // Create & Compile the shader objects
+ ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(),
+ "shader", "shader/bin", shaderBasename, true);
+ ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(),
+ "shader", "shader/bin", shaderBasename, true);
+ vp0.replaceInShaderSource("NO_OF_INSTANCE", String.valueOf(NO_OF_INSTANCE));
+
+ vp0.defaultShaderCustomization(gl, true, true);
+ fp0.defaultShaderCustomization(gl, true, true);
+
+ //vp0.dumpShaderSource(System.out);
+
+ // Create & Link the shader program
+ ShaderProgram sp = new ShaderProgram();
+ sp.add(vp0);
+ sp.add(fp0);
+ if(!sp.link(gl, System.err)) {
+ throw new GLException("Couldn't link program: "+sp);
+ }
+
+ // Let's manage all our states using ShaderState.
+ st = new ShaderState();
+ st.attachShaderProgram(gl, sp, true);
+ }
+
+
+ private static final float[] vertices = {
+ 1.0f, 0.0f, 0,
+ -0.5f, 0.866f, 0,
+ -0.5f, -0.866f, 0
+ };
+
+ private final float[] colors = {
+ 1.0f, 0.0f, 0.0f, 1.0f,
+ 0.0f, 1.0f, 0.0f, 1.0f,
+ 0f, 0f, 1.0f, 1f
+ };
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TrianglesInstancedRendererHardcoded.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TrianglesInstancedRendererHardcoded.java
new file mode 100644
index 000000000..739670053
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TrianglesInstancedRendererHardcoded.java
@@ -0,0 +1,285 @@
+package com.jogamp.opengl.test.junit.jogl.demos.gl4;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.nio.FloatBuffer;
+import java.util.Random;
+
+import javax.media.opengl.DebugGL4;
+import javax.media.opengl.GL2;
+import javax.media.opengl.GL4;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.TraceGL4;
+
+import com.jogamp.common.nio.Buffers;
+import com.jogamp.opengl.math.Matrix4;
+import com.jogamp.opengl.util.PMVMatrix;
+
+public class TrianglesInstancedRendererHardcoded implements GLEventListener {
+ private float aspect;
+
+ private int shaderProgram;
+ private int vertShader;
+ private int fragShader;
+ private int projectionMatrixLocation;
+ private int transformMatrixLocation;
+ private static final int locPos = 1;
+ private static final int locCol = 2;
+ private PMVMatrix projectionMatrix;
+
+ private static final int NO_OF_INSTANCE = 30;
+ private final FloatBuffer triangleTransform = FloatBuffer.allocate(16 * NO_OF_INSTANCE);
+ private final Matrix4[] mat = new Matrix4[NO_OF_INSTANCE];
+ private final float[] rotationSpeed = new float[NO_OF_INSTANCE];
+
+ private int[] vbo;
+ private int[] vao;
+ private PrintStream stream;
+ private final IInstancedRenderingView view;
+
+ private static final boolean useTraceGL = false;
+
+ public TrianglesInstancedRendererHardcoded(IInstancedRenderingView view) {
+ this.view = view;
+ initTransform();
+
+ if(useTraceGL) {
+ try {
+ stream = new PrintStream(new FileOutputStream(new File("instanced.txt")));
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ public void init(GLAutoDrawable drawable) {
+ GL4 gl = drawable.getGL().getGL4();
+ drawable.setGL(new DebugGL4(gl));
+ if(useTraceGL) {
+ drawable.setGL(new TraceGL4(gl, stream));
+ }
+
+ gl.glClearColor(1, 1, 1, 1); //white background
+ // gl.glClearColor(0, 0, 0, 1); //black background
+ gl.glClearDepth(1.0f);
+
+ System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
+ System.err.println("INIT GL IS: " + gl.getClass().getName());
+ System.err.println("GL_VENDOR: " + gl.glGetString(GL4.GL_VENDOR));
+ System.err.println("GL_RENDERER: " + gl.glGetString(GL4.GL_RENDERER));
+ System.err.println("GL_VERSION: " + gl.glGetString(GL4.GL_VERSION));
+
+ try {
+ initShaders(gl);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ initVBO(gl);
+ }
+
+ @Override
+ public void display(GLAutoDrawable drawable) {
+
+ GL4 gl = drawable.getGL().getGL4();
+ gl.glClear(GL4.GL_COLOR_BUFFER_BIT | GL4.GL_DEPTH_BUFFER_BIT);
+
+ gl.glUseProgram(shaderProgram);
+
+ projectionMatrix.glMatrixMode(GL2.GL_PROJECTION);
+
+ projectionMatrix.glPushMatrix();
+ float winScale = 0.1f;
+ if(view != null) {
+ winScale = view.getScale();
+ }
+ projectionMatrix.glScalef(winScale, winScale, winScale);
+ projectionMatrix.update();
+ gl.glUniformMatrix4fv(projectionMatrixLocation, 1, false, projectionMatrix.glGetPMatrixf());
+ projectionMatrix.glPopMatrix();
+ generateTriangleTransform();
+ gl.glUniformMatrix4fv(transformMatrixLocation, NO_OF_INSTANCE, false, triangleTransform);
+
+ gl.glBindVertexArray(vao[0]);
+ gl.glDrawArraysInstanced(GL4.GL_TRIANGLES, 0, 3, NO_OF_INSTANCE);
+ gl.glBindVertexArray(0);
+ gl.glUseProgram(0);
+ }
+
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ System.out.println("Window resized to width=" + width + " height=" + height);
+ GL4 gl3 = drawable.getGL().getGL4();
+ gl3.glViewport(0, 0, width, height);
+ aspect = (float) width / (float) height;
+
+ projectionMatrix = new PMVMatrix();
+ projectionMatrix.glMatrixMode(GL2.GL_PROJECTION);
+ projectionMatrix.glLoadIdentity();
+ projectionMatrix.gluPerspective(45, aspect, 0.001f, 20f);
+ projectionMatrix.gluLookAt(0, 0, -10, 0, 0, 0, 0, 1, 0);
+ }
+
+ @Override
+ public void dispose(GLAutoDrawable drawable){
+ GL4 gl = drawable.getGL().getGL4();
+ gl.glUseProgram(0);
+ gl.glDeleteBuffers(2, vbo, 0);
+ gl.glDetachShader(shaderProgram, vertShader);
+ gl.glDeleteShader(vertShader);
+ gl.glDetachShader(shaderProgram, fragShader);
+ gl.glDeleteShader(fragShader);
+ gl.glDeleteProgram(shaderProgram);
+ }
+
+ private void initTransform() {
+ Random rnd = new Random();
+ for(int i = 0; i < NO_OF_INSTANCE; i++) {
+ rotationSpeed[i] = 0.3f * rnd.nextFloat();
+ mat[i] = new Matrix4();
+ mat[i].loadIdentity();
+ float scale = 1f + 4 * rnd.nextFloat();
+ mat[i].scale(scale, scale, scale);
+ //setup initial position of each triangle
+ mat[i].translate(20f * rnd.nextFloat() - 10f,
+ 10f * rnd.nextFloat() - 5f,
+ 0f);
+ }
+ }
+
+ private void initVBO(GL4 gl) {
+ FloatBuffer interleavedBuffer = Buffers.newDirectFloatBuffer(vertices.length + colors.length);
+ for(int i = 0; i < vertices.length/3; i++) {
+ for(int j = 0; j < 3; j++) {
+ interleavedBuffer.put(vertices[i*3 + j]);
+ }
+ for(int j = 0; j < 4; j++) {
+ interleavedBuffer.put(colors[i*4 + j]);
+ }
+ }
+ interleavedBuffer.flip();
+
+ vao = new int[1];
+ gl.glGenVertexArrays(1, vao , 0);
+ gl.glBindVertexArray(vao[0]);
+ vbo = new int[1];
+ gl.glGenBuffers(1, vbo, 0);
+ gl.glBindBuffer(GL4.GL_ARRAY_BUFFER, vbo[0]);
+ gl.glBufferData(GL4.GL_ARRAY_BUFFER, interleavedBuffer.limit() * Buffers.SIZEOF_FLOAT, interleavedBuffer, GL4.GL_STATIC_DRAW);
+
+ gl.glEnableVertexAttribArray(locPos);
+ gl.glEnableVertexAttribArray(locCol);
+
+ int stride = Buffers.SIZEOF_FLOAT * (3+4);
+ gl.glVertexAttribPointer( locPos, 3, GL4.GL_FLOAT, false, stride, 0);
+ gl.glVertexAttribPointer( locCol, 4, GL4.GL_FLOAT, false, stride, Buffers.SIZEOF_FLOAT * 3);
+ }
+
+ private void initShaders(GL4 gl) throws IOException {
+ vertShader = gl.glCreateShader(GL4.GL_VERTEX_SHADER);
+ fragShader = gl.glCreateShader(GL4.GL_FRAGMENT_SHADER);
+
+ String[] vlines = new String[] { vertexShaderString };
+ int[] vlengths = new int[] { vlines[0].length() };
+ gl.glShaderSource(vertShader, vlines.length, vlines, vlengths, 0);
+ gl.glCompileShader(vertShader);
+
+ int[] compiled = new int[1];
+ gl.glGetShaderiv(vertShader, GL4.GL_COMPILE_STATUS, compiled, 0);
+ if(compiled[0] != 0) {
+ System.out.println("Vertex shader compiled");
+ } else {
+ int[] logLength = new int[1];
+ gl.glGetShaderiv(vertShader, GL4.GL_INFO_LOG_LENGTH, logLength, 0);
+
+ byte[] log = new byte[logLength[0]];
+ gl.glGetShaderInfoLog(vertShader, logLength[0], (int[])null, 0, log, 0);
+
+ System.err.println("Error compiling the vertex shader: " + new String(log));
+ System.exit(1);
+ }
+
+ String[] flines = new String[] { fragmentShaderString };
+ int[] flengths = new int[] { flines[0].length() };
+ gl.glShaderSource(fragShader, flines.length, flines, flengths, 0);
+ gl.glCompileShader(fragShader);
+
+ gl.glGetShaderiv(fragShader, GL4.GL_COMPILE_STATUS, compiled, 0);
+ if(compiled[0] != 0){
+ System.out.println("Fragment shader compiled.");
+ } else {
+ int[] logLength = new int[1];
+ gl.glGetShaderiv(fragShader, GL4.GL_INFO_LOG_LENGTH, logLength, 0);
+
+ byte[] log = new byte[logLength[0]];
+ gl.glGetShaderInfoLog(fragShader, logLength[0], (int[])null, 0, log, 0);
+
+ System.err.println("Error compiling the fragment shader: " + new String(log));
+ System.exit(1);
+ }
+
+ shaderProgram = gl.glCreateProgram();
+ gl.glAttachShader(shaderProgram, vertShader);
+ gl.glAttachShader(shaderProgram, fragShader);
+
+ gl.glBindAttribLocation(shaderProgram, locPos, "mgl_Vertex");
+ gl.glBindAttribLocation(shaderProgram, locCol, "mgl_Color");
+
+ gl.glLinkProgram(shaderProgram);
+
+ projectionMatrixLocation = gl.glGetUniformLocation(shaderProgram, "mgl_PMatrix");
+ System.out.println("projectionMatrixLocation:" + projectionMatrixLocation);
+ transformMatrixLocation = gl.glGetUniformLocation(shaderProgram, "mgl_MVMatrix");
+ System.out.println("transformMatrixLocation:" + transformMatrixLocation);
+ }
+
+ private void generateTriangleTransform() {
+ triangleTransform.clear();
+ for(int i = 0; i < NO_OF_INSTANCE; i++) {
+ // mat[i].translate(0.1f, 0.1f, 0);
+ mat[i].rotate(rotationSpeed[i], 0, 0, 1);
+ // mat[i].translate(-0.1f, -0.1f, 0);
+ triangleTransform.put(mat[i].getMatrix());
+ }
+ triangleTransform.flip();
+ }
+
+ private final String vertexShaderString =
+ "#version 410 \n" +
+ "\n" +
+ "uniform mat4 mgl_PMatrix; \n" +
+ "uniform mat4 mgl_MVMatrix[" + NO_OF_INSTANCE + "]; \n" +
+ "in vec3 mgl_Vertex; \n" +
+ "in vec4 mgl_Color; \n" +
+ "out vec4 frontColor; \n" +
+ "void main(void) \n" +
+ "{ \n" +
+ " frontColor = mgl_Color; \n" +
+ " gl_Position = mgl_PMatrix * mgl_MVMatrix[gl_InstanceID] * vec4(mgl_Vertex, 1);" +
+ "} ";
+
+ private final String fragmentShaderString =
+ "#version 410\n" +
+ "\n" +
+ "in vec4 frontColor; \n" +
+ "out vec4 mgl_FragColor; \n" +
+ "void main (void) \n" +
+ "{ \n" +
+ " mgl_FragColor = frontColor; \n" +
+ "} ";
+
+ private final float[] vertices = {
+ 1.0f, 0.0f, 0,
+ -0.5f, 0.866f, 0,
+ -0.5f, -0.866f, 0
+ };
+
+ private final float[] colors = {
+ 1.0f, 0.0f, 0.0f, 1.0f,
+ 0.0f, 1.0f, 0.0f, 1.0f,
+ 0f, 0f, 1.0f, 1f
+ };
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/awt/TestInstancedReneringGL4AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/awt/TestInstancedReneringGL4AWT.java
new file mode 100644
index 000000000..c602ffd7b
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/awt/TestInstancedReneringGL4AWT.java
@@ -0,0 +1,244 @@
+/**
+ * Copyright 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.demos.gl4.awt;
+
+import java.awt.AWTException;
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLJPanel;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.newt.event.KeyEvent;
+import com.jogamp.newt.event.TraceKeyAdapter;
+import com.jogamp.newt.event.TraceWindowAdapter;
+import com.jogamp.newt.event.awt.AWTKeyAdapter;
+import com.jogamp.newt.event.awt.AWTWindowAdapter;
+import com.jogamp.opengl.test.junit.jogl.demos.gl4.TriangleInstancedRendererWithShaderState;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.FPSAnimator;
+
+/**
+ * Test Instanced rendering demo TrianglesInstancedRenderer
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestInstancedReneringGL4AWT extends UITestCase {
+ static GLProfile glp;
+ static int width, height;
+ static boolean shallUsePBuffer = false;
+ static boolean shallUseBitmap = false;
+ static boolean useMSAA = false;
+ static int swapInterval = 0;
+ static boolean useAnimator = true;
+ static boolean manualTest = false;
+
+ @BeforeClass
+ public static void initClass() {
+ if(GLProfile.isAvailable(GLProfile.GL4)) {
+ glp = GLProfile.get(GLProfile.GL4);
+ Assert.assertNotNull(glp);
+ width = 640;
+ height = 480;
+ } else {
+ setTestSupported(false);
+ }
+ }
+
+ @AfterClass
+ public static void releaseClass() {
+ }
+
+ protected void runTestGL(final GLCapabilities caps)
+ throws AWTException, InterruptedException, InvocationTargetException
+ {
+ final JFrame frame = new JFrame("Swing GLJPanel");
+ Assert.assertNotNull(frame);
+ final GLJPanel glJPanel = new GLJPanel(caps);
+ Assert.assertNotNull(glJPanel);
+ final Dimension glc_sz = new Dimension(width, height);
+ glJPanel.setMinimumSize(glc_sz);
+ glJPanel.setPreferredSize(glc_sz);
+ glJPanel.setSize(glc_sz);
+ glJPanel.addGLEventListener(new TriangleInstancedRendererWithShaderState(null));
+ final SnapshotGLEventListener snap = new SnapshotGLEventListener();
+ glJPanel.addGLEventListener(snap);
+ final FPSAnimator animator = useAnimator ? new FPSAnimator(glJPanel, 60) : null;
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ frame.getContentPane().add(glJPanel, BorderLayout.CENTER);
+ frame.getContentPane().validate();
+ frame.pack();
+ frame.setVisible(true);
+ } } ) ;
+ if( useAnimator ) {
+ animator.setUpdateFPSFrames(60, System.err);
+ animator.start();
+ Assert.assertEquals(true, animator.isAnimating());
+ }
+ final QuitAdapter quitAdapter = new QuitAdapter();
+ new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), glJPanel).addTo(glJPanel);
+ new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glJPanel).addTo(frame);
+ final com.jogamp.newt.event.KeyListener kl = new com.jogamp.newt.event.KeyAdapter() {
+ @Override
+ public void keyPressed(final KeyEvent e) {
+ if( e.isAutoRepeat() ) {
+ return;
+ }
+ if(e.getKeyChar()=='m') {
+ final GLCapabilitiesImmutable capsPre = glJPanel.getChosenGLCapabilities();
+ final GLCapabilities capsNew = new GLCapabilities(capsPre.getGLProfile());
+ capsNew.copyFrom(capsPre);
+ final boolean msaa;
+ if( capsPre.getSampleBuffers() ) {
+ capsNew.setSampleBuffers(false);
+ capsNew.setDoubleBuffered(false);
+ msaa = false;
+ } else {
+ capsNew.setSampleBuffers(true);
+ capsNew.setNumSamples(4);
+ msaa = true;
+ }
+ System.err.println("[set MSAA "+msaa+" Caps had]: "+capsPre);
+ System.err.println("[set MSAA "+msaa+" Caps new]: "+capsNew);
+ System.err.println("XXX-A1: "+animator.toString());
+// glJPanel.setRequestedGLCapabilities(capsNew);
+ System.err.println("XXX-A2: "+animator.toString());
+ System.err.println("XXX: "+glJPanel.toString());
+ } else if(e.getKeyChar()=='b') {
+ final GLCapabilitiesImmutable capsPre = glJPanel.getChosenGLCapabilities();
+ final GLCapabilities capsNew = new GLCapabilities(capsPre.getGLProfile());
+ capsNew.copyFrom(capsPre);
+ final boolean bmp;
+ if( capsPre.isBitmap() ) {
+ capsNew.setBitmap(false); // auto-choose
+ bmp = false;
+ } else {
+ capsNew.setBitmap(true);
+ capsNew.setFBO(false);
+ capsNew.setPBuffer(false);
+ bmp = true;
+ }
+ System.err.println("[set Bitmap "+bmp+" Caps had]: "+capsPre);
+ System.err.println("[set Bitmap "+bmp+" Caps new]: "+capsNew);
+ System.err.println("XXX-A1: "+animator.toString());
+// glJPanel.setRequestedGLCapabilities(capsNew);
+ System.err.println("XXX-A2: "+animator.toString());
+ System.err.println("XXX: "+glJPanel.toString());
+ }
+ } };
+ new AWTKeyAdapter(kl, glJPanel).addTo(glJPanel);
+ final long t0 = System.currentTimeMillis();
+ long t1 = t0;
+ boolean triggerSnap = false;
+ while(!quitAdapter.shouldQuit() && t1 - t0 < duration) {
+ Thread.sleep(100);
+ t1 = System.currentTimeMillis();
+ snap.getDisplayCount();
+ if( !triggerSnap && snap.getDisplayCount() > 1 ) {
+ // Snapshot only after one frame has been rendered to suite FBO MSAA!
+ snap.setMakeSnapshot();
+ triggerSnap = true;
+ }
+ }
+ Assert.assertNotNull(frame);
+ Assert.assertNotNull(glJPanel);
+ Assert.assertNotNull(animator);
+ if( useAnimator ) {
+ animator.stop();
+ Assert.assertEquals(false, animator.isAnimating());
+ }
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ frame.setVisible(false);
+ frame.getContentPane().remove(glJPanel);
+ frame.remove(glJPanel);
+ glJPanel.destroy();
+ frame.dispose();
+ } } );
+ }
+
+ @Test
+ public void test01_DefaultMsaa()
+ throws AWTException, InterruptedException, InvocationTargetException
+ {
+ if( manualTest ) {
+ return;
+ }
+ final GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL4));
+ caps.setNumSamples(4);
+ caps.setSampleBuffers(true);
+ runTestGL(caps);
+ }
+
+ static long duration = 500; // ms
+
+ public static void main(final String args[]) {
+ for(int i=0; i= 130
+ #define varying in
+ out vec4 mgl_FragColor;
+ #define texture2D texture
+#else
+ #define mgl_FragColor gl_FragColor
+#endif
+
+varying vec4 frontColor;
+
+void main (void) {
+ mgl_FragColor = frontColor;
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/triangles.vp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/triangles.vp
new file mode 100644
index 000000000..91cc6eff9
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/triangles.vp
@@ -0,0 +1,17 @@
+// Copyright 2014 JogAmp Community. All rights reserved.
+
+#if __VERSION__ >= 130
+ #define attribute in
+ #define varying out
+#endif
+
+uniform mat4 mgl_PMatrix;
+uniform mat4 mgl_MVMatrix[NO_OF_INSTANCE];
+attribute vec3 mgl_Vertex;
+attribute vec4 mgl_Color;
+varying vec4 frontColor;
+
+void main(void) {
+ frontColor = mgl_Color;
+ gl_Position = mgl_PMatrix * mgl_MVMatrix[gl_InstanceID] * vec4(mgl_Vertex, 1);
+}
--
cgit v1.2.3
From 2ba049d30d7c9e112c3bb2feb7c98c9666aaa3bf Mon Sep 17 00:00:00 2001
From: Julien Gouesse
Date: Thu, 23 Oct 2014 13:34:57 +0200
Subject: Skips ARB_create_context with ATI Radeon 3100 (see the bug 1038)
---
.../com/jogamp/opengl/GLRendererQuirks.java | 28 ++++++++++++++++++++--
src/jogl/classes/jogamp/opengl/GLContextImpl.java | 11 +++++++++
.../opengl/windows/wgl/WindowsWGLContext.java | 2 +-
3 files changed, 38 insertions(+), 3 deletions(-)
(limited to 'src')
diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
index 7b5e6b8f1..e4cd5c5d9 100644
--- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
+++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
@@ -394,9 +394,33 @@ public class GLRendererQuirks {
*
*/
public static final int NeedSharedObjectSync = 20;
+
+ /**
+ * No reliable ARB_create_context implementation,
+ * even if driver claims otherwise.
+ *
+ * Some drivers wrongly claim to support ARB_create_context.
+ * However, the creation of such context fails:
+ *
+ * javax.media.opengl.GLException: AWT-EventQueue-0: WindowsWGLContex.createContextImpl ctx !ARB, profile > GL2
+ * requested (OpenGL >= 3.0.1). Requested: GLProfile[GL3bc/GL3bc.hw], current: 2.1 (Compat profile, FBO, hardware)
+ * - 2.1.8787
+ *
+ *
+ *
+ * Appears on:
+ *
+ * - GL_VENDOR ATI Technologies Inc.
+ * - GL_RENDERER ATI Radeon 3100 Graphics
+ * - GL_VERSION 2.1.8787
+ * - Platform Windows
+ *
+ *
+ */
+ public static final int NoARBCreateContext = 21;
/** Return the number of known quirks. */
- public static final int getCount() { return 21; }
+ public static final int getCount() { return 22; }
private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval",
"NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard",
@@ -405,7 +429,7 @@ public class GLRendererQuirks {
"NoFullFBOSupport", "GLSLNonCompliant", "GL4NeedsGL3Request",
"GLSharedContextBuggy", "GLES3ViaEGLES2Config", "SingletonEGLDisplayOnly",
"NoMultiSamplingBuffers", "BuggyColorRenderbuffer", "NoPBufferWithAccum",
- "NeedSharedObjectSync"
+ "NeedSharedObjectSync", "NoARBCreateContext"
};
private static final IdentityHashMap stickyDeviceQuirks = new IdentityHashMap();
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 45a4f2426..06d1c9e3f 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -1851,6 +1851,17 @@ public abstract class GLContextImpl extends GLContext {
}
quirks.addQuirk( quirk );
}
+
+ if ( vendorVersion.compareTo(VersionNumberString.zeroVersion) == 0 ) {
+ final VersionNumber glVersionNumber = new VersionNumber(glVersion);
+ if ( glVersionNumber.getSub() <= 8787 && glRenderer.equals("ATI Radeon 3100 Graphics") ) { // "old" driver -> sub-minor = vendor version
+ final int quirk = GLRendererQuirks.NoARBCreateContext;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", [Vendor "+glVendor+", Renderer "+glRenderer+" and Version "+glVersion+"]");
+ }
+ quirks.addQuirk( quirk );
+ }
+ }
} else if( isDriverIntel && glRenderer.equals("Intel Bear Lake B") ) {
final int quirk = GLRendererQuirks.NoPBufferWithAccum;
if(DEBUG) {
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
index 33980d663..ebd107c47 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
@@ -331,7 +331,7 @@ public class WindowsWGLContext extends GLContextImpl {
isProcCreateContextAttribsARBAvailable = false;
isExtARBCreateContextAvailable = false;
}
- if ( isProcCreateContextAttribsARBAvailable && isExtARBCreateContextAvailable && !GLProfile.disableOpenGLARBContext ) {
+ if ( isProcCreateContextAttribsARBAvailable && isExtARBCreateContextAvailable && !GLProfile.disableOpenGLARBContext && !getRendererQuirks().exist( GLRendererQuirks.NoARBCreateContext ) ) {
// initial ARB context creation
contextHandle = createContextARB(shareWithHandle, true);
createContextARBTried=true;
--
cgit v1.2.3
From 1e039b27aa1c036f663091d1018c3c15b259b80d Mon Sep 17 00:00:00 2001
From: Julien Gouesse
Date: Fri, 24 Oct 2014 13:44:14 +0200
Subject: Fixes the indentation :s
---
src/jogl/classes/jogamp/opengl/GLContextImpl.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'src')
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 06d1c9e3f..a44075e90 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -1854,8 +1854,8 @@ public abstract class GLContextImpl extends GLContext {
if ( vendorVersion.compareTo(VersionNumberString.zeroVersion) == 0 ) {
final VersionNumber glVersionNumber = new VersionNumber(glVersion);
- if ( glVersionNumber.getSub() <= 8787 && glRenderer.equals("ATI Radeon 3100 Graphics") ) { // "old" driver -> sub-minor = vendor version
- final int quirk = GLRendererQuirks.NoARBCreateContext;
+ if ( glVersionNumber.getSub() <= 8787 && glRenderer.equals("ATI Radeon 3100 Graphics") ) { // "old" driver -> sub-minor = vendor version
+ final int quirk = GLRendererQuirks.NoARBCreateContext;
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", [Vendor "+glVendor+", Renderer "+glRenderer+" and Version "+glVersion+"]");
}
--
cgit v1.2.3