/* Paper.java * * Copyright (c) 2002-2003, Tuomas Lukka * * This file is part of Libvob. * * 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. * * 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 Libvob; if not, write to the Free * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * */ /* * Written by Tuomas Lukka */ package org.nongnu.libvob.gl; import java.util.ArrayList; /** The interface to the paper library. */ public class Paper implements GLDeletable { public static boolean dbg = true; private static void p(String s) { if(dbg) System.out.println(s); } private static void pa(String s) { System.err.println(s); } /** The identififier to be passed to C for this object. */ private int c_id; /** Put all objects that manage displaylists and textures * used by this paper here to ensure they don't get * GCed before this. */ private ArrayList depends; public class Pass { private int index; private Pass(int index) { this.index = index; } public int getNTexGens() { return impl_Pass_getNTexGens(c_id, index); } public void setNTexGens(int n) { impl_Pass_setNTexGens(c_id, index, n); } public int getNLightSetups() { return impl_Pass_getNLightSetups(c_id, index); } public void setNLightSetups(int n) { impl_Pass_setNLightSetups(c_id, index, n); } public void setSetupcode(String code) { impl_Pass_setSetupcode(c_id, index, code); } public String getSetupcode() { return impl_Pass_getSetupcode(c_id, index); } public void setTeardowncode(String code) { impl_Pass_setTeardowncode(c_id, index, code); } public String getTeardowncode() { return impl_Pass_getTeardowncode(c_id, index); } public void putNormalTexGen(int ind, float[] matrix) { impl_Pass_putNormalTexGen(c_id, index, ind, matrix); } public void putEmbossTexGen(int ind, float[] matrix, float eps) { impl_Pass_putEmbossTexGen(c_id, index, ind, matrix, eps); } } public int getNPasses() { return impl_getNPasses(c_id); } public void setNPasses(int i) { impl_setNPasses(c_id, i); } public Pass getPass(int p) { if(p < 0 || p >= getNPasses()) throw new ArrayIndexOutOfBoundsException(); return new Pass(p); } public Object clone() { Paper p = new Paper(); impl_clone(c_id, p.c_id); return p; } public Paper() { c_id = impl_create(); } public void finalize() { if(c_id != 0) GL.addDeletable(this); } public void deleteObject() { impl_delete(c_id); c_id = 0; } int getId() { return c_id; } static private native int impl_create(); static private native void impl_delete(int pid); static private native void impl_clone(int from_id, int to_id); static private native int impl_getNPasses(int pid); static private native void impl_setNPasses(int pid, int i); static private native int impl_Pass_getNTexGens(int pid, int pass); static private native void impl_Pass_setNTexGens(int pid, int pass, int i); static private native int impl_Pass_getNLightSetups(int pid, int pass); static private native void impl_Pass_setNLightSetups(int pid, int pass, int i); static private native void impl_Pass_setSetupcode(int pid, int pass, String code); static private native String impl_Pass_getSetupcode(int pid, int pass); static private native void impl_Pass_setTeardowncode(int pid, int pass, String code); static private native String impl_Pass_getTeardowncode(int pid, int pass); static private native void impl_Pass_putNormalTexGen(int pid, int pass, int ind, float[] matrix) ; static private native void impl_Pass_putEmbossTexGen(int pid, int pass, int ind, float[] matrix, float eps) ; }