[Fencommits] libvob: GL.java and GLRen.java refactored - urgh.

Matti J. Katila majukati at cc.jyu.fi
Tue Mar 7 02:05:30 EET 2006


Tue Mar  7 01:12:00 EET 2006  Matti J. Katila <majukati at cc.jyu.fi>
  * GL.java and GLRen.java refactored - urgh.

diff -rN -u libvob-old/org/nongnu/libvob/gl/GL.java libvob-new/org/nongnu/libvob/gl/GL.java
--- libvob-old/org/nongnu/libvob/gl/GL.java	2006-03-07 02:05:28.001765743 +0200
+++ libvob-new/org/nongnu/libvob/gl/GL.java	2006-03-07 01:34:37.000000000 +0200
@@ -103,7 +103,7 @@
 
     static public interface GLinstance {
 	String iGetGLString(String s);
-	
+	Texture iCreateTexture();
     }
     
     
@@ -234,7 +234,8 @@
 	protected abstract void deleteObj();
 	/** Get the C++ integer id associated with this object.
 	 */
-	protected int getId() { return id; }
+	public
+	/*protected*/ int getId() { return id; }
     }
 
     /** A Java object which is not supposed to be placed on display lists.
@@ -427,35 +428,17 @@
     /** A texture object. Represents a single OpenGL texture object.
      * Here, id == directly the texture id.
      */
