public static final GL2 getCurrentGL2() throws GLException {
   GLContext curContext = GLContext.getCurrent();
   if (curContext == null) {
     throw new GLException("No OpenGL context current on this thread");
   }
   return curContext.getGL().getGL2();
 }
Example #2
0
 public StringBuilder toString(StringBuilder sb) {
   final String crtab = Platform.getNewline() + "\t";
   if (null == sb) {
     sb = new StringBuilder();
   }
   sb.append("GLDebugEvent[ id ");
   toHexString(sb, dbgId)
       .append(crtab)
       .append("type ")
       .append(getDbgTypeString(dbgType))
       .append(crtab)
       .append("severity ")
       .append(getDbgSeverityString(dbgSeverity))
       .append(crtab)
       .append("source ")
       .append(getDbgSourceString(dbgSource))
       .append(crtab)
       .append("msg ")
       .append(dbgMsg)
       .append(crtab)
       .append("when ")
       .append(when);
   if (null != source) {
     sb.append(crtab)
         .append("source ")
         .append(source.getGLVersion())
         .append(" - hash 0x")
         .append(Integer.toHexString(source.hashCode()));
   }
   sb.append("]");
   return sb;
 }
Example #3
0
 private static ProfileInformation getProfileInformation(final GL gl) {
   final GLContext context = gl.getContext();
   context.validateCurrent();
   ProfileInformation data = (ProfileInformation) context.getAttachedObject(implObjectKey);
   if (data == null) {
     data = new ProfileInformation();
     context.attachObject(implObjectKey, data);
   }
   return data;
 }
 @Override
 public void render() {
   GL2GL3 gl = GLContext.getCurrentGL().getGL2GL3();
   gl.glEnable(gl.GL_BLEND);
   gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA);
   super.render();
   gl.glDisable(gl.GL_BLEND);
 }
Example #5
0
 public void surfaceUpdated(Object updater, NativeWindow window, long when) {
   if (updater instanceof GLDrawable) {
     GLDrawable drawable = (GLDrawable) updater;
     GLContext ctx = GLContext.getCurrent();
     if (null != ctx && ctx.getGLDrawable() == drawable) {
       GL gl = ctx.getGL();
       // FIXME glFinish() is an expensive paranoia sync, should not be necessary due to spec
       gl.glFinish();
       readBufferUtil.fetchOffscreenTexture(drawable, gl);
       gl.glFinish();
       try {
         surface2File("shot");
       } catch (IOException ex) {
         throw new RuntimeException("can not write survace to file", ex);
       }
     }
   }
 }
 private static final GLUgl2ProcAddressTable getGLUProcAddressTable() {
   if (gluProcAddressTable == null) {
     GLContext curContext = GLContext.getCurrent();
     if (curContext == null) {
       throw new GLException("No OpenGL context current on this thread");
     }
     GLDynamicLookupHelper glLookupHelper =
         ((GLContextImpl) curContext).getGLDynamicLookupHelper();
     glLookupHelper.loadGLULibrary();
     GLUgl2ProcAddressTable tmp = new GLUgl2ProcAddressTable(new GLProcAddressResolver());
     tmp.reset(glLookupHelper);
     gluProcAddressTable = tmp;
   }
   return gluProcAddressTable;
 }
Example #7
0
 protected void copyImpl(GLContext source, int mask) throws GLException {
   long dst = getHandle();
   long src = source.getHandle();
   if (!isNSContext()) {
     if (((MacOSXCGLContext) source).isNSContext()) {
       throw new GLException("Source OpenGL Context is NS ; Destination Context is CGL.");
     }
     CGL.CGLCopyContext(src, dst, mask);
   } else {
     if (!((MacOSXCGLContext) source).isNSContext()) {
       throw new GLException("Source OpenGL Context is CGL ; Destination Context is NS.");
     }
     CGL.copyContext(dst, src, mask);
   }
 }
Example #8
0
  private static void shutdownImpl() {
    // Following code will _always_ remain in shutdown hook
    // due to special semantics of native utils, i.e. X11Utils.
    // The latter requires shutdown at JVM-Shutdown only.
    synchronized (glDrawableFactories) {
      for (int i = 0; i < glDrawableFactories.size(); i++) {
        glDrawableFactories.get(i).destroy();
      }
      glDrawableFactories.clear();

      // both were members of glDrawableFactories and are shutdown already
      nativeOSFactory = null;
      eglFactory = null;
    }
    GLContext.shutdown();
    NativeWindowFactory.shutdown(isJVMShuttingDown);
  }
  public void applyInternalTransform(DrawContext dc) {
    if (dc == null) {
      String message = Logging.getMessage("nullValue.DrawContextIsNull");
      Logging.logger().severe(message);
      throw new IllegalStateException(message);
    }

    Texture texture = this.getTexture(dc);
    if (texture == null) texture = this.requestTexture(dc);

    if (texture == null) return;

    if (texture.getMustFlipVertically()) {
      GL gl = GLContext.getCurrent().getGL();
      gl.glMatrixMode(GL.GL_TEXTURE);
      gl.glLoadIdentity();
      gl.glScaled(1, -1, 1);
      gl.glTranslated(0, -1, 0);
    }
  }
Example #10
0
 /**
  * Returns true if GeometryShader is supported, i.e. whether GLContext is &ge; 3.2 or
  * ARB_geometry_shader4 extension is available.
  */
 public static boolean isGeometryShaderSupported(final GL _gl) {
   final GLContext ctx = _gl.getContext();
   return ctx.getGLVersionNumber().compareTo(GLContext.Version320) >= 0
       || ctx.isExtensionAvailable(GLExtensions.ARB_geometry_shader4);
 }
Example #11
0
 GL2 gl() {
   if (gl == null) {
     gl = GLContext.getCurrentGL().getGL2();
   }
   return gl;
 }