aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-03-05 01:23:34 +0000
committerSven Gothel <[email protected]>2009-03-05 01:23:34 +0000
commit6833b2827d31a7bf08e22963b0d44be6470bdf07 (patch)
tree0a4db7776d9a1489d2bec772227a6410eeb62cf6 /src/classes/com/sun
parent8e2154eebe45e2f5fd6b0c6598a26ef16617e425 (diff)
- Fixed rootrel.build usage, this works properly through gluegen, jogl-demos and this build.
You can say -Drootrel.build=build-x86_64 for example. - Fixed jogl-demos in regard to this changeset - Gluegen - Fixed gluegen BuildComposablePipeline's 'getGL*' methods. Now they return 'this', otherwise the pipeline would be broken/removed. - Add BuildComposablePipeline CustomPipeline, which allows customized class composition with an interface (to be wrapped), prolog class and the downstream class. - Add GlueGen (incl. ant task) 'outputRootDir' to be able to set a top output root dir via ant / commandline. - GL fixed function - Package 'javax.media.opengl.sub.fixed.*' defines some fixed function interfaces. This allows partitioning of custom implementation. - Using gluegen's new CustomPipeline to compose a GLFixedFuncIf implementation, using a GL downstream and a GLFixedFuncHookIf prolog. The latter implements the fixed functionality. Example is the GLFixedFuncImpl. gl.getContext().setGL( new GLFixedFuncImpl(gl, new FixedFuncHook(gl.getGL2ES2())) ) ; or gl.getContext().setGL( new GLFixedFuncImpl(gl, gl.getGL2ES1()) ) ; - The example GLFixedFuncHookIf impl FixedFuncPipeline/ can be instantiated with custom shader code. - ES2 and all other interfaces only contain the original functionality, besides minor convenient data access methods. - Fix: GL2ES2 createCompileShader() and createLoadShader() is moved to ShaderCode util class. - Updated PMVMatrix - Add: GLAutoDrawable.setContext() .. and all it's implementations Necessary to set a new GLContext. - Add: GLContext getAttachedObject(int) and putAttachedObject(int, Object), to allow the user to attach application specific and TLS sensitive objects to the GLContext. - git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1856 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun')
-rw-r--r--src/classes/com/sun/javafx/newt/GLWindow.java14
-rw-r--r--src/classes/com/sun/opengl/impl/GLArrayHandler.java1
-rw-r--r--src/classes/com/sun/opengl/impl/GLContextImpl.java8
-rw-r--r--src/classes/com/sun/opengl/impl/GLFixedArrayHandler.java21
-rw-r--r--src/classes/com/sun/opengl/impl/GLPbufferImpl.java4
-rw-r--r--src/classes/com/sun/opengl/impl/GLReflection.java7
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/ProjectFloat.java11
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/GLSLArrayHandler.java10
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/fixed/FixedFuncPipeline.java103
-rw-r--r--src/classes/com/sun/opengl/impl/glu/GLUquadricImpl.java17
-rw-r--r--src/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java16
-rw-r--r--src/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java10
-rw-r--r--src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXContext.java2
-rw-r--r--src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java12
-rw-r--r--src/classes/com/sun/opengl/util/glsl/ShaderCode.java69
-rwxr-xr-xsrc/classes/com/sun/opengl/util/glsl/fixed/FixedFuncHook.java333
16 files changed, 542 insertions, 96 deletions
diff --git a/src/classes/com/sun/javafx/newt/GLWindow.java b/src/classes/com/sun/javafx/newt/GLWindow.java
index c8c707e98..23f959799 100644
--- a/src/classes/com/sun/javafx/newt/GLWindow.java
+++ b/src/classes/com/sun/javafx/newt/GLWindow.java
@@ -338,22 +338,24 @@ public class GLWindow extends Window implements GLAutoDrawable {
return factory;
}
+ public void setContext(GLContext newCtx) {
+ context = newCtx;
+ }
+
public GLContext getContext() {
return context;
}
public GL getGL() {
- GLContext ctx = getContext();
- if (ctx == null) {
+ if (context == null) {
return null;
}
- return ctx.getGL();
+ return context.getGL();
}
public void setGL(GL gl) {
- GLContext ctx = getContext();
- if (ctx != null) {
- ctx.setGL(gl);
+ if (context != null) {
+ context.setGL(gl);
}
}
diff --git a/src/classes/com/sun/opengl/impl/GLArrayHandler.java b/src/classes/com/sun/opengl/impl/GLArrayHandler.java
index bba190835..d34e04b10 100644
--- a/src/classes/com/sun/opengl/impl/GLArrayHandler.java
+++ b/src/classes/com/sun/opengl/impl/GLArrayHandler.java
@@ -2,6 +2,7 @@
package com.sun.opengl.impl;
import javax.media.opengl.*;
+import javax.media.opengl.sub.*;
public interface GLArrayHandler {
diff --git a/src/classes/com/sun/opengl/impl/GLContextImpl.java b/src/classes/com/sun/opengl/impl/GLContextImpl.java
index 02cbd6581..d00afde4d 100644
--- a/src/classes/com/sun/opengl/impl/GLContextImpl.java
+++ b/src/classes/com/sun/opengl/impl/GLContextImpl.java
@@ -48,7 +48,7 @@ import com.sun.gluegen.runtime.opengl.*;
public abstract class GLContextImpl extends GLContext {
protected GLContextLock lock = new GLContextLock();
- protected static final boolean DEBUG = Debug.debug("GLContextImpl");
+ protected static final boolean DEBUG = Debug.debug("GLContext");
protected static final boolean VERBOSE = Debug.verbose();
protected static final boolean NO_FREE = Debug.isPropertyDefined("jogl.GLContext.nofree");
// NOTE: default sense of GLContext optimization disabled in JSR-231
@@ -223,6 +223,12 @@ public abstract class GLContextImpl extends GLContext {
}
public void setGL(GL gl) {
+ if(DEBUG) {
+ String sgl1 = (null!=this.gl)?this.gl.getClass().toString()+", "+this.gl.toString():new String("<null>");
+ String sgl2 = (null!=gl)?gl.getClass().toString()+", "+gl.toString():new String("<null>");
+ Exception e = new Exception("setGL: "+Thread.currentThread()+", "+sgl1+" -> "+sgl2);
+ e.printStackTrace();
+ }
this.gl = gl;
}
diff --git a/src/classes/com/sun/opengl/impl/GLFixedArrayHandler.java b/src/classes/com/sun/opengl/impl/GLFixedArrayHandler.java
index 868385447..b9e2ca613 100644
--- a/src/classes/com/sun/opengl/impl/GLFixedArrayHandler.java
+++ b/src/classes/com/sun/opengl/impl/GLFixedArrayHandler.java
@@ -2,6 +2,8 @@
package com.sun.opengl.impl;
import javax.media.opengl.*;
+import javax.media.opengl.sub.*;
+import javax.media.opengl.sub.fixed.*;
import java.nio.*;
public class GLFixedArrayHandler implements GLArrayHandler {
@@ -11,18 +13,18 @@ public class GLFixedArrayHandler implements GLArrayHandler {
this.ad = ad;
}
- protected final void passArrayPointer(GL gl) {
+ protected final void passArrayPointer(GLPointerIf gl) {
switch(ad.getIndex()) {
- case GL.GL_VERTEX_ARRAY:
+ case GLPointerIf.GL_VERTEX_ARRAY:
gl.glVertexPointer(ad);
break;
- case GL.GL_NORMAL_ARRAY:
+ case GLPointerIf.GL_NORMAL_ARRAY:
gl.glNormalPointer(ad);
break;
- case GL.GL_COLOR_ARRAY:
+ case GLPointerIf.GL_COLOR_ARRAY:
gl.glColorPointer(ad);
break;
- case GL.GL_TEXTURE_COORD_ARRAY:
+ case GLPointerIf.GL_TEXTURE_COORD_ARRAY:
gl.glTexCoordPointer(ad);
break;
default:
@@ -31,8 +33,9 @@ public class GLFixedArrayHandler implements GLArrayHandler {
}
public void enableBuffer(GL gl, boolean enable) {
+ GLPointerIf glp = GLFixedFuncUtil.getGLFixedFuncIf(gl);
if(enable) {
- gl.glEnableClientState(ad.getIndex());
+ glp.glEnableClientState(ad.getIndex());
Buffer buffer = ad.getBuffer();
@@ -46,16 +49,16 @@ public class GLFixedArrayHandler implements GLArrayHandler {
}
ad.setBufferWritten(true);
}
- passArrayPointer(gl);
+ passArrayPointer(glp);
} else if(null!=buffer) {
- passArrayPointer(gl);
+ passArrayPointer(glp);
ad.setBufferWritten(true);
}
} else {
if(ad.isVBO()) {
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
}
- gl.glDisableClientState(ad.getIndex());
+ glp.glDisableClientState(ad.getIndex());
}
}
}
diff --git a/src/classes/com/sun/opengl/impl/GLPbufferImpl.java b/src/classes/com/sun/opengl/impl/GLPbufferImpl.java
index 74fc0fe1a..14c218c45 100644
--- a/src/classes/com/sun/opengl/impl/GLPbufferImpl.java
+++ b/src/classes/com/sun/opengl/impl/GLPbufferImpl.java
@@ -112,6 +112,10 @@ public class GLPbufferImpl implements GLPbuffer {
drawableHelper.removeGLEventListener(listener);
}
+ public void setContext(GLContext ctx) {
+ context=(GLContextImpl)ctx;
+ }
+
public GLContext getContext() {
return context;
}
diff --git a/src/classes/com/sun/opengl/impl/GLReflection.java b/src/classes/com/sun/opengl/impl/GLReflection.java
index 256a9b9af..8c89c50dd 100644
--- a/src/classes/com/sun/opengl/impl/GLReflection.java
+++ b/src/classes/com/sun/opengl/impl/GLReflection.java
@@ -45,7 +45,7 @@ public final class GLReflection {
try {
Class clazz = Class.forName(clazzName);
return null!=clazz;
- } catch (Exception e) { }
+ } catch (Throwable e) { }
return false;
}
@@ -64,7 +64,10 @@ public final class GLReflection {
throw new GLUnsupportedException("Constructor: '" + clazzName + "("+cstrArgTypes+")' not found");
}
return factory;
- } catch (Exception e) {
+ } catch (Throwable e) {
+ if (Debug.debug("GLReflection")) {
+ e.printStackTrace();
+ }
throw new GLUnsupportedException(e);
}
}
diff --git a/src/classes/com/sun/opengl/impl/ProjectFloat.java b/src/classes/com/sun/opengl/impl/ProjectFloat.java
index 309a6bdaf..61c1bd8a1 100755
--- a/src/classes/com/sun/opengl/impl/ProjectFloat.java
+++ b/src/classes/com/sun/opengl/impl/ProjectFloat.java
@@ -118,6 +118,7 @@ import java.nio.*;
import javax.media.opengl.*;
import javax.media.opengl.util.*;
+import javax.media.opengl.sub.fixed.GLMatrixIf;
/**
* ProjectFloat.java
@@ -538,7 +539,7 @@ public class ProjectFloat {
* @param bottom
* @param top
*/
- public void gluOrtho2D(GL gl, float left, float right, float bottom, float top) {
+ public void gluOrtho2D(GLMatrixIf gl, float left, float right, float bottom, float top) {
gl.glOrthof(left, right, bottom, top, -1, 1);
}
@@ -550,7 +551,7 @@ public class ProjectFloat {
* @param zNear
* @param zFar
*/
- public void gluPerspective(GL gl, float fovy, float aspect, float zNear, float zFar) {
+ public void gluPerspective(GLMatrixIf gl, float fovy, float aspect, float zNear, float zFar) {
float sine, cotangent, deltaZ;
float radians = fovy / 2 * (float) Math.PI / 180;
@@ -588,7 +589,7 @@ public class ProjectFloat {
* @param upy
* @param upz
*/
- public void gluLookAt(GL gl,
+ public void gluLookAt(GLMatrixIf gl,
float eyex,
float eyey,
float eyez,
@@ -1001,7 +1002,7 @@ public class ProjectFloat {
* @param deltaY
* @param viewport
*/
- public void gluPickMatrix(GL gl,
+ public void gluPickMatrix(GLMatrixIf gl,
float x,
float y,
float deltaX,
@@ -1029,7 +1030,7 @@ public class ProjectFloat {
* @param viewport
* @param viewport_offset
*/
- public void gluPickMatrix(GL gl,
+ public void gluPickMatrix(GLMatrixIf gl,
float x,
float y,
float deltaX,
diff --git a/src/classes/com/sun/opengl/impl/glsl/GLSLArrayHandler.java b/src/classes/com/sun/opengl/impl/glsl/GLSLArrayHandler.java
index d74298a7c..3edfe43d5 100644
--- a/src/classes/com/sun/opengl/impl/glsl/GLSLArrayHandler.java
+++ b/src/classes/com/sun/opengl/impl/glsl/GLSLArrayHandler.java
@@ -4,6 +4,7 @@ package com.sun.opengl.impl.glsl;
import com.sun.opengl.impl.*;
import javax.media.opengl.*;
+import javax.media.opengl.sub.*;
import com.sun.opengl.util.glsl.ShaderState;
import java.nio.*;
@@ -19,6 +20,9 @@ public class GLSLArrayHandler implements GLArrayHandler {
}
public void enableBuffer(GL gl, boolean enable) {
+ if(!gl.isGL2ES2()) {
+ throw new GLException("GLSLArrayHandler expects a GL2ES2 implementation");
+ }
GL2ES2 glsl = gl.getGL2ES2();
ShaderState st = ShaderState.getCurrent();
if(null==st) {
@@ -33,10 +37,10 @@ public class GLSLArrayHandler implements GLArrayHandler {
if(ad.isVBO()) {
// always bind and refresh the VBO mgr,
// in case more than one gl*Pointer objects are in use
- gl.glBindBuffer(GL.GL_ARRAY_BUFFER, ad.getVBOName());
+ glsl.glBindBuffer(GL.GL_ARRAY_BUFFER, ad.getVBOName());
if(!ad.isBufferWritten()) {
if(null!=buffer) {
- gl.glBufferData(GL.GL_ARRAY_BUFFER, buffer.limit() * ad.getComponentSize(), buffer, ad.getBufferUsage());
+ glsl.glBufferData(GL.GL_ARRAY_BUFFER, buffer.limit() * ad.getComponentSize(), buffer, ad.getBufferUsage());
}
ad.setBufferWritten(true);
}
@@ -47,7 +51,7 @@ public class GLSLArrayHandler implements GLArrayHandler {
}
} else {
if(ad.isVBO()) {
- gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
+ glsl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
}
st.glDisableVertexAttribArray(glsl, ad.getName());
}
diff --git a/src/classes/com/sun/opengl/impl/glsl/fixed/FixedFuncPipeline.java b/src/classes/com/sun/opengl/impl/glsl/fixed/FixedFuncPipeline.java
index 7cd3d7bbb..c5b85924d 100644
--- a/src/classes/com/sun/opengl/impl/glsl/fixed/FixedFuncPipeline.java
+++ b/src/classes/com/sun/opengl/impl/glsl/fixed/FixedFuncPipeline.java
@@ -3,6 +3,7 @@ package com.sun.opengl.impl.glsl.fixed;
import javax.media.opengl.*;
import javax.media.opengl.util.*;
+import javax.media.opengl.sub.fixed.*;
import com.sun.opengl.util.glsl.*;
import java.nio.*;
@@ -11,7 +12,16 @@ public class FixedFuncPipeline {
public static final int MAX_LIGHTS = 8;
public FixedFuncPipeline(GL2ES2 gl, PMVMatrix pmvMatrix) {
- init(gl, pmvMatrix);
+ init(gl, pmvMatrix, FixedFuncPipeline.class, shaderSrcRootDef, shaderBinRootDef,
+ vertexColorFileDef, vertexColorLightFileDef, fragmentColorFileDef, fragmentColorTextureFileDef);
+ }
+ public FixedFuncPipeline(GL2ES2 gl, PMVMatrix pmvMatrix, Class shaderRootClass, String shaderSrcRoot, String shaderBinRoot,
+ String vertexColorFile,
+ String vertexColorLightFile,
+ String fragmentColorFile,
+ String fragmentColorTextureFile) {
+ init(gl, pmvMatrix, shaderRootClass, shaderSrcRoot, shaderBinRoot,
+ vertexColorFile, vertexColorLightFile, fragmentColorFile, fragmentColorTextureFile);
}
public boolean verbose() { return verbose; }
@@ -33,11 +43,11 @@ public class FixedFuncPipeline {
public String getArrayIndexName(int glArrayIndex) {
String name = GLContext.getPredefinedArrayIndexName(glArrayIndex);
switch(glArrayIndex) {
- case GL.GL_VERTEX_ARRAY:
- case GL.GL_NORMAL_ARRAY:
- case GL.GL_COLOR_ARRAY:
+ case GLPointerIf.GL_VERTEX_ARRAY:
+ case GLPointerIf.GL_NORMAL_ARRAY:
+ case GLPointerIf.GL_COLOR_ARRAY:
break;
- case GL.GL_TEXTURE_COORD_ARRAY:
+ case GLPointerIf.GL_TEXTURE_COORD_ARRAY:
name = name + activeTextureUnit;
}
return name;
@@ -105,38 +115,38 @@ public class FixedFuncPipeline {
public void glLightfv(GL2ES2 gl, int light, int pname, java.nio.FloatBuffer params) {
shaderState.glUseProgram(gl, true);
- light -=GL.GL_LIGHT0;
+ light -=GLLightingIf.GL_LIGHT0;
if(0 <= light && light < MAX_LIGHTS) {
GLUniformData ud = null;
switch(pname) {
- case GL.GL_AMBIENT:
+ case GLLightingIf.GL_AMBIENT:
ud = shaderState.getUniform(mgl_LightSource+"["+light+"].ambient");
break;
- case GL.GL_DIFFUSE:
+ case GLLightingIf.GL_DIFFUSE:
ud = shaderState.getUniform(mgl_LightSource+"["+light+"].diffuse");
break;
- case GL.GL_SPECULAR:
+ case GLLightingIf.GL_SPECULAR:
ud = shaderState.getUniform(mgl_LightSource+"["+light+"].specular");
break;
- case GL.GL_POSITION:
+ case GLLightingIf.GL_POSITION:
ud = shaderState.getUniform(mgl_LightSource+"["+light+"].position");
break;
- case GL.GL_SPOT_DIRECTION:
+ case GLLightingIf.GL_SPOT_DIRECTION:
ud = shaderState.getUniform(mgl_LightSource+"["+light+"].spotDirection");
break;
- case GL.GL_SPOT_EXPONENT:
+ case GLLightingIf.GL_SPOT_EXPONENT:
ud = shaderState.getUniform(mgl_LightSource+"["+light+"].spotExponent");
break;
- case GL.GL_SPOT_CUTOFF:
+ case GLLightingIf.GL_SPOT_CUTOFF:
ud = shaderState.getUniform(mgl_LightSource+"["+light+"].spotCutoff");
break;
- case GL.GL_CONSTANT_ATTENUATION:
+ case GLLightingIf.GL_CONSTANT_ATTENUATION:
ud = shaderState.getUniform(mgl_LightSource+"["+light+"].constantAttenuation");
break;
- case GL.GL_LINEAR_ATTENUATION:
+ case GLLightingIf.GL_LINEAR_ATTENUATION:
ud = shaderState.getUniform(mgl_LightSource+"["+light+"].linearAttenuation");
break;
- case GL.GL_QUADRATIC_ATTENUATION:
+ case GLLightingIf.GL_QUADRATIC_ATTENUATION:
ud = shaderState.getUniform(mgl_LightSource+"["+light+"].quadraticAttenuation");
break;
default:
@@ -171,22 +181,22 @@ public class FixedFuncPipeline {
GLUniformData ud = null;
switch(pname) {
- case GL.GL_AMBIENT:
+ case GLLightingIf.GL_AMBIENT:
ud = shaderState.getUniform(mgl_FrontMaterial+".ambient");
break;
- case GL.GL_AMBIENT_AND_DIFFUSE:
- glMaterialfv(gl, face, GL.GL_AMBIENT, params);
+ case GLLightingIf.GL_AMBIENT_AND_DIFFUSE:
+ glMaterialfv(gl, face, GLLightingIf.GL_AMBIENT, params);
// fall through intended ..
- case GL.GL_DIFFUSE:
+ case GLLightingIf.GL_DIFFUSE:
ud = shaderState.getUniform(mgl_FrontMaterial+".diffuse");
break;
- case GL.GL_SPECULAR:
+ case GLLightingIf.GL_SPECULAR:
ud = shaderState.getUniform(mgl_FrontMaterial+".specular");
break;
- case GL.GL_EMISSION:
+ case GLLightingIf.GL_EMISSION:
ud = shaderState.getUniform(mgl_FrontMaterial+".emission");
break;
- case GL.GL_SHININESS:
+ case GLLightingIf.GL_SHININESS:
ud = shaderState.getUniform(mgl_FrontMaterial+".shininess");
break;
default:
@@ -231,30 +241,36 @@ public class FixedFuncPipeline {
}
}
- public void glEnable(GL2ES2 gl, int cap, boolean enable) {
+ /**
+ * @return false if digested in regard to GL2ES2 spec,
+ * eg this call must not be passed to an underlying ES2 implementation.
+ * true if this call shall be passed to an underlying GL2ES2/ES2 implementation as well.
+ */
+ public boolean glEnable(GL2ES2 gl, int cap, boolean enable) {
switch(cap) {
case GL.GL_TEXTURE_2D:
textureEnabled=enable;
- return;
- case GL.GL_LIGHTING:
+ return true;
+ case GLLightingIf.GL_LIGHTING:
lightingEnabled=enable;
- return;
+ return false;
case GL.GL_CULL_FACE:
cullFace=Math.abs(cullFace);
if(!enable) {
cullFace*=-1;
}
- return;
+ return true;
}
- int light = cap - GL.GL_LIGHT0;
+ int light = cap - GLLightingIf.GL_LIGHT0;
if(0 <= light && light < MAX_LIGHTS) {
if ( (lightsEnabled.get(light)==1) != enable ) {
lightsEnabled.put(light, enable?1:0);
lightsEnabledDirty = true;
- return;
+ return false;
}
}
+ return true; // pass it on ..
}
public void glCullFace(GL2ES2 gl, int faceName) {
@@ -355,7 +371,12 @@ public class FixedFuncPipeline {
"]";
}
- protected void init(GL2ES2 gl, PMVMatrix pmvMatrix) {
+ protected void init(GL2ES2 gl, PMVMatrix pmvMatrix, Class shaderRootClass, String shaderSrcRoot, String shaderBinRoot,
+ String vertexColorFile,
+ String vertexColorLightFile,
+ String fragmentColorFile,
+ String fragmentColorTextureFile)
+ {
if(null==pmvMatrix) {
throw new GLException("PMVMatrix is null");
}
@@ -364,16 +385,16 @@ public class FixedFuncPipeline {
this.shaderState.setVerbose(verbose);
ShaderCode vertexColor, vertexColorLight, fragmentColor, fragmentColorTexture;
- vertexColor = ShaderCode.create( gl, gl.GL_VERTEX_SHADER, 1, FixedFuncPipeline.class,
+ vertexColor = ShaderCode.create( gl, gl.GL_VERTEX_SHADER, 1, shaderRootClass,
shaderSrcRoot, shaderBinRoot, vertexColorFile);
- vertexColorLight = ShaderCode.create( gl, gl.GL_VERTEX_SHADER, 1, FixedFuncPipeline.class,
+ vertexColorLight = ShaderCode.create( gl, gl.GL_VERTEX_SHADER, 1, shaderRootClass,
shaderSrcRoot, shaderBinRoot, vertexColorLightFile);
- fragmentColor = ShaderCode.create( gl, gl.GL_FRAGMENT_SHADER, 1, FixedFuncPipeline.class,
+ fragmentColor = ShaderCode.create( gl, gl.GL_FRAGMENT_SHADER, 1, shaderRootClass,
shaderSrcRoot, shaderBinRoot, fragmentColorFile);
- fragmentColorTexture = ShaderCode.create( gl, gl.GL_FRAGMENT_SHADER, 1, FixedFuncPipeline.class,
+ fragmentColorTexture = ShaderCode.create( gl, gl.GL_FRAGMENT_SHADER, 1, shaderRootClass,
shaderSrcRoot, shaderBinRoot, fragmentColorTextureFile);
shaderProgramColor = new ShaderProgram();
@@ -502,11 +523,11 @@ public class FixedFuncPipeline {
public static final FloatBuffer defMatEmission= BufferUtil.newFloatBuffer(new float[] { 0f, 0f, 0f, 1f});
public static final float defMatShininess = 0f;
- protected static final String vertexColorFile = "FixedFuncColor";
- protected static final String vertexColorLightFile = "FixedFuncColorLight";
- protected static final String fragmentColorFile = "FixedFuncColor";
- protected static final String fragmentColorTextureFile = "FixedFuncColorTexture";
- protected static final String shaderSrcRoot = "shader" ;
- protected static final String shaderBinRoot = "shader/bin" ;
+ protected static final String vertexColorFileDef = "FixedFuncColor";
+ protected static final String vertexColorLightFileDef = "FixedFuncColorLight";
+ protected static final String fragmentColorFileDef = "FixedFuncColor";
+ protected static final String fragmentColorTextureFileDef = "FixedFuncColorTexture";
+ protected static final String shaderSrcRootDef = "shader" ;
+ protected static final String shaderBinRootDef = "shader/bin" ;
}
diff --git a/src/classes/com/sun/opengl/impl/glu/GLUquadricImpl.java b/src/classes/com/sun/opengl/impl/glu/GLUquadricImpl.java
index e8d039d1e..218f904b3 100644
--- a/src/classes/com/sun/opengl/impl/glu/GLUquadricImpl.java
+++ b/src/classes/com/sun/opengl/impl/glu/GLUquadricImpl.java
@@ -117,6 +117,7 @@ package com.sun.opengl.impl.glu;
import javax.media.opengl.util.ImmModeSink;
import javax.media.opengl.*;
+import javax.media.opengl.sub.*;
import javax.media.opengl.glu.*;
import java.nio.*;
@@ -1110,7 +1111,7 @@ public class GLUquadricImpl implements GLUquadric {
if(immModeSinkEnabled) {
immModeSink.glBegin(mode);
} else {
- ((GL2)gl).glBegin(mode);
+ gl.getGL2().glBegin(mode);
}
}
@@ -1118,7 +1119,7 @@ public class GLUquadricImpl implements GLUquadric {
if(immModeSinkEnabled) {
immModeSink.glEnd(gl, immModeSinkImmediate);
} else {
- ((GL2)gl).glEnd();
+ gl.getGL2().glEnd();
}
}
@@ -1126,7 +1127,7 @@ public class GLUquadricImpl implements GLUquadric {
if(immModeSinkEnabled) {
immModeSink.glVertex2f(x, y);
} else {
- ((GL2)gl).glVertex2f(x, y);
+ gl.getGL2().glVertex2f(x, y);
}
}
@@ -1134,7 +1135,7 @@ public class GLUquadricImpl implements GLUquadric {
if(immModeSinkEnabled) {
immModeSink.glVertex3f(x, y, z);
} else {
- ((GL2)gl).glVertex3f(x, y, z);
+ gl.getGL2().glVertex3f(x, y, z);
}
}
@@ -1145,7 +1146,7 @@ public class GLUquadricImpl implements GLUquadric {
if(immModeSinkEnabled) {
immModeSink.glNormal3s(a, b, c);
} else {
- ((GL2)gl).glNormal3s(a, b, c);
+ gl.getGL2().glNormal3s(a, b, c);
}
}
@@ -1156,7 +1157,7 @@ public class GLUquadricImpl implements GLUquadric {
if(immModeSinkEnabled) {
immModeSink.glNormal3b(a, b, c);
} else {
- ((GL2)gl).glNormal3b(a, b, c);
+ gl.getGL2().glNormal3b(a, b, c);
}
}
@@ -1166,7 +1167,7 @@ public class GLUquadricImpl implements GLUquadric {
if(immModeSinkEnabled) {
immModeSink.glNormal3f(x,y,z);
} else {
- ((GL2)gl).glNormal3f(x,y,z);
+ gl.getGL2().glNormal3f(x,y,z);
}
break;
case GL.GL_SHORT:
@@ -1182,7 +1183,7 @@ public class GLUquadricImpl implements GLUquadric {
if(immModeSinkEnabled) {
immModeSink.glTexCoord2f(x, y);
} else {
- ((GL2)gl).glTexCoord2f(x, y);
+ gl.getGL2().glTexCoord2f(x, y);
}
}
diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index d99b237e5..9ee93793a 100644
--- a/src/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -278,11 +278,11 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
int[] res = new int[MAX_ATTRIBS];
int idx = 0;
if (pbuffer) {
- res[idx++] = GLXExt.GLX_DRAWABLE_TYPE;
- res[idx++] = GLXExt.GLX_PBUFFER_BIT;
+ res[idx++] = GLX.GLX_DRAWABLE_TYPE;
+ res[idx++] = GLX.GLX_PBUFFER_BIT;
- res[idx++] = GLXExt.GLX_RENDER_TYPE;
- res[idx++] = GLXExt.GLX_RGBA_BIT;
+ res[idx++] = GLX.GLX_RENDER_TYPE;
+ res[idx++] = GLX.GLX_RGBA_BIT;
} else {
res[idx++] = GLX.GLX_RGBA;
}
@@ -334,9 +334,9 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
res[idx++] = caps.getAccumAlphaBits();
}
if (isMultisampleAvailable && caps.getSampleBuffers()) {
- res[idx++] = GLXExt.GLX_SAMPLE_BUFFERS;
+ res[idx++] = GLX.GLX_SAMPLE_BUFFERS;
res[idx++] = GL.GL_TRUE;
- res[idx++] = GLXExt.GLX_SAMPLES;
+ res[idx++] = GLX.GLX_SAMPLES;
res[idx++] = caps.getNumSamples();
}
if (pbuffer) {
@@ -411,11 +411,11 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
caps.setAccumAlphaBits(ivalues[i]);
break;
- case GLXExt.GLX_SAMPLE_BUFFERS:
+ case GLX.GLX_SAMPLE_BUFFERS:
caps.setSampleBuffers(ivalues[i] != GL.GL_FALSE);
break;
- case GLXExt.GLX_SAMPLES:
+ case GLX.GLX_SAMPLES:
caps.setNumSamples(ivalues[i]);
break;
diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java b/src/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
index 23835f21b..ac228b68a 100644
--- a/src/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
+++ b/src/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
@@ -81,4 +81,14 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable {
protected void setChosenGLCapabilities(GLCapabilities caps) {
super.setChosenGLCapabilities(caps);
}
+
+ public void setRealized(boolean realized) {
+ if (realized) {
+ X11GLXDrawableFactory factory = (X11GLXDrawableFactory) getFactory();
+ NativeWindow window = getNativeWindow();
+ setChosenGLCapabilities(factory.lookupCapabilitiesByScreenAndVisualID(window.getScreenIndex(),
+ window.getVisualID()));
+ }
+ super.setRealized(realized);
+ }
}
diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXContext.java b/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXContext.java
index 377d92f98..a32ee99d7 100644
--- a/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXContext.java
+++ b/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXContext.java
@@ -83,7 +83,7 @@ public class X11PbufferGLXContext extends X11GLXContext {
}
}
context = GLX.glXCreateNewContext(drawable.getNativeWindow().getDisplayHandle(),
- drawable.getFBConfig(), GLXExt.GLX_RGBA_TYPE, share, true);
+ drawable.getFBConfig(), GLX.GLX_RGBA_TYPE, share, true);
if (context == 0) {
throw new GLException("pbuffer creation error: glXCreateNewContext() failed");
}
diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java b/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
index 390ca96a4..d720fe7e8 100644
--- a/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
+++ b/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
@@ -149,9 +149,9 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
// Create the p-buffer.
int niattribs = 0;
- iattributes[niattribs++] = GLXExt.GLX_PBUFFER_WIDTH;
+ iattributes[niattribs++] = GLX.GLX_PBUFFER_WIDTH;
iattributes[niattribs++] = nw.getWidth();
- iattributes[niattribs++] = GLXExt.GLX_PBUFFER_HEIGHT;
+ iattributes[niattribs++] = GLX.GLX_PBUFFER_HEIGHT;
iattributes[niattribs++] = nw.getHeight();
iattributes[niattribs++] = 0;
@@ -167,8 +167,8 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
this.fbConfig = fbConfig;
// Pick innocent query values if multisampling or floating point buffers not available
- int sbAttrib = X11Util.isMultisampleAvailable() ? GLXExt.GLX_SAMPLE_BUFFERS: GLX.GLX_RED_SIZE;
- int samplesAttrib = X11Util.isMultisampleAvailable() ? GLXExt.GLX_SAMPLES: GLX.GLX_RED_SIZE;
+ int sbAttrib = X11Util.isMultisampleAvailable() ? GLX.GLX_SAMPLE_BUFFERS: GLX.GLX_RED_SIZE;
+ int samplesAttrib = X11Util.isMultisampleAvailable() ? GLX.GLX_SAMPLES: GLX.GLX_RED_SIZE;
int floatNV = capabilities.getPbufferFloatingPointBuffers() ? GLXExt.GLX_FLOAT_COMPONENTS_NV : GLX.GLX_RED_SIZE;
// Query the fbconfig to determine its GLCapabilities
@@ -196,9 +196,9 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
// Determine the actual width and height we were able to create.
int[] tmp = new int[1];
- GLX.glXQueryDrawable(display, drawable, GLXExt.GLX_WIDTH, tmp, 0);
+ GLX.glXQueryDrawable(display, drawable, GLX.GLX_WIDTH, tmp, 0);
int width = tmp[0];
- GLX.glXQueryDrawable(display, drawable, GLXExt.GLX_HEIGHT, tmp, 0);
+ GLX.glXQueryDrawable(display, drawable, GLX.GLX_HEIGHT, tmp, 0);
int height = tmp[0];
nw.setSize(width, height);
diff --git a/src/classes/com/sun/opengl/util/glsl/ShaderCode.java b/src/classes/com/sun/opengl/util/glsl/ShaderCode.java
index 8addf339c..288ef760b 100644
--- a/src/classes/com/sun/opengl/util/glsl/ShaderCode.java
+++ b/src/classes/com/sun/opengl/util/glsl/ShaderCode.java
@@ -51,7 +51,9 @@ public class ShaderCode {
id = getNextID();
}
- public static ShaderCode create(int type, int number, Class context, String[] sourceFiles) {
+ public static ShaderCode create(GL2ES2 gl, int type, int number, Class context, String[] sourceFiles) {
+ if(!gl.glShaderCompilerAvailable()) return null;
+
String[][] shaderSources = null;
if(null!=sourceFiles) {
shaderSources = new String[sourceFiles.length][1];
@@ -112,7 +114,7 @@ public class ShaderCode {
String srcPath[] = new String[1];
srcFileName = srcRoot + '/' + basename + "." + getFileSuffix(false, type);
srcPath[0] = srcFileName;
- res = create(type, number, context, srcPath);
+ res = create(gl, type, number, context, srcPath);
if(null!=res) {
return res;
}
@@ -134,6 +136,61 @@ public class ShaderCode {
return res;
}
+ public static boolean createAndLoadShader(GL2ES2 gl, IntBuffer shader, int shaderType,
+ int binFormat, java.nio.Buffer bin,
+ PrintStream verboseOut)
+ {
+ int err = gl.glGetError(); // flush previous errors ..
+ if(err!=GL.GL_NO_ERROR && null!=verboseOut) {
+ verboseOut.println("createAndLoadShader: Pre GL Error: 0x"+Integer.toHexString(err));
+ }
+
+ gl.glCreateShader(shaderType, shader);
+ err = gl.glGetError();
+ if(err!=GL.GL_NO_ERROR) {
+ throw new GLException("createAndLoadShader: CreateShader failed, GL Error: 0x"+Integer.toHexString(err));
+ }
+
+
+ gl.glShaderBinary(shader, binFormat, bin);
+
+ err = gl.glGetError();
+ if(err!=GL.GL_NO_ERROR && null!=verboseOut) {
+ verboseOut.println("createAndLoadShader: ShaderBinary failed, GL Error: 0x"+Integer.toHexString(err));
+ }
+ return err == GL.GL_NO_ERROR;
+ }
+
+ public static boolean createAndCompileShader(GL2ES2 gl, IntBuffer shader, int shaderType,
+ java.lang.String[][] sources,
+ PrintStream verboseOut)
+ {
+ int err = gl.glGetError(); // flush previous errors ..
+ if(err!=GL.GL_NO_ERROR && null!=verboseOut) {
+ verboseOut.println("createAndCompileShader: Pre GL Error: 0x"+Integer.toHexString(err));
+ }
+
+ gl.glCreateShader(shaderType, shader);
+ err = gl.glGetError();
+ if(err!=GL.GL_NO_ERROR) {
+ throw new GLException("createAndCompileShader: CreateShader failed, GL Error: 0x"+Integer.toHexString(err));
+ }
+
+ gl.glShaderSource(shader, sources);
+ err = gl.glGetError();
+ if(err!=GL.GL_NO_ERROR) {
+ throw new GLException("createAndCompileShader: ShaderSource failed, GL Error: 0x"+Integer.toHexString(err));
+ }
+
+ gl.glCompileShader(shader);
+ err = gl.glGetError();
+ if(err!=GL.GL_NO_ERROR && null!=verboseOut) {
+ verboseOut.println("createAndCompileShader: CompileShader failed, GL Error: 0x"+Integer.toHexString(err));
+ }
+
+ return gl.glIsShaderStatusValid(shader, gl.GL_COMPILE_STATUS, verboseOut) && err == GL.GL_NO_ERROR;
+ }
+
/**
* returns the uniq shader id as an integer
* @see #key()
@@ -176,11 +233,11 @@ public class ShaderCode {
// Create & Compile the vertex/fragment shader objects
if(null!=shaderSource) {
- valid=gl.glCreateCompileShader(shader, shaderType,
- shaderSource, verboseOut);
+ valid=createAndCompileShader(gl, shader, shaderType,
+ shaderSource, verboseOut);
} else if(null!=shaderBinary) {
- valid=gl.glCreateLoadShader(shader, shaderType,
- shaderBinaryFormat, shaderBinary, verboseOut);
+ valid=createAndLoadShader(gl, shader, shaderType,
+ shaderBinaryFormat, shaderBinary, verboseOut);
} else {
throw new GLException("no code (source or binary)");
}
diff --git a/src/classes/com/sun/opengl/util/glsl/fixed/FixedFuncHook.java b/src/classes/com/sun/opengl/util/glsl/fixed/FixedFuncHook.java
new file mode 100755
index 000000000..d4b3be046
--- /dev/null
+++ b/src/classes/com/sun/opengl/util/glsl/fixed/FixedFuncHook.java
@@ -0,0 +1,333 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ */
+
+package com.sun.opengl.util.glsl.fixed;
+
+import javax.media.opengl.*;
+import javax.media.opengl.sub.*;
+import javax.media.opengl.sub.fixed.*;
+import javax.media.opengl.util.*;
+import javax.media.opengl.glu.*;
+import com.sun.gluegen.runtime.BufferFactory;
+import com.sun.opengl.util.glsl.*;
+import com.sun.opengl.impl.glsl.fixed.*;
+import java.nio.*;
+
+public class FixedFuncHook implements GLFixedFuncHookIf {
+ public static final int MAX_TEXTURE_UNITS = 8;
+
+ protected FixedFuncPipeline fixedFunction=null;
+ protected PMVMatrix pmvMatrix=null;
+ protected GL2ES2 gl=null;
+
+ public FixedFuncHook (GL2ES2 gl) {
+ this(gl, null);
+ }
+
+ public FixedFuncHook (GL2ES2 gl, PMVMatrix matrix) {
+ this.gl = gl;
+ pmvMatrix = (null!=matrix)?matrix:new PMVMatrix();
+
+ fixedFunction = new FixedFuncPipeline(gl, pmvMatrix);
+ }
+
+ public FixedFuncHook(GL2ES2 gl, PMVMatrix matrix,
+ Class shaderRootClass, String shaderSrcRoot, String shaderBinRoot,
+ String vertexColorFile,
+ String vertexColorLightFile,
+ String fragmentColorFile,
+ String fragmentColorTextureFile) {
+ this.gl = gl;
+ pmvMatrix = matrix;
+
+ fixedFunction = new FixedFuncPipeline(gl, pmvMatrix,
+ shaderRootClass, shaderSrcRoot, shaderBinRoot,
+ vertexColorFile, vertexColorLightFile, fragmentColorFile, fragmentColorTextureFile);
+ }
+
+ public void dispose() {
+ fixedFunction.release(gl);
+ fixedFunction = null;
+ }
+
+ public PMVMatrix getMatrix() { return pmvMatrix; }
+
+ //
+ // FixedFuncHookIf - hooks
+ //
+ public void glDrawArrays(int mode, int first, int count) {
+ fixedFunction.validate(gl);
+ gl.glDrawArrays(mode, first, count);
+ }
+ public void glDrawElements(int mode, int count, int type, java.nio.Buffer indices) {
+ fixedFunction.validate(gl);
+ gl.glDrawElements(mode, count, type, indices);
+ }
+ public void glDrawElements(int mode, int count, int type, long indices_buffer_offset) {
+ fixedFunction.validate(gl);
+ gl.glDrawElements(mode, count, type, indices_buffer_offset);
+ }
+
+ public void glActiveTexture(int texture) {
+ fixedFunction.glActiveTexture(gl, texture);
+ gl.glActiveTexture(texture);
+ }
+ public void glEnable(int cap) {
+ if(fixedFunction.glEnable(gl, cap, true)) {
+ gl.glEnable(cap);
+ }
+ }
+ public void glDisable(int cap) {
+ if(fixedFunction.glEnable(gl, cap, false)) {
+ gl.glDisable(cap);
+ }
+ }
+ public void glCullFace(int faceName) {
+ fixedFunction.glCullFace(gl, faceName);
+ gl.glCullFace(faceName);
+ }
+
+ public void glGetFloatv(int pname, java.nio.FloatBuffer params) {
+ if(pmvMatrix.isMatrixGetName(pname)) {
+ pmvMatrix.glGetFloatv(pname, params);
+ return;
+ }
+ gl.glGetFloatv(pname, params);
+ }
+ public void glGetFloatv(int pname, float[] params, int params_offset) {
+ if(pmvMatrix.isMatrixGetName(pname)) {
+ pmvMatrix.glGetFloatv(pname, params, params_offset);
+ return;
+ }
+ gl.glGetFloatv(pname, params, params_offset);
+ }
+ public void glGetIntegerv(int pname, IntBuffer params) {
+ if(pmvMatrix.isMatrixGetName(pname)) {
+ pmvMatrix.glGetIntegerv(pname, params);
+ return;
+ }
+ gl.glGetIntegerv(pname, params);
+ }
+ public void glGetIntegerv(int pname, int[] params, int params_offset) {
+ if(pmvMatrix.isMatrixGetName(pname)) {
+ pmvMatrix.glGetIntegerv(pname, params, params_offset);
+ return;
+ }
+ gl.glGetIntegerv(pname, params, params_offset);
+ }
+
+ //
+ // MatrixIf
+ //
+ public int glGetMatrixMode() {
+ return pmvMatrix.glGetMatrixMode();
+ }
+ public void glMatrixMode(int mode) {
+ pmvMatrix.glMatrixMode(mode);
+ }
+ public void glLoadMatrixf(java.nio.FloatBuffer m) {
+ pmvMatrix.glLoadMatrixf(m);
+ }
+ public void glLoadMatrixf(float[] m, int m_offset) {
+ glLoadMatrixf(BufferUtil.newFloatBuffer(m, m_offset));
+ }
+ public void glPopMatrix() {
+ pmvMatrix.glPopMatrix();
+ }
+ public void glPushMatrix() {
+ pmvMatrix.glPushMatrix();
+ }
+ public void glLoadIdentity() {
+ pmvMatrix.glLoadIdentity();
+ }
+ public void glMultMatrixf(java.nio.FloatBuffer m) {
+ pmvMatrix.glMultMatrixf(m);
+ }
+ public void glMultMatrixf(float[] m, int m_offset) {
+ glMultMatrixf(BufferUtil.newFloatBuffer(m, m_offset));
+ }
+ public void glTranslatef(float x, float y, float z) {
+ pmvMatrix.glTranslatef(x, y, z);
+ }
+ public void glRotatef(float angdeg, float x, float y, float z) {
+ pmvMatrix.glRotatef(angdeg, x, y, z);
+ }
+ public void glScalef(float x, float y, float z) {
+ pmvMatrix.glScalef(x, y, z);
+ }
+ public void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar) {
+ pmvMatrix.glOrthof(left, right, bottom, top, zNear, zFar);
+ }
+ public void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar) {
+ pmvMatrix.glFrustumf(left, right, bottom, top, zNear, zFar);
+ }
+
+ //
+ // LightingIf
+ //
+ public void glColor4f(float red, float green, float blue, float alpha) {
+ fixedFunction.glColor4fv(gl, BufferUtil.newFloatBuffer(new float[] { red, green, blue, alpha }));
+ }
+
+ public void glLightfv(int light, int pname, java.nio.FloatBuffer params) {
+ fixedFunction.glLightfv(gl, light, pname, params);
+ }
+ public void glLightfv(int light, int pname, float[] params, int params_offset) {
+ glLightfv(light, pname, BufferUtil.newFloatBuffer(params, params_offset));
+ }
+ public void glMaterialfv(int face, int pname, java.nio.FloatBuffer params) {
+ fixedFunction.glMaterialfv(gl, face, pname, params);
+ }
+ public void glMaterialfv(int face, int pname, float[] params, int params_offset) {
+ glMaterialfv(face, pname, BufferUtil.newFloatBuffer(params, params_offset));
+ }
+ public void glMaterialf(int face, int pname, float param) {
+ glMaterialfv(face, pname, BufferUtil.newFloatBuffer(new float[] { param }));
+ }
+ public void glShadeModel(int mode) {
+ fixedFunction.glShadeModel(gl, mode);
+ }
+
+ //
+ // PointerIf
+ //
+ public void glEnableClientState(int glArrayIndex) {
+ fixedFunction.glEnableClientState(gl, glArrayIndex);
+ }
+ public void glDisableClientState(int glArrayIndex) {
+ fixedFunction.glDisableClientState(gl, glArrayIndex);
+ }
+
+ public void glVertexPointer(GLArrayData array) {
+ if(array.isVBO()) {
+ if(!gl.glIsVBOArrayEnabled()) {
+ throw new GLException("VBO array is not enabled: "+array);
+ }
+ } else {
+ if(gl.glIsVBOArrayEnabled()) {
+ throw new GLException("VBO array is not disabled: "+array);
+ }
+ BufferFactory.rangeCheck(array.getBuffer(), 1);
+ if (!BufferFactory.isDirect(array.getBuffer())) {
+ throw new GLException("Argument \"pointer\" was not a direct buffer"); }
+ }
+ fixedFunction.glVertexPointer(gl, array);
+ }
+
+ public void glVertexPointer(int size, int type, int stride, java.nio.Buffer pointer) {
+ glVertexPointer(GLArrayDataWrapper.createFixed(GL_VERTEX_ARRAY, size, type, false, stride, pointer, 0, 0));
+ }
+ public void glVertexPointer(int size, int type, int stride, long pointer_buffer_offset) {
+ int vboName = gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER);
+ if(vboName==0) {
+ throw new GLException("no GL_ARRAY_BUFFER VBO bound");
+ }
+ glVertexPointer(GLArrayDataWrapper.createFixed(GL_VERTEX_ARRAY, size, type, false,
+ stride, null, vboName, pointer_buffer_offset));
+ }
+
+ public void glColorPointer(GLArrayData array) {
+ if(array.isVBO()) {
+ if(!gl.glIsVBOArrayEnabled()) {
+ throw new GLException("VBO array is not enabled: "+array);
+ }
+ } else {
+ if(gl.glIsVBOArrayEnabled()) {
+ throw new GLException("VBO array is not disabled: "+array);
+ }
+ BufferFactory.rangeCheck(array.getBuffer(), 1);
+ if (!BufferFactory.isDirect(array.getBuffer())) {
+ throw new GLException("Argument \"pointer\" was not a direct buffer"); }
+ }
+ fixedFunction.glColorPointer(gl, array);
+ }
+ public void glColorPointer(int size, int type, int stride, java.nio.Buffer pointer) {
+ glColorPointer(GLArrayDataWrapper.createFixed(GL_COLOR_ARRAY, size, type, false,
+ stride, pointer, 0, 0));
+ }
+ public void glColorPointer(int size, int type, int stride, long pointer_buffer_offset) {
+ int vboName = gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER);
+ if(vboName==0) {
+ throw new GLException("no GL_ARRAY_BUFFER VBO bound");
+ }
+ glColorPointer(GLArrayDataWrapper.createFixed(GL_COLOR_ARRAY, size, type, false,
+ stride, null, vboName, pointer_buffer_offset));
+ }
+
+ public void glNormalPointer(GLArrayData array) {
+ if(array.getComponentNumber()!=3) {
+ throw new GLException("Only 3 components per normal allowed");
+ }
+ if(array.isVBO()) {
+ if(!gl.glIsVBOArrayEnabled()) {
+ throw new GLException("VBO array is not enabled: "+array);
+ }
+ } else {
+ if(gl.glIsVBOArrayEnabled()) {
+ throw new GLException("VBO array is not disabled: "+array);
+ }
+ BufferFactory.rangeCheck(array.getBuffer(), 1);
+ if (!BufferFactory.isDirect(array.getBuffer())) {
+ throw new GLException("Argument \"pointer\" was not a direct buffer"); }
+ }
+ fixedFunction.glNormalPointer(gl, array);
+ }
+ public void glNormalPointer(int type, int stride, java.nio.Buffer pointer) {
+ glNormalPointer(GLArrayDataWrapper.createFixed(GL_NORMAL_ARRAY, 3, type, false,
+ stride, pointer, 0, 0));
+ }
+ public void glNormalPointer(int type, int stride, long pointer_buffer_offset) {
+ int vboName = gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER);
+ if(vboName==0) {
+ throw new GLException("no GL_ARRAY_BUFFER VBO bound");
+ }
+ glNormalPointer(GLArrayDataWrapper.createFixed(GL_NORMAL_ARRAY, 3, type, false,
+ stride, null, vboName, pointer_buffer_offset));
+ }
+
+ public void glTexCoordPointer(GLArrayData array) {
+ if(array.isVBO()) {
+ if(!gl.glIsVBOArrayEnabled()) {
+ throw new GLException("VBO array is not enabled: "+array);
+ }
+ } else {
+ if(gl.glIsVBOArrayEnabled()) {
+ throw new GLException("VBO array is not disabled: "+array);
+ }
+ BufferFactory.rangeCheck(array.getBuffer(), 1);
+ if (!BufferFactory.isDirect(array.getBuffer())) {
+ throw new GLException("Argument \"pointer\" was not a direct buffer"); }
+ }
+ fixedFunction.glTexCoordPointer(gl, array);
+ }
+ public void glTexCoordPointer(int size, int type, int stride, java.nio.Buffer pointer) {
+ glTexCoordPointer(
+ GLArrayDataWrapper.createFixed(GL_TEXTURE_COORD_ARRAY, size, type, false, stride, pointer, 0,0));
+ }
+ public void glTexCoordPointer(int size, int type, int stride, long pointer_buffer_offset) {
+ int vboName = gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER);
+ if(vboName==0) {
+ throw new GLException("no GL_ARRAY_BUFFER VBO bound");
+ }
+ glTexCoordPointer(
+ GLArrayDataWrapper.createFixed(GL_TEXTURE_COORD_ARRAY, size, type, false,
+ stride, null, vboName, pointer_buffer_offset) );
+ }
+
+ public final String toString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append(getClass().getName()+" (");
+ if(null!=pmvMatrix) {
+ buf.append(", matrixDirty: "+pmvMatrix.isDirty());
+ }
+ buf.append("\n\t, FixedFunction: "+fixedFunction);
+ buf.append(gl);
+ buf.append(" )");
+
+ return buf.toString();
+ }
+
+}
+
+