Module: SDL2::GL

Defined in:
gl.c

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

INT2NUM(SDL_GL_CONTEXT_FLAGS)
CONTEXT_PROFILE_MASK =

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

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 =
INT2NUM(SDL_GL_CONTEXT_DEBUG_FLAG)
CONTEXT_FORWARD_COMPATIBLE_FLAG =
INT2NUM(SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG)
CONTEXT_ROBUST_ACCESS_FLAG =
INT2NUM(SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG)
CONTEXT_RESET_ISOLATION_FLAG =
INT2NUM(SDL_GL_CONTEXT_RESET_ISOLATION_FLAG)
CONTEXT_PROFILE_CORE =
INT2NUM(SDL_GL_CONTEXT_PROFILE_CORE)
CONTEXT_PROFILE_COMPATIBILITY =
INT2NUM(SDL_GL_CONTEXT_PROFILE_COMPATIBILITY)
CONTEXT_PROFILE_ES =
INT2NUM(SDL_GL_CONTEXT_PROFILE_ES)

Class Method Summary (collapse)

Class Method Details

+ (Boolean) extension_supported?(extension)

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)


100
101
102
103
# File 'gl.c', line 100

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

+ (Integer) get_attribute(attr)

Get the acutal value for an attribute from current context.

Parameters:

  • attr (Integer)

    the OpenGL attribute to query

Returns:

  • (Integer)


144
145
146
147
148
149
# File 'gl.c', line 144

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

+ (value) set_attribute(attr, 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)


159
160
161
162
163
# File 'gl.c', line 159

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

+ (Integer) swap_interval

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).



114
115
116
117
# File 'gl.c', line 114

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

+ (nil) swap_interval=(interval)

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)


131
132
133
134
135
# File 'gl.c', line 131

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