-    static public class Texture extends NonRenderableJavaObject {
-	/** Whether the destruction of this texture object
-	 * should cause the underlying implementation texture
-	 * object to be deleted.
-	 */
-	boolean delReal;
-
-	/** Create a texture object whose GL texture will not be deleted
-	 * upon the deletion of the Java object.
-	 */
-	private Texture(int id) { super(id); delReal = false; }
-	/** Create a texture object whose GL texture may be deleted
-	 * upon the deletion of the Java object.
-	 * @param delReal If true, delete the OpenGL texture
-	 */
-	private Texture(int id, boolean delReal) { super(id); 
-	    this.delReal = delReal; }
-	protected void deleteObj() { 
-	    if(delReal) impl_deleteTexture(getId()); 
+    static public abstract class Texture extends NonRenderableJavaObject {
+
+	protected Texture(int id) {
+	    super(id);
 	}
 
 	/** Delete this texture.
 	 * Do not use this object any more after calling this
 	 * method.
 	 */
-	public void deleteTexture() {
-	    delReal = false;
-	    impl_deleteTexture(getId());
-	}
+	public abstract void deleteTexture();
 
 	/** Get the OpenGL texture id of this texture.
 	 */
@@ -464,168 +447,124 @@
 	public void setTexParameter(String target, String param, float value) {
 	    this.setTexParameter(target, param, ""+value);
 	}
-	public void setTexParameter(String target, String param, String value) {
-	    call("BindTexture "+target+" "+getTexId()+"\n"+
-		    "TexParameter "+target+" "+param+" "+value+"\n"+
-		    "BindTexture "+target+" 0\n");
-	}
+	public abstract void setTexParameter(String target, String param, String value);
+//	{
+//	    call("BindTexture "+target+" "+getTexId()+"\n"+
+//		    "TexParameter "+target+" "+param+" "+value+"\n"+
+//		    "BindTexture "+target+" 0\n");
+//	}
 
 	/** Call libtexture to create the image into this texture object.
 	 */
-	public int shade(int w, int h, int d, int comps, 
+	public abstract int shade(int w, int h, int d, int comps, 
 		String internalFormat, String format,
-		String shaderName, String[] params) {
-	    return impl_Texture_shade(getId(), w, h, d, comps, internalFormat, format,
-		shaderName, params, false);
-	}
+		String shaderName, String[] params);
 
 	/** Call glGetCompressedTexImage.
 	 */
-	public byte[] getCompressedTexImage(int lod) {
-	    return impl_Texture_getCompressedTexImage(getId(), lod, null);
-	}
+	public abstract byte[] getCompressedTexImage(int lod);
 
 	/** Call glGetCompressedTexImage, with an array for the data.
 	 */
-	public byte[] getCompressedTexImage(int lod, byte[] prearr) {
-	    return impl_Texture_getCompressedTexImage(getId(), lod, prearr);
-	}
+	public abstract byte[] getCompressedTexImage(int lod, byte[] prearr);
+
+	public abstract void getTexImage(int lod, String format, String type,
+			byte[] array);
 
-	public void getTexImage(int lod, String format, String type,
-			byte[] array) {
-	    impl_Texture_getTexImage(getId(), lod, format, type,
-			    array);
-	}
 
 	/** Call glCompressedTexImage.
 	 * The length of data is used so it needs to be right.
 	 */
-	public void compressedTexImage(int level, 
+	public abstract void compressedTexImage(int level, 
 		    String internalFormat, int width, int height, 
-			int border, byte[] data) {
-	    compressedTexImage(level, internalFormat, width, height,
-		    border, data.length, data);
-	}
-	public void compressedTexImage(int level, 
+			int border, byte[] data);
+	public abstract void compressedTexImage(int level, 
 		    String internalFormat, int width, int height, 
-			int border, int size, byte[] data) {
-	    impl_Texture_compressedTexImage(getId(), 
-		    level, internalFormat, width, height,
-			border, size, data);
-	}
+			int border, int size, byte[] data);
 
-	public void compressedTexSubImage2D(int level,
+	public abstract void compressedTexSubImage2D(int level,
 		    int xoffs, int yoffs, int width, int height,
-		    String format, int size, byte[] data) {
-	    impl_Texture_compressedTexSubImage2D(getId(),
-		    level, xoffs, yoffs, width, height, format, size, data);
-	}
+		    String format, int size, byte[] data);
 
 	/** Call glTexImage2D.
 	 * The length of data is used so it needs to be right.
 	 */
-	public void texImage2D(int level, 
+	public abstract void texImage2D(int level, 
 			String internalFormat, int w, int h, 
 			int border, String format, String type, 
-			byte[] data) {
-	    impl_Texture_texImage2D(getId(), 
-			level, internalFormat, w, h, border, format, 
-			type, data);
-	}
+			byte[] data);
 
 	/** Call glTexSubImage2D.
 	 * The length of data is used so it needs to be right.
 	 */
-	public void texSubImage2D(int level, 
+	public abstract void texSubImage2D(int level, 
 			int x, int y, int w, int h, 
 			int border, String format, String type, 
-			byte[] data) {
-	    impl_Texture_texSubImage2D(getId(), 
-			level, x, y, w, h, border, format, 
-			type, data);
-	}
+			byte[] data);
 
 	/** Call libtexture to create the image for each mipmap level separately.
 	 */
-	public int shade_all_levels(int w, int h, int d, int comps, 
+	public abstract int shade_all_levels(int w, int h, int d, int comps, 
 		String internalFormat, String format,
-		String shaderName, String[] params) {
-	    return impl_Texture_shade(getId(), w, h, d, comps, internalFormat, format,
-		shaderName, params, true);
-	}
+		String shaderName, String[] params);
 
 	/** Load a NULL pointer to the texture, which clears the image
 	 * and sets the mip maps.
 	 */
-	public void loadNull2D(String target, int level, 
+	public abstract void loadNull2D(String target, int level, 
 			String internalFormat, int w, int h, 
-			int border, String format, String type) {
-	    impl_Texture_loadNull2D(getId(), target,
-			level, internalFormat, w, h, border, format, type);
-	}
-
+			int border, String format, String type);
 
 	/** Load an image into a part of this texture.
 	 */
-	public void loadSubImage(int level, Image img, int x, int y, int xoffs, int yoffs, int w, int h) {
-	    impl_Texture_loadSubImage(getId(), level, img.getId(), x, y, xoffs, yoffs, w, h);
-	}
+	public abstract void loadSubImage(int level, Image img, int x, int y, int xoffs, int yoffs, int w, int h);
 
 	/** Read into this texture from screen.
 	 */
-	public void copyTexImage2D(RenderingSurface win, String buffer,
+	public abstract void copyTexImage2D(RenderingSurface win, String buffer,
 		    String target, int level,
 		    String internalFormat, int x, int y,
-		    int w, int h, int border) {
-	    impl_Texture_copyTexImage2D(getId(), win.getId(), 
-			buffer, target,
-			level, internalFormat, x, y, w, h,
-			border);
-	}
-	public float[] getParameter(String name) {
-	    return getGLTexParameterFloat("TEXTURE_2D", getId(), name);
-	}
-	public float[] getLevelParameter(int level, String name) {
-	    return getGLTexLevelParameterFloat("TEXTURE_2D", getId(), level, name);
-	}
-
+		    int w, int h, int border);
+	public abstract float[] getParameter(String name);
+	public abstract float[] getLevelParameter(int level, String name);
     }
 
     /** Create a new OpenGL texture object.
      */
     static public Texture createTexture() { 
-	return new Texture(impl_createTexture(), true);
+	return instance.iCreateTexture(); 
+	//new Texture(impl_createTexture(), true);
     }
-    static private native int impl_createTexture();
-    static private native void impl_deleteTexture(int id);
-    static private native int impl_Texture_shade(int id, int w, int h, int d, int comps, 
+    static public /*private*/ native int impl_createTexture();
+    static public /*private*/ native void impl_deleteTexture(int id);
+    static public /*private*/ native int impl_Texture_shade(int id, int w, int h, int d, int comps, 
 		String internalFormat, String format,
 		String shaderName, String[] params, 
 		boolean shade_all_levels);
 
-    static private native void impl_Texture_loadNull2D(int id, String target, 
+    static public /*private*/ native void impl_Texture_loadNull2D(int id, String target, 
 			int level, 
 			String internalFormat, int w, int h, 
 			int border, String format, String type) ;
-    static private native void impl_Texture_texImage2D(int id, int level, 
+    static public /*private*/ native void impl_Texture_texImage2D(int id, int level, 
 			String internalFormat, int w, int h, 
 			int border, String format, String type, byte[] data) ;
-    static private native void impl_Texture_texSubImage2D(int id, int level, 
+    static public /*private*/ native void impl_Texture_texSubImage2D(int id, int level, 
 			int x, int y, int w, int h, 
 			int border, String format, String type, byte[] data) ;
-    static private native void impl_Texture_loadSubImage(int id,
+    static public /*private*/ native void impl_Texture_loadSubImage(int id,
 	int level, int imgid, int x, int y, int xoffs, int yoffs, int w, int h) ;
-    static private native void impl_Texture_copyTexImage2D(
+    static public /*private*/ native void impl_Texture_copyTexImage2D(
 		int id, int wid, String buffer,
 		    String target, int level,
 		    String internalFormat, int x, int y,
 		    int w, int h, int border) ;
-    static private native byte[] impl_Texture_getCompressedTexImage(int id, int lod, byte[] preArray);
-    static private native void impl_Texture_compressedTexImage(int id, int level, String internalFormat,
+    static public /*private*/ native byte[] impl_Texture_getCompressedTexImage(int id, int lod, byte[] preArray);
+    static public /*private*/ native void impl_Texture_compressedTexImage(int id, int level, String internalFormat,
 		    int width, int height, int border, int size, byte[] data);
-    static private native void impl_Texture_compressedTexSubImage2D(int id, int level,
+    static public /*private*/ native void impl_Texture_compressedTexSubImage2D(int id, int level,
 		    int xoffs, int yoffs, int width, int height, String format, int size, byte[] data);
-    static private native void impl_Texture_getTexImage(int id, 
+    static public /*private*/ native void impl_Texture_getTexImage(int id, 
 		    int lod, String format, String type, byte[] array) ;
 
 // -------- IndirectTexture
diff -rN -u libvob-old/org/nongnu/libvob/gl/GLRen.java libvob-new/org/nongnu/libvob/gl/GLRen.java
--- libvob-old/org/nongnu/libvob/gl/GLRen.java	2006-03-07 02:05:27.995766650 +0200
+++ libvob-new/org/nongnu/libvob/gl/GLRen.java	2006-03-07 01:34:37.000000000 +0200
@@ -28,6 +28,7 @@
 
 package org.nongnu.libvob.gl;
 import org.nongnu.libvob.*;
+import org.nongnu.libvob.gl.PaperMill.Paper;
 import org.nongnu.libvob.gl.impl.lwjgl.LWJGLRen;
 import org.nongnu.libvob.impl.lwjgl.LWJGL_API;
 
@@ -137,7 +138,7 @@
 // <vob/trans/LinearPrimitives.hxx>
  
 // <vob/vobs/Texture.hxx>
- static public class CopyTexSubImage2D extends GL.Renderable1JavaObject  { private CopyTexSubImage2D(int i) { super(i); }
+ static public class CopyTexSubImage2D extends GL.Renderable1JavaObject implements Ren.CopyTexSubImage2D { private CopyTexSubImage2D(int i) { super(i); }
 }
 static public CopyTexSubImage2D createCopyTexSubImage2D(String p0, int p1, int p2, int p3, int p4, int p5) { 
 CopyTexSubImage2D _ = new CopyTexSubImage2D(
@@ -146,7 +147,7 @@
  return _; }
 
 static private native int implcreateCopyTexSubImage2D(String p0, int p1, int p2, int p3, int p4, int p5) ; 
-static public class TexSubImage2D extends GL.Renderable0JavaObject  { private TexSubImage2D(int i) { super(i); }
+static public class TexSubImage2D extends GL.Renderable0JavaObject implements Ren.TexSubImage2D { private TexSubImage2D(int i) { super(i); }
 GL.ByteVector p8;
 }
 static public TexSubImage2D createTexSubImage2D(String p0, int p1, int p2, int p3, int p4, int p5, String p6, String p7, GL.ByteVector p8) { 
@@ -159,7 +160,7 @@
 static private native int implcreateTexSubImage2D(String p0, int p1, int p2, int p3, int p4, int p5, String p6, String p7, int p8) ; 
 
 // <vob/vobs/Debug.hxx>
- static public class DebugSwitch extends GL.Renderable0JavaObject  { private DebugSwitch(int i) { super(i); }
+ static public class DebugSwitch extends GL.Renderable0JavaObject implements Ren.DebugSwitch { private DebugSwitch(int i) { super(i); }
 }
 static public DebugSwitch createDebugSwitch(String p0, int p1) { 
 DebugSwitch _ = new DebugSwitch(
@@ -170,7 +171,7 @@
 static private native int implcreateDebugSwitch(String p0, int p1) ; 
 
 // <vob/vobs/Fillet.hxx>
- static public class SortedConnections extends GL.RenderableNJavaObject  { private SortedConnections(int i) { super(i); }
+ static public class SortedConnections extends GL.RenderableNJavaObject implements Ren.SortedConnections { private SortedConnections(int i) { super(i); }
 GL.RenderableNJavaObject p0;
 GL.RenderableNJavaObject p1;
 }
@@ -183,7 +184,7 @@
  return _; }
 
 static private native int implcreateSortedConnections(int p0, int p1, int p2) ; 
-static public class IterConnections extends GL.RenderableNJavaObject  { private IterConnections(int i) { super(i); }
+static public class IterConnections extends GL.RenderableNJavaObject implements Ren.IterConnections { private IterConnections(int i) { super(i); }
 GL.RenderableNJavaObject p0;
 GL.RenderableNJavaObject p1;
 }
@@ -196,7 +197,7 @@
  return _; }
 
 static private native int implcreateIterConnections(int p0, int p1, int p2) ; 
-static public class FilletSpan2 extends GL.RenderableNJavaObject  { private FilletSpan2(int i) { super(i); }
+static public class FilletSpan2 extends GL.RenderableNJavaObject implements Ren.FilletSpan2 { private FilletSpan2(int i) { super(i); }
 }
 static public FilletSpan2 createFilletSpan2(float p0, int p1, int p2) { 
 FilletSpan2 _ = new FilletSpan2(
@@ -205,7 +206,7 @@
  return _; }
 
 static private native int implcreateFilletSpan2(float p0, int p1, int p2) ; 
-static public class Fillet3D extends GL.RenderableNJavaObject  { private Fillet3D(int i) { super(i); }
+static public class Fillet3D extends GL.RenderableNJavaObject implements Ren.Fillet3D { private Fillet3D(int i) { super(i); }
 }
 static public Fillet3D createFillet3D(float p0, int p1, int p2) { 
 Fillet3D _ = new Fillet3D(
@@ -214,7 +215,7 @@
  return _; }
 
 static private native int implcreateFillet3D(float p0, int p1, int p2) ; 
-static public class Fillet3DBlend extends GL.RenderableNJavaObject  { private Fillet3DBlend(int i) { super(i); }
+static public class Fillet3DBlend extends GL.RenderableNJavaObject implements Ren.Fillet3DBlend { private Fillet3DBlend(int i) { super(i); }
 }
 static public Fillet3DBlend createFillet3DBlend(int p0, float p1, int p2, int p3) { 
 Fillet3DBlend _ = new Fillet3DBlend(
@@ -225,7 +226,7 @@
 static private native int implcreateFillet3DBlend(int p0, float p1, int p2, int p3) ; 
 
 // <vob/vobs/Lines.hxx>
- static public class ContinuousLine extends GL.Renderable1JavaObject  { private ContinuousLine(int i) { super(i); }
+ static public class ContinuousLine extends GL.Renderable1JavaObject implements Ren.ContinuousLine { private ContinuousLine(int i) { super(i); }
 }
 static public ContinuousLine createContinuousLine(int p0, float p1, int p2, boolean p3, float [] p4) { 
 ContinuousLine _ = new ContinuousLine(
@@ -236,7 +237,7 @@
 static private native int implcreateContinuousLine(int p0, float p1, int p2, boolean p3, float [] p4) ; 
 
 // <vob/vobs/GLState.hxx>
- static public class TransMatrix extends GL.Renderable1JavaObject  { private TransMatrix(int i) { super(i); }
+ static public class TransMatrix extends GL.Renderable1JavaObject implements Ren.TransMatrix { private TransMatrix(int i) { super(i); }
 }
 static public TransMatrix createTransMatrix(String p0) { 
 TransMatrix _ = new TransMatrix(
@@ -245,7 +246,7 @@
  return _; }
 
 static private native int implcreateTransMatrix(String p0) ; 
-static public class TestStateRetainSetup extends GL.Renderable0JavaObject  { private TestStateRetainSetup(int i) { super(i); }
+static public class TestStateRetainSetup extends GL.Renderable0JavaObject implements Ren.TestStateRetainSetup { private TestStateRetainSetup(int i) { super(i); }
 }
 static public TestStateRetainSetup createTestStateRetainSetup() { 
 TestStateRetainSetup _ = new TestStateRetainSetup(
@@ -254,7 +255,7 @@
  return _; }
 
 static private native int implcreateTestStateRetainSetup() ; 
-static public class TestStateRetainTest extends GL.Renderable0JavaObject  { private TestStateRetainTest(int i) { super(i); }
+static public class TestStateRetainTest extends GL.Renderable0JavaObject implements Ren.TestStateRetainTest { private TestStateRetainTest(int i) { super(i); }
 }
 static public TestStateRetainTest createTestStateRetainTest() { 
 TestStateRetainTest _ = new TestStateRetainTest(
@@ -265,7 +266,7 @@
 static private native int implcreateTestStateRetainTest() ; 
 
 // <vob/vobs/Program.hxx>
- static public class ProgramLocalParameterARB extends GL.Renderable1JavaObject  { private ProgramLocalParameterARB(int i) { super(i); }
+ static public class ProgramLocalParameterARB extends GL.Renderable1JavaObject implements Ren.ProgramLocalParameterARB { private ProgramLocalParameterARB(int i) { super(i); }
 }
 static public ProgramLocalParameterARB createProgramLocalParameterARB(String p0, int p1) { 
 ProgramLocalParameterARB _ = new ProgramLocalParameterARB(
@@ -274,7 +275,7 @@
  return _; }
 
 static private native int implcreateProgramLocalParameterARB(String p0, int p1) ; 
-static public class ProgramNamedParameterNV extends GL.Renderable1JavaObject  { private ProgramNamedParameterNV(int i) { super(i); }
+static public class ProgramNamedParameterNV extends GL.Renderable1JavaObject implements Ren.ProgramNamedParameterNV { private ProgramNamedParameterNV(int i) { super(i); }
 }
 static public ProgramNamedParameterNV createProgramNamedParameterNV(int p0, String p1) { 
 ProgramNamedParameterNV _ = new ProgramNamedParameterNV(
@@ -285,7 +286,7 @@
 static private native int implcreateProgramNamedParameterNV(int p0, String p1) ; 
 
 // <vob/vobs/Irregu.hxx>
- static public class IrregularQuad extends GL.Renderable2JavaObject  { private IrregularQuad(int i) { super(i); }
+ static public class IrregularQuad extends GL.Renderable2JavaObject implements Ren.IrregularQuad { private IrregularQuad(int i) { super(i); }
 GL.DisplayList p7;
 }
 static public IrregularQuad createIrregularQuad(float p0, float p1, float p2, float p3, float p4, float p5, int p6, GL.DisplayList p7, float p8) { 
@@ -296,7 +297,7 @@
  return _; }
 
 static private native int implcreateIrregularQuad(float p0, float p1, float p2, float p3, float p4, float p5, int p6, int p7, float p8) ; 
-static public class IrregularEdge extends GL.Renderable2JavaObject  { private IrregularEdge(int i) { super(i); }
+static public class IrregularEdge extends GL.Renderable2JavaObject implements Ren.IrregularEdge { private IrregularEdge(int i) { super(i); }
 GL.DisplayList p13;
 }
 static public IrregularEdge createIrregularEdge(int p0, float p1, float p2, float p3, float p4, float p5, float p6, float p7, String p8, String p9, int p10, int p11, int p12, GL.DisplayList p13, float p14) { 
@@ -309,7 +310,7 @@
 static private native int implcreateIrregularEdge(int p0, float p1, float p2, float p3, float p4, float p5, float p6, float p7, String p8, String p9, int p10, int p11, int p12, int p13, float p14) ; 
 
 // <vob/vobs/Paper.hxx>
- static public class DiceTester extends GL.Renderable1JavaObject  { private DiceTester(int i) { super(i); }
+ static public class DiceTester extends GL.Renderable1JavaObject implements Ren.DiceTester { private DiceTester(int i) { super(i); }
 }
 static public DiceTester createDiceTester(float p0, float p1, int p2, int p3) { 
 DiceTester _ = new DiceTester(
@@ -318,7 +319,7 @@
  return _; }
 
 static private native int implcreateDiceTester(float p0, float p1, int p2, int p3) ; 
-static public class FixedPaperQuad extends GL.Renderable1JavaObject  { private FixedPaperQuad(int i) { super(i); }
+static public class FixedPaperQuad extends GL.Renderable1JavaObject implements Ren.FixedPaperQuad { private FixedPaperQuad(int i) { super(i); }
 Paper p0;
 GL.TexAccum p9;
 }
@@ -331,7 +332,7 @@
  return _; }
 
 static private native int implcreateFixedPaperQuad(int p0, float p1, float p2, float p3, float p4, int p5, float p6, float p7, int p8, int p9, float p10) ; 
-static public class PaperQuad extends GL.Renderable2JavaObject  { private PaperQuad(int i) { super(i); }
+static public class PaperQuad extends GL.Renderable2JavaObject implements Ren.PaperQuad { private PaperQuad(int i) { super(i); }
 Paper p0;
 }
 static public PaperQuad createPaperQuad(Paper p0, float p1, float p2, float p3, float p4, float p5, float p6, int p7) { 
@@ -342,7 +343,7 @@
  return _; }
 
 static private native int implcreatePaperQuad(int p0, float p1, float p2, float p3, float p4, float p5, float p6, int p7) ; 
-static public class EasyPaperQuad extends GL.Renderable2JavaObject  { private EasyPaperQuad(int i) { super(i); }
+static public class EasyPaperQuad extends GL.Renderable2JavaObject implements Ren.EasyPaperQuad { private EasyPaperQuad(int i) { super(i); }
 Paper p0;
 }
 static public EasyPaperQuad createEasyPaperQuad(Paper p0, float p1, int p2) { 
@@ -353,7 +354,7 @@
  return _; }
 
 static private native int implcreateEasyPaperQuad(int p0, float p1, int p2) ; 
-static public class BasisPaperQuad extends GL.Renderable2JavaObject  { private BasisPaperQuad(int i) { super(i); }
+static public class BasisPaperQuad extends GL.Renderable2JavaObject implements Ren.BasisPaperQuad { private BasisPaperQuad(int i) { super(i); }
 Paper p0;
 GL.DisplayList p9;
 GL.DisplayList p10;
@@ -372,7 +373,7 @@
 static private native int implcreateBasisPaperQuad(int p0, float p1, float p2, float p3, float p4, float p5, float p6, float p7, float p8, int p9, int p10, int p11) ; 
 
 // <vob/vobs/Text.hxx>
- static public class Text1 extends GL.Renderable1JavaObject  { private Text1(int i) { super(i); }
+ static public class Text1 extends GL.Renderable1JavaObject implements Ren.Text1 { private Text1(int i) { super(i); }
 GL.QuadFont p0;
 }
 static public Text1 createText1(GL.QuadFont p0, String p1, float p2, int p3) { 
@@ -383,7 +384,7 @@
  return _; }
 
 static private native int implcreateText1(int p0, String p1, float p2, int p3) ; 
-static public class TextSuper4 extends GL.Renderable1JavaObject  { private TextSuper4(int i) { super(i); }
+static public class TextSuper4 extends GL.Renderable1JavaObject implements Ren.TextSuper4 { private TextSuper4(int i) { super(i); }
 GL.QuadFont p0;
 }
 static public TextSuper4 createTextSuper4(GL.QuadFont p0, String p1, float p2, int p3) { 
@@ -396,7 +397,7 @@
 static private native int implcreateTextSuper4(int p0, String p1, float p2, int p3) ; 
 
 // <vob/vobs/Pixel.hxx>
- static public class DrawPixels extends GL.Renderable1JavaObject  { private DrawPixels(int i) { super(i); }
+ static public class DrawPixels extends GL.Renderable1JavaObject implements Ren.DrawPixels { private DrawPixels(int i) { super(i); }
 GL.ByteVector p4;
 }
 static public DrawPixels createDrawPixels(int p0, int p1, String p2, String p3, GL.ByteVector p4) { 
@@ -407,7 +408,7 @@
  return _; }
 
 static private native int implcreateDrawPixels(int p0, int p1, String p2, String p3, int p4) ; 
-static public class ReadPixels extends GL.Renderable1JavaObject  { private ReadPixels(int i) { super(i); }
+static public class ReadPixels extends GL.Renderable1JavaObject implements Ren.ReadPixels { private ReadPixels(int i) { super(i); }
 GL.ByteVector p4;
 }
 static public ReadPixels createReadPixels(int p0, int p1, String p2, String p3, GL.ByteVector p4) { 
@@ -418,7 +419,7 @@
  return _; }
 
 static private native int implcreateReadPixels(int p0, int p1, String p2, String p3, int p4) ; 
-static public class CopyPixels extends GL.Renderable2JavaObject  { private CopyPixels(int i) { super(i); }
+static public class CopyPixels extends GL.Renderable2JavaObject implements Ren.CopyPixels { private CopyPixels(int i) { super(i); }
 }
 static public CopyPixels createCopyPixels(int p0, int p1, String p2) { 
 CopyPixels _ = new CopyPixels(
@@ -429,7 +430,7 @@
 static private native int implcreateCopyPixels(int p0, int p1, String p2) ; 
 
 // <vob/vobs/Trivial.hxx>
- static public class LineConnector extends GL.Renderable2JavaObject  { private LineConnector(int i) { super(i); }
+ static public class LineConnector extends GL.Renderable2JavaObject implements Ren.LineConnector { private LineConnector(int i) { super(i); }
 }
 static public LineConnector createLineConnector(float p0, float p1, float p2, float p3) { 
 LineConnector _ = new LineConnector(
@@ -438,7 +439,7 @@
  return _; }
 
 static private native int implcreateLineConnector(float p0, float p1, float p2, float p3) ; 
-static public class PinStub extends GL.Renderable2JavaObject  { private PinStub(int i) { super(i); }
+static public class PinStub extends GL.Renderable2JavaObject implements Ren.PinStub { private PinStub(int i) { super(i); }
 }
 static public PinStub createPinStub(float p0, float p1, float p2, float p3, float p4, float p5) { 
 PinStub _ = new PinStub(
@@ -447,7 +448,7 @@
  return _; }
 
 static private native int implcreatePinStub(float p0, float p1, float p2, float p3, float p4, float p5) ; 
-static public class NonFilledRectangle extends GL.Renderable1JavaObject  { private NonFilledRectangle(int i) { super(i); }
+static public class NonFilledRectangle extends GL.Renderable1JavaObject implements Ren.NonFilledRectangle { private NonFilledRectangle(int i) { super(i); }
 }
 static public NonFilledRectangle createNonFilledRectangle(float p0, float p1, float p2, float p3, float p4, float p5, float p6, float p7, float p8) { 
 NonFilledRectangle _ = new NonFilledRectangle(
@@ -456,7 +457,7 @@
  return _; }
 
 static private native int implcreateNonFilledRectangle(float p0, float p1, float p2, float p3, float p4, float p5, float p6, float p7, float p8) ; 
-static public class CallList extends GL.Renderable0JavaObject  { private CallList(int i) { super(i); }
+static public class CallList extends GL.Renderable0JavaObject implements Ren.CallList { private CallList(int i) { super(i); }
 GL.DisplayList p0;
 }
 static public CallList createCallList(GL.DisplayList p0) { 
@@ -467,7 +468,7 @@
  return _; }
 
 static private native int implcreateCallList(int p0) ; 
-static public class CallListCoorded extends GL.Renderable1JavaObject  { private CallListCoorded(int i) { super(i); }
+static public class CallListCoorded extends GL.Renderable1JavaObject implements Ren.CallListCoorded { private CallListCoorded(int i) { super(i); }
 GL.DisplayList p0;
 }
 static public CallListCoorded createCallListCoorded(GL.DisplayList p0) { 
@@ -478,7 +479,7 @@
  return _; }
 
 static private native int implcreateCallListCoorded(int p0) ; 
-static public class CallListBoxCoorded extends GL.Renderable1JavaObject  { private CallListBoxCoorded(int i) { super(i); }
+static public class CallListBoxCoorded extends GL.Renderable1JavaObject implements Ren.CallListBoxCoorded { private CallListBoxCoorded(int i) { super(i); }
 GL.DisplayList p0;
 }
 static public CallListBoxCoorded createCallListBoxCoorded(GL.DisplayList p0) { 
@@ -489,7 +490,7 @@
  return _; }
 
 static private native int implcreateCallListBoxCoorded(int p0) ; 
-static public class Quad extends GL.Renderable1JavaObject  { private Quad(int i) { super(i); }
+static public class Quad extends GL.Renderable1JavaObject implements Ren.Quad { private Quad(int i) { super(i); }
 }
 static public Quad createQuad(int p0, int p1, int p2) { 
 Quad _ = new Quad(
@@ -498,7 +499,7 @@
  return _; }
 
 static private native int implcreateQuad(int p0, int p1, int p2) ; 
-static public class TransTest extends GL.Renderable1JavaObject  { private TransTest(int i) { super(i); }
+static public class TransTest extends GL.Renderable1JavaObject implements Ren.TransTest { private TransTest(int i) { super(i); }
 }
 static public TransTest createTransTest(int p0, int p1) { 
 TransTest _ = new TransTest(
@@ -507,7 +508,7 @@
  return _; }
 
 static private native int implcreateTransTest(int p0, int p1) ; 
-static public class SelectVob extends GL.Renderable2JavaObject  { private SelectVob(int i) { super(i); }
+static public class SelectVob extends GL.Renderable2JavaObject implements Ren.SelectVob { private SelectVob(int i) { super(i); }
 GL.Renderable1JavaObject p0;
 GL.Renderable1JavaObject p1;
 GL.Renderable1JavaObject p2;
diff -rN -u libvob-old/org/nongnu/libvob/gl/Paper.java libvob-new/org/nongnu/libvob/gl/Paper.java
--- libvob-old/org/nongnu/libvob/gl/Paper.java	2006-03-07 02:05:28.002765592 +0200
+++ libvob-new/org/nongnu/libvob/gl/Paper.java	2006-03-07 01:34:37.000000000 +0200
@@ -41,7 +41,7 @@
  * added as empties - getPass gives the Pass object to use 
  * to place stuff into the pass.
  */
-public class Paper implements GLDeletable {
+public class Paper implements GLDeletable, org.nongnu.libvob.gl.PaperMill.Paper {
     public static boolean dbg = true;
     private static void pa(String s) { System.err.println(s); }
 
@@ -167,7 +167,7 @@
 	c_id = 0;
     }
 
-    int getId() { return c_id; }
+    public int getId() { return c_id; }
 
     static private native int impl_create();
     static private native void impl_delete(int pid);
diff -rN -u libvob-old/org/nongnu/libvob/gl/PaperMill.java libvob-new/org/nongnu/libvob/gl/PaperMill.java
--- libvob-old/org/nongnu/libvob/gl/PaperMill.java	2006-03-07 02:05:28.003765440 +0200
+++ libvob-new/org/nongnu/libvob/gl/PaperMill.java	2006-03-07 01:34:37.000000000 +0200
@@ -27,11 +27,14 @@
  */
 
 package org.nongnu.libvob.gl;
-import org.nongnu.libvob.GraphicsAPI;
 import org.python.util.PythonInterpreter;
 
 public abstract class PaperMill {
 
+    public static interface Paper { 
+	int getId();
+    }
+    
     /** Get the paper corresponding to the given seed.
      */
     public abstract Paper getPaper(int seed);
diff -rN -u libvob-old/org/nongnu/libvob/gl/impl/LWJGL_Wrapper.java libvob-new/org/nongnu/libvob/gl/impl/LWJGL_Wrapper.java
--- libvob-old/org/nongnu/libvob/gl/impl/LWJGL_Wrapper.java	2006-03-07 02:05:27.988767708 +0200
+++ libvob-new/org/nongnu/libvob/gl/impl/LWJGL_Wrapper.java	2006-03-07 01:34:37.000000000 +0200
@@ -1,7 +1,19 @@
 package org.nongnu.libvob.gl.impl;
 
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+
+import org.lwjgl.BufferUtils;
 import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL12;
+import org.lwjgl.opengl.glu.GLU;
 import org.nongnu.libvob.gl.GL;
+import org.nongnu.libvob.gl.GL.Image;
+import org.nongnu.libvob.gl.GL.RenderingSurface;
+import org.nongnu.libvob.gl.impl.lwjgl.CallGL;
+import org.nongnu.libvob.gl.impl.lwjgl.texture.NamedTexture;
+import org.nongnu.libvob.gl.impl.lwjgl.texture.TextureParam;
+import org.nongnu.libvob.gl.impl.lwjgl.texture.TextureUtils;
 
 public class LWJGL_Wrapper implements GL.GLinstance {
 
@@ -17,4 +29,134 @@
 	return GL11.glGetString(GL11.GL_EXTENSIONS);
     }
 
+    public GL.Texture iCreateTexture() {
+	return new LwjglTexture();
+    }
+
+    static class LwjglTexture extends GL.Texture {
+	IntBuffer textId = BufferUtils.createIntBuffer(1);
+	LwjglTexture() {
+	    super(-1);
+	    GL11.glGenTextures(textId);
+	}
+	public void deleteTexture() {
+	}
+	public int shade(int w, int h, int d, int comps, String internalFormat, String format, String shaderName, String[] params) {
+	    return shadeImpl(w,h,d,comps, internalFormat, format, shaderName, params, false);
+	}
+	public int shade_all_levels(int w, int h, int d, int comps, String internalFormat, String format, String shaderName, String[] params) {
+	    return shadeImpl(w,h,d,comps, internalFormat, format, shaderName, params, true);
+	}
+	public int shadeImpl(int w, int h, int d, int comps, String internalFormat, String format, String shaderName, String[] params, boolean shade_all_levels) {
+	    System.out.println(w+", "+h+", "+d+", "+comps+", "+internalFormat+", "+format+", "+shaderName+", ");
+	    for (int i = 0; i < params.length; i++) {
+		System.out.println(i+": "+params[i]);
+	    }
+	    
+	    NamedTexture s = NamedTexture.getTexture(shaderName);
+	    if (s == null) return 0;
+
+	    TextureParam p = new TextureParam(params);
+	    FloatBuffer value = BufferUtils.createFloatBuffer(w * h * (d==0?1:d) * comps);
+
+	    int target = (d == 0) ? GL11.GL_TEXTURE_2D : GL12.GL_TEXTURE_3D;
+
+	    GL11.glBindTexture(target, textId.get(0));
+
+	    boolean buildmipmaps = false;
+
+	      if (!shade_all_levels) {
+		  if (false && GL.hasExtension("GL_SGIS_generate_mipmap")) {
+		      throw new Error("unimpl.");
+//		      GL11.glTexParameteri(target, GLU.GL_GENERATE_MIPMAP_SGIS, GL11.GL_TRUE);
+//		      
+//		      GLERR;
+		  } else {
+		      buildmipmaps = true;
+		  }
+	      } 
+		
+	      int level;
+	      for (level = 0;; level++) {
+		  s.render(p, w, h, (d==0?1:d), comps, value);
+
+		  if (buildmipmaps) {
+		      if (d != 0) //assert(d==0); // 3D buildmipmaps not implemented in libutil
+			  throw new Error("un impl. 3D buildmipmaps");
+//		      Util::buildmipmaps(GL_TEXTURE_2D, 
+//					 tokenFromJstring(env, internalFormat),
+//					 w, h, 
+//					 tokenFromJstring(env, format),
+//					 GL_FLOAT,
+//					 value);
+		      TextureUtils.buildMipmaps(GL11.GL_TEXTURE_2D, CallGL.getToken(internalFormat),
+			      w,h, CallGL.getToken(format), GL11.GL_FLOAT, value);
+		  } else 
+		      if (d == 0)
+			  GL11.glTexImage2D(GL11.GL_TEXTURE_2D, level, CallGL.getToken(internalFormat),
+				   w, h, 0, CallGL.getToken(format), GL11.GL_FLOAT, value);
+		      else
+			  GL12.glTexImage3D(GL12.GL_TEXTURE_3D, level, CallGL.getToken(internalFormat),
+				   w, h, d, 0, CallGL.getToken(format), 
+				   GL11.GL_FLOAT,  value);
+		  CallGL.checkGlError("after shade");
+		      
+		  if (! (shade_all_levels && (w > 1 || h > 1 || d > 1))) break;
+		  
+		  w = (w + 1) >> 1;
+		  h = (h + 1) >> 1;
+		  d = (d + 1) >> 1;
+	      } 
+	      
+	      if (shade_all_levels) {
+		  GL11.glTexParameterf(target, GL12.GL_TEXTURE_BASE_LEVEL, 0);
+		  GL11.glTexParameterf(target, GL12.GL_TEXTURE_MAX_LEVEL, level);
+	      }
+
+	      GL11.glBindTexture(target, 0);
+	      CallGL.checkGlError("shade done.");
+
+	      return 1;
+	}
+
+	public void setTexParameter(String target, String param, String value) {
+	    CallGL.call("BindTexture "+target+" "+textId.get(0)+"\n"+
+	    "TexParameter "+target+" "+param+" "+value+"\n"+
+	    "BindTexture "+target+" 0\n");
+	}
+
+	
+	public byte[] getCompressedTexImage(int lod) {
+	    return null;
+	}
+	public byte[] getCompressedTexImage(int lod, byte[] prearr) {
+	    return null;
+	}
+	public void getTexImage(int lod, String format, String type, byte[] array) {
+	}
+	public void compressedTexImage(int level, String internalFormat, int width, int height, int border, byte[] data) {
+	}
+	public void compressedTexImage(int level, String internalFormat, int width, int height, int border, int size, byte[] data) {
+	}
+	public void compressedTexSubImage2D(int level, int xoffs, int yoffs, int width, int height, String format, int size, byte[] data) {
+	}
+	public void texImage2D(int level, String internalFormat, int w, int h, int border, String format, String type, byte[] data) {
+	}
+	public void texSubImage2D(int level, int x, int y, int w, int h, int border, String format, String type, byte[] data) {
+	}
+	public void loadNull2D(String target, int level, String internalFormat, int w, int h, int border, String format, String type) {
+	}
+	public void loadSubImage(int level, Image img, int x, int y, int xoffs, int yoffs, int w, int h) {
+	}
+	public void copyTexImage2D(RenderingSurface win, String buffer, String target, int level, String internalFormat, int x, int y, int w, int h, int border) {
+	}
+	public float[] getParameter(String name) {
+	    return null;
+	}
+	public float[] getLevelParameter(int level, String name) {
+	    return null;
+	}
+	protected void deleteObj() {
+	}
+    }
 }
diff -rN -u libvob-old/org/nongnu/libvob/gl/impl/NativeLoopBack.java libvob-new/org/nongnu/libvob/gl/impl/NativeLoopBack.java
--- libvob-old/org/nongnu/libvob/gl/impl/NativeLoopBack.java	2006-03-07 02:05:27.991767254 +0200
+++ libvob-new/org/nongnu/libvob/gl/impl/NativeLoopBack.java	2006-03-07 01:34:37.000000000 +0200
@@ -1,12 +1,192 @@
 package org.nongnu.libvob.gl.impl;
 
 import org.nongnu.libvob.gl.GL;
+import org.nongnu.libvob.gl.GL.Image;
+import org.nongnu.libvob.gl.GL.NonRenderableJavaObject;
+import org.nongnu.libvob.gl.GL.RenderingSurface;
+import org.nongnu.libvob.gl.GL.Texture;
 
 public class NativeLoopBack implements GL.GLinstance {
 
     public String iGetGLString(String name) {
 	return GL.getGLString(name);
     }
+
+    public GL.Texture iCreateTexture() {
+	return new NatTexture(GL.impl_createTexture(), true);
+    }
+    
+    
     
     
+    
+//  --------- Texture
+    /** A texture object. Represents a single OpenGL texture object.
+     * Here, id == directly the texture id.
+     */
+    static public class NatTexture extends GL.Texture { 
+	/** Whether the destruction of this texture object
+	 * should cause the underlying implementation texture
+	 * object to be deleted.
+	 */
+	boolean delReal;
+
+	/** Create a texture object whose GL texture will not be deleted
+	 * upon the deletion of the Java object.
+	 */
+	private NatTexture(int id) { super(id); delReal = false; }
+	/** Create a texture object whose GL texture may be deleted
+	 * upon the deletion of the Java object.
+	 * @param delReal If true, delete the OpenGL texture
+	 */
+	private NatTexture(int id, boolean delReal) { super(id); 
+	    this.delReal = delReal; }
+	protected void deleteObj() { 
+	    if(delReal) GL.impl_deleteTexture(getId()); 
+	}
+
+	/** Delete this texture.
+	 * Do not use this object any more after calling this
+	 * method.
+	 */
+	public void deleteTexture() {
+	    delReal = false;
+	    GL.impl_deleteTexture(getId());
+	}
+
+	/** Get the OpenGL texture id of this texture.
+	 */
+	public int getTexId() { return getId(); }
+
+	public void setTexParameter(String target, String param, float value) {
+	    this.setTexParameter(target, param, ""+value);
+	}
+	public void setTexParameter(String target, String param, String value) {
+	    GL.call("BindTexture "+target+" "+getTexId()+"\n"+
+		    "TexParameter "+target+" "+param+" "+value+"\n"+
+		    "BindTexture "+target+" 0\n");
+	}
+
+	/** Call libtexture to create the image into this texture object.
+	 */
+	public int shade(int w, int h, int d, int comps, 
+		String internalFormat, String format,
+		String shaderName, String[] params) {
+	    return GL.impl_Texture_shade(getId(), w, h, d, comps, internalFormat, format,
+		shaderName, params, false);
+	}
+
+	/** Call glGetCompressedTexImage.
+	 */
+	public byte[] getCompressedTexImage(int lod) {
+	    return GL.impl_Texture_getCompressedTexImage(getId(), lod, null);
+	}
+
+	/** Call glGetCompressedTexImage, with an array for the data.
+	 */
+	public byte[] getCompressedTexImage(int lod, byte[] prearr) {
+	    return GL.impl_Texture_getCompressedTexImage(getId(), lod, prearr);
+	}
+
+	public void getTexImage(int lod, String format, String type,
+			byte[] array) {
+	    GL.impl_Texture_getTexImage(getId(), lod, format, type,
+			    array);
+	}
+
+	/** Call glCompressedTexImage.
+	 * The length of data is used so it needs to be right.
+	 */
+	public void compressedTexImage(int level, 
+		    String internalFormat, int width, int height, 
+			int border, byte[] data) {
+	    compressedTexImage(level, internalFormat, width, height,
+		    border, data.length, data);
+	}
+	public void compressedTexImage(int level, 
+		    String internalFormat, int width, int height, 
+			int border, int size, byte[] data) {
+	    GL.impl_Texture_compressedTexImage(getId(), 
+		    level, internalFormat, width, height,
+			border, size, data);
+	}
+
+	public void compressedTexSubImage2D(int level,
+		    int xoffs, int yoffs, int width, int height,
+		    String format, int size, byte[] data) {
+	    GL.impl_Texture_compressedTexSubImage2D(getId(),
+		    level, xoffs, yoffs, width, height, format, size, data);
+	}
+
+	/** Call glTexImage2D.
+	 * The length of data is used so it needs to be right.
+	 */
+	public void texImage2D(int level, 
+			String internalFormat, int w, int h, 
+			int border, String format, String type, 
+			byte[] data) {
+	    GL.impl_Texture_texImage2D(getId(), 
+			level, internalFormat, w, h, border, format, 
+			type, data);
+	}
+
+	/** Call glTexSubImage2D.
+	 * The length of data is used so it needs to be right.
+	 */
+	public void texSubImage2D(int level, 
+			int x, int y, int w, int h, 
+			int border, String format, String type, 
+			byte[] data) {
+	    GL.impl_Texture_texSubImage2D(getId(), 
+			level, x, y, w, h, border, format, 
+			type, data);
+	}
+
+	/** Call libtexture to create the image for each mipmap level separately.
+	 */
+	public int shade_all_levels(int w, int h, int d, int comps, 
+		String internalFormat, String format,
+		String shaderName, String[] params) {
+	    return GL.impl_Texture_shade(getId(), w, h, d, comps, internalFormat, format,
+		shaderName, params, true);
+	}
+
+	/** Load a NULL pointer to the texture, which clears the image
+	 * and sets the mip maps.
+	 */
+	public void loadNull2D(String target, int level, 
+			String internalFormat, int w, int h, 
+			int border, String format, String type) {
+	    GL.impl_Texture_loadNull2D(getId(), target,
+			level, internalFormat, w, h, border, format, type);
+	}
+
+
+	/** Load an image into a part of this texture.
+	 */
+	public void loadSubImage(int level, Image img, int x, int y, int xoffs, int yoffs, int w, int h) {
+	    GL.impl_Texture_loadSubImage(getId(), level, img.getId(), x, y, xoffs, yoffs, w, h);
+	}
+
+	/** Read into this texture from screen.
+	 */
+	public void copyTexImage2D(RenderingSurface win, String buffer,
+		    String target, int level,
+		    String internalFormat, int x, int y,
+		    int w, int h, int border) {
+	    GL.impl_Texture_copyTexImage2D(getId(), win.getId(), 
+			buffer, target,
+			level, internalFormat, x, y, w, h,
+			border);
+	}
+	public float[] getParameter(String name) {
+	    return GL.getGLTexParameterFloat("TEXTURE_2D", getId(), name);
+	}
+	public float[] getLevelParameter(int level, String name) {
+	    return GL.getGLTexLevelParameterFloat("TEXTURE_2D", getId(), level, name);
+	}
+
+    }
+
+    
 }




More information about the Fencommits mailing list