class SF::Context
- SF::Context
- Reference
- Object
Overview
Class holding a valid drawing context
If you need to make OpenGL calls without having an active window (like in a thread), you can use an instance of this class to get a valid context.
Having a valid context is necessary for every OpenGL call.
Note that a context is only active in its current thread, if you create a new thread it will have no valid context by default.
To use a SF::Context
instance, just construct it and let it
live as long as you need a valid context. No explicit activation
is needed, all it has to do is to exist. Its destructor
will take care of deactivating and freeing all the attached
resources.
Usage example:
void threadFunction(void*)
SF::Context context
# from now on, you have a valid context
# you can make OpenGL calls
glClear(GL_DEPTH_BUFFER_BIT)
end
# the context is automatically deactivated and destroyed
# by the SF::Context destructor
Included Modules
Defined in:
window/obj.crConstructors
-
.new(settings : ContextSettings, width : Int, height : Int)
Construct a in-memory context
-
.new
Default constructor
Class Method Summary
-
.active_context_id : UInt64
Get the currently active context's ID
-
.extension_available?(name : String) : Bool
Check whether a given OpenGL extension is available
Instance Method Summary
-
#active=(active : Bool) : Bool
Activate or deactivate explicitly the context
-
#finalize
Destructor
-
#settings : ContextSettings
Get the settings of the context
Constructor Detail
Construct a in-memory context
This constructor is for internal use, you don't need to bother with it.
- settings - Creation parameters
- width - Back buffer width
- height - Back buffer height
Class Method Detail
Get the currently active context's ID
The context ID is used to identify contexts when managing unshareable OpenGL resources.
Returns: The active context's ID or 0 if no context is currently active
Check whether a given OpenGL extension is available
- name - Name of the extension to check for
Returns: True if available, false if unavailable
Instance Method Detail
Activate or deactivate explicitly the context
- active - True to activate, false to deactivate
Returns: True on success, false on failure
Get the settings of the context
Note that these settings may be different than the ones passed to the constructor; they are indeed adjusted if the original settings are not directly supported by the system.
Returns: Structure containing the settings