sfml3.rb

Class: SFML::Context

Inherits:
Object
  • Object
show all
Defined in:
ext/window/context.c,
ext/window/context.c

Overview

A raw OpenGL context, usable off-screen or on a thread without a Window.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#new ⇒ Context

Creates and activates a new OpenGL context on the current thread.

Raises:

  • (RuntimeError) —

    if context creation fails



44
45
46
# File 'ext/window/context.c', line 44

static VALUE Context_initialize(VALUE self) {
    return self;
}

Class Method Details

.active_context_id ⇒ Integer

Returns the unique identifier of the currently active context on the calling thread, or 0 if none is active.

Returns:

  • (Integer)

Returns:

  • (Integer) —

    the unique identifier of the currently active context on the calling thread, or 0 if none is active



104
105
106
# File 'ext/window/context.c', line 104

static VALUE Context_active_context_id(VALUE klass) {
    return ULL2NUM(sfContext_getActiveContextId());
}

.extension_available?(name) ⇒ Boolean

Returns true if the OpenGL extension name is available in the currently active context.

Returns:

  • (Boolean)

Returns:

  • (Boolean) —

    whether the OpenGL extension name is available in the currently active context



57
58
59
# File 'ext/window/context.c', line 57

static VALUE Context_extension_available(VALUE klass, VALUE rb_name) {
    return BOOL2RB(sfContext_isExtensionAvailable(StringValueCStr(rb_name)));
}

.function(name) ⇒ Integer

Returns the address of the OpenGL function name as an Integer, or 0 when it is not available.

Returns:

  • (Integer)

Returns:

  • (Integer) —

    the address of the OpenGL function name, as a raw pointer value, or 0 if it is not available



82
83
84
# File 'ext/window/context.c', line 82

static VALUE Context_get_function(VALUE klass, VALUE rb_name) {
    return ULL2NUM((unsigned long long)(uintptr_t)sfContext_getFunction(StringValueCStr(rb_name)));
}

Instance Method Details

#active=(value) ⇒ Boolean

Activates or deactivates this context as the current one on the calling thread.

Returns:

  • (Boolean)

Returns:

  • (Boolean) —

    whether activation succeeded



69
70
71
# File 'ext/window/context.c', line 69

static VALUE Context_set_active(VALUE self, VALUE rb_active) {
    return BOOL2RB(sfContext_setActive(Get_Context_Struct(self), RTEST(rb_active)));
}

#settings ⇒ ContextSettings

Returns the settings this context was created with.

Returns:

Returns:



92
93
94
# File 'ext/window/context.c', line 92

static VALUE Context_get_settings(VALUE self) {
    return context_settings_to_rb(sfContext_getSettings(Get_Context_Struct(self)));
}