Class: SDL2::GL::Context
- Inherits:
-
Object
- Object
- SDL2::GL::Context
- Defined in:
- gl.c,
gl.c
Overview
This class represents an OpenGL context.
You must create a new OpenGL context before using OpenGL functions.
Class Method Summary collapse
-
.create(window) ⇒ SDL2::GL::Context
Create an OpenGL context for use with an OpenGL window, and make it current.
-
.current ⇒ SDL2::GL::Context?
Get the current OpenGL context.
Instance Method Summary collapse
-
#destroy ⇒ nil
Delete the OpenGL context.
-
#destroy? ⇒ Boolean
Return true if the context is destroyed.
-
#make_current(window) ⇒ nil
Set the OpenGL context for rendering into an OpenGL window.
Class Method Details
.create(window) ⇒ SDL2::GL::Context
76 77 78 79 80 81 82 83 |
# File 'gl.c', line 76
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));
}
|
.current ⇒ SDL2::GL::Context?
Get the current OpenGL context.
123 124 125 126 |
# File 'gl.c', line 123
static VALUE GLContext_s_current(VALUE self)
{
return current_context;
}
|
Instance Method Details
#destroy ⇒ nil
Delete the OpenGL context.
92 93 94 95 96 97 98 99 |
# File 'gl.c', line 92
static VALUE GLContext_destroy(VALUE self)
{
GLContext* c = Get_GLContext(self);
if (c->context)
SDL_GL_DeleteContext(c->context);
c->context = NULL;
return Qnil;
}
|
#destroy? ⇒ Boolean
Return true if the context is destroyed.
#make_current(window) ⇒ nil
108 109 110 111 112 113 |
# File 'gl.c', line 108
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;
}
|