diff options
author | Sven Gothel <[email protected]> | 2009-10-04 00:19:32 -0700 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2009-10-04 00:19:32 -0700 |
commit | 4b9a72c24bb97ed81c79c3931d4ffb5fa53d9978 (patch) | |
tree | 0237b562f04fbe56fe0245dbbefecfc6c608caee /src/demos/GLNewtRun.java | |
parent | 30c1fe267c0cf47a25db06ac93c6065881af2a20 (diff) |
Add ReadBuffer Demos/ModuleTests; Incl. SurfaceUpdated Listener, ReadPixel to file, texture - direct or via attaching the drawable to another context as it's readbuffer
Diffstat (limited to 'src/demos/GLNewtRun.java')
-rwxr-xr-x | src/demos/GLNewtRun.java | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/demos/GLNewtRun.java b/src/demos/GLNewtRun.java index dca68b4..0df07fc 100755 --- a/src/demos/GLNewtRun.java +++ b/src/demos/GLNewtRun.java @@ -93,6 +93,23 @@ public class GLNewtRun implements WindowListener, KeyListener, MouseListener { return def; } + public static boolean setField(Object instance, String fieldName, Object value) { + try { + Field f = instance.getClass().getField(fieldName); + if(f.getType().isInstance(value)) { + f.set(instance, value); + return true; + } else { + System.out.println(instance.getClass()+" '"+fieldName+"' field not assignable with "+value.getClass()+", it's a: "+f.getType()); + } + } catch (NoSuchFieldException nsfe) { + System.out.println(instance.getClass()+" has no '"+fieldName+"' field"); + } catch (Throwable t) { + t.printStackTrace(); + } + return false; + } + public static void main(String[] args) { boolean parented = false; boolean useAWTTestFrame = false; @@ -208,18 +225,8 @@ public class GLNewtRun implements WindowListener, KeyListener, MouseListener { } window = GLWindow.create(nWindow); - try { - Field f = demo.getClass().getField("window"); - if(f.getType().isInstance(window)) { - f.set(demo, window); - } else { - System.out.println("Demo's 'window' field not a Window, but: "+f.getType()); - - } - } catch (NoSuchFieldException nsfe) { - System.out.println("Demo has no 'window' field"); - } catch (Throwable t) { - t.printStackTrace(); + if(!setField(demo, "window", window)) { + setField(demo, "glWindow", window); } window.addWindowListener(listener); |