Module: SDL2::GL

Defined in:
gl.c,
gl.c

Overview

This module provides the initialize/shutdown functions of OpenGL.

Defined Under Namespace

Classes: Context

Constant Summary

RED_SIZE =

OpenGL attribute - minimal bits of red channel in color buffer, default is 3

INT2NUM(SDL_GL_RED_SIZE)
GREEN_SIZE =

OpenGL attribute - minimal bits of green channel in color buffer, default is 3

INT2NUM(SDL_GL_GREEN_SIZE)
BLUE_SIZE =

OpenGL attribute - minimal bits of blue channel in color buffer, default is 2

INT2NUM(SDL_GL_BLUE_SIZE)
ALPHA_SIZE =

OpenGL attribute - minimal bits of alpha channel in color buffer, default is 0

INT2NUM(SDL_GL_ALPHA_SIZE)
BUFFER_SIZE =

OpenGL attribute - minimal bits of framebufer, default is 0

INT2NUM(SDL_GL_BUFFER_SIZE)
DOUBLEBUFFER =

OpenGL attribute - whether the single buffer (0) or double buffer (1), default is double buffer

INT2NUM(SDL_GL_DOUBLEBUFFER)
DEPTH_SIZE =

OpenGL attribute - bits of depth buffer, default is 16

INT2NUM(SDL_GL_DEPTH_SIZE)
STENCIL_SIZE =

OpenGL attribute - bits of stencil buffer, default is 0

INT2NUM(SDL_GL_STENCIL_SIZE)
ACCUM_RED_SIZE =

OpenGL attribute - minimal bits of red channel in accumlation buffer, default is 0

INT2NUM(SDL_GL_ACCUM_RED_SIZE)
ACCUM_GREEN_SIZE =

OpenGL attribute - minimal bits of green channel in accumlation buffer, default is 0

INT2NUM(SDL_GL_ACCUM_GREEN_SIZE)
ACCUM_BLUE_SIZE =

OpenGL attribute - minimal bits of blue channel in accumlation buffer, default is 0

INT2NUM(SDL_GL_ACCUM_BLUE_SIZE)
ACCUM_ALPHA_SIZE =

OpenGL attribute - minimal bits of alpha channel in accumlation buffer, default is 0

INT2NUM(SDL_GL_ACCUM_ALPHA_SIZE)
STEREO =

OpenGL attribute - whether output is stereo (1) or not (0), default is 0

INT2NUM(SDL_GL_STEREO)
MULTISAMPLEBUFFERS =

OpenGL attribuite - the number of buffers used for multisampe anti-aliasing, default is 0

INT2NUM(SDL_GL_MULTISAMPLEBUFFERS)
MULTISAMPLESAMPLES =

OpenGL attribute - the number of samples used around the current pixel use for multisample anti-aliasing, default is 0

INT2NUM(SDL_GL_MULTISAMPLESAMPLES)
ACCELERATED_VISUAL =

OpenGL attribute - 1 for requiring hardware acceleration, 0 for software rendering, default is allowing either

INT2NUM(SDL_GL_ACCELERATED_VISUAL)
RETAINED_BACKING =

OpenGL attribute - not used (deprecated)

INT2NUM(SDL_GL_RETAINED_BACKING)
CONTEXT_MAJOR_VERSION =

OpenGL attribute - OpenGL context major version

INT2NUM(SDL_GL_CONTEXT_MAJOR_VERSION)
CONTEXT_MINOR_VERSION =

OpenGL attribute - OpenGL context minor version

INT2NUM(SDL_GL_CONTEXT_MINOR_VERSION)
CONTEXT_FLAGS =

OpenGL attribute - the bit combination of following constants, or 0. default is 0

These flags are mapped to some OpenGL extensions. Please see the documentation of each constant for more details.

https://wiki.libsdl.org/SDL_GLcontextFlag

INT2NUM(SDL_GL_CONTEXT_FLAGS)
CONTEXT_PROFILE_MASK =

OpenGL attribute - type of GL context, one of the following constants, defaults depends on platform

https://wiki.libsdl.org/SDL_GLprofile

INT2NUM(SDL_GL_CONTEXT_PROFILE_MASK)
SHARE_WITH_CURRENT_CONTEXT =

OpenGL attribute - OpenGL context sharing, default is 0

INT2NUM(SDL_GL_SHARE_WITH_CURRENT_CONTEXT)
FRAMEBUFFER_SRGB_CAPABLE =

OpenGL attribute - 1 for requesting sRGB capable visual, default to 0

