Qyoto  4.0.7
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties
QtOpenGL.QGLPixelBuffer Class Reference

The QGLPixelBuffer class encapsulates an OpenGL pbuffer. More...

Inheritance diagram for QtOpenGL.QGLPixelBuffer:
Collaboration diagram for QtOpenGL.QGLPixelBuffer:

Public Member Functions

 QGLPixelBuffer (QSize size)
  More...
 
 QGLPixelBuffer (QSize size, QGLFormat format, QGLWidget shareWidget=null)
  More...
 
 QGLPixelBuffer (int width, int height)
  More...
 
 QGLPixelBuffer (int width, int height, QGLFormat format, QGLWidget shareWidget=null)
  More...
 
override void CreateProxy ()
 
new uint BindTexture (QImage image)
  More...
 
new uint BindTexture (QPixmap pixmap)
  More...
 
new uint BindTexture (QImage image, int target)
  More...
 
new uint BindTexture (QPixmap pixmap, int target)
  More...
 
new uint BindTexture (string fileName)
  More...
 
new bool BindToDynamicTexture (uint texture)
  More...
 
new void DeleteTexture (uint texture_id)
  More...
 
new bool DoneCurrent ()
  More...
 
new void DrawTexture (QRectF target, uint textureId)
  More...
 
new void DrawTexture (QPointF point, uint textureId)
  More...
 
new void DrawTexture (QRectF target, uint textureId, int textureTarget)
  More...
 
new void DrawTexture (QPointF point, uint textureId, int textureTarget)
  More...
 
new uint GenerateDynamicTexture ()
  More...
 
new bool MakeCurrent ()
  More...
 
new void ReleaseFromDynamicTexture ()
  More...
 
new QImage ToImage ()
  More...
 
new void UpdateDynamicTexture (uint texture_id)
  More...
 
new void Dispose ()
 
- Public Member Functions inherited from QtGui.QPaintDevice
virtual System.IntPtr GetDC ()
 
virtual void ReleaseDC (System.IntPtr hdc)
 
new void Dispose ()
 

Protected Member Functions

 QGLPixelBuffer (System.Type dummy)
 
override int Metric (QPaintDevice.PaintDeviceMetric metric)
  More...
 
- Protected Member Functions inherited from QtGui.QPaintDevice
 QPaintDevice (System.Type dummy)
 
 QPaintDevice ()
  More...
 

Properties

override int DevType [get]
 
QGLFormat Format [get]
  More...
 
static bool HasOpenGLPbuffers [get]
  More...
 
bool IsValid [get]
  More...
 
override QPaintEngine PaintEngine [get]
  More...
 
QSize Size [get]
  More...
 
- Properties inherited from QtGui.QPaintDevice
int ColorCount [get]
  More...
 
int Depth [get]
  More...
 
virtual int DevType [get]
 
int Height [get]
  More...
 
int HeightMM [get]
  More...
 
int LogicalDpiX [get]
  More...
 
int LogicalDpiY [get]
  More...
 
int NumColors [get]
  More...
 
virtual QPaintEngine PaintEngine [get]
  More...
 
bool PaintingActive [get]
  More...
 
int PhysicalDpiX [get]
  More...
 
int PhysicalDpiY [get]
  More...
 
int Width [get]
  More...
 
int WidthMM [get]
  More...
 
virtual System.IntPtr SmokeObject [get, set]
 
new ushort Painters [get, set]
 
- Properties inherited from QtGui.IQPaintDevice
System.Int32 ColorCount [get]
  More...
 
System.Int32 Depth [get]
  More...
 
System.Int32 DevType [get]
 
System.Int32 Height [get]
  More...
 
System.Int32 HeightMM [get]
  More...
 
System.Int32 LogicalDpiX [get]
  More...
 
System.Int32 LogicalDpiY [get]
  More...
 
System.Int32 NumColors [get]
  More...
 
