Package org.lwjgl.opengl

# Class SharedDrawable

java.lang.Object
org.lwjgl.opengl.SharedDrawable

All Implemented Interfaces:
  `Drawable`

public final class SharedDrawable extends Object
A Drawable implementation that shares its context with another Drawable. This is useful for background loading of resources. See org.lwjgl.test.opengl.multithread.BackgroundLoad for an example.

Author:
  Spasi

## Field Summary

Fields
Modifier and Type
Field
Description
`protected org.lwjgl.opengl.ContextGL`
`context`
The OpenGL Context.
`protected org.lwjgl.opengl.PeerInfo`
`peer_info`
Handle to the native GL rendering context
`protected PixelFormat`
`pixel_format`
The PixelFormat used to create the drawable.

## Constructor Summary

Constructors
Constructor
Description
`SharedDrawable(Drawable drawable)`

## Method Summary

Modifier and Type
Method
Description
`protected final void`
`checkDestroyed()`
`void`
`checkGLError()`
`org.lwjgl.opengl.ContextGL`
`createSharedContext()`
`void`
`destroy()`
Destroys the Drawable.
`org.lwjgl.opengl.ContextGL`
`getContext()`
`PixelFormatLWJGL`
`getPixelFormat()`
`void`
`initContext(float r, float g, float b)`
`boolean`
`isCurrent()`
Returns true if the Drawable's context is current in the current thread.
`void`
`makeCurrent()`
Makes the Drawable's context current in the current thread.
`void`
`releaseContext()`
If the Drawable's context is current in the current thread, no context will be current after a call to this method.
`void`
`setCLSharingProperties(PointerBuffer properties)`
Sets the appropriate khr_gl_sharing properties in the target `PointerBuffer`, so that if it is used in a `clCreateContext(FromType)` call, the created CL context will be sharing objects with this `Drawable`'s GL context.
`void`
`setPixelFormat(PixelFormatLWJGL pf)`
`void`
`setPixelFormat(PixelFormatLWJGL pf, ContextAttribs attribs)`
`void`
`setSwapInterval(int swap_interval)`
`void`
`swapBuffers()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### pixel_format

protected PixelFormat pixel_format
The PixelFormat used to create the drawable.

### peer_info

protected org.lwjgl.opengl.PeerInfo peer_info
Handle to the native GL rendering context

### context

protected org.lwjgl.opengl.ContextGL context
The OpenGL Context.

## Constructor Details

### SharedDrawable

public SharedDrawable(Drawable drawable) throws LWJGLException

Throws:
  `LWJGLException`

## Method Details

### createSharedContext

public org.lwjgl.opengl.ContextGL createSharedContext()

### setPixelFormat

public void setPixelFormat(PixelFormatLWJGL pf) throws LWJGLException

Throws:
  `LWJGLException`

### setPixelFormat

public void setPixelFormat(PixelFormatLWJGL pf, ContextAttribs attribs) throws LWJGLException

Throws:
  `LWJGLException`

### getPixelFormat

public PixelFormatLWJGL getPixelFormat()

### getContext

public org.lwjgl.opengl.ContextGL getContext()

### checkGLError

public void checkGLError()

### setSwapInterval

public void setSwapInterval(int swap_interval)

### swapBuffers

public void swapBuffers() throws LWJGLException

Throws:
  `LWJGLException`

### initContext

public void initContext(float r, float g, float b)

### isCurrent

public boolean isCurrent() throws LWJGLException
Description copied from interface: `Drawable`
Returns true if the Drawable's context is current in the current thread.

Specified by:
  `isCurrent` in interface `Drawable`
Throws:
  `LWJGLException`

### makeCurrent

public void makeCurrent() throws LWJGLException
Description copied from interface: `Drawable`
Makes the Drawable's context current in the current thread.

Specified by:
  `makeCurrent` in interface `Drawable`
Throws:
  `LWJGLException`

### releaseContext

public void releaseContext() throws LWJGLException
Description copied from interface: `Drawable`
If the Drawable's context is current in the current thread, no context will be current after a call to this method.

Specified by:
  `releaseContext` in interface `Drawable`
Throws:
  `LWJGLException`

### destroy

public void destroy()
Description copied from interface: `Drawable`
Destroys the Drawable.

Specified by:
  `destroy` in interface `Drawable`

### setCLSharingProperties

public void setCLSharingProperties(PointerBuffer properties) throws LWJGLException
Description copied from interface: `Drawable`
Sets the appropriate khr_gl_sharing properties in the target `PointerBuffer`, so that if it is used in a `clCreateContext(FromType)` call, the created CL context will be sharing objects with this `Drawable`'s GL context. After a call to this method, the target buffer position will have advanced by 2 to 4 positions, depending on the implementation.

Specified by:
  `setCLSharingProperties` in interface `Drawable`
Parameters:
  `properties` - The target properties buffer. It must have at least 4 positions remaining.
Throws:
  `LWJGLException`

### checkDestroyed

protected final void checkDestroyed()