Package com.peterhi.ui.gl

Source Code of com.peterhi.ui.gl.GLObject

package com.peterhi.ui.gl;

import javax.media.opengl.GL;
import javax.media.opengl.GLException;

public abstract class GLObject {

  private final GL gl;
  private int id;
  private boolean disposed;
 
  public GLObject(GL gl) {
    if (gl == null) {
      throw new NullPointerException();
    }
   
    this.gl = gl;
  }
 
  public final GL getGL() {
    if (isDisposed()) {
      throw new GLException();
    }
   
    return gl;
  }
 
  public final int getId() {
    if (isDisposed()) {
      throw new GLException();
    }
   
    return id;
  }
 
  public final boolean isDisposed() {
    return disposed;
  }
 
  public void dispose() {
    if (isDisposed()) {
      return;
    }
   
    disposed = true;
  }
 
  protected final void setId(int value) {
    if (id != 0) {
      throw new GLException();
    }
   
    id = value;
  }
 
  protected final Object glInvoke(String name, Class<?>[] types, Object[] args) {
    return GLUtil.glInvoke(getGL(), name, types, args);
  }
 
  protected final Object glInvoke(String name, Object...typesAndArgs) {
    return GLUtil.glInvoke(getGL(), name, typesAndArgs);
  }
}
TOP

Related Classes of com.peterhi.ui.gl.GLObject

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.