QPaintEngine PaintEngine [get]
  More...
 
System.Boolean PaintingActive [get]
  More...
 
System.Int32 PhysicalDpiX [get]
  More...
 
System.Int32 PhysicalDpiY [get]
  More...
 
System.Int32 Width [get]
  More...
 
System.Int32 WidthMM [get]
  More...
 

Additional Inherited Members

- Public Types inherited from QtGui.QPaintDevice
enum  PaintDeviceMetric {
  PdmDepth = 6, PdmDpiX = 7, PdmDpiY = 8, PdmHeight = 2,
  PdmHeightMM = 4, PdmNumColors = 5, PdmPhysicalDpiX = 9, PdmPhysicalDpiY = 10,
  PdmWidth = 1, PdmWidthMM = 3
}
  More...
 
- Protected Attributes inherited from QtGui.QPaintDevice
SmokeInvocation interceptor
 

Detailed Description

The QGLPixelBuffer class encapsulates an OpenGL pbuffer.

Rendering into a pbuffer is normally done using full hardware acceleration. This can be significantly faster than rendering into a QPixmap.

There are three approaches to using this class:

We can draw into the pbuffer and convert it to a QImage using toImage(). This is normally much faster than calling QGLWidget::renderPixmap().

We can draw into the pbuffer and copy the contents into an OpenGL texture using updateDynamicTexture(). This allows us to create dynamic textures and works on all systems with pbuffer support.

On systems that support it, we can bind the pbuffer to an OpenGL texture. The texture is then updated automatically when the pbuffer contents change, eliminating the need for additional copy operations. This is supported only on Windows and Mac OS X systems that provide the render_texture extension. Note that under Windows, a multi-sampled pbuffer can't be used in conjunction with the render_texture extension. If a multi-sampled pbuffer is requested under Windows, the render_texture extension is turned off for that pbuffer.

Threading

As of Qt 4.8, it's possible to render into a QGLPixelBuffer using a QPainter in a separate thread. Note that OpenGL 2.0 or OpenGL ES 2.0 is required for this to work. Also, under X11, it's necessary to set the Qt::AA_X11InitThreads application attribute.

Pbuffers are provided by the OpenGL pbuffer extension; call hasOpenGLPbuffer() to find out if the system provides pbuffers.

See also Pbuffers Example.

Constructor & Destructor Documentation

QtOpenGL.QGLPixelBuffer.QGLPixelBuffer ( System.Type  dummy)
protected
QtOpenGL.QGLPixelBuffer.QGLPixelBuffer ( QSize  size)

Constructs an OpenGL pbuffer of the given size. If no format is specified, the default format is used. If the shareWidget parameter points to a valid QGLWidget, the pbuffer will share its context with shareWidget.

If you intend to bind this pbuffer as a dynamic texture, the width and height components of size must be powers of two (e.g., 512 x 128).

See also size() and format().

Here is the call graph for this function:

QtOpenGL.QGLPixelBuffer.QGLPixelBuffer ( QSize  size,
QGLFormat  format,
QGLWidget  shareWidget = null 
)

Constructs an OpenGL pbuffer of the given size. If no format is specified, the default format is used. If the shareWidget parameter points to a valid QGLWidget, the pbuffer will share its context with shareWidget.

If you intend to bind this pbuffer as a dynamic texture, the width and height components of size must be powers of two (e.g., 512 x 128).

See also size() and format().

Here is the call graph for this function:

QtOpenGL.QGLPixelBuffer.QGLPixelBuffer ( int  width,
int  height 
)

This is an overloaded function.

Constructs an OpenGL pbuffer with the width and height. If no format is specified, the default format is used. If the shareWidget parameter points to a valid QGLWidget, the pbuffer will share its context with shareWidget.

If you intend to bind this pbuffer as a dynamic texture, the width and height components of size must be powers of two (e.g., 512 x 128).

See also size() and format().

