[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ff-cvs] libvob doc/mipzip.rst include/vob/vobs/GLState....
From: |
Tuomas J. Lukka |
Subject: |
[ff-cvs] libvob doc/mipzip.rst include/vob/vobs/GLState.... |
Date: |
Sat, 18 Oct 2003 02:11:17 -0400 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Branch:
Changes by: Tuomas J. Lukka <address@hidden> 03/10/18 02:11:16
Modified files:
doc : mipzip.rst
include/vob/vobs: GLState.hxx
org/nongnu/libvob: AbstractUpdateManager.java ColorableVob.java
GraphicsAPI.java Screen.java TextStyle.java
VobMatcher.java package.html
org/nongnu/libvob/buoy: BuoyGeometer.java
org/nongnu/libvob/gl: GL.java GLUtil.java MipzipFile.java
PaperMill.java SimpleAlphaFont.java
org/nongnu/libvob/gl/virtualtexture: IndirectMipzipManager.java
NonDeletingIndirectMipzipManager.java
VirtualTexture.java
nondeletingindirectmipzipmanager.test
org/nongnu/libvob/impl/gl: GLAPI.java
org/nongnu/libvob/lava/placeable: TextPlaceable.java
org/nongnu/libvob/linebreaking: HBox.java HChain.java
Linebreaker.java
LinebreakingUtil.java
org/nongnu/libvob/util: ThreadBackground.java
src/jni : Main.cxx Texture.cxx
src/main : IndirectTexture.cxx
src/os : Os-GLX.cxx
test/tools : gfx.py
vob/demo/aniso : probe1.py
vob/putil : mipzipmaker.py
vob/usertest : color6.py
Log message:
Arch sync
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/doc/mipzip.rst.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/GLState.hxx.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/AbstractUpdateManager.java.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/ColorableVob.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/GraphicsAPI.java.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/Screen.java.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/TextStyle.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/VobMatcher.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/package.html.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/buoy/BuoyGeometer.java.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/GL.java.diff?tr1=1.26&tr2=1.27&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/GLUtil.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/MipzipFile.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/PaperMill.java.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/virtualtexture/IndirectMipzipManager.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/virtualtexture/NonDeletingIndirectMipzipManager.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/virtualtexture/VirtualTexture.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/virtualtexture/nondeletingindirectmipzipmanager.test.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/impl/gl/GLAPI.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/lava/placeable/TextPlaceable.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/linebreaking/HBox.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/linebreaking/HChain.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/linebreaking/Linebreaker.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/linebreaking/LinebreakingUtil.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/util/ThreadBackground.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/Main.cxx.diff?tr1=1.27&tr2=1.28&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/Texture.cxx.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/main/IndirectTexture.cxx.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/os/Os-GLX.cxx.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/test/tools/gfx.py.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/aniso/probe1.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/putil/mipzipmaker.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/usertest/color6.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: libvob/doc/mipzip.rst
diff -u libvob/doc/mipzip.rst:1.1 libvob/doc/mipzip.rst:1.2
--- libvob/doc/mipzip.rst:1.1 Mon Oct 6 04:50:38 2003
+++ libvob/doc/mipzip.rst Sat Oct 18 02:11:14 2003
@@ -31,9 +31,20 @@
The constant entries are
``texformat``
- The texture format used. The **comment** of this entry (not the
- entry contents!) stores the OpenGL token string, without the ``GL_``
prefix,
- for example ``COMPRESSED_RGB_S3TC_DXT1_EXT``.
+ The texture format used in the file. The **comment** of this entry
+ (not the entry contents!) stores the OpenGL token string,
+ without the ``GL_`` prefix,
+ for example ``COMPRESSED_RGB_S3TC_DXT1_EXT`` or ``RGB``.
+
+``internaltexformat``
+ (optional - not used for compressed textures)
+ The recommended internalformat token to give OpenGL for this
+ texture. E.g. ``RGB4``
+
+``datatype``
+ (optional - not used for compressed textures)
+ Specifies the data type to give to the OpenGL texImage2D command.
+ E.g. ``UNSIGNED_SHORT_5_6_5``
``origsize``
The size of the original image inside this mipzip, as
(texcoord1)x(texcoord2),
Index: libvob/include/vob/vobs/GLState.hxx
diff -u libvob/include/vob/vobs/GLState.hxx:1.3
libvob/include/vob/vobs/GLState.hxx:1.4
--- libvob/include/vob/vobs/GLState.hxx:1.3 Wed Jun 11 13:41:56 2003
+++ libvob/include/vob/vobs/GLState.hxx Sat Oct 18 02:11:14 2003
@@ -47,8 +47,10 @@
using namespace Vob::VecGL;
-/** Transform the given GL matrix with the given transformation.
- * Assumes that the transformation is linear in homogeneous coords.
+/** Cause the given GL matrix with to contain the matrix
+ * for the given transformation.
+ * Obviously the transformation has to be gl-performable, which
+ * requires that the transformation be linear in homogeneous coords.
*/
struct TransMatrix {
enum { NTrans = 1 };
Index: libvob/org/nongnu/libvob/AbstractUpdateManager.java
diff -u libvob/org/nongnu/libvob/AbstractUpdateManager.java:1.11
libvob/org/nongnu/libvob/AbstractUpdateManager.java:1.12
--- libvob/org/nongnu/libvob/AbstractUpdateManager.java:1.11 Wed Sep 10
09:40:52 2003
+++ libvob/org/nongnu/libvob/AbstractUpdateManager.java Sat Oct 18 02:11:14 2003
@@ -105,8 +105,10 @@
* @diagram screen
*/
boolean animUseful();
- /** Render state between start and end (interpolation), with the
- * specified level of detail. fract is in [0, 1], and so is lod.
+ /** Render a state between start and end (interpolation), with the
+ * specified level of detail. The value
+ * of fract is usually in [0, 1], but extrapolation
+ * is also allowed.
* 0.5 should be assumed to be the default lod. If the end state
* doesn't exist, may crash.
* @param showFinal Whether to show (unanimated) the parts
@@ -127,7 +129,8 @@
*/
void changeStartState(float fract);
/** Same as renderAnim(0, lod), except that it's not allowed to crash
- * even if the end state doesn't exist. lod may be interpreted
+ * even if the end state doesn't exist. The parameter
+ * lod may be interpreted
* differently to show things that are not important when animating
* (such as connections).
* @diagram screen
@@ -396,7 +399,12 @@
}
if(r != null) {
if(dbg) pa("Updmanager idle: run "+r);
- r.run();
+ try {
+ r.run();
+ } catch(Exception e) {
+ e.printStackTrace();
+ pa("EXCEPTION IN BG!!! "+e);
+ }
if(dbg) pa("Updmanager idle: finished run "+r);
return true;
} else {
Index: libvob/org/nongnu/libvob/ColorableVob.java
diff -u libvob/org/nongnu/libvob/ColorableVob.java:1.3
libvob/org/nongnu/libvob/ColorableVob.java:1.4
--- libvob/org/nongnu/libvob/ColorableVob.java:1.3 Wed Sep 10 09:40:52 2003
+++ libvob/org/nongnu/libvob/ColorableVob.java Sat Oct 18 02:11:14 2003
@@ -29,8 +29,8 @@
import java.util.List;
import java.awt.Color;
-/** Interface for multiple background colors, which are shown
- * e.g. as parallel vertical stripes inside a vob.
+/** Interface for multiple background colors, which are shown,
+ * e.g., as parallel vertical stripes inside a vob.
*/
public interface ColorableVob extends Vob {
/** Create a multi-colored clone of the vob. Replace existing colors.
Index: libvob/org/nongnu/libvob/GraphicsAPI.java
diff -u libvob/org/nongnu/libvob/GraphicsAPI.java:1.7
libvob/org/nongnu/libvob/GraphicsAPI.java:1.8
--- libvob/org/nongnu/libvob/GraphicsAPI.java:1.7 Tue Aug 5 05:41:06 2003
+++ libvob/org/nongnu/libvob/GraphicsAPI.java Sat Oct 18 02:11:14 2003
@@ -88,7 +88,7 @@
/** Obtain a text style object for an abstract font at a given
* size. The parameters are as
- * in address@hidden java.awt.Font#Font()}
+ * in java.awt.Font.Font().
*
*/
public abstract TextStyle getTextStyle(String family, int style, int size);
Index: libvob/org/nongnu/libvob/Screen.java
diff -u libvob/org/nongnu/libvob/Screen.java:1.5
libvob/org/nongnu/libvob/Screen.java:1.6
--- libvob/org/nongnu/libvob/Screen.java:1.5 Wed Sep 10 09:40:52 2003
+++ libvob/org/nongnu/libvob/Screen.java Sat Oct 18 02:11:14 2003
@@ -33,7 +33,6 @@
/** An aggregate which defines a user-visible window and its contents.
* The View+Controller part of MVC.
- * @diagram screen MP %t.c = (300,300);
*/
public class Screen implements AbstractUpdateManager.Window {
@@ -42,17 +41,14 @@
/** The window system -level window.
- * @diagram screen AggregatePart
*/
public final GraphicsAPI.Window window;
/** The input handler (controller).
- * @diagram screen AggregatePart
*/
public final Binder binder;
/** The view.
- * @diagram screen AggregatePart
*/
public final Shower shower;
Index: libvob/org/nongnu/libvob/TextStyle.java
diff -u libvob/org/nongnu/libvob/TextStyle.java:1.3
libvob/org/nongnu/libvob/TextStyle.java:1.4
--- libvob/org/nongnu/libvob/TextStyle.java:1.3 Wed Sep 10 09:40:52 2003
+++ libvob/org/nongnu/libvob/TextStyle.java Sat Oct 18 02:11:14 2003
@@ -65,7 +65,8 @@
/** Return the offset in the string which corresponds to the x
* coordinate given.
- * 0 = beginning of string, s.length() = end, etc.
+ * For example, return value
+ * 0 = beginning of string, and s.length() = end, etc.
*/
public int getOffsetInText(String s, float scale, float x) {
return getOffsetInText(s.toCharArray(), 0, s.length(), scale, x);
Index: libvob/org/nongnu/libvob/VobMatcher.java
diff -u libvob/org/nongnu/libvob/VobMatcher.java:1.2
libvob/org/nongnu/libvob/VobMatcher.java:1.3
--- libvob/org/nongnu/libvob/VobMatcher.java:1.2 Fri Mar 7 06:38:21 2003
+++ libvob/org/nongnu/libvob/VobMatcher.java Sat Oct 18 02:11:14 2003
@@ -61,8 +61,9 @@
int getParent(int cs);
/** Whether calling getParent(cs) recursively
- * (at least one time!) would eventually
- * return parent. I.e. the coordinate system
+ * (at least one time) would eventually
+ * return parent.
+ * The coordinate system
* itself is not its own ancestor.
*/
boolean isAncestor(int cs, int ancestor);
Index: libvob/org/nongnu/libvob/buoy/BuoyGeometer.java
diff -u libvob/org/nongnu/libvob/buoy/BuoyGeometer.java:1.6
libvob/org/nongnu/libvob/buoy/BuoyGeometer.java:1.7
--- libvob/org/nongnu/libvob/buoy/BuoyGeometer.java:1.6 Sat Aug 16 06:29:37 2003
+++ libvob/org/nongnu/libvob/buoy/BuoyGeometer.java Sat Oct 18 02:11:15 2003
@@ -52,8 +52,6 @@
void prepare(VobScene vs, int into, Object key, boolean create);
/** Create or set the main coordinate system size.
- * @param into The matching parent and parent, giving the rectangle in
- * which the whole buoyview and mainview are placed.
* @param anchor The coordinate system of the anchor, or -1 if not
applicable.
* @param direction 1 for right, -1 for left.
* @param key The key to use for the returned coordinate system
@@ -61,7 +59,9 @@
* @param index The index of the buoy (counted from the anchor)
* @param total The total number of buoys from the anchor
* (might be inaccurate)
- * @param w,h The size the buoy should be closest
+ * @param w The width the buoy should be closest
+ * to the focus. This should be the box size of the CS returned.
+ * @param h The height the buoy should be closest
* to the focus. This should be the box size of the CS returned.
* @param scale The scale that should be applied to the w, h at
* focus
Index: libvob/org/nongnu/libvob/gl/GL.java
diff -u libvob/org/nongnu/libvob/gl/GL.java:1.26
libvob/org/nongnu/libvob/gl/GL.java:1.27
--- libvob/org/nongnu/libvob/gl/GL.java:1.26 Fri Oct 10 09:52:23 2003
+++ libvob/org/nongnu/libvob/gl/GL.java Sat Oct 18 02:11:15 2003
@@ -51,6 +51,7 @@
*/
private static native int init(int debug);
+ static private boolean firstWindowTaken = false;
/** Whether the library is loaded.
*/
@@ -339,9 +340,14 @@
/** Create a new window.
*/
static public Window createWindow(int x, int y, int w, int h, EventHandler
eh) {
- return new Window(createWindowImpl(x, y, w, h, eh));
+ boolean first = false;
+ if(! firstWindowTaken) {
+ first = true;
+ firstWindowTaken = true;
+ }
+ return new Window(createWindowImpl(first, x, y, w, h, eh));
}
- static private native int createWindowImpl(int x, int y, int w, int h,
EventHandler eh);
+ static private native int createWindowImpl(boolean first, int x, int y,
int w, int h, EventHandler eh);
static private native void deleteWindow(int i);
static private native void getWindowSize(int id, Rectangle into);
@@ -361,7 +367,7 @@
private Image(int id) { super(id); }
protected void deleteObj() { deleteImage(getId()); }
/** Get the size of this Image.
- * @param dimno The dimension (0=x, 1=y) to get.
+ * @param dimNo The dimension (0=x, 1=y) to get.
*/
public int getSize(int dimNo) { return getImageSize(getId(), dimNo); }
public int getPixel(int offset) { return getImagePixel(getId(),
offset); }
@@ -414,6 +420,15 @@
if(delReal) impl_deleteTexture(getId());
}
+ /** Delete this texture.
+ * Do not use this object any more after calling this
+ * method.
+ */
+ public void deleteTexture() {
+ delReal = false;
+ impl_deleteTexture(getId());
+ }
+
/** Get the OpenGL texture id of this texture.
*/
public int getTexId() { return getId(); }
@@ -778,9 +793,8 @@
/** Set the measurements of a single glyph.
* @param glyph The index of the glyph.
- * @param texInds The indices of the textures to be bound
- * for this glyph. Lenght == layers given to
- * setTextures.
+ * @param texInd The index of the textures to be bound
+ * for this glyph.
*/
public void setMeasurements(int glyph,
int texInd,
@@ -942,8 +956,8 @@
* @param y The y coordinate to read from - note that this uses
* OpenGL's default coordinate system which is
* the opposite of ours in the y direction.
- * @param w The width to read
- * @param h The height to read
+ * @param width The width to read
+ * @param height The height to read
* @param format The format which to store in the vector,
* e.g. "RGB", "RGBA"
* @param type The type to read to, e.g. "FLOAT" or "UNSIGNED_BYTE"
@@ -957,8 +971,9 @@
}
/**
- * @param x,y The coordinates to set raster position to.
- * This is a bit kludgy...
+ * This is a bit kludgy...
+ * @param x The x coordinate to set raster position to.
+ * @param y The y coordinate to set raster position to.
*/
public void drawPixels(RenderingSurface win,
int x, int y, float z, int width, int height,
@@ -1182,11 +1197,27 @@
* @param name The parameter to query, e.g. "VENDOR", "VERSION"
*/
public static native String getGLString(String name);
+
+ /** Get float(s) describing the current OpenGL context.
+ * See the manpage of glGetFloatv(3)
+ * Note: this uses the default window.
+ * @param name The parameter to query, e.g. "ALPHA_BITS"
+ */
+ public static float[] getGLFloat(String name) {
+ return implgetGLFloat(-1, name);
+ }
+
+
/** Get float(s) describing the current OpenGL context.
* See the manpage of glGetFloatv(3)
* @param name The parameter to query, e.g. "ALPHA_BITS"
*/
- public static native float[] getGLFloat(String name);
+ public static float[] getGLFloat(RenderingSurface s, String name) {
+ return implgetGLFloat(s.getId(), name);
+ }
+
+ private static native float[] implgetGLFloat(int rsid, String name);
+
/** Get the given program parameter.
* @param target The name of the program target, e.g. "VERTEX_PROGRAM_ARB"
* @param name The name of the parameter to return, e.g.
"MAX_PROGRAM_INSTRUCTIONS_ARB"
Index: libvob/org/nongnu/libvob/gl/GLUtil.java
diff -u libvob/org/nongnu/libvob/gl/GLUtil.java:1.3
libvob/org/nongnu/libvob/gl/GLUtil.java:1.4
--- libvob/org/nongnu/libvob/gl/GLUtil.java:1.3 Fri Sep 12 14:44:31 2003
+++ libvob/org/nongnu/libvob/gl/GLUtil.java Sat Oct 18 02:11:15 2003
@@ -139,4 +139,43 @@
return null;
}
+
+ /** How many bytes will one texel of a normal (uncompressed)
+ * texture format cover.
+ * For instance, findBpt("RGB", "UNSIGNED_INT") == 12
+ */
+ static public int findBpt(String format, String datatype) {
+ int ncomps = 0;
+ if(format.equals("RED") ||
+ format.equals("GREEN") ||
+ format.equals("BLUE") ||
+ format.equals("ALPHA") ||
+ format.equals("LUMINANCE"))
+ ncomps = 1;
+ else if(format.equals("LUMINANCE_ALPHA"))
+ ncomps = 2;
+ else if(format.equals("RGB") ||
+ format.equals("BGR"))
+ ncomps = 3;
+ else if(format.equals("RGBA") ||
+ format.equals("BGRA"))
+ ncomps = 4;
+
+ if(ncomps == 0) throw new Error("Unknown texture format " + format);
+
+ if(datatype.equals("UNSIGNED_BYTE") ||
+ datatype.equals("BYTE"))
+ return ncomps * 1;
+ if(datatype.equals("UNSIGNED_SHORT") ||
+ datatype.equals("SHORT"))
+ return ncomps * 2;
+ if(datatype.equals("UNSIGNED_INT") ||
+ datatype.equals("INT") ||
+ datatype.equals("FLOAT"))
+ return ncomps * 4;
+
+ throw new Error("Unknown datatype " + datatype);
+
+ }
+
}
Index: libvob/org/nongnu/libvob/gl/MipzipFile.java
diff -u libvob/org/nongnu/libvob/gl/MipzipFile.java:1.2
libvob/org/nongnu/libvob/gl/MipzipFile.java:1.3
--- libvob/org/nongnu/libvob/gl/MipzipFile.java:1.2 Fri Oct 10 09:52:23 2003
+++ libvob/org/nongnu/libvob/gl/MipzipFile.java Sat Oct 18 02:11:15 2003
@@ -34,12 +34,14 @@
import java.util.zip.*;
/** A class for representing Mipzip -format files.
+ * The mipzip file format packs all texture mipmap levels of a single
+ * image into a single .zip file.
* The mipzip file format is defined in the Libvob
* design documentation.
* <p>
- * RESPONSIBILITIES: Manage
- * file accesses to a mipzip file, getting the metadata and
- * the texture levels at will.
+ * This class manages the
+ * file accesses to a mipzip file, providing access to the metadata and
+ * the texture level data.
*/
public class MipzipFile {
public static boolean dbg = false;
@@ -75,6 +77,18 @@
*/
private final String texFormat;
+ /** The internal texture format recommended to use.
+ * Interned string, can be compared with "==".
+ * For compressed formats, null.
+ */
+ private final String internalFormat;
+
+ /** The data type of the texture data.
+ * Interned string, can be compared with "==".
+ * For compressed formats, null.
+ */
+ private final String datatype;
+
/** Whether the texture format is a compressed format.
* OpenGL requires the use of different calls for compressed
* and uncompressed formats.
@@ -96,6 +110,8 @@
// --- methods
+ /** Create a new Mipzip file.
+ */
public MipzipFile(File file) throws IOException {
this.file = file;
synchronized(zlibLock) {
@@ -111,6 +127,18 @@
this.texFormat = e.getComment().intern();
this.compressedFormat = texFormat.indexOf("COMPRESS") != -1;
+ e = zipFile.getEntry("internaltexformat");
+ if(e != null) {
+ this.internalFormat = e.getComment().intern();
+ } else
+ this.internalFormat = null;
+ e = zipFile.getEntry("datatype");
+ if(e != null) {
+ this.datatype = e.getComment().intern();
+ } else
+ this.datatype = null;
+
+
e = zipFile.getEntry("origsize");
if(e == null) throw new IOException("Invalid format: no origsize in
mipzip");
String origSize = e.getComment();
@@ -152,7 +180,9 @@
}
}
- /** Get whether the texture format is compressed.
+ /** Whether the texture format is compressed.
+ * Compressed texture formats require different calls
+ * to be used: glCompressedTexImage instead of glTexImage2D.
*/
public boolean getIsCompressedFormat() {
return compressedFormat;
@@ -160,12 +190,29 @@
/** Get the texture format as a GL string, without the GL_ prefix.
* For example, "COMPRESSED_RGB_S3TC_DXT1_EXT'
- * Returns an interned string for fast comparisons.
+ * Guaranteed to return an interned string to allow fast comparisons.
*/
public String getTexFormat() {
return texFormat;
}
+ /** Get the internal format recommended for this texture.
+ * Null for compressed textures.
+ * Guaranteed to return an interned string to allow fast comparisons.
+ */
+ public String getInternalFormat() {
+ return internalFormat;
+ }
+
+ /** Get the data type used for this texture in the file.
+ * Null for compressed textures.
+ * Guaranteed to return an interned string to allow fast comparisons.
+ */
+ public String getDatatype() {
+ return datatype;
+ }
+
+
/** Get the number of mipmap levels in the file.
*/
public int getNLevels() {
@@ -216,7 +263,7 @@
ZipEntry e = zipFile.getEntry(name);
int size = getLevelSize(level);
byte[] loadedData;
- if(into != null || into.length >= size)
+ if(into != null && into.length >= size)
loadedData = into;
else
loadedData = new byte[(int)e.getSize()];
Index: libvob/org/nongnu/libvob/gl/PaperMill.java
diff -u libvob/org/nongnu/libvob/gl/PaperMill.java:1.6
libvob/org/nongnu/libvob/gl/PaperMill.java:1.7
--- libvob/org/nongnu/libvob/gl/PaperMill.java:1.6 Wed Sep 10 16:07:21 2003
+++ libvob/org/nongnu/libvob/gl/PaperMill.java Sat Oct 18 02:11:15 2003
@@ -44,7 +44,7 @@
* <p>
* HOWEVER, this does not work on ATI drivers; so it is not
* guaranteed that the paper will be like that. Check it first.
- * @see GL.workaroundStupidBuggyAtiDrivers
+ * @see org.nongnu.libvob.GL#workaroundStupidBuggyAtiDrivers
*/
public Paper getOptimizedPaper(int seed) {
return getPaper(seed);
Index: libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java
diff -u libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java:1.1
libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java:1.2
--- libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java:1.1 Sun Sep 28
09:02:17 2003
+++ libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java Sat Oct 18 02:11:15 2003
@@ -60,7 +60,9 @@
}
/** Convert a file name to FTFont to a GLFont.
- * @param font The FTFont to convert.
+ * @param ftfont The FTFont to convert.
+ * @param border The amount of border (in texels) to add around the
+ * characters to ensure all gets rendered.
* @param xscale The scale to apply to the X axis.
* @param yscale The scale to apply to the Y axis.
*/
Index: libvob/org/nongnu/libvob/gl/virtualtexture/IndirectMipzipManager.java
diff -u
libvob/org/nongnu/libvob/gl/virtualtexture/IndirectMipzipManager.java:1.1
libvob/org/nongnu/libvob/gl/virtualtexture/IndirectMipzipManager.java:1.2
--- libvob/org/nongnu/libvob/gl/virtualtexture/IndirectMipzipManager.java:1.1
Fri Oct 10 09:52:24 2003
+++ libvob/org/nongnu/libvob/gl/virtualtexture/IndirectMipzipManager.java
Sat Oct 18 02:11:15 2003
@@ -1,12 +1,96 @@
// (c) Tuomas J. Lukka
package org.nongnu.libvob.gl.virtualtexture;
+import org.nongnu.libvob.util.Background;
/** An indirect virtual texture manager: load and unload mipzip files
* to given levels.
* Objects implementing
* this interface manages a set of texture images that have the same
* format, and the same level-0 width and height.
+ * <p>
+ * The basic model is that there is a fixed number of *slots*
+ * of each mipmap-level size, and a single
+ * VirtualTexture object may be
+ * assigned to a single slot at a time.
+ * The slots may be implemented by simply loading and removing mipmap
+ * levels from the underlying texture, but this interface exists
+ * to allow a more static implementation that stresses
+ * the underlying OpenGL implementation less (exposing less bugs),
+ * see NonDeletingIndirectMipzipManager.
+ * <p>
+ * This interface is a little clumsy, containing initialization
+ * as well as use; the alternative would be to have a factory and
+ * that would not be fun.
+ * <p>
+ * The reason for this interface is that we've had *lots* of trouble
+ * with the OpenGL drivers about this sort of stuff -- they've
+ * obviously not been written with this in mind. The interface
+ * is here so that different implementations that may work better
+ * or worse on specific drivers may be tried.
*/
public interface IndirectMipzipManager {
+
+ /** Initialize this object.
+ * @param format The GL texture format string,
+ * @param width The width of mipmap level 0.
+ * @param height The height of mipmap level 0.
+ * e.g. COMPRESSED_RGB_S3TC_DXT1_EXT.
+ */
+ void init(String format, int width, int height) ;
+
+ /** Set the default texture parameters.
+ * For now, should be called exactly once between
+ * init and setAllocations.
+ * <p>
+ * Example use:
+ * <pre>
+ * setTexParameters(new String[] {
+ * "TEXTURE_MAG_FILTER", "LINEAR",
+ * "TEXTURE_MIN_FILTER", "LINEAR_MIPMAP_LINEAR",
+ * "TEXTURE_MAX_ANISOTROPY_EXT", "10",
+ * });
+ * </pre>
+ * <p>
+ * If you set any of the texture parameters for any virtual textures
+ * given to this class (which is actually not yet possible but will
+ * be in the future), remember to give the default value here,
+ * as otherwise the value cannot be reset when the texture is moved.
+ * <p>
+ * NOTE: Don't set TEXTURE_BASE_LEVEL or any of the LOD (except
+ * LOD bias) parameters here, as the mipmap levels may be shifted
+ * inside the class. Setting GENERATE_MIPMAP_SGIS would be just plain
+ * daft.
+ * @param params The texture parameters, as pair of parameter-value.
+ */
+ void setDefaultTexParameters(String[] params);
+
+ /** Set the number of slots of each mipmap level
+ * to allocate.
+ * XXX May currently interact nastily with
+ * reservations - run this only just after
+ * construction. This restriction will be lifted
+ * later.
+ * @param ntextures Indexed by mipmap level,
+ * the number of textures of that
+ * size to allocate.
+ */
+ void setAllocations(int[] ntextures) ;
+
+ /** Set the background objects that this object should use.
+ * @param background The background object to use for
+ * non-OpenGL tasks.
+ * @param bgPriority The priority to give to those tasks
+ * @param glBackground The background object to use for OpenGL tasks
+ * @param glPriority The priority to give to those tasks
+ */
+ void setBackgrounds(Background background, float bgPriority,
+ Background glBackground, float glPriority) ;
+
+ /** Set what the slots should contain.
+ * The change is not immediate but happens in the background,
+ * starting from the lowest levels (highest resolutions)
+ * which are considered a priority.
+ */
+ void setSlotContents(VirtualTexture[][] newContents) ;
}
Index:
libvob/org/nongnu/libvob/gl/virtualtexture/NonDeletingIndirectMipzipManager.java
diff -u
libvob/org/nongnu/libvob/gl/virtualtexture/NonDeletingIndirectMipzipManager.java:1.1
libvob/org/nongnu/libvob/gl/virtualtexture/NonDeletingIndirectMipzipManager.java:1.2
---
libvob/org/nongnu/libvob/gl/virtualtexture/NonDeletingIndirectMipzipManager.java:1.1
Fri Oct 10 09:52:24 2003
+++
libvob/org/nongnu/libvob/gl/virtualtexture/NonDeletingIndirectMipzipManager.java
Sat Oct 18 02:11:15 2003
@@ -12,9 +12,11 @@
/** An IndirectMipzipManager that doesn't delete or move
* textures in OpenGL (as a workaround for driver problems).
- * shall not get glDeleteTexture()d or re-teximaged
+ * This IndirectMipzipManager will
+ * not call glDeleteTexture() or re-teximag textures
* but instead, when detail levels are shifted,
- * are shifted around. Only uses glTexSubImage() and glCompressedTexSubImage
+ * shifts them from one constant, fixed texture to
+ * another. Only uses glTexSubImage() and glCompressedTexSubImage
* after initialization.
* <p>
* There are two main issues that make this class complicated:
@@ -22,89 +24,22 @@
* from the disk (zip files) in a background thread, and
* 2) the OpenGL thread must be kept occupied only for short amounts
* of time at a time, to avoid loss of interactivity.
+ * <p>
+ * <b>Main problem of this class: it doesn't work at all
+ * with NV 44.96 drivers, as was initially hoped.
+ * The changes to the textures do not get propagated correctly.
+ * Using __GL_TEX_MEMORY_SPACE_ENABLES=0 makes it work but
+ * it's dog slow. TODO: proper C test case for nvidia...</b>
*/
-public class NonDeletingIndirectMipzipManager {
- public static boolean dbg = true;
- private static void pa(String s) { System.out.println(s); }
-
-// ---- Final metadata
- private final String format;
- private final boolean isCompressedFormat;
- private final int width, height;
- private final int bitsPerTexel;
- private final int nlevels;
-
- private final int[] levelWidths;
- private final int[] levelHeights;
+public class NonDeletingIndirectMipzipManager
+ extends AbstractIndirectMipzipManager
+ implements IndirectMipzipManager
+{
+ public static boolean dbg = false;
+ private static void pa(String s) { System.out.println("NDMZM: "+s); }
// ---- Stable temporary data arrays
- /** A mipmap array stored in memory, with a given maximum detail
- * level.
- * LOCKING: all data is locked on a per-mipmap level,
- * by locking levels[level].
- */
- private class MipmapArray {
- /** The minimum level that this object should
- * contain data for.
- */
- int minLevel;
- /** The levels.
- */
- byte[][] levels = new byte[nlevels][];
- /** The number of bytes of data
- * in a level.
- * -1 = should be loaded, 0 = couldn't load,
- * greater than 0 = contains the data.
- */
- int[] levelSizes = new int[nlevels];
- /** What the data in each level array is for.
- */
- VirtualTexture[] virtualTextures = new VirtualTexture[nlevels];
-
- MipmapArray(int minLevel) {
- this.minLevel = minLevel;
- for(int i=minLevel; i<levels.length; i++)
- levels[i] = new byte[0];
- }
-
- /** If data is scheduled to be loaded but has not
- * yet been loaded, load it.
- * This is separated from teximageData because
- * we can run this in a non-gl thread, allowing a speed
- * boost especially on SMP systems.
- * @return true, if something was done.
- */
- public boolean loadData() throws IOException {
- // Start from the small levels; having a large
- // level without the small ones is useless
- for(int i=levels.length-1; i>=0; i--) {
- synchronized(levels[i]) {
- if(virtualTextures[i] != null && levelSizes[i] == -1) {
- // load this level
- // This may change the member we locked,
- // but it's ok at this point.
- levels[i] =
- virtualTextures[i].mipzipFile.getLevelData(i,
- levels[i]);
- // Mark it loaded by setting the size
- levelSizes[i] =
- virtualTextures[i].mipzipFile.getLevelSize(i);
- return true;
- }
- }
- }
- return false;
- }
-
- public void setLoadRequest(int level, VirtualTexture virtualTexture) {
- synchronized(levels[level]) {
- levelSizes[level] = -1;
- virtualTextures[level] = virtualTexture;
- }
- }
- }
-
/** The termporary array where data can be left
* for a longer time.
* No element 0.
@@ -158,11 +93,15 @@
this.slotLevel = level;
this.slotIndex = index;
for(int i=0; i < nlevels - slotLevel; i++) {
+ if(dbg) pa("Creating slot: "+
+ i+" "+
+ levelWidths[i+slotLevel]+" "+
+ levelWidths[i+slotLevel]+" ");
texture.loadNull2D("TEXTURE_2D", i,
- format,
- levelWidths[i + slotLevel],
- levelHeights[i + slotLevel], 0,
- "RGB", "FLOAT");
+ format,
+ levelWidths[i + slotLevel],
+ levelHeights[i + slotLevel], 0,
+ "RGB", "FLOAT");
}
}
@@ -175,6 +114,7 @@
* on the new slot.
*/
synchronized void changeImage(VirtualTexture newImage) {
+ if(dbg) pa("ChangeImage "+this+" "+newImage);
if(currentImage != null) {
currentImage.indirectTexture.setTexture(null);
virtualImage2slot.remove(currentImage);
@@ -185,11 +125,21 @@
virtualImage2slot.put(newImage, this);
}
currentImage = newImage;
+ setBaseLevel();
+ }
+
+ void setTexParameters(String[] params) {
+ if(params == null) return;
+ for(int i=0; i<params.length; i+=2) {
+ texture.setTexParameter("TEXTURE_2D", params[i], params[i+1]);
+ }
}
/** Whether all the levels needed for the current image have been
loaded.
*/
- boolean allLoaded() { return baselevel == slotLevel; }
+ boolean allLoaded() {
+ return currentImage == null || baselevel == slotLevel;
+ }
/** Call the base level setting on the texture.
*/
@@ -204,12 +154,16 @@
if(i == nlevels) i--;
texture.setTexParameter("TEXTURE_2D",
"TEXTURE_BASE_LEVEL", i - slotLevel +1);
+ if(dbg) pa(""+this+" Baselevel set to "+(i-slotLevel+1));
+ setTexParameters(defaultTexParameters);
return;
}
}
baselevel = slotLevel;
texture.setTexParameter("TEXTURE_2D",
- "TEXTURE_BASE_LEVEL", slotLevel );
+ "TEXTURE_BASE_LEVEL", 0 );
+ setTexParameters(defaultTexParameters);
+ if(dbg) pa(""+this+" Baselevel set to 0 - all loaded");
}
/** Save data of a level to a byte array.
@@ -220,12 +174,26 @@
* @return Data size saved.
*/
synchronized int saveData(int level, byte[][] data, int index) {
- if(dbg) pa("SaveData "+this+" "+level+" "+data[index]);
- int size = (int)(texture.getLevelParameter(level - slotLevel,
-
"TEXTURE_COMPRESSED_IMAGE_SIZE_ARB")[0]);
+ int size;
+ if(isCompressedFormat) {
+ size = (int)(texture.getLevelParameter(level - slotLevel,
+ "TEXTURE_COMPRESSED_IMAGE_SIZE_ARB")[0]);
+ } else {
+ size = levelWidths[level] * levelHeights[level]
+ * GLUtil.findBpt(format,
+ currentImage.mipzipFile.getDatatype());
+ }
if(data[index].length < size)
data[index] = new byte[size];
- texture.getCompressedTexImage(level - slotLevel, data[index]);
+ if(dbg) pa("SaveData "+this+" "+level+" "+data[index]);
+
+ if(isCompressedFormat) {
+ texture.getCompressedTexImage(level - slotLevel, data[index]);
+ } else {
+ texture.getTexImage(level - slotLevel, format,
+ currentImage.mipzipFile.getDatatype(),
+ data[index]);
+ }
return size;
}
@@ -234,14 +202,45 @@
* @param level The **absolute** mipmap level
*/
synchronized void loadData(int level, byte[] data, int size) {
- if(dbg) pa("LoadData: "+this+" "+level+" "+data+" "+size);
+ if(dbg) {
+ StringBuffer s = new StringBuffer();
+ for(int j=0; j < 24 && j< size; j ++) {
+ s.append(data[j]);
+ s.append(",");
+ }
+ if(dbg) pa("LoadData: "+this+" "+level+" "+data+" "+size+" "+s);
+ }
if(level < slotLevel)
throw new Error("Tried to load too high a level");
if(size <= 0)
throw new Error("LoadData: NO DATA???");
- texture.compressedTexSubImage2D(level - slotLevel,
- 0, 0, levelWidths[level], levelHeights[level],
- format, size, data);
+
+ /* Set baselevel to 0 temporarily. NV driver 44.96 has a bug
+ * where texImage calls to levels below BASE_LEVEL affect
+ * the OpenGL state (i.e. getTexImage returns the correct values)
+ * but not the texture that will be rendered.
+ * The code in lava/bugs/nvtex shows this.
+ *
+ * N.B. finding that this was the problem took Tjl several days
+ * of EXTREME hard work and stress, since this is a vital code
+ * path for us.
+ */
+ texture.setTexParameter("TEXTURE_2D",
+ "TEXTURE_BASE_LEVEL", 0 );
+
+ if(isCompressedFormat) {
+ texture.compressedTexSubImage2D(level - slotLevel,
+ 0, 0, levelWidths[level], levelHeights[level],
+ format, size, data);
+ } else {
+ texture.texSubImage2D(level - slotLevel,
+ 0, 0, levelWidths[level], levelHeights[level],
+ 0, currentImage.mipzipFile.getTexFormat(),
+ currentImage.mipzipFile.getDatatype(),
+ data);
+ }
+
+
levelsLoaded[level] = true;
}
@@ -272,22 +271,22 @@
/** Load all relevant levels from the temporary array.
*/
synchronized void loadFromTmp(MipmapArray from) {
- for(int i=0; i<nlevels; i++) {
- if(i >= slotLevel &&
- from.levels[i] != null &&
- (!levelsLoaded[i]) &&
- from.virtualTextures[i] == this.currentImage) {
- synchronized(from.levels[i]) {
- // Have to make sure this still stands
- // in the synchronized section
- if(from.virtualTextures[i] == this.currentImage) {
- if(from.levelSizes[i] > 0)
- loadData(i, from.levels[i], from.levelSizes[i]);
- if(from.levelSizes[i] == 0) {
- from.levelSizes[i] = -1;
- from.virtualTextures[i] = null;
+ synchronized(from) {
+ for(int i=nlevels-1; i>=0; i--) {
+ if(i >= slotLevel &&
+ from.levels[i] != null &&
+ (!levelsLoaded[i]) &&
+ from.virtualTextures[i] == this.currentImage) {
+ // Have to make sure this still stands
+ // in the synchronized section
+ if(from.virtualTextures[i] == this.currentImage) {
+ if(from.levelSizes[i] > 0)
+ loadData(i, from.levels[i],
from.levelSizes[i]);
+ if(from.levelSizes[i] == 0) {
+ from.levelSizes[i] = -1;
+ from.virtualTextures[i] = null;
+ }
}
- }
}
}
}
@@ -295,7 +294,8 @@
}
public String toString() {
- return "[Slot: "+slotLevel+" "+slotIndex+"]";
+ return "[Slot: "+slotLevel+" "+slotIndex+" ("+texture.getTexId()
+ +")]";
}
}
@@ -316,106 +316,46 @@
*/
HashMap virtualImage2targetSlot = new HashMap();
- boolean targetsChanged;
// ---- External API
-
- /** Create a new NonDeletingIndirectMipzipManager.
- * @param format The GL texture format string,
- * e.g. COMPRESSED_RGB_S3TC_DXT1_EXT.
- */
- public NonDeletingIndirectMipzipManager(String format, int width, int
height) {
- this.format = format.intern();
- this.bitsPerTexel = GL.bitsPerTexel(format);
- this.width = width;
- this.height = height;
-
- int w = width, h = height;
- int nlevels = 0;
- while(w > 0 && h > 0) {
- nlevels ++;
- w /= 2;
- h /= 2;
- }
- this.nlevels = nlevels;
- this.levelWidths = new int[nlevels];
- this.levelHeights = new int[nlevels];
- w = width; h = height;
- for(int i=0; i<nlevels; i++) {
- levelWidths[i] = w;
- levelHeights[i] = h;
- w /= 2; if(w == 0) w = 1;
- h /= 2; if(h == 0) h = 1;
- }
-
+ public void setAllocations(int[] ntextures) {
slots = new Slot[nlevels][];
slotTargets = new VirtualTexture[nlevels][];
- isCompressedFormat = (format.indexOf("COMPRESS") != -1);
-
- stableTmp = new MipmapArray(1);
- swapTmp = new MipmapArray(1);
- loadTmp = new MipmapArray(0);
- }
+ stableTmp = new MipmapArray(nlevels, 1);
+ swapTmp = new MipmapArray(nlevels, 1);
+ loadTmp = new MipmapArray(nlevels, 0);
- /** Return the number of mipmap levels
- * that textures of this size have.
- */
- public int getNLevels() {
- return nlevels;
- }
-
- /** Set the number of slots of each mipmap level
- * to allocate.
- * XXX May currently interact nastily with
- * reservations - run this only just after
- * construction. This restriction will be lifted
- * later.
- * @param ntextures Indexed by mipmap level,
- * the number of textures of that
- * size to allocate.
- */
- public void setAllocations(int[] ntextures) {
if(ntextures.length != nlevels)
throw new Error("Invalid length "+ntextures.length+" "+nlevels);
// Assuming no previous allocations...
for(int i=0; i<nlevels; i++) {
slots[i] = new Slot[ntextures[i]];
slotTargets[i] = new VirtualTexture[ntextures[i]];
- for(int j=0; j<ntextures[i]; j++)
+ for(int j=0; j<ntextures[i]; j++) {
slots[i][j] = new Slot(i, j);
+ slots[i][j].setTexParameters(defaultTexParameters);
+ }
}
}
- /** The priority to give to the GL update manager.
- */
- public int glPriority = 5;
- /** The priority to give to the Bg update manager.
- */
- public int bgPriority = 5;
- /** The background object to run the non-gl jobs in.
- */
- public Background background = ThreadBackground.getDefaultInstance();
-
- /** The background object to run the gl jobs in.
- * Usually AbstractUpdateManager.getInstance()
- */
- public Background glBackground;
-
private Runnable r_runBg = new Runnable() {
public void run() {
- boolean res;
- try {
- res =loadTmp.loadData();
- } catch(IOException e) {
- pa("IO EXCEPTION LOADING MIPZIP");
- res = true;
- }
- if(res) {
- background.addTask(r_runBg, bgPriority);
- glBackground.addTask(r_runGL, glPriority);
+ synchronized(NonDeletingIndirectMipzipManager.this) {
+ if(dbg) pa("runbg");
+ boolean res;
+ try {
+ res =loadTmp.loadData();
+ } catch(IOException e) {
+ pa("IO EXCEPTION LOADING MIPZIP");
+ res = true;
+ }
+ if(res) {
+ background.addTask(r_runBg, bgPriority);
+ glBackground.addTask(r_runGL, glPriority);
+ }
}
}
};
@@ -478,9 +418,16 @@
private Runnable r_runGL = new Runnable() {
public void run() {
+ if(dbg) pa("rungl");
/* Figure out what's missing from having all the
* slots filled with the correct textures.
*/
+ synchronized(NonDeletingIndirectMipzipManager.this) {
+ if(defaultTexParametersChanged) {
+ for(int i=0; i<nlevels; i++)
+ for(int j=0; j<slots[i].length; j++)
+ slots[i][j].setTexParameters(defaultTexParameters);
+ }
synchronized(slots) {
Slot unfinished = null;
boolean loadScheduled = false;
@@ -517,18 +464,16 @@
if(loadScheduled || demoted)
glBackground.addTask(r_runGL, glPriority);
}
+ }
}
};
- /** Set what the slots should contain.
- * The change is not immediate but happens in the background,
- * starting from the lowest levels (highest resolutions)
- * which are considered a priority.
- */
- public void setSlotContents(VirtualTexture[][] newContents) {
+ public synchronized void setSlotContents(VirtualTexture[][] newContents) {
+ if(dbg) pa("setSlotContents");
Set onLevel = new HashSet();
Set toBe = new HashSet();
Set newComers = new HashSet();
+ int changed = 0;
// Keep the existing ones there, others are assigned
// arbitrarily. Should we optimize?
synchronized(slots) {
@@ -544,13 +489,25 @@
}
newComers.addAll(toBe);
newComers.removeAll(onLevel);
+ changed += newComers.size();
Iterator newIter = newComers.iterator();
+ while(newIter.hasNext()) {
+ VirtualTexture vt = (VirtualTexture)newIter.next();
+ Dimension size = vt.mipzipFile.getLevelDimension(0);
+ if(size.width != width && size.height != height)
+ throw new Error("Invalid mipzip added:" + size);
+ if(!(vt.mipzipFile.getTexFormat().equals(format)))
+ throw new Error("Invalid mipzip added:" +
vt.mipzipFile.getTexFormat());
+ }
+ newIter = newComers.iterator();
for(int j=0; j<slots[i].length; j++) {
- if(! newIter.hasNext()) break;
if(slotTargets[i][j] != null)
virtualImage2targetSlot.remove(slotTargets[i][j]);
if(!toBe.contains(slots[i][j].currentImage)) {
- slotTargets[i][j] = (VirtualTexture)newIter.next();
+ if(! newIter.hasNext())
+ slotTargets[i][j] = null;
+ else
+ slotTargets[i][j] = (VirtualTexture)newIter.next();
} else {
slotTargets[i][j] = slots[i][j].currentImage;
}
@@ -560,14 +517,10 @@
}
}
}
+ if(dbg) pa("Slot contents: changed "+changed);
glBackground.addTask(r_runGL, glPriority);
/*
- Dimension size = mipzipFile.getLevelDimension(0);
- if(size.width != width && size.height != height)
- throw new Error("Invalid mipzip added:" + size);
- if(!(mipzipFile.getTexFormat().equals(format)))
- throw new Error("Invalid mipzip added:" +
mipzipFile.getTexFormat());
return new VirtualTexture(GL.createIndirectTexture(), mipzipFile);
*/
}
Index: libvob/org/nongnu/libvob/gl/virtualtexture/VirtualTexture.java
diff -u libvob/org/nongnu/libvob/gl/virtualtexture/VirtualTexture.java:1.1
libvob/org/nongnu/libvob/gl/virtualtexture/VirtualTexture.java:1.2
--- libvob/org/nongnu/libvob/gl/virtualtexture/VirtualTexture.java:1.1 Fri Oct
10 09:52:24 2003
+++ libvob/org/nongnu/libvob/gl/virtualtexture/VirtualTexture.java Sat Oct
18 02:11:15 2003
@@ -9,10 +9,18 @@
import java.util.*;
import java.util.zip.*;
-/** An object that associates a mipzip file and an indirect texture.
+/** An object that represents a texture to be incrementally loaded from
+ * the disk or re-forgotten.
+ * The texture on disk is represented by a Mipzip file,
+ * and in memory by a GL.IndirectTexture object that will point
+ * to the texture where the image is currently loaded to.
*/
public class VirtualTexture {
+ public VirtualTexture(MipzipFile mipzipFile) {
+ this.indirectTexture = GL.createIndirectTexture();
+ this.mipzipFile = mipzipFile;
+ }
public VirtualTexture(GL.IndirectTexture indirectTexture,
MipzipFile mipzipFile) {
this.indirectTexture = indirectTexture;
Index:
libvob/org/nongnu/libvob/gl/virtualtexture/nondeletingindirectmipzipmanager.test
diff -u
libvob/org/nongnu/libvob/gl/virtualtexture/nondeletingindirectmipzipmanager.test:1.1
libvob/org/nongnu/libvob/gl/virtualtexture/nondeletingindirectmipzipmanager.test:1.2
---
libvob/org/nongnu/libvob/gl/virtualtexture/nondeletingindirectmipzipmanager.test:1.1
Fri Oct 10 09:52:24 2003
+++
libvob/org/nongnu/libvob/gl/virtualtexture/nondeletingindirectmipzipmanager.test
Sat Oct 18 02:11:15 2003
@@ -6,92 +6,11 @@
import vob
import org
from test.tools.gfx import *
+from vob.putil.misc import *
needGL()
-def testSingleGetsLoaded_nosynch():
- """Test with separate copies of a single image that
- the image gets loaded to the right levels of detail.
+from vob.gl.virtualtexture.testindirectmipzipmanager import *
- XXX Make this test not use compressed textures...
- """
-
- indirectMipzipManager =
org.nongnu.libvob.gl.virtualtexture.NonDeletingIndirectMipzipManager(
- "COMPRESSED_RGB_S3TC_DXT1_EXT", 1024, 1024)
-
- indirectMipzipManager.glBackground = vob.util.ExplicitBackground();
- indirectMipzipManager.background = vob.util.ExplicitBackground();
-
- indirectMipzipManager.setAllocations([
- 1, 2, 4,6, 8, 0, 0, 0, 0, 0, 0])
-
- virtualTextures = [
-
org.nongnu.libvob.gl.virtualtexture.VirtualTexture(vob.gl.GL.createIndirectTexture(),
- vob.gl.MipzipFile(java.io.File("testdata/modularspace.mipzip")))
- for i in range(0, 20)]
-
- def vt(*ar):
- def mvt(i):
- if i == None: return None
- return virtualTextures[i]
- return [mvt(i) for i in ar]
-
- indirectMipzipManager.setSlotContents([
- vt(0),
- vt(1,2),
- vt(3,4,5,6),
- vt(7,8,9,10,11,12),
- vt(13,14,15,16,17,18,19,None),
- [], [], [], [], [], []
- ])
-
- def gb(i):
- """Get the base level of the given texture.
- 100 = not loaded.
- """
- tex = virtualTextures[i].indirectTexture.getTexture()
- if tex == None: return 100
- return tex.getParameter("TEXTURE_BASE_LEVEL")[0]
-
- def totlev(i, l):
- """Whether the virtualtexture i is totally loaded
- at level l.
- """
- if gb(i) != 0: return 0
- tex = virtualTextures[i].indirectTexture.getTexture()
- wid = tex.getLevelParameter(0, "TEXTURE_WIDTH")[0]
- if wid != (1024 >> l): return 0
- return 1
-
- done = 0
- for i in range(0, 10000):
- indirectMipzipManager.glBackground.performOneTask()
- indirectMipzipManager.background.performOneTask()
-
- if totlev(0,0) and totlev(1,1) and totlev(10,3) and totlev(19,4):
- done = 1
- break
- assert done, (gb(0), gb(1), gb(10), gb(19))
-
- indirectMipzipManager.setSlotContents([
- vt(1),
- vt(3,0),
- vt(4,2,5,6),
- vt(7,8,9,10,11,12),
- vt(13,14,15,16,17,18,19,None),
- [], [], [], [], [], []
- ])
-
-
- done = 0
- for i in range(0, 10000):
- indirectMipzipManager.glBackground.performOneTask()
- indirectMipzipManager.background.performOneTask()
-
- if totlev(0,1) and totlev(1,0) and totlev(3, 1) \
- and totlev(10,3) and totlev(19,4):
- done = 1
- break
- assert done, (gb(0), gb(1), gb(10), gb(19))
-
-# vim: set syntax=python :
+def setUp():
+
setUp_imzm(org.nongnu.libvob.gl.virtualtexture.NonDeletingIndirectMipzipManager(),
0)
Index: libvob/org/nongnu/libvob/impl/gl/GLAPI.java
diff -u libvob/org/nongnu/libvob/impl/gl/GLAPI.java:1.4
libvob/org/nongnu/libvob/impl/gl/GLAPI.java:1.5
--- libvob/org/nongnu/libvob/impl/gl/GLAPI.java:1.4 Fri May 16 07:02:41 2003
+++ libvob/org/nongnu/libvob/impl/gl/GLAPI.java Sat Oct 18 02:11:15 2003
@@ -3,20 +3,20 @@
*
* Copyright (c) 2002, Tuomas Lukka
*
- * This file is part of Gzz.
+ * This file is part of Libvob.
*
- * Gzz is free software; you can redistribute it and/or modify it under
+ * Libvob is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * Gzz is distributed in the hope that it will be useful, but WITHOUT
+ * Libvob is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
* Public License for more details.
*
* You should have received a copy of the GNU Lesser General
- * Public License along with Gzz; if not, write to the Free
+ * Public License along with Libvob; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
Index: libvob/org/nongnu/libvob/lava/placeable/TextPlaceable.java
diff -u libvob/org/nongnu/libvob/lava/placeable/TextPlaceable.java:1.2
libvob/org/nongnu/libvob/lava/placeable/TextPlaceable.java:1.3
--- libvob/org/nongnu/libvob/lava/placeable/TextPlaceable.java:1.2 Mon Aug
18 08:54:11 2003
+++ libvob/org/nongnu/libvob/lava/placeable/TextPlaceable.java Sat Oct 18
02:11:15 2003
@@ -35,12 +35,14 @@
public interface TextPlaceable extends Placeable {
/**
* Get the coordinates before the given character position.
- * The Y coordinate will be located just below the the line.
+ * This returns one x and two y coordinates: the top and
+ * bottom of the line.
* @param position The text cursor position.
- * @param xyOut The lower left corner of the character on
- * The text cursor's position.
+ * @param xyyOut The coordinates of the given text cursor position:
+ * the x coordinate, the top y coordinate, and the
+ * bottom y coordinate.
*/
- void getCursorXY(int position, float[] xyOut);
+ void getCursorXYY(int position, float[] xyyOut);
/**
* Get the position of the first character placed the most
Index: libvob/org/nongnu/libvob/linebreaking/HBox.java
diff -u libvob/org/nongnu/libvob/linebreaking/HBox.java:1.4
libvob/org/nongnu/libvob/linebreaking/HBox.java:1.5
--- libvob/org/nongnu/libvob/linebreaking/HBox.java:1.4 Wed Sep 10 09:40:53 2003
+++ libvob/org/nongnu/libvob/linebreaking/HBox.java Sat Oct 18 02:11:15 2003
@@ -73,7 +73,7 @@
*/
int getLength();
- /** Get the position after a unit (e.g. character)
+ /** Get the position after a unit (usually character)
* inside this HBox.
*/
float getX(int i, float scale) throws IndexOutOfBoundsException;
Index: libvob/org/nongnu/libvob/linebreaking/HChain.java
diff -u libvob/org/nongnu/libvob/linebreaking/HChain.java:1.1
libvob/org/nongnu/libvob/linebreaking/HChain.java:1.2
--- libvob/org/nongnu/libvob/linebreaking/HChain.java:1.1 Sun Mar 16
10:55:04 2003
+++ libvob/org/nongnu/libvob/linebreaking/HChain.java Sat Oct 18 02:11:15 2003
@@ -39,7 +39,7 @@
int GLUE_STRETCH = 1;
int GLUE_SHRINK = 2;
- /** Return the length of, i.e. the number of HBoxes in, this vob chain. */
+ /** Return the length of, i.e., the number of HBoxes in, this vob chain. */
int length();
/** Return the <code>n</code>th box in this chain. */
Index: libvob/org/nongnu/libvob/linebreaking/Linebreaker.java
diff -u libvob/org/nongnu/libvob/linebreaking/Linebreaker.java:1.2
libvob/org/nongnu/libvob/linebreaking/Linebreaker.java:1.3
--- libvob/org/nongnu/libvob/linebreaking/Linebreaker.java:1.2 Wed Sep 10
09:40:53 2003
+++ libvob/org/nongnu/libvob/linebreaking/Linebreaker.java Sat Oct 18
02:11:15 2003
@@ -47,8 +47,6 @@
* @param ctoken The index of the cursor in this lbchain.
* @param crow The index of the row in lines that the token
* indicated by ctoken should land on
- * @param into An array that contains the starts of the lines
- * in terms of tokens in this box.
* @return A configuration of lines as a <code>Broken</code> object.
*/
Broken breakLines(LinebreakableChain chain,
@@ -80,7 +78,8 @@
/** Put this configuration of lines into a <code>VobPlacer</code>.
* This calls <code>LinebreakableChain.putLine</code> for each
* individual line.
- * @param x,y The coordinates of the upper left corner.
+ * @param x The x coordinate of the upper left corner.
+ * @param y The y coordinate of the upper left corner.
*/
public void putLines(VobScene into, int cs) {
int x = 0, y = 0, d = 0;
Index: libvob/org/nongnu/libvob/linebreaking/LinebreakingUtil.java
diff -u libvob/org/nongnu/libvob/linebreaking/LinebreakingUtil.java:1.2
libvob/org/nongnu/libvob/linebreaking/LinebreakingUtil.java:1.3
--- libvob/org/nongnu/libvob/linebreaking/LinebreakingUtil.java:1.2 Wed Sep
10 09:40:53 2003
+++ libvob/org/nongnu/libvob/linebreaking/LinebreakingUtil.java Sat Oct 18
02:11:15 2003
@@ -90,9 +90,13 @@
}
/** Put a line into the given vobPlacer.
- * @param x,y The x and y coordinate of the leftmost point
+ * @param x The x coordinate of the leftmost point
* of the baseline.
- * @param start,end The index of the first and the index after the last
+ * @param y The y coordinate of the leftmost point
+ * of the baseline.
+ * @param end The index of the first
+ * box to place on the line.
+ * @param end The index after the last
* box to place on the line.
* @param cs coordsys to place stuff into
*/
Index: libvob/org/nongnu/libvob/package.html
diff -u libvob/org/nongnu/libvob/package.html:1.3
libvob/org/nongnu/libvob/package.html:1.4
--- libvob/org/nongnu/libvob/package.html:1.3 Mon Aug 11 07:56:10 2003
+++ libvob/org/nongnu/libvob/package.html Sat Oct 18 02:11:15 2003
@@ -16,11 +16,11 @@
</head>
<body bgcolor="white">
-<h1>org.nongnu.libvob</h1>
+<h1>org.nongnu.libvob - the main API of Libvob compatible with both AWT and GL.
+</h1>
<p>
-The high-level graphics library for animation and connections.
-Does not depend on the rest of Gzz.
+A high-level graphics library for animation and connections.
</body>
</html>
Index: libvob/org/nongnu/libvob/util/ThreadBackground.java
diff -u libvob/org/nongnu/libvob/util/ThreadBackground.java:1.4
libvob/org/nongnu/libvob/util/ThreadBackground.java:1.5
--- libvob/org/nongnu/libvob/util/ThreadBackground.java:1.4 Wed Sep 10
08:48:42 2003
+++ libvob/org/nongnu/libvob/util/ThreadBackground.java Sat Oct 18 02:11:15 2003
@@ -31,7 +31,8 @@
package org.nongnu.libvob.util;
/** An implementation of Background using another thread.
- * // XXX Reimplement using ExplicitBackground as a base
+ * Implementation Note:
+ * XXX should Reimplement using ExplicitBackground as a base
*/
public class ThreadBackground implements Background {
Index: libvob/src/jni/Main.cxx
diff -u libvob/src/jni/Main.cxx:1.27 libvob/src/jni/Main.cxx:1.28
--- libvob/src/jni/Main.cxx:1.27 Fri Oct 10 09:52:25 2003
+++ libvob/src/jni/Main.cxx Sat Oct 18 02:11:15 2003
@@ -320,11 +320,22 @@
// Window
jf(jint, createWindowImpl)
- (JNIEnv *env, jclass, jint x, jint y, jint w, jint h, jobject eh) {
+ (JNIEnv *env, jclass, jboolean first,
+ jint x, jint y, jint w, jint h, jobject eh) {
DBG(dbg) << "Creating new window for Java "<<x<<" "<<y<<" "<<w<<"
"<<h<<"\n";
jobject ehglobal = env->NewGlobalRef(eh);
GZZJNIEventHandler *evh = new GZZJNIEventHandler(env, ehglobal);
- Os::Window *win = ws->openWindow(x, y, w, h);
+
+ Os::Window *win;
+ if(first) {
+ /* Reuse the window that was created at init time.
+ */
+ win = defaultWindow;
+ win->resize(w,h);
+ win->move(x, y);
+ } else {
+ win = ws->openWindow(x, y, w, h);
+ }
DBG(dbg) << "Setting its eventhandler to "<<((int)evh)<<"\n";
win->setEventHandler(evh);
DBG(dbg) << "Return to J\n";
@@ -601,12 +612,20 @@
return env->NewStringUTF(value);
}
-jf(jfloatArray, getGLFloat)
- (JNIEnv *env, jclass, jstring name) {
+jf(jfloatArray, implgetGLFloat)
+ (JNIEnv *env, jclass, jint rsid, jstring name) {
std::string utf = jstr2stdstr(env, name);
+
+ if(rsid >= 0)
+ setWindow(rsid);
+
vector<float> vec = CallGL::getFloat(utf.c_str()) ;
jfloatArray result = env->NewFloatArray(vec.size());
env->SetFloatArrayRegion(result, 0, vec.size(), &vec[0]);
+
+ if(rsid >= 0)
+ releaseWindow();
+
return result;
}
Index: libvob/src/jni/Texture.cxx
diff -u libvob/src/jni/Texture.cxx:1.1 libvob/src/jni/Texture.cxx:1.2
--- libvob/src/jni/Texture.cxx:1.1 Fri Oct 10 09:53:37 2003
+++ libvob/src/jni/Texture.cxx Sat Oct 18 02:11:15 2003
@@ -64,22 +64,18 @@
// Texture
jf(jint, impl_1createTexture)
(JNIEnv *, jclass) {
- setWindow();
GLuint ret;
glGenTextures(1, &ret);
DBG(dbg) << "Created texture id "<<ret<<"\n";
GLERR;
- releaseWindow();
return ret;
}
jf(void, impl_1deleteTexture)
(JNIEnv *, jclass, jint id) {
- setWindow();
GLuint rel = id;
glDeleteTextures(1, &rel);
GLERR;
- releaseWindow();
}
bool hasGenMipmaps() {
@@ -204,8 +200,8 @@
glCompressedTexImage2DARB(GL_TEXTURE_2D, level, internalFormat,
width, height, border, size, data);
- glFinish(); // Appears that NV 4191 drivers need this.
glBindTexture(GL_TEXTURE_2D, 0);
+// glFinish(); // Appears that NV 4191 drivers need this.
env->ReleaseByteArrayElements(jdata, data, 0);
GLERR;
@@ -220,8 +216,8 @@
glCompressedTexSubImage2DARB(GL_TEXTURE_2D, level, xoffs, yoffs,
width, height, format, size, data);
- glFinish(); // Appears that NV 4191 drivers need this.
glBindTexture(GL_TEXTURE_2D, 0);
+// glFinish(); // Appears that NV 4191 drivers need this.
env->ReleaseByteArrayElements(jdata, data, 0);
GLERR;
@@ -284,7 +280,6 @@
jstring internalFormat,
jstring format,
jstring name, jobjectArray params, jboolean shade_all_levels) {
- setWindow();
DBG(dbg)<<"Shade into "<<id<<"\n";
std::string name_utf = jstr2stdstr(env, name);
@@ -362,7 +357,6 @@
delete[] value;
delete s;
- releaseWindow();
return 1;
}
Index: libvob/src/main/IndirectTexture.cxx
diff -u libvob/src/main/IndirectTexture.cxx:1.1
libvob/src/main/IndirectTexture.cxx:1.2
--- libvob/src/main/IndirectTexture.cxx:1.1 Fri Oct 10 09:53:37 2003
+++ libvob/src/main/IndirectTexture.cxx Sat Oct 18 02:11:15 2003
@@ -27,8 +27,13 @@
*/
#include <vob/IndirectTexture.hxx>
+#include <iostream>
+#include <vob/Debug.hxx>
namespace Vob {
+
+ DBGVAR(dbg_indirectbind, "IndirectBind");
+
IndirectTextureBind::IndirectTextureBind() :
activeTexture(0),
textureTarget(0),
@@ -42,12 +47,16 @@
indirectTexture(indirectTexture) { }
void IndirectTextureBind::bind() {
+ DBG(dbg_indirectbind) << "bind "<<activeTexture<<" "<<textureTarget
+ <<" "<<indirectTexture<<" "<<indirectTexture->texId<<"\n";
if(indirectTexture == 0) return;
glActiveTextureARB(activeTexture);
glBindTexture(textureTarget, indirectTexture->texId);
glActiveTextureARB(GL_TEXTURE0_ARB);
}
void IndirectTextureBind::unbind() {
+ DBG(dbg_indirectbind) << "unbind "<<activeTexture<<" "<<textureTarget
+ <<" "<<indirectTexture<<" "<<indirectTexture->texId<<"\n";
if(indirectTexture == 0) return;
glActiveTextureARB(activeTexture);
glBindTexture(textureTarget, 0);
Index: libvob/src/os/Os-GLX.cxx
diff -u libvob/src/os/Os-GLX.cxx:1.16 libvob/src/os/Os-GLX.cxx:1.17
--- libvob/src/os/Os-GLX.cxx:1.16 Fri Sep 12 14:44:31 2003
+++ libvob/src/os/Os-GLX.cxx Sat Oct 18 02:11:15 2003
@@ -85,7 +85,11 @@
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
- GLX_ALPHA_SIZE, 1,
+
+// No alpha by default - should have option to get it
+// but too many cards / configs don't have it
+// GLX_ALPHA_SIZE, 1,
+//
GLX_DEPTH_SIZE, 1,
GLX_STENCIL_SIZE, 1,
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
@@ -114,7 +118,11 @@
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
- GLX_ALPHA_SIZE, 1,
+
+// No alpha by default - should have option to get it
+// but too many cards / configs don't have it
+// GLX_ALPHA_SIZE, 1,
+
GLX_DEPTH_SIZE, 1,
GLX_STENCIL_SIZE, 1,
None
Index: libvob/test/tools/gfx.py
diff -u libvob/test/tools/gfx.py:1.13 libvob/test/tools/gfx.py:1.14
--- libvob/test/tools/gfx.py:1.13 Sun Sep 28 09:02:18 2003
+++ libvob/test/tools/gfx.py Sat Oct 18 02:11:16 2003
@@ -1,20 +1,20 @@
#
# Copyright (c) 2003, Tuomas J. Lukka
#
-# This file is part of Gzz.
+# This file is part of Libvob.
#
-# Gzz is free software; you can redistribute it and/or modify it under
+# Libvob is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
-# Gzz is distributed in the hope that it will be useful, but WITHOUT
+# Libvob is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
# Public License for more details.
#
# You should have received a copy of the GNU Lesser General
-# Public License along with Gzz; if not, write to the Free
+# Public License along with Libvob; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
Index: libvob/vob/demo/aniso/probe1.py
diff -u libvob/vob/demo/aniso/probe1.py:1.3 libvob/vob/demo/aniso/probe1.py:1.4
--- libvob/vob/demo/aniso/probe1.py:1.3 Fri Oct 10 09:52:29 2003
+++ libvob/vob/demo/aniso/probe1.py Sat Oct 18 02:11:16 2003
@@ -9,18 +9,25 @@
# Create the textures with a single lit pixel at (0,0)
# of a single mipmap level
-nlevels = 6
-maxsize = 2**nlevels
+nlevels = 7
+maxsize = 2**(nlevels-1)
ebytes = jarray.zeros( 4 * maxsize*maxsize, 'b')
+
+# The texture whose mipmapping we look at
tex = vob.gl.GL.createTexture()
+# A scratch texture
+tex2 = vob.gl.GL.createTexture()
+tex2.setTexParameter("TEXTURE_2D", "TEXTURE_MAG_FILTER", "NEAREST")
+tex2.setTexParameter("TEXTURE_2D", "TEXTURE_MIN_FILTER", "NEAREST")
+
#for i in range(0,300): ebytes[i] = -1
#for i in range(300,600): ebytes[i] = 127
-for i in range(0, nlevels + 1):
+for i in range(0, nlevels ):
tex.texImage2D(i, "RGBA",
maxsize >> i, maxsize >> i, 0,
"RGBA", "UNSIGNED_BYTE", ebytes)
@@ -40,6 +47,22 @@
""")
quadlistId = quadlist.getDisplayListID()
+lc = -2
+uc = 3
+triplequadlist = vob.gl.GL.createDisplayList("""
+ Begin QUADS
+ TexCoord %(lc)s %(lc)s
+ Vertex %(lc)s %(lc)s
+ TexCoord %(lc)s %(uc)s
+ Vertex %(lc)s %(uc)s
+ TexCoord %(uc)s %(uc)s
+ Vertex %(uc)s %(uc)s
+ TexCoord %(uc)s %(lc)s
+ Vertex %(uc)s %(lc)s
+ End
+""" % locals())
+triplequadlistId = triplequadlist.getDisplayListID()
+
if 1:
# Use the simple distorted surrounding-square mode
def getSqSize(level):
@@ -63,7 +86,7 @@
return ret
squareLists = []
- for level in range(0, nlevels + 1):
+ for level in range(0, nlevels ):
sqSize = getSqSize(level)
sql = []
for i in range(0, sqSize):
@@ -84,9 +107,7 @@
""" % locals())
squareLists.append(GL.createDisplayList("".join(sql)))
else:
- # XXX unfinished use real square
- def getSqCoord(level, x):
- return nlevels - level + (nlevels+1)*0
+ pass
xoffs = 0
list = ["""
@@ -96,17 +117,24 @@
sqx = 10
sqy = 100
+list2 = ["""
+ BindTexture TEXTURE_2D %s
+""" % tex2.getTexId()]
+
+zeroval = 0
-for i in range(0, nlevels + 1):
+for i in range(0, nlevels ):
listId = squareLists[i].getDisplayListID()
+ levelSize = maxsize >> i
for x in range(0, maxsize >> i):
xsq = sqx + getSqCoord(i, x)
for y in range(0, maxsize >> i):
ysq = sqy + getSqCoord(i, y)
xm = x + xoffs
ym = y
+ yinv = levelSize - 1 - y
list.append("""
- TexSubImage2D TEXTURE_2D %(i)s %(x)s %(y)s 1 1 RGBA 1 1 1 1
+ TexSubImage2D TEXTURE_2D %(i)s %(x)s %(yinv)s 1 1 RGBA 1 1 1 1
PushMatrix
Translate %(xm)s %(ym)s 0
CallList %(quadlistId)s
@@ -121,17 +149,64 @@
""" % locals())
list.append("""
- TexSubImage2D TEXTURE_2D %(i)s %(x)s %(y)s 1 1 RGBA 0.5 0.5
0.5 0.5
+ TexSubImage2D TEXTURE_2D %(i)s %(x)s %(yinv)s 1 1 RGBA
%(zeroval)s %(zeroval)s %(zeroval)s %(zeroval)s
"""% locals())
+
+ # y coordinate in the OpenGL coordinate system
+ yingl = 768 - levelSize
+ list2.append("""
+ CopyTexImage2D TEXTURE_2D 0 RGBA8 %(xoffs)s %(yingl)s %(levelSize)s
%(levelSize)s 0
+ CallList %(triplequadlistId)s
+ """ % locals())
+
xoffs += maxsize >> i
xoffs += 2
-# print "".join(list)
+print "".join(list2)
list = getDListNocoords("".join(list))
+list2 = getDList("".join(list2))
# XXX SHould adddepend to dlist but not vital
+supervp = GL.createProgram("""!!ARBvp1.0 OPTION ARB_position_invariant;
+ATTRIB tex0 = vertex.texcoord;
+ATTRIB col = vertex.color;
+PARAM mat[4] = { state.matrix.modelview };
+PARAM texmat[4] = { state.matrix.texture[0] };
+
+TEMP t;
+
+PARAM foo = {1, .5, .25, 0};
+
+MOV t, tex0;
+SUB t, tex0, foo.zzww;
+DP4 result.texcoord[0].x, texmat[0], t;
+DP4 result.texcoord[0].y, texmat[1], t;
+DP4 result.texcoord[0].z, texmat[2], t;
+DP4 result.texcoord[0].w, texmat[3], t;
+
+ADD t, t, foo.ywww;
+DP4 result.texcoord[1].x, texmat[0], t;
+DP4 result.texcoord[1].y, texmat[1], t;
+DP4 result.texcoord[1].z, texmat[2], t;
+DP4 result.texcoord[1].w, texmat[3], t;
+
+ADD t, t, foo.wyww;
+DP4 result.texcoord[2].x, texmat[0], t;
+DP4 result.texcoord[2].y, texmat[1], t;
+DP4 result.texcoord[2].z, texmat[2], t;
+DP4 result.texcoord[2].w, texmat[3], t;
+
+SUB t, t, foo.ywww;
+DP4 result.texcoord[3].x, texmat[0], t;
+DP4 result.texcoord[3].y, texmat[1], t;
+DP4 result.texcoord[3].z, texmat[2], t;
+DP4 result.texcoord[3].w, texmat[3], t;
+
+MOV result.color, col;
+END
+""")
class Scene:
def __init__(self):
@@ -173,28 +248,92 @@
Color 1 1 1
TexEnv TEXTURE_ENV TEXTURE_ENV_MODE REPLACE
+ """)))
-
- # Strengthen by multiplying by 4
-
- Enable REGISTER_COMBINERS_NV
-
- SPARE0 = ( (+TEX0) + (-.5) ) * 4
-
- SPARE0 = (+SPARE0) + (.5)
-
- color = SPARE0
- alpha = 1
-
-
- # MatrixMode TEXTURE
- # LoadIdentity
- # PushMatrix
- # Translate .5 .5 0
- # Rotate 30 0 0 1
- # Scale 0.2 0.1 1
- # # Scale 1 1 1
- """)))
+ if 0:
+ # 2x2 super-sampling:
+ # Doesn't work with NV25_EMULATE (it looks as if
+ # there was some additional lod bias),
+ # haven't tried with real hardware yet..
+ progid = supervp.getProgId()
+ texid = tex.getTexId()
+ vs.put(getDListNocoords(vob.putil.nvcode.parseCombiner("""
+ BindProgram VERTEX_PROGRAM_ARB %(progid)s
+ Enable VERTEX_PROGRAM_ARB
+
+ ActiveTexture TEXTURE3_ARB
+ TexEnv TEXTURE_FILTER_CONTROL TEXTURE_LOD_BIAS -1
+ BindTexture TEXTURE_2D %(texid)s
+ Enable TEXTURE_2D
+
+ ActiveTexture TEXTURE2_ARB
+ TexEnv TEXTURE_FILTER_CONTROL TEXTURE_LOD_BIAS -1
+ BindTexture TEXTURE_2D %(texid)s
+ Enable TEXTURE_2D
+
+ ActiveTexture TEXTURE1_ARB
+ TexEnv TEXTURE_FILTER_CONTROL TEXTURE_LOD_BIAS -1
+ BindTexture TEXTURE_2D %(texid)s
+ Enable TEXTURE_2D
+
+ ActiveTexture TEXTURE0_ARB
+ TexEnv TEXTURE_FILTER_CONTROL TEXTURE_LOD_BIAS -1
+ BindTexture TEXTURE_2D %(texid)s
+ Enable TEXTURE_2D
+ """ % locals())))
+ if zeroval == 0:
+ vs.put(getDListNocoords(vob.putil.nvcode.parseCombiner("""
+ # Strengthen by multiplying by 4
+
+ Enable REGISTER_COMBINERS_NV
+
+ SPARE0 = (TEX0 + TEX1) * 0.5
+
+ SPARE1 = (TEX2 + TEX3) * 0.5
+
+ color = SPARE0 + SPARE1
+ alpha = 1
+ """)))
+ else:
+ vs.put(getDListNocoords(vob.putil.nvcode.parseCombiner("""
+ # Strengthen by multiplying by 4
+
+ Enable REGISTER_COMBINERS_NV
+
+ SPARE0 = TEX0 + TEX1 - 0.5
+
+ SPARE1 = TEX2 + TEX3 - 0.5
+
+ color = SPARE0 + SPARE1
+ alpha = 1
+ """)))
+ else:
+
+ if zeroval == 0:
+ vs.put(getDListNocoords(vob.putil.nvcode.parseCombiner("""
+ # Strengthen by multiplying by 4
+
+ Enable REGISTER_COMBINERS_NV
+
+ SPARE0 = ( (+TEX0) ) * 2
+
+ color = SPARE0
+ alpha = 1
+ """)))
+ else:
+ vs.put(getDListNocoords(vob.putil.nvcode.parseCombiner("""
+ # Strengthen by multiplying by 4
+
+ Enable REGISTER_COMBINERS_NV
+
+ SPARE0 = ( (+TEX0) + (-.5) ) * 4
+
+ SPARE0 = (+SPARE0) + (.5)
+
+ color = SPARE0
+ alpha = 1
+ """)))
+
vs.put(GLRen.createTransMatrix("TEXTURE"),
texturemat)
vs.put(list)
@@ -206,7 +345,22 @@
vs.put(getDListNocoords("""
PopAttrib
+
+ ActiveTexture TEXTURE3_ARB
+ TexEnv TEXTURE_FILTER_CONTROL TEXTURE_LOD_BIAS 0
+ Disable TEXTURE_2D
+ ActiveTexture TEXTURE2_ARB
+ TexEnv TEXTURE_FILTER_CONTROL TEXTURE_LOD_BIAS 0
+ Disable TEXTURE_2D
+ ActiveTexture TEXTURE1_ARB
+ TexEnv TEXTURE_FILTER_CONTROL TEXTURE_LOD_BIAS 0
+ Disable TEXTURE_2D
+ ActiveTexture TEXTURE0_ARB
+ TexEnv TEXTURE_FILTER_CONTROL TEXTURE_LOD_BIAS 0
+ Disable TEXTURE_2D
+
Disable TEXTURE_2D
+ Disable BLEND
PolygonMode FRONT_AND_BACK LINE
"""))
@@ -217,6 +371,39 @@
PolygonMode FRONT_AND_BACK FILL
"""))
- print vs.coords.transformPoints3(footprintCS, [0,0,0, 0,1,0, 1,0,0,
1,1,0], None)
+ pixzoomcs = vs.orthoCS(0, "PFP", 0, 100, 550, 50, 50)
+
+ vs.put(getDList("""
+ Enable TEXTURE_2D
+ Color 0 0 0
+
+ CallList %(triplequadlistId)s
+
+ Color 1 1 1
+
+ Disable REGISTER_COMBINERS_NV
+ Enable BLEND
+ BlendFunc 1 1
+ """ % globals()), pixzoomcs)
+
+
+
+
+ # Then, render the texels in coordinate space...
+ vs.put(GLRen.createTransMatrix("TEXTURE"),
+ texturemat)
+ vs.put(list2, pixzoomcs)
+
+ vs.put(getDListNocoords("""
+ Disable TEXTURE_2D
+ Disable BLEND
+ PolygonMode FRONT_AND_BACK LINE
+ """))
+ vs.put(coloredQuad((1,0,0)), pixzoomcs)
+ vs.put(getDListNocoords("""
+ PolygonMode FRONT_AND_BACK FILL
+ """))
+
+ # print vs.coords.transformPoints3(footprintCS, [0,0,0, 0,1,0, 1,0,0,
1,1,0], None)
Index: libvob/vob/putil/mipzipmaker.py
diff -u libvob/vob/putil/mipzipmaker.py:1.5 libvob/vob/putil/mipzipmaker.py:1.6
--- libvob/vob/putil/mipzipmaker.py:1.5 Mon Aug 18 05:44:08 2003
+++ libvob/vob/putil/mipzipmaker.py Sat Oct 18 02:11:16 2003
@@ -28,10 +28,12 @@
# Usage: something like:
#
-# make runjython DBG="gfx/util/mipzipmaker.py ../tmpimg/*-170-*[0-9]"
+# make runjython DBG="vob/putil/mipzipmaker.py ../tmpimg/*-170-*[0-9]"
# Can also be used as a python module - fenfire does this automatically
+from __future__ import nested_scopes
+
import sys
import getopt
from java.lang import Runnable, System
@@ -56,19 +58,19 @@
n /= 4
return 4 * n
-format = 0
+defaultTexFormat = 0
def _init():
- global format, suffix
- if format:
+ global defaultTexFormat, suffix
+ if defaultTexFormat:
return
if GL.workaroundStupidBuggyAtiDrivers:
- format = "RGB"
+ defaultTexFormat = "RGB"
suffix = ".mipzipBLAH"
else:
- format = "COMPRESSED_RGB_S3TC_DXT1_EXT"
+ defaultTexFormat = "COMPRESSED_RGB_S3TC_DXT1_EXT"
suffix = ".mipzip"
def _clipmax(x, max):
@@ -76,15 +78,42 @@
if max > x: return x
return max
-def makeMipzip(image, mipzip, maxwidth=-1, maxheight=-1):
+def bytesPerTexel(format, dataType):
+ return vob.gl.GLUtil.findBpt(format, dataType)
+
+def makeMipzip(image, mipzip, maxwidth=-1, maxheight=-1,
+ texformat = None,
+ internalTexFormat = None,
+ uncompressedTexType = None
+ ):
"""Convert the given image file into a mipzip file.
image -- the image file name
mipzip -- the mipzip file name
maxwidth -- if image is wider than maxwidth, cut off edge
maxheight -- if image is taller than maxheight, cut off edge
+ texformat -- The texture format to use
+ internalTexFormat -- The internal texture format to represent the data in
+ for compressed textures, same as texformat
+ uncompressedTexType -- The datatype (relevant only for uncompressed
+ textures)
"""
+ if texformat == None:
+ if not defaultTexFormat:
+ _init()
+ texformat = defaultTexFormat
+
+ print "TEXFORMAT: ",texformat, defaultTexFormat
+ isCompressed = (java.lang.String(texformat).indexOf("COMPRESS") >= 0)
+
+ if internalTexFormat == None:
+ internalTexFormat = texformat
+
+ if not isCompressed:
+ if uncompressedTexType == None:
+ uncompressedTexType = "UNSIGNED_BYTE"
+
_init()
GL.freeQueue()
@@ -100,7 +129,7 @@
w = roundup2(d.width)
h = roundup2(d.height)
tex = GL.createTexture()
- tex.loadNull2D('TEXTURE_2D',0, format, w, h, 0, "RGB", "BYTE")
+ tex.loadNull2D('TEXTURE_2D',0, internalTexFormat, w, h, 0, "RGB", "BYTE")
print "WH: ",w, h
tex.loadSubImage(0, im, 0, 0, 0, 0, chomp4(d.width), chomp4(d.height))
@@ -108,29 +137,36 @@
out = zip.ZipOutputStream(java.io.FileOutputStream(mipzip))
- entry = zip.ZipEntry("texformat")
- entry.setComment(format)
- entry.setSize(0)
- out.putNextEntry(entry)
- out.closeEntry()
+ def metaEntry(name, comment):
+ entry = zip.ZipEntry(name)
+ entry.setComment(comment)
+ entry.setSize(0)
+ out.putNextEntry(entry)
+ out.closeEntry()
+
+ metaEntry("texformat", texformat)
- entry = zip.ZipEntry("origsize")
- entry.setComment("%sx%s" % (d.width / float(w),
+ if not isCompressed:
+ metaEntry("internaltexformat", internalTexFormat)
+ metaEntry("datatype", uncompressedTexType)
+
+ metaEntry("origsize", "%sx%s" % (d.width / float(w),
d.height/ float(h)))
- entry.setSize(0)
- out.putNextEntry(entry)
- out.closeEntry()
l = 0
while 1:
w = int(tex.getLevelParameter(l, "TEXTURE_WIDTH")[0])
h = int(tex.getLevelParameter(l, "TEXTURE_HEIGHT")[0])
print "WH: ", w, h
- if GL.workaroundStupidBuggyAtiDrivers:
- bytes = jarray.zeros(4 * w * h, "b")
- tex.getTexImage(l, "RGB", "BYTE", bytes)
- else:
+
+ if isCompressed:
bytes = tex.getCompressedTexImage(l)
+ else:
+ bpt = bytesPerTexel(texformat, uncompressedTexType)
+
+ bytes = jarray.zeros(bpt * w * h, "b")
+ tex.getTexImage(l, texformat, uncompressedTexType, bytes)
+
print "Bytes: ",l, len(bytes)
entry = zip.ZipEntry(str(l))
entry.setComment("%sx%s" % (int(w),int(h)))
@@ -147,8 +183,10 @@
class Main(Runnable):
- def __init__(self, texfiles):
+ def __init__(self, texfiles, **mzparms):
self.texfiles = texfiles
+ self.mzparms = mzparms
+ _init()
def run(self):
w = gfxapi.createWindow()
for texfile in self.texfiles:
@@ -157,19 +195,33 @@
def handle(self, texfile):
of = texfile + suffix
- makeMipzip(texfile, of)
+ makeMipzip(texfile, of, **self.mzparms)
if __name__ == '__main__':
opts, args = getopt.getopt(sys.argv[1:],
- vob.util.dbg.short,
- vob.util.dbg.long)
+ vob.putil.dbg.short,
+ ["texFormat=", "internalTexFormat=", "datatype="]
+ + vob.putil.dbg.long)
+ texFormat = None
+ internalTexFormat = None
+ datatype = None
for o,a in opts:
print "Opt: ",o,a
- if o in vob.util.dbg.all:
- vob.util.dbg.option(o,a)
+ if o in vob.putil.dbg.all:
+ vob.putil.dbg.option(o,a)
+ if o == "--texFormat":
+ texFormat = a
+ if o == "--internalTexFormat":
+ internalTexFormat = a
+ if o == "--datatype":
+ datatype = a
gfxapi = vob.GraphicsAPI.getInstance()
- gfxapi.startUpdateManager(Main(args))
+ gfxapi.startUpdateManager(Main(args,
+ texformat=texFormat,
+ internalTexFormat=internalTexFormat,
+ uncompressedTexType=datatype
+ ))
Index: libvob/vob/usertest/color6.py
diff -u libvob/vob/usertest/color6.py:1.1 libvob/vob/usertest/color6.py:1.2
--- libvob/vob/usertest/color6.py:1.1 Mon Sep 22 04:49:01 2003
+++ libvob/vob/usertest/color6.py Sat Oct 18 02:11:16 2003
@@ -44,7 +44,7 @@
return col2rgb(getcol0(st))
def run():
- demowindow.w.setLocation(1600,0,1600,1200)
+ demowindow.w.setLocation(0,0,1600,1200)
outfile = open("RES", "a")
outfile.write("---\n")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [ff-cvs] libvob doc/mipzip.rst include/vob/vobs/GLState....,
Tuomas J. Lukka <=