INT2NUM(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE)
CONTEXT_EGL =

OpenGL attribute - not used (deprecated)

INT2NUM(SDL_GL_CONTEXT_EGL)
CONTEXT_DEBUG_FLAG =

This flag maps to GLX_CONTEXT_DEBUG_BIT_ARB in the GLX_ARB_create_context extension for X11 and WGL_CONTEXT_DEBUG_BIT_ARB in the WGL_ARB_create_context extension for Windows.

INT2NUM(SDL_GL_CONTEXT_DEBUG_FLAG)
CONTEXT_FORWARD_COMPATIBLE_FLAG =

This flag maps to GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB in the GLX_ARB_create_context extension for X11 and WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB in the WGL_ARB_create_context extension for Windows.

INT2NUM(SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG)
CONTEXT_ROBUST_ACCESS_FLAG =

This flag maps to GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB in the GLX_ARB_create_context_robustness extension for X11 and WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB in the WGL_ARB_create_context_robustness extension for Windows.

INT2NUM(SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG)
CONTEXT_RESET_ISOLATION_FLAG =

This flag maps to GLX_CONTEXT_RESET_ISOLATION_BIT_ARB in the GLX_ARB_robustness_isolation extension for X11 and WGL_CONTEXT_RESET_ISOLATION_BIT_ARB in the WGL_ARB_create_context_robustness extension for Windows.

INT2NUM(SDL_GL_CONTEXT_RESET_ISOLATION_FLAG)
CONTEXT_PROFILE_CORE =

OpenGL core profile - deprecated functions are disabled

INT2NUM(SDL_GL_CONTEXT_PROFILE_CORE)
CONTEXT_PROFILE_COMPATIBILITY =

OpenGL compatibility profile - deprecated functions are allowed

INT2NUM(SDL_GL_CONTEXT_PROFILE_COMPATIBILITY)
CONTEXT_PROFILE_ES =

OpenGL ES profile - only a subset of the base OpenGL functionality is available

INT2NUM(SDL_GL_CONTEXT_PROFILE_ES)

Class Method Summary collapse

Class Method Details

.extension_supported?(extension) ⇒ Boolean

Return true if the current context supports extension

Examples:

SDL2::GL.extension_supported?("GL_EXT_framebuffer_blit")

Parameters:

  • extension (String)

    the name of an extension

Returns:

  • (Boolean)


136
137
138
139
# File 'gl.c', line 136

static VALUE GL_s_extension_supported_p(VALUE self, VALUE extension)
{
    return INT2BOOL(SDL_GL_ExtensionSupported(StringValueCStr(extension)));
}

.get_attribute(attr) ⇒ Integer

Get the acutal value for an attribute from current context.

Parameters:

  • attr (Integer)

    the OpenGL attribute to query

Returns:

  • (Integer)


180
181
182
183
184
185
# File 'gl.c', line 180

static VALUE GL_s_get_attribute(VALUE self, VALUE attr)
{
    int value;
    HANDLE_ERROR(SDL_GL_GetAttribute(NUM2INT(attr), &value));
    return INT2NUM(value);
}

.set_attribute(attr, value) ⇒ value

Set an OpenGL window attribute before window creation.

Parameters:

  • attr (Integer)

    the OpenGL attribute to set

  • value (Integer)

    the desired value for the attribute

Returns:

  • (value)


195
196
197
198
199
# File 'gl.c', line 195

static VALUE GL_s_set_attribute(VALUE self, VALUE attr, VALUE value)
{
    HANDLE_ERROR(SDL_GL_SetAttribute(NUM2INT(attr), NUM2INT(value)));
    return value;
}

.swap_intervalInteger

Get the state of swap interval of the current context.

Returns:

  • (Integer)

    return 0 when vsync is not used, return 1 when vsync is used, and return -1 when vsync is not supported by the system (OS).



150
151
152
153
# File 'gl.c', line 150

static VALUE GL_s_swap_interval(VALUE self)
{
    return INT2NUM(SDL_GL_GetSwapInterval());
}

.swap_interval=(interval) ⇒ nil

Set the state of swap interval of the current context.

Parameters:

  • interval (Integer)

    0 if you don’t want to wait for vsync, 1 if you want to wait for vsync, -1 if you want to use late swap tearing

Returns:

  • (nil)


167
168
169
170
171
# File 'gl.c', line 167

static VALUE GL_s_set_swap_interval(VALUE self, VALUE interval)
{
    HANDLE_ERROR(SDL_GL_SetSwapInterval(NUM2INT(interval)));
    return Qnil;
}