Here is the call graph for this function:

QtOpenGL.QGLPixelBuffer.QGLPixelBuffer ( int  width,
int  height,
QGLFormat  format,
QGLWidget  shareWidget = null 
)

This is an overloaded function.

Constructs an OpenGL pbuffer with the width and height. If no format is specified, the default format is used. If the shareWidget parameter points to a valid QGLWidget, the pbuffer will share its context with shareWidget.

If you intend to bind this pbuffer as a dynamic texture, the width and height components of size must be powers of two (e.g., 512 x 128).

See also size() and format().

Here is the call graph for this function:

Member Function Documentation

new uint QtOpenGL.QGLPixelBuffer.BindTexture ( QImage  image)

Generates and binds a 2D GL texture to the current context, based on image. The generated texture id is returned and can be used in later glBindTexture() calls.

The target parameter specifies the texture target.

Equivalent to calling QGLContext::bindTexture().

See also deleteTexture().

new uint QtOpenGL.QGLPixelBuffer.BindTexture ( QPixmap  pixmap)

This is an overloaded function.

Generates and binds a 2D GL texture based on pixmap.

Equivalent to calling QGLContext::bindTexture().

See also deleteTexture().

new uint QtOpenGL.QGLPixelBuffer.BindTexture ( QImage  image,
int  target 
)

Generates and binds a 2D GL texture to the current context, based on image. The generated texture id is returned and can be used in later glBindTexture() calls.

The target parameter specifies the texture target.

Equivalent to calling QGLContext::bindTexture().

See also deleteTexture().

new uint QtOpenGL.QGLPixelBuffer.BindTexture ( QPixmap  pixmap,
int  target 
)

This is an overloaded function.

Generates and binds a 2D GL texture based on pixmap.

Equivalent to calling QGLContext::bindTexture().

See also deleteTexture().

new uint QtOpenGL.QGLPixelBuffer.BindTexture ( string  fileName)

This is an overloaded function.

Reads the DirectDrawSurface (DDS) compressed file fileName and generates a 2D GL texture from it.

Equivalent to calling QGLContext::bindTexture().

See also deleteTexture().

new bool QtOpenGL.QGLPixelBuffer.BindToDynamicTexture ( uint  texture)

Binds the texture specified by texture_id to this pbuffer. Returns true on success; otherwise returns false.

The texture must be of the same size and format as the pbuffer.

To unbind the texture, call releaseFromDynamicTexture(). While the texture is bound, it is updated automatically when the pbuffer contents change, eliminating the need for additional copy operations.

Example:

QGLPixelBuffer pbuffer(...);

...

pbuffer.makeCurrent();

GLuint dynamicTexture = pbuffer.generateDynamicTexture();

pbuffer.bindToDynamicTexture(dynamicTexture);

...

pbuffer.releaseFromDynamicTexture();

Warning: This function uses the render_texture extension, which is currently not supported under X11. An alternative that works on all systems (including X11) is to manually copy the pbuffer contents to a texture using updateDynamicTexture().

Warning: For the bindToDynamicTexture() call to succeed on the Mac OS X, the pbuffer needs a shared context, i.e. the QGLPixelBuffer must be created with a share widget.

See also generateDynamicTexture() and releaseFromDynamicTexture().

override void QtOpenGL.QGLPixelBuffer.CreateProxy ( )
virtual

Reimplemented from QtGui.QPaintDevice.

Here is the caller graph for this function:

new void QtOpenGL.QGLPixelBuffer.DeleteTexture ( uint  texture_id)

Removes the texture identified by texture_id from the texture cache.

Equivalent to calling QGLContext::deleteTexture().

new void QtOpenGL.QGLPixelBuffer.Dispose ( )
new bool QtOpenGL.QGLPixelBuffer.DoneCurrent ( )

Makes no context the current OpenGL context. Returns true on success; otherwise returns false.

