From 6833b2827d31a7bf08e22963b0d44be6470bdf07 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 5 Mar 2009 01:23:34 +0000 Subject: - 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 --- src/classes/javax/media/opengl/sub/GLObject.java | 75 +++++++++++++++++++++ .../media/opengl/sub/fixed/GLFixedFuncHookIf.java | 33 ++++++++++ .../media/opengl/sub/fixed/GLFixedFuncIf.java | 18 +++++ .../media/opengl/sub/fixed/GLFixedFuncUtil.java | 50 ++++++++++++++ .../javax/media/opengl/sub/fixed/GLLightingIf.java | 50 ++++++++++++++ .../javax/media/opengl/sub/fixed/GLMatrixIf.java | 77 ++++++++++++++++++++++ .../javax/media/opengl/sub/fixed/GLPointerIf.java | 39 +++++++++++ 7 files changed, 342 insertions(+) create mode 100644 src/classes/javax/media/opengl/sub/GLObject.java create mode 100644 src/classes/javax/media/opengl/sub/fixed/GLFixedFuncHookIf.java create mode 100644 src/classes/javax/media/opengl/sub/fixed/GLFixedFuncIf.java create mode 100644 src/classes/javax/media/opengl/sub/fixed/GLFixedFuncUtil.java create mode 100644 src/classes/javax/media/opengl/sub/fixed/GLLightingIf.java create mode 100644 src/classes/javax/media/opengl/sub/fixed/GLMatrixIf.java create mode 100644 src/classes/javax/media/opengl/sub/fixed/GLPointerIf.java (limited to 'src/classes/javax/media/opengl/sub') diff --git a/src/classes/javax/media/opengl/sub/GLObject.java b/src/classes/javax/media/opengl/sub/GLObject.java new file mode 100644 index 000000000..1426f75d1 --- /dev/null +++ b/src/classes/javax/media/opengl/sub/GLObject.java @@ -0,0 +1,75 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + */ + +package javax.media.opengl.sub; + +import java.nio.*; + +import javax.media.opengl.*; + +/** + * GLObject specifies the GL profile related implementations + * and it's composition with GLContext, which is a lifetime one. + */ +public interface GLObject { + + public boolean isGL(); + + public boolean isGL2(); + + public boolean isGLES1(); + + public boolean isGLES2(); + + public boolean isGLES(); + + public boolean isGL2ES1(); + + public boolean isGL2ES2(); + + /** + * @return This object cast to GL + * @throws GLException is this GLObject is not a GL implementation + */ + public GL getGL() throws GLException; + + /** + * @return This object cast to GL2 + * @throws GLException is this GLObject is not a GL2 implementation + */ + public GL2 getGL2() throws GLException; + + /** + * @return This object cast to GLES1 + * @throws GLException is this GLObject is not a GLES1 implementation + */ + public GLES1 getGLES1() throws GLException; + + /** + * @return This object cast to GLES2 + * @throws GLException is this GLObject is not a GLES2 implementation + */ + public GLES2 getGLES2() throws GLException; + + /** + * @return This object cast to GL2ES1 + * @throws GLException is this GLObject is not a GL2ES1 implementation + */ + public GL2ES1 getGL2ES1() throws GLException; + + /** + * @return This object cast to GL2ES2 + * @throws GLException is this GLObject is not a GL2ES2 implementation + */ + public GL2ES2 getGL2ES2() throws GLException; + + public String toString(); + + /** + * @return This GL object's bound GLContext + */ + public GLContext getContext(); + +} + diff --git a/src/classes/javax/media/opengl/sub/fixed/GLFixedFuncHookIf.java b/src/classes/javax/media/opengl/sub/fixed/GLFixedFuncHookIf.java new file mode 100644 index 000000000..05e0f2ca7 --- /dev/null +++ b/src/classes/javax/media/opengl/sub/fixed/GLFixedFuncHookIf.java @@ -0,0 +1,33 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + */ + +package javax.media.opengl.sub.fixed; + +import java.nio.*; + +import javax.media.opengl.*; +import javax.media.opengl.sub.*; + +/** + * Fixed function implementation hook interface

+ * + * An implementation shall implement the below interface methods + * and pipeline the call to the underlying GL impl. if necessary.

+ * + * An implementation must implement all extended interface methods.

+ */ +public interface GLFixedFuncHookIf extends GLLightingIf, GLMatrixIf, GLPointerIf { + public void glDrawArrays(int mode, int first, int count) ; + public void glDrawElements(int mode, int count, int type, java.nio.Buffer indices) ; + public void glDrawElements(int mode, int count, int type, long indices_buffer_offset) ; + public void glActiveTexture(int texture) ; + public void glEnable(int cap) ; + public void glDisable(int cap) ; + public void glCullFace(int faceName) ; + public void glGetFloatv(int pname, java.nio.FloatBuffer params) ; + public void glGetFloatv(int pname, float[] params, int params_offset) ; + public void glGetIntegerv(int pname, IntBuffer params) ; + public void glGetIntegerv(int pname, int[] params, int params_offset) ; +} + diff --git a/src/classes/javax/media/opengl/sub/fixed/GLFixedFuncIf.java b/src/classes/javax/media/opengl/sub/fixed/GLFixedFuncIf.java new file mode 100644 index 000000000..cc3e299e8 --- /dev/null +++ b/src/classes/javax/media/opengl/sub/fixed/GLFixedFuncIf.java @@ -0,0 +1,18 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + */ + +package javax.media.opengl.sub.fixed; + +import java.nio.*; + +import javax.media.opengl.*; +import javax.media.opengl.sub.*; + +/** + * GL Fixed function module interface + * + */ +public interface GLFixedFuncIf extends GL, GLFixedFuncHookIf, GLLightingIf, GLMatrixIf, GLPointerIf { +} + diff --git a/src/classes/javax/media/opengl/sub/fixed/GLFixedFuncUtil.java b/src/classes/javax/media/opengl/sub/fixed/GLFixedFuncUtil.java new file mode 100644 index 000000000..4c0d1b87f --- /dev/null +++ b/src/classes/javax/media/opengl/sub/fixed/GLFixedFuncUtil.java @@ -0,0 +1,50 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + */ + +package javax.media.opengl.sub.fixed; + +import javax.media.opengl.*; +import javax.media.opengl.sub.*; + +/** + * Contains values to handle the fixed implementation. + */ +public class GLFixedFuncUtil { + + /** + * @return The current GLContext's GL object cast as GLFixedFuncIf + * @throws GLException is this GL Object is not a GLFixedFuncIf implementation, + * or no GLContext is current + */ + public static final GLFixedFuncIf getCurrentGLFixedFuncIf() throws GLException { + GLContext curContext = GLContext.getCurrent(); + if (curContext == null) { + throw new GLException("No OpenGL context current on this thread"); + } + GL gl = curContext.getGL(); + if(gl instanceof GLFixedFuncIf) { + return (GLFixedFuncIf) gl; + } + throw new GLException("Not a GLFixedFuncIf implementation"); + } + + /** + * @return true if GL object is a GLFixedFuncIf + */ + public static final boolean isGLFixedFuncIf(GL gl) { + return (gl instanceof GLFixedFuncIf) ; + } + + /** + * @return The object cast as GLFixedFuncIf + * @throws GLException is this GL Object is not a GLFixedFuncIf implementation + */ + public static final GLFixedFuncIf getGLFixedFuncIf(GL gl) { + if(gl instanceof GLFixedFuncIf) { + return (GLFixedFuncIf) gl; + } + throw new GLException("Not a GLFixedFuncIf implementation"); + } +} + diff --git a/src/classes/javax/media/opengl/sub/fixed/GLLightingIf.java b/src/classes/javax/media/opengl/sub/fixed/GLLightingIf.java new file mode 100644 index 000000000..1f3aa9ab7 --- /dev/null +++ b/src/classes/javax/media/opengl/sub/fixed/GLLightingIf.java @@ -0,0 +1,50 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + */ + +package javax.media.opengl.sub.fixed; + +import java.nio.*; + +import javax.media.opengl.*; +import javax.media.opengl.sub.*; + +public interface GLLightingIf { + public static final int GL_LIGHT0 = 0x4000; + public static final int GL_LIGHT1 = 0x4001; + public static final int GL_LIGHT2 = 0x4002; + public static final int GL_LIGHT3 = 0x4003; + public static final int GL_LIGHT4 = 0x4004; + public static final int GL_LIGHT5 = 0x4005; + public static final int GL_LIGHT6 = 0x4006; + public static final int GL_LIGHT7 = 0x4007; + public static final int GL_LIGHTING = 0xB50; + public static final int GL_AMBIENT = 0x1200; + public static final int GL_DIFFUSE = 0x1201; + public static final int GL_SPECULAR = 0x1202; + public static final int GL_POSITION = 0x1203; + public static final int GL_SPOT_DIRECTION = 0x1204; + public static final int GL_SPOT_EXPONENT = 0x1205; + public static final int GL_SPOT_CUTOFF = 0x1206; + public static final int GL_CONSTANT_ATTENUATION = 0x1207; + public static final int GL_LINEAR_ATTENUATION = 0x1208; + public static final int GL_QUADRATIC_ATTENUATION = 0x1209; + public static final int GL_EMISSION = 0x1600; + public static final int GL_SHININESS = 0x1601; + public static final int GL_AMBIENT_AND_DIFFUSE = 0x1602; + public static final int GL_COLOR_MATERIAL = 0xB57; + public static final int GL_NORMALIZE = 0xBA1; + + public static final int GL_FLAT = 0x1D00; + public static final int GL_SMOOTH = 0x1D01; + + public void glLightfv(int light, int pname, java.nio.FloatBuffer params); + public void glLightfv(int light, int pname, float[] params, int params_offset); + public void glMaterialf(int face, int pname, float param); + public void glMaterialfv(int face, int pname, java.nio.FloatBuffer params); + public void glMaterialfv(int face, int pname, float[] params, int params_offset); + public void glColor4f(float red, float green, float blue, float alpha); + public void glShadeModel(int mode); + +} + diff --git a/src/classes/javax/media/opengl/sub/fixed/GLMatrixIf.java b/src/classes/javax/media/opengl/sub/fixed/GLMatrixIf.java new file mode 100644 index 000000000..834731b98 --- /dev/null +++ b/src/classes/javax/media/opengl/sub/fixed/GLMatrixIf.java @@ -0,0 +1,77 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + */ + +package javax.media.opengl.sub.fixed; + +import java.nio.*; + +import javax.media.opengl.*; +import javax.media.opengl.sub.*; + +public interface GLMatrixIf { + + public static final int GL_MATRIX_MODE = 0x0BA0; + public static final int GL_MODELVIEW = 0x1700; + public static final int GL_PROJECTION = 0x1701; + // public static final int GL_TEXTURE = 0x1702; // Use GL.GL_TEXTURE due to ambiguous GL usage + public static final int GL_MODELVIEW_MATRIX = 0x0BA6; + public static final int GL_PROJECTION_MATRIX = 0x0BA7; + public static final int GL_TEXTURE_MATRIX = 0x0BA8; + + /** + * glGetFloatv + * @param pname GL_MODELVIEW_MATRIX, GL_PROJECTION_MATRIX or GL_TEXTURE_MATRIX + * @param params the FloatBuffer's position remains unchanged, + * which is the same behavior than the native JOGL GL impl + */ + public void glGetFloatv(int pname, java.nio.FloatBuffer params); + public void glGetFloatv(int pname, float[] params, int params_offset); + /** + * glGetIntegerv + * @param pname GL_MATRIX_MODE + * @param params the FloatBuffer's position remains unchanged + * which is the same behavior than the native JOGL GL impl + */ + public void glGetIntegerv(int pname, IntBuffer params); + public void glGetIntegerv(int pname, int[] params, int params_offset); + + /** + * sets the current matrix + * @param pname GL_MODELVIEW, GL_PROJECTION or GL.GL_TEXTURE + */ + public void glMatrixMode(int mode) ; + + public void glPushMatrix(); + public void glPopMatrix(); + + public void glLoadIdentity() ; + + /** + * glLoadMatrixf + * @param params the FloatBuffer's position remains unchanged, + * which is the same behavior than the native JOGL GL impl + */ + public void glLoadMatrixf(java.nio.FloatBuffer m) ; + public void glLoadMatrixf(float[] m, int m_offset); + + /** + * glMultMatrixf + * @param params the FloatBuffer's position remains unchanged, + * which is the same behavior than the native JOGL GL impl + */ + public void glMultMatrixf(java.nio.FloatBuffer m) ; + public void glMultMatrixf(float[] m, int m_offset); + + public void glTranslatef(float x, float y, float z) ; + + public void glRotatef(float angle, float x, float y, float z); + + public void glScalef(float x, float y, float z) ; + + public void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar) ; + + public void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar); + +} + diff --git a/src/classes/javax/media/opengl/sub/fixed/GLPointerIf.java b/src/classes/javax/media/opengl/sub/fixed/GLPointerIf.java new file mode 100644 index 000000000..2f4cda1aa --- /dev/null +++ b/src/classes/javax/media/opengl/sub/fixed/GLPointerIf.java @@ -0,0 +1,39 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + */ + +package javax.media.opengl.sub.fixed; + +import java.nio.*; + +import javax.media.opengl.*; +import javax.media.opengl.sub.*; + +public interface GLPointerIf { + public static final int GL_VERTEX_ARRAY = 0x8074; + public static final int GL_NORMAL_ARRAY = 0x8075; + public static final int GL_COLOR_ARRAY = 0x8076; + public static final int GL_TEXTURE_COORD_ARRAY = 0x8078; + + public void glEnableClientState(int arrayName); + public void glDisableClientState(int arrayName); + + public void glVertexPointer(GLArrayData array); + public void glVertexPointer(int size, int type, int stride, java.nio.Buffer pointer); + public void glVertexPointer(int size, int type, int stride, long pointer_buffer_offset); + + public void glColorPointer(GLArrayData array); + public void glColorPointer(int size, int type, int stride, java.nio.Buffer pointer); + public void glColorPointer(int size, int type, int stride, long pointer_buffer_offset); + public void glColor4f(float red, float green, float blue, float alpha); + + public void glNormalPointer(GLArrayData array); + public void glNormalPointer(int type, int stride, java.nio.Buffer pointer); + public void glNormalPointer(int type, int stride, long pointer_buffer_offset); + + public void glTexCoordPointer(GLArrayData array); + public void glTexCoordPointer(int size, int type, int stride, java.nio.Buffer pointer); + public void glTexCoordPointer(int size, int type, int stride, long pointer_buffer_offset); + +} + -- cgit v1.2.3