Class: SDL2::GL::Context

Inherits:
Object
  • Object
show all
Defined in:
gl.c

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (SDL2::GL::Context) create(window)

Create an OpenGL context for use with an OpenGL window, and make it current.

Parameters:

  • window (SDL2::Window)

    the window associate with a new context

Returns:

See Also:

  • #delete


40
41
42
43
44
45
46
47
# File 'gl.c', line 40

static VALUE GLContext_s_create(VALUE self, VALUE window)
{
    SDL_GLContext context = SDL_GL_CreateContext(Get_SDL_Window(window));
    if (!context)
        SDL_ERROR();

    return (current_context = GLContext_new(context));
}

+ (SDL2::GL::Context?) current

Get the current OpenGL context.

Returns:

  • (SDL2::GL::Context)

    the curren context

  • (nil)

    if there is no current context

See Also:



87
88
89
90
# File 'gl.c', line 87

static VALUE GLContext_s_current(VALUE self)
{
    return current_context;
}

Instance Method Details

- (nil) destroy

Delete the OpenGL context.

Returns:

  • (nil)

See Also:



56
57
58
59
60
61
62
63
# File 'gl.c', line 56

static VALUE GLContext_destroy(VALUE self)
{
    GLContext* c = Get_GLContext(self);
    if (c->context)
        SDL_GL_DeleteContext(c->context);
    c->context = NULL;
    return Qnil;
}

- (Boolean) destroy?

Returns:

  • (Boolean)

- (nil) make_current(window)

Set the OpenGL context for rendering into an OpenGL window.

Parameters:

  • window (SDL2::Window)

    the window to associate with the context

Returns:

  • (nil)


72
73
74
75
76
77
# File 'gl.c', line 72

static VALUE GLContext_make_current(VALUE self, VALUE window)
{
    HANDLE_ERROR(SDL_GL_MakeCurrent(Get_SDL_Window(window), Get_SDL_GLContext(self)));
    current_context = self;
    return Qnil;
}