new void QtOpenGL.QGLPixelBuffer.DrawTexture ( QRectF  target,
uint  textureId 
)

Draws the given texture, textureId, to the given target rectangle, target, in OpenGL model space. The textureTarget should be a 2D texture target.

Equivalent to the corresponding QGLContext::drawTexture().

This function was introduced in Qt 4.4.

new void QtOpenGL.QGLPixelBuffer.DrawTexture ( QPointF  point,
uint  textureId 
)

Draws the given texture, textureId, at the given point in OpenGL model space. The textureTarget parameter should be a 2D texture target.

Equivalent to the corresponding QGLContext::drawTexture().

This function was introduced in Qt 4.4.

new void QtOpenGL.QGLPixelBuffer.DrawTexture ( QRectF  target,
uint  textureId,
int  textureTarget 
)

Draws the given texture, textureId, to the given target rectangle, target, in OpenGL model space. The textureTarget should be a 2D texture target.

Equivalent to the corresponding QGLContext::drawTexture().

This function was introduced in Qt 4.4.

new void QtOpenGL.QGLPixelBuffer.DrawTexture ( QPointF  point,
uint  textureId,
int  textureTarget 
)

Draws the given texture, textureId, at the given point in OpenGL model space. The textureTarget parameter should be a 2D texture target.

Equivalent to the corresponding QGLContext::drawTexture().

This function was introduced in Qt 4.4.

new uint QtOpenGL.QGLPixelBuffer.GenerateDynamicTexture ( )

Generates and binds a 2D GL texture that is the same size as the pbuffer, and returns the texture's ID. This can be used in conjunction with bindToDynamicTexture() and updateDynamicTexture().

See also size().

new bool QtOpenGL.QGLPixelBuffer.MakeCurrent ( )

Makes this pbuffer the current OpenGL rendering context. Returns true on success; otherwise returns false.

See also QGLContext::makeCurrent() and doneCurrent().

override int QtOpenGL.QGLPixelBuffer.Metric ( QPaintDevice.PaintDeviceMetric  metric)
protectedvirtual

Reimplemented from QPaintDevice::metric().

Reimplemented from QtGui.QPaintDevice.

new void QtOpenGL.QGLPixelBuffer.ReleaseFromDynamicTexture ( )

Releases the pbuffer from any previously bound texture.

See also bindToDynamicTexture().

new QImage QtOpenGL.QGLPixelBuffer.ToImage ( )

Returns the contents of the pbuffer as a QImage.

new void QtOpenGL.QGLPixelBuffer.UpdateDynamicTexture ( uint  texture_id)

Copies the pbuffer contents into the texture specified with texture_id.

The texture must be of the same size and format as the pbuffer.

Example:

QGLPixelBuffer pbuffer(...);

...

pbuffer.makeCurrent();

GLuint dynamicTexture = pbuffer.generateDynamicTexture();

...

pbuffer.updateDynamicTexture(dynamicTexture);

An alternative on Windows and Mac OS X systems that support the render_texture extension is to use bindToDynamicTexture() to get dynamic updates of the texture.

See also generateDynamicTexture() and bindToDynamicTexture().

Property Documentation

override int QtOpenGL.QGLPixelBuffer.DevType
get
QGLFormat QtOpenGL.QGLPixelBuffer.Format
get

Returns the format of the pbuffer. The format may be different from the one that was requested.

bool QtOpenGL.QGLPixelBuffer.HasOpenGLPbuffers
staticget

Returns true if the OpenGL pbuffer extension is present on this system; otherwise returns false.

bool QtOpenGL.QGLPixelBuffer.IsValid
get

Returns true if this pbuffer is valid; otherwise returns false.

override QPaintEngine QtOpenGL.QGLPixelBuffer.PaintEngine
get

Reimplemented from QPaintDevice::paintEngine().

QSize QtOpenGL.QGLPixelBuffer.Size
get

Returns the size of the pbuffer.