com.jogamp.opengl.impl
Class GLDrawableFactoryImpl

java.lang.Object
  extended by javax.media.opengl.GLDrawableFactory
      extended by com.jogamp.opengl.impl.GLDrawableFactoryImpl
Direct Known Subclasses:
EGLDrawableFactory, MacOSXCGLDrawableFactory, WindowsWGLDrawableFactory, X11GLXDrawableFactory

public abstract class GLDrawableFactoryImpl
extends GLDrawableFactory

Extends GLDrawableFactory with a few methods for handling typically software-accelerated offscreen rendering (Device Independent Bitmaps on Windows, pixmaps on X11). Direct access to these GLDrawables is not supplied directly to end users, though they may be instantiated by the GLJPanel implementation.


Field Summary
protected static boolean DEBUG
           
 
Fields inherited from class javax.media.opengl.GLDrawableFactory
glDrawableFactories
 
Constructor Summary
protected GLDrawableFactoryImpl()
           
 
Method Summary
abstract  boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device)
           
abstract  boolean canCreateGLPbuffer(AbstractGraphicsDevice device)
          Returns true if it is possible to create a GLPbuffer.
abstract  GLContext createContextOnJava2DSurface(Object graphics, GLContext shareWith)
           
 GLContext createExternalGLContext()
           Creates a GLContext object representing an existing OpenGL context in an external (third-party) OpenGL-based library.
protected abstract  GLContext createExternalGLContextImpl()
           
 GLDrawable createExternalGLDrawable()
           Creates a GLDrawable object representing an existing OpenGL drawable in an external (third-party) OpenGL-based library.
protected abstract  GLDrawable createExternalGLDrawableImpl()
           
 GLDrawable createGLDrawable(NativeSurface target)
          Returns a GLDrawable according to it's chosen Capabilities,
which determines pixel format, on- and offscreen incl.
 GLPbuffer createGLPbuffer(GLCapabilitiesImmutable capabilities, GLCapabilitiesChooser chooser, int width, int height, GLContext shareWith)
          Creates a GLPbuffer with the given capabilites and dimensions.
 GLDrawable createGLPbufferDrawable(GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height)
          Creates a Pbuffer GLDrawable with the given capabilites and dimensions.
protected abstract  GLDrawableImpl createGLPbufferDrawableImpl(NativeSurface target)
          Target must implement SurfaceChangeable
 GLDrawable createOffscreenDrawable(GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height)
          Creates a Offscreen GLDrawable with the given capabilites and dimensions.
protected abstract  GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target)
           
protected abstract  NativeSurface createOffscreenSurfaceImpl(GLCapabilitiesImmutable capabilities, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height)
          creates an offscreen NativeSurface, which must implement SurfaceChangeable as well, so the windowing system related implementation is able to set the surface handle.
protected abstract  GLDrawableImpl createOnscreenDrawableImpl(NativeSurface target)
           
static GLDrawableFactoryImpl getFactoryImpl(GLProfile glp)
          Returns the sole GLDrawableFactoryImpl instance.
protected  Buffer getGammaRamp()
          Gets the current gamma ramp.
protected  int getGammaRampLength()
          Returns the length of the computed gamma ramp for this OS and hardware.
abstract  GLDynamicLookupHelper getGLDynamicLookupHelper(int profile)
          Returns the GLDynamicLookupHelper
protected  void maybeDoSingleThreadedWorkaround(Runnable action)
           
 void resetDisplayGamma()
           
protected  void resetGammaRamp(Buffer originalGammaRamp)
          Resets the gamma ramp, potentially using the specified Buffer as data to restore the original values.
 boolean setDisplayGamma(float gamma, float brightness, float contrast)
          Sets the gamma, brightness, and contrast of the current main display.
protected  boolean setGammaRamp(float[] ramp)
          Sets the gamma ramp for the main screen.
 
Methods inherited from class javax.media.opengl.GLDrawableFactory
canCreateExternalGLDrawable, getDefaultDevice, getFactory, getFactoryImpl, getIsDeviceCompatible, getIsSharedContextAvailable, getOrCreateSharedContext, getOrCreateSharedContextImpl, shutdown, shutdownInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

