GdkGLContext

GdkGLContext — OpenGL context

Functions

Properties

GdkDisplay * display Read / Write / Construct Only
GdkGLProfile profile Read / Write / Construct Only
GdkGLContext * shared-context Read / Write / Construct Only
GdkWindow * window Read / Write / Construct Only

Types and Values

Object Hierarchy

    GObject
    ╰── GdkGLContext

Includes

#include <gdk/gdk.h>

Description

GdkGLContext is an object representing the platform-specific OpenGL drawing context.

GdkGLContexts are created for a GdkWindow using gdk_window_create_gl_context(), and the context will match the GdkVisual of the window.

A GdkGLContext is not tied to any particular normal framebuffer. For instance, it cannot draw to the GdkWindow back buffer. The GDK repaint system is in full control of the painting to that. Instead, you can create render buffers or textures and use gdk_cairo_draw_from_gl() in the draw function of your widget to draw them. Then GDK will handle the integration of your rendering with that of other widgets.

Support for GdkGLContext is platform-specific, context creation can fail, returning NULL context.

A GdkGLContext has to be made "current" in order to start using it, otherwise any OpenGL call will be ignored.

Creating a new OpenGL context

In order to create a new GdkGLContext instance you need a GdkWindow, which you typically get during the realize call of a widget.

Using a GdkGLContext

You will need to make the GdkGLContext the current context before issuing OpenGL calls; the system sends OpenGL commands to whichever context is current. It is possible to have multiple contexts, so you always need to ensure that the one which you want to draw with is the current one before issuing commands:

You can now perform your drawing using OpenGL commands.

You can check which GdkGLContext is the current one by using gdk_gl_context_get_current(); you can also unset any GdkGLContext that is currently set by calling gdk_gl_context_clear_current().

Functions

gdk_gl_context_get_window ()

GdkWindow *
gdk_gl_context_get_window (GdkGLContext *context);

Retrieves the GdkWindow used by the context .

Parameters

context

a GdkGLContext

 

Returns

a GdkWindow or NULL.

[transfer none]

Since 3.16


gdk_gl_context_make_current ()

void
gdk_gl_context_make_current (GdkGLContext *context);

Makes the context the current one.

Parameters

context

a GdkGLContext

 

Since 3.16


gdk_gl_context_clear_current ()

void
gdk_gl_context_clear_current (void);

Clears the current GdkGLContext.

Any OpenGL call after this function returns will be ignored until gdk_gl_context_make_current() is called.

Since 3.16


gdk_gl_context_get_current ()

GdkGLContext *
gdk_gl_context_get_current (void);

Retrieves the current GdkGLContext.

Returns

the current GdkGLContext, or NULL.

[transfer none]

Since 3.16


GDK_GL_ERROR

#define GDK_GL_ERROR       (gdk_gl_error_quark ())

GDK_TYPE_GL_ERROR

#define GDK_TYPE_GL_ERROR (gdk_gl_error_get_type ())

GDK_TYPE_GL_PROFILE

#define GDK_TYPE_GL_PROFILE (gdk_gl_profile_get_type ())

Types and Values

GdkGLContext

typedef struct _GdkGLContext GdkGLContext;

enum GdkGLProfile

...

Members

GDK_GL_PROFILE_DEFAULT

...

 

GDK_GL_PROFILE_LEGACY

...

 

GDK_GL_PROFILE_3_2_CORE

...

 

enum GdkGLError

Members

GDK_GL_ERROR_NOT_AVAILABLE

   

GDK_GL_ERROR_UNSUPPORTED_FORMAT

   

GDK_GL_ERROR_UNSUPPORTED_PROFILE

   

Property Details

The “display” property

  “display”                  GdkDisplay *

The GdkWindow the gl context is bound to.

Flags: Read / Write / Construct Only

Since 3.16


The “profile” property

  “profile”                  GdkGLProfile

The GdkGLProfile of the context

Flags: Read / Write / Construct Only

Default value: GDK_GL_PROFILE_DEFAULT

Since 3.16


The “shared-context” property

  “shared-context”           GdkGLContext *

The GdkGLContext that this context is sharing data with, or NULL

Flags: Read / Write / Construct Only

Since 3.16


The “window” property

  “window”                   GdkWindow *

The GdkWindow the gl context is bound to.

Flags: Read / Write / Construct Only

Since 3.16