gtk3-0.15.10: Binding to the Gtk+ 3 graphical user interface library

Maintainer | gtk2hs-users@lists.sourceforge.net
Stability | provisional
Portability | portable (depends on GHC)
Safe Haskell | None
Language | Haskell98

Graphics.UI.Gtk.Misc.GLArea

Contents

- Detail
- Class Hierarchy
- Types
- Constructors
- Methods
- Attributes
- Signals

Description

A widget for custom drawing with OpenGL

Synopsis

- data GLArea
- class WidgetClass o => GLAreaClass o
- castToGLArea :: GObjectClass obj => obj -> GLArea
- gTypeGLArea :: GType
- toGLArea :: GLAreaClass o => o -> GLArea
- glAreaNew :: IO GLArea
- glAreaGetContext :: GLAreaClass self => self -> IO (Maybe GLContext)
- glAreaMakeCurrent :: GLAreaClass self => self -> IO ()
- glAreaQueueRender :: GLAreaClass self => self -> IO ()
- glAreaAttachBuffers :: GLAreaClass self => self -> IO ()
- glAreaSetAutoRender :: GLAreaClass self => self -> Bool -> IO ()
- glAreaGetAutoRender :: GLAreaClass self => self -> IO Bool
- glAreaSetHasAlpha :: GLAreaClass self => self -> Bool -> IO ()
- glAreaGetHasAlpha :: GLAreaClass self => self -> IO Bool
- glAreaSetHasDepthBuffer :: GLAreaClass self => self -> Bool -> IO ()
- glAreaGetHasDepthBuffer :: GLAreaClass self => self -> IO Bool
- glAreaSetHasStencilBuffer :: GLAreaClass self => self -> Bool -> IO ()
- glAreaGetHasStencilBuffer :: GLAreaClass self => self -> IO Bool
- glAreaGetRequiredVersion :: GLAreaClass self => self -> IO (Int, Int)
- glAreaSetRequiredVersion :: GLAreaClass self => self -> Int -> Int -> IO ()
- glAreaGetError :: GLAreaClass self => self -> IO (Maybe GError)
- glAreaAutoRender :: GLAreaClass self => Attr self Bool
- glAreaContext :: GLAreaClass self => ReadAttr self (Maybe GLContext)
- glAreaHasAlpha :: GLAreaClass self => Attr self Bool
- glAreaHasDepthBuffer :: GLAreaClass self => Attr self Bool
- glAreaHasStencilBuffer :: GLAreaClass self => Attr self Bool
- glAreaResize :: GLAreaClass glac => Signal glac (Int -> Int -> IO ())
- glAreaRender :: GLAreaClass glac => Signal glac (Maybe GLContext -> IO Bool)

# Detail

The `GLArea` is a widget that allows drawing with OpenGL.

GLArea sets up its own `GLContext` for the window it creates, and creates a custom GL framebuffer that the widget will do GL rendering onto. It also ensures that this framebuffer is the default GL rendering target when rendering.

In order to draw, you have to connect to the `glAreaRender` signal.

The GLArea widget ensures that the `GLContext` is associated with the widget's drawing area, and it is kept updated when the size and position of the drawing area changes.

If you need to initialize OpenGL state, e.g. buffer objects or shaders, you should use the `realize` signal; you can use the `unrealize` signal to clean up.

To receive mouse events on a drawing area, you will need to enable them with `widgetAddEvents`. To receive keyboard events, you will need to set the `widgetCanFocus` attribute on the drawing area.

# Class Hierarchy

    | GObject
    | +----Object
    | +----Widget
    | +----GLArea

# Types

data GLArea Source #

#### Instances

Instances details

Eq GLArea Source # |
Instance details Defined in Graphics.UI.Gtk.Types Methods (==) :: GLArea -> GLArea -> Bool Source # (/=) :: GLArea -> GLArea -> Bool Source #
Ord GLArea Source # |
Instance details Defined in Graphics.UI.Gtk.Types Methods compare :: GLArea -> GLArea -> Ordering Source # (<) :: GLArea -> GLArea -> Bool Source # (<=) :: GLArea -> GLArea -> Bool Source # (>) :: GLArea -> GLArea -> Bool Source # (>=) :: GLArea -> GLArea -> Bool Source # max :: GLArea -> GLArea -> GLArea Source # min :: GLArea -> GLArea -> GLArea Source #
GObjectClass GLArea Source # |
Instance details Defined in Graphics.UI.Gtk.Types Methods toGObject :: GLArea -> GObject Source # unsafeCastGObject :: GObject -> GLArea Source #
GLAreaClass GLArea Source # |
Instance details Defined in Graphics.UI.Gtk.Types
WidgetClass GLArea Source # |
Instance details Defined in Graphics.UI.Gtk.Types

class WidgetClass o => GLAreaClass o Source #

#### Instances

Instances details

GLAreaClass GLArea Source # |
Instance details Defined in Graphics.UI.Gtk.Types

castToGLArea :: GObjectClass obj => obj -> GLArea Source #

gTypeGLArea :: GType Source #

toGLArea :: GLAreaClass o => o -> GLArea Source #

# Constructors

glAreaNew :: IO GLArea Source #

Creates a new GLArea widget.

# Methods

glAreaGetContext :: GLAreaClass self => self -> IO (Maybe GLContext) Source #

Retrieves the `GLContext` used by area.

glAreaMakeCurrent :: GLAreaClass self => self -> IO () Source #

Ensures that the `GLContext` used by area is associated with the GLArea.

This function is automatically called before emitting the `glAreaRender` signal, and doesn't normally need to be called by application code.

glAreaQueueRender :: GLAreaClass self => self -> IO () Source #

Marks the currently rendered data (if any) as invalid, and queues a redraw of the widget, ensuring that the `glAreaRender` signal is emitted during the draw.

This is only needed when `glAreaSetAutoRender` has been called with a False value. The default behaviour is to emit `glAreaRender` on each draw.

glAreaAttachBuffers :: GLAreaClass self => self -> IO () Source #

Ensures that the area framebuffer object is made the current draw and read target, and that all the required buffers for the area are created and bound to the framebuffer.

This function is automatically called before emitting the `glAreaRender` signal, and doesn't normally need to be called by application code.

glAreaSetAutoRender :: GLAreaClass self => self -> Bool -> IO () Source #

If autoRender is True the `glAreaRender` signal will be emitted every time the widget draws. This is the default and is useful if drawing the widget is faster.

If autoRender is False the data from previous rendering is kept around and will be used for drawing the widget the next time, unless the window is resized. In order to force a rendering `glAreaQueueRender` must be called. This mode is useful when the scene changes seldomly, but takes a long time to redraw.

glAreaGetAutoRender :: GLAreaClass self => self -> IO Bool Source #

Returns whether the area is in auto render mode or not.

glAreaSetHasAlpha :: GLAreaClass self => self -> Bool -> IO () Source #

If hasAlpha is True the buffer allocated by the widget will have an alpha channel component, and when rendering to the window the result will be composited over whatever is below the widget.

If hasAlpha is False there will be no alpha channel, and the buffer will fully replace anything below the widget.

glAreaGetHasAlpha :: GLAreaClass self => self -> IO Bool Source #

Returns whether the area has an alpha component.

glAreaSetHasDepthBuffer :: GLAreaClass self => self -> Bool -> IO () Source #

If hasDepthBuffer is True the widget will allocate and enable a depth buffer for the target framebuffer. Otherwise there will be none.

glAreaGetHasDepthBuffer :: GLAreaClass self => self -> IO Bool Source #

Returns whether the area has a depth buffer.

glAreaSetHasStencilBuffer :: GLAreaClass self => self -> Bool -> IO () Source #

If hasStencilBuffer is True the widget will allocate and enable a stencil buffer for the target framebuffer. Otherwise there will be none.

glAreaGetHasStencilBuffer :: GLAreaClass self => self -> IO Bool Source #

Returns whether the area has a stencil buffer.

glAreaGetRequiredVersion :: GLAreaClass self => self -> IO (Int, Int) Source #

Retrieves the required version of OpenGL set using `glAreaSetRequiredVersion`.

glAreaSetRequiredVersion :: GLAreaClass self => self -> Int -> Int -> IO () Source #

Sets the required version of OpenGL to be used when creating the context for the widget.

This function must be called before the area has been realized.

glAreaGetError :: GLAreaClass self => self -> IO (Maybe GError) Source #

Gets the current error set on the area.

# Attributes

glAreaAutoRender :: GLAreaClass self => Attr self Bool Source #

If set to True the `glAreaRender` signal will be emitted every time the widget draws. This is the default and is useful if drawing the widget is faster.

If set to False the data from previous rendering is kept around and will be used for drawing the widget the next time, unless the window is resized. In order to force a rendering `glAreaQueueRender` must be called. This mode is useful when the scene changes seldomly, but takes a long time to redraw.

Default value: True

glAreaContext :: GLAreaClass self => ReadAttr self (Maybe GLContext) Source #

The `GLContext` used by the GLArea widget.

The GLArea widget is responsible for creating the `GLContext` instance. If you need to render with other kinds of buffers (stencil, depth, etc), use render buffers.

glAreaHasAlpha :: GLAreaClass self => Attr self Bool Source #

If set to True the buffer allocated by the widget will have an alpha channel component, and when rendering to the window the result will be composited over whatever is below the widget.

If set to False there will be no alpha channel, and the buffer will fully replace anything below the widget.

Default value: False

glAreaHasDepthBuffer :: GLAreaClass self => Attr self Bool Source #

If set to True the widget will allocate and enable a depth buffer for the target framebuffer.

Default value: False

glAreaHasStencilBuffer :: GLAreaClass self => Attr self Bool Source #

If set to True the widget will allocate and enable a stencil buffer for the target framebuffer.

Default value: False

# Signals

glAreaResize :: GLAreaClass glac => Signal glac (Int -> Int -> IO ()) Source #

The glAreaResize signal is emitted once when the widget is realized, and then each time the widget is changed while realized. This is useful in order to keep GL state up to date with the widget size, like for instance camera properties which may depend on the width/height ratio.

The GL context for the area is guaranteed to be current when this signal is emitted.

The default handler sets up the GL viewport.

glAreaRender :: GLAreaClass glac => Signal glac (Maybe GLContext -> IO Bool) Source #

The glAreaRender signal is emitted every time the contents of the GLArea should be redrawn.

The context is bound to the area prior to emitting this function, and the buffers are painted to the window once the emission terminates.