protected static final boolean DEBUG
Constructor Detail

GLDrawableFactoryImpl

protected GLDrawableFactoryImpl()
Method Detail

getGLDynamicLookupHelper

public abstract GLDynamicLookupHelper getGLDynamicLookupHelper(int profile)
Returns the GLDynamicLookupHelper

Parameters:
profile - if EGL/ES, profile 1 refers to ES1 and 2 to ES2, otherwise the profile is ignored.

createGLDrawable

public GLDrawable createGLDrawable(NativeSurface target)
Description copied from class: GLDrawableFactory
Returns a GLDrawable according to it's chosen Capabilities,
which determines pixel format, on- and offscreen incl. PBuffer type.

The native platform's chosen Capabilties are referenced within the target NativeSurface's AbstractGraphicsConfiguration.

In case Capabilities.isOnscreen() is true,
an onscreen GLDrawable will be realized.

In case Capabilities.isOnscreen() is false,
either a Pbuffer drawable is created if GLCapabilities.isPBuffer() is true,
or a simple offscreen drawable is creates. The latter is unlikely to be hardware accelerated.

Specified by:
createGLDrawable in class GLDrawableFactory
See Also:
javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)

createOnscreenDrawableImpl

protected abstract GLDrawableImpl createOnscreenDrawableImpl(NativeSurface target)

canCreateGLPbuffer

public abstract boolean canCreateGLPbuffer(AbstractGraphicsDevice device)
Description copied from class: GLDrawableFactory
Returns true if it is possible to create a GLPbuffer. Some older graphics cards do not have this capability.

Specified by:
canCreateGLPbuffer in class GLDrawableFactory

createGLPbufferDrawableImpl

protected abstract GLDrawableImpl createGLPbufferDrawableImpl(NativeSurface target)
Target must implement SurfaceChangeable


createGLPbufferDrawable

public GLDrawable createGLPbufferDrawable(GLCapabilitiesImmutable capsRequested,
                                          GLCapabilitiesChooser chooser,
                                          int width,
                                          int height)
Description copied from class: GLDrawableFactory
Creates a Pbuffer GLDrawable with the given capabilites and dimensions.

Specified by:
createGLPbufferDrawable in class GLDrawableFactory

createGLPbuffer

public GLPbuffer createGLPbuffer(GLCapabilitiesImmutable capabilities,
                                 GLCapabilitiesChooser chooser,
                                 int width,
                                 int height,
                                 GLContext shareWith)
Description copied from class: GLDrawableFactory
Creates a GLPbuffer with the given capabilites and dimensions.

See the note in the overview documentation on context sharing.

Specified by:
createGLPbuffer in class GLDrawableFactory

createOffscreenDrawableImpl

protected abstract GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target)

createOffscreenDrawable

public GLDrawable createOffscreenDrawable(GLCapabilitiesImmutable capsRequested,
                                          GLCapabilitiesChooser chooser,
                                          int width,
                                          int height)
Description copied from class: GLDrawableFactory
Creates a Offscreen GLDrawable with the given capabilites and dimensions.

Specified by:
createOffscreenDrawable in class GLDrawableFactory

createOffscreenSurfaceImpl

protected abstract NativeSurface createOffscreenSurfaceImpl(GLCapabilitiesImmutable capabilities,
                                                            GLCapabilitiesImmutable capsRequested,
                                                            GLCapabilitiesChooser chooser,
                                                            int width,
                                                            int height)
creates an offscreen NativeSurface, which must implement SurfaceChangeable as well, so the windowing system related implementation is able to set the surface handle.


createExternalGLContextImpl

protected abstract GLContext createExternalGLContextImpl()

createExternalGLContext

public GLContext createExternalGLContext()
Description copied from class: GLDrawableFactory

Creates a GLContext object representing an existing OpenGL context in an external (third-party) OpenGL-based library. This GLContext object may be used to draw into this preexisting context using its GL and GLU objects. New contexts created through GLDrawables may share textures and display lists with this external context.

The underlying OpenGL context must be current on the current thread at the time this method is called. The user is responsible for the maintenance of the underlying OpenGL context; calls to makeCurrent and release on the returned GLContext object have no effect. If the underlying OpenGL context is destroyed, the destroy method should be called on the GLContext. A new GLContext object should be created for each newly-created underlying OpenGL context.

Specified by:
createExternalGLContext in class GLDrawableFactory

createExternalGLDrawableImpl

protected abstract GLDrawable createExternalGLDrawableImpl()

createExternalGLDrawable

public GLDrawable createExternalGLDrawable()
Description copied from class: GLDrawableFactory

Creates a GLDrawable object representing an existing OpenGL drawable in an external (third-party) OpenGL-based library. This GLDrawable object may be used to create new, fully-functional GLContexts on the OpenGL drawable. This is useful when interoperating with a third-party OpenGL-based library and it is essential to not perturb the state of the library's existing context, even to the point of not sharing textures or display lists with that context.

An underlying OpenGL context must be current on the desired drawable and the current thread at the time this method is called. The user is responsible for the maintenance of the underlying drawable. If one or more contexts are created on the drawable using GLDrawable.createContext(javax.media.opengl.GLContext), and the drawable is deleted by the third-party library, the user is responsible for calling GLContext.destroy() on these contexts.

Calls to setSize, getWidth and getHeight are illegal on the returned GLDrawable. If these operations are required by the user, they must be performed by the third-party library.

It is legal to create both an external GLContext and GLDrawable representing the same third-party OpenGL entities. This can be used, for example, to query current state information using the external GLContext and then create and set up new GLContexts using the external GLDrawable.

This functionality may not be available on all platforms and GLDrawableFactory.canCreateExternalGLDrawable(javax.media.nativewindow.AbstractGraphicsDevice) should be called first to see if it is present. For example, on X11 platforms, this API requires the presence of GLX 1.3 or later.

Specified by:
createExternalGLDrawable in class GLDrawableFactory

maybeDoSingleThreadedWorkaround

protected void maybeDoSingleThreadedWorkaround(Runnable action)

getFactoryImpl

public static GLDrawableFactoryImpl getFactoryImpl(GLProfile glp)
Returns the sole GLDrawableFactoryImpl instance.

Parameters:
glProfile - GLProfile to determine the factory type, ie EGLDrawableFactory, or one of the native GLDrawableFactory's, ie X11/GLX, Windows/WGL or MacOSX/CGL.

canCreateContextOnJava2DSurface

public abstract boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device)

createContextOnJava2DSurface

public abstract GLContext createContextOnJava2DSurface(Object graphics,
                                                       GLContext shareWith)
                                                throws GLException
Throws:
GLException

setDisplayGamma

public boolean setDisplayGamma(float gamma,
                               float brightness,
                               float contrast)
                        throws IllegalArgumentException
Sets the gamma, brightness, and contrast of the current main display. Returns true if the settings were changed, false if not. If this method returns true, the display settings will automatically be reset upon JVM exit (assuming the JVM does not crash); if the user wishes to change the display settings back to normal ahead of time, use resetDisplayGamma(). Throws IllegalArgumentException if any of the parameters were out-of-bounds.

Parameters:
gamma - The gamma value, typically > 1.0 (default value is 1.0)
brightness - The brightness value between -1.0 and 1.0, inclusive (default value is 0)
contrast - The contrast, greater than 0.0 (default value is 1)
Throws:
IllegalArgumentException - if any of the parameters were out-of-bounds

resetDisplayGamma

public void resetDisplayGamma()

getGammaRampLength

protected int getGammaRampLength()
Returns the length of the computed gamma ramp for this OS and hardware. Returns 0 if gamma changes are not supported.


setGammaRamp

protected boolean setGammaRamp(float[] ramp)
Sets the gamma ramp for the main screen. Returns false if gamma ramp changes were not supported.


getGammaRamp

protected Buffer getGammaRamp()
Gets the current gamma ramp. This is basically an opaque value used only on some platforms to reset the gamma ramp to its original settings.


resetGammaRamp

protected void resetGammaRamp(Buffer originalGammaRamp)
Resets the gamma ramp, potentially using the specified Buffer as data to restore the original values.



Copyright 2010 JogAmp Community.