aboutsummaryrefslogtreecommitdiffstats
path: root/gl4java/utils/Test.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2001-04-06 10:05:10 +0000
committerSven Gothel <[email protected]>2001-04-06 10:05:10 +0000
commitee8232711affbf052576b038aee079250c985416 (patch)
tree6af9c3d569611615d29dee5d051a69ab68e18b0d /gl4java/utils/Test.java
parent6c0f57e382ff6a739551630b0f9acac14f0a539a (diff)
2.7.0 release ..
Diffstat (limited to 'gl4java/utils/Test.java')
-rw-r--r--gl4java/utils/Test.java198
1 files changed, 106 insertions, 92 deletions
diff --git a/gl4java/utils/Test.java b/gl4java/utils/Test.java
index a430de5..37718d6 100644
--- a/gl4java/utils/Test.java
+++ b/gl4java/utils/Test.java
@@ -22,14 +22,96 @@ import gl4java.applet.SimpleGLAnimApplet1;
public class Test
{
+
+ String testClazzName;
+ int width, height;
+ String glName, gluName;
- public Test(String name, Object tstObj, int width, int height)
+ public Test(String testClazzName, int width, int height,
+ String glName, String gluName)
{
+ this.testClazzName = testClazzName;
+ this.width = width;
+ this.height = height;
+ this.glName = glName;
+ this.gluName = gluName;
+ }
+
+ public void loadNStartTestClazz()
+ {
+ Object tstObj = null;
+
+ try {
+ Class canvasClazz =
+ Class.forName("gl4java.awt.GLCanvas");
+ Class animCanvasClazz =
+ Class.forName("gl4java.awt.GLAnimCanvas");
+ Class animAppletCanvasClazz =
+ Class.forName("gl4java.applet.SimpleGLAnimApplet1");
+
+ Class tstClazz = Class.forName(testClazzName);
+
+ if( ! canvasClazz.isAssignableFrom(tstClazz) &&
+ ! animAppletCanvasClazz.isAssignableFrom(tstClazz) )
+ {
+ System.out.println("Your test-clazz is neither derived from gl4java.awt.GLCanvas nor from gl4java.applet.SimpleGLAnimApplet1!");
+ throw new Exception();
+ }
+
+ /**
+ * Std. conversion from Integer -> int
+ */
+ Class[] parameterTypes = new Class[4];
+ parameterTypes[0] = Class.forName("java.lang.Integer");
+ parameterTypes[1] = Class.forName("java.lang.Integer");
+ parameterTypes[2] = Class.forName("java.lang.String");
+ parameterTypes[3] = Class.forName("java.lang.String");
+
+ Object[] parameters = null;
+ java.lang.reflect.Constructor tstObjConstr = null;
+
+ try {
+ tstObjConstr = tstClazz.getConstructor(parameterTypes);
+
+ parameters = new Object[4];
+ parameters[0] = new java.lang.Integer(width);
+ parameters[1] = new java.lang.Integer(height);
+ parameters[2] = glName;
+ parameters[3] = gluName;
+
+ } catch (java.lang.NoSuchMethodException nsme) {
+
+ try {
+ parameterTypes = new Class[4];
+ parameterTypes[0] = Class.forName("java.lang.Integer");
+ parameterTypes[1] = Class.forName("java.lang.Integer");
+
+ tstObjConstr = tstClazz.getConstructor(parameterTypes);
+
+ parameters = new Object[4];
+ parameters[0] = new java.lang.Integer(width);
+ parameters[1] = new java.lang.Integer(height);
+
+ } catch (java.lang.NoSuchMethodException nsme2) {
+ tstObj = tstClazz.newInstance();
+ }
+ }
+
+ if(tstObj==null && parameters!=null)
+ tstObj = tstObjConstr.newInstance(parameters);
+
+ } catch (Exception ex) {
+ System.out.println("Instantiation of: "+testClazzName+" failed !");
+ System.out.println(ex);
+ ex.printStackTrace();
+ System.exit(1);
+ }
+
if(tstObj instanceof SimpleGLAnimApplet1)
{
SimpleGLAnimApplet1 glSAnimApplet = (SimpleGLAnimApplet1)tstObj;
- Frame f = new Frame(name);
+ Frame f = new Frame(testClazzName);
f.addWindowListener( new WindowAdapter()
{
@@ -68,7 +150,7 @@ public class Test
GLAnimCanvasTest applet = new GLAnimCanvasTest();
- Frame f = new Frame(name);
+ Frame f = new Frame(testClazzName);
f.addWindowListener( new WindowAdapter()
{
@@ -103,7 +185,7 @@ public class Test
GLCanvasTest applet = new GLCanvasTest();
- Frame f = new Frame(name);
+ Frame f = new Frame(testClazzName);
f.addWindowListener( new WindowAdapter()
{
@@ -143,8 +225,6 @@ public class Test
* @param args, a list of args,
*
* -gljlib <glj-libname> gl4java-glj-lib native library
- * -gllib <gl-libname> gl4java-gl-lib native library
- * -glulib <glu-libname> gl4java-glu-lib native library
* -glclass <gl-class> gl4java-gl-class java GLFunc implementation
* -gluclass <glu-class> gl4java-glu-class java GLUFunc implementation
* -testclass <GLCanvas or SimpleGLAnimApplet1 Implementation Class> A derivation of GLCanvas (GLAnimCanvas also) or SimpleGLAnimApplet1 can be started here for testing purposes !
@@ -156,6 +236,8 @@ public class Test
*/
public static void main( String args[] )
{
+ String nativeGLLib = null;
+ String nativeGLULib = null;
String gljLibName = null;
String glLibName = null;
String gluLibName = null;
@@ -169,12 +251,12 @@ public class Test
if(args.length==0)
{
- System.out.println("usage: java gl4java.GLContext <options>, where options can be: ");
- System.out.println(" -gljlib <glj-libname> \t\t\t choose a custom the gl4java-glj-lib native library (default: GL4JavaJauGljJNI)");
- System.out.println(" -gllib <gl-libname> \t\t\t choose a custom the gl4java-gl-lib native library (default: GL4JavaJauGLJNI)");
- System.out.println(" -glulib <glu-libname> \t\t\t choose a custom the gl4java-glu-lib native library (default: GL4JavaJauGLUJNI");
- System.out.println(" -glclass <gl-class> \t\t\t choose a custom the gl4java-gl-class java GLFunc implementation (default: GLFuncJauJNI)");
- System.out.println(" -gluclass <glu-class> \t\t\t choose a custom the gl4java-glu-class java GLUFunc implementation (default: GLUFuncJauJNI)");
+ System.out.println("usage: java gl4java.utils.Test <options>, where options can be: ");
+ System.out.println(" -GLLib <OpenGL Libname> \t choose a custom OpenGL native library (default: libGL, or OPENGL32, ..)");
+ System.out.println(" -GLULib <GLU Libname> \t choose a custom GLU native library (default: libGLU, or GLU32, ..)");
+ System.out.println(" -gljlib <glj-libname> \t choose a custom gl4java-glj-lib native library (default: GL4JavaJauGljJNI)");
+ System.out.println(" -glclass <gl-class> \t choose a custom gl4java-gl-class java GLFunc implementation (default: GLFuncJauJNI)");
+ System.out.println(" -gluclass <glu-class> \t choose a custom gl4java-glu-class java GLUFunc implementation (default: GLUFuncJauJNI)");
System.out.println(" -testclass <GLCanvas Implementation Class> \t\t\t a derivation of GLCanvas (GLCanvas or GLAnimCanvas) can be started here for testing purposes !");
System.out.println(" -w <int> \t\t\t the testclass window width (default 800) !");
System.out.println(" -h <int> \t\t\t the testclass window height (default 600) !");
@@ -184,12 +266,12 @@ public class Test
while(args.length>i)
{
- if(args[i].equals("-gljlib")) {
+ if(args[i].equals("-GLLib")) {
+ if(args.length>++i) nativeGLLib=args[i];
+ } else if(args[i].equals("-GLULib")) {
+ if(args.length>++i) nativeGLULib=args[i];
+ } else if(args[i].equals("-gljlib")) {
if(args.length>++i) gljLibName=args[i];
- } else if(args[i].equals("-gllib")) {
- if(args.length>++i) glLibName=args[i];
- } else if(args[i].equals("-glulib")) {
- if(args.length>++i) gluLibName=args[i];
} else if(args[i].equals("-glclass")) {
if(args.length>++i) glName=args[i];
} else if(args[i].equals("-gluclass")) {
@@ -232,90 +314,22 @@ public class Test
GLContext.gljClassDebug = false;
}
- if(GLContext.loadNativeLibraries(gljLibName, glLibName, gluLibName))
+ if(GLContext.doLoadNativeLibraries(gljLibName,
+ nativeGLLib, nativeGLULib
+ )
+ )
System.out.println("native Libraries loaded succesfull");
else {
System.out.println("native library NOT loaded complete");
ok=false;
}
- Object tstObj = null;
-
- if(ok==true)
- {
- try {
- Class canvasClazz =
- Class.forName("gl4java.awt.GLCanvas");
- Class animCanvasClazz =
- Class.forName("gl4java.awt.GLAnimCanvas");
- Class animAppletCanvasClazz =
- Class.forName("gl4java.applet.SimpleGLAnimApplet1");
-
- Class tstClazz =
- Class.forName(testClazzName);
-
- if( ! canvasClazz.isAssignableFrom(tstClazz) &&
- ! animAppletCanvasClazz.isAssignableFrom(tstClazz) )
- {
- System.out.println("Your test-clazz is neither derived from gl4java.awt.GLCanvas nor from gl4java.applet.SimpleGLAnimApplet1!");
- ok=false;
- throw new Exception();
- }
-
- /**
- * Std. conversion from Integer -> int
- */
- Class[] parameterTypes = new Class[4];
- parameterTypes[0] = Class.forName("java.lang.Integer");
- parameterTypes[1] = Class.forName("java.lang.Integer");
- parameterTypes[2] = Class.forName("java.lang.String");
- parameterTypes[3] = Class.forName("java.lang.String");
-
- Object[] parameters = null;
- java.lang.reflect.Constructor tstObjConstr = null;
-
- try {
- tstObjConstr = tstClazz.getConstructor(parameterTypes);
-
- parameters = new Object[4];
- parameters[0] = new java.lang.Integer(width);
- parameters[1] = new java.lang.Integer(height);
- parameters[2] = glName;
- parameters[3] = gluName;
-
- } catch (java.lang.NoSuchMethodException nsme) {
-
- try {
- parameterTypes = new Class[4];
- parameterTypes[0] = Class.forName("java.lang.Integer");
- parameterTypes[1] = Class.forName("java.lang.Integer");
-
- tstObjConstr = tstClazz.getConstructor(parameterTypes);
-
- parameters = new Object[4];
- parameters[0] = new java.lang.Integer(width);
- parameters[1] = new java.lang.Integer(height);
-
- } catch (java.lang.NoSuchMethodException nsme2) {
- tstObj = tstClazz.newInstance();
- }
- }
-
- if(tstObj==null && parameters!=null)
- tstObj = tstObjConstr.newInstance(parameters);
-
- } catch (Exception ex) {
- System.out.println("Instantiation of: "+testClazzName+" failed !");
- System.out.println(ex);
- ok =false;
- }
-
- ok = tstObj!=null ;
- }
if(ok) {
// let's do it ...
- Test test = new Test(testClazzName, tstObj, width, height);
+ Test test = new Test(testClazzName, width, height,
+ glName, gluName);
+ test.loadNStartTestClazz();
}
}