An OpenGL context corresponds to the state of a running OpenGL screen. More...
#include <OSDLOpenGL.h>
Public Types | |
enum | ProjectionMode { Orthographic, Perspective } |
Describes a projection mode:
| |
enum | ShadingModel { Flat, Smooth } |
Describes a shading model. More... | |
enum | CulledFacet { Front, Back, FrontAndBack } |
Describes which facets should be culled, i.e. More... | |
enum | FrontOrientation { Clockwise, CounterClockwise } |
Determines how front-facing polygons are defined, depending on their winding. More... | |
Public Member Functions | |
OpenGLContext (OpenGL::Flavour flavour, BitsPerPixel plannedBpp, Length viewportWidth, Length viewportHeight) | |
Creates a new blank OpenGL context, according to the specified flavour and color depth. | |
virtual | ~OpenGLContext () throw () |
Virtual destructor. | |
virtual void | selectFlavour (OpenGL::Flavour flavour) |
If OpenGL is to be used, allows to select a flavour, which provides convenient presets. | |
virtual void | set2DFlavour () |
Sets the OpenGL 2D flavour, i.e. | |
virtual void | set3DFlavour () |
Sets the OpenGL 3D flavour, i.e. | |
virtual void | blank () |
Blanks the current settings in the actual OpenGL state machine. | |
virtual void | reload () |
Requests the OpenGL context to reload the current settings in the actual OpenGL state machine. | |
virtual void | setBlendingFunction (GLEnumeration sourceFactor, GLEnumeration destinationFactor) |
Sets the OpenGL blending function. | |
virtual void | setShadingModel (ShadingModel newShadingModel=Smooth) |
Sets the shading technique to be used. | |
virtual void | setCullingStatus (bool newStatus) |
Sets the cullings status, i.e. | |
virtual void | setCulling (CulledFacet culledFacet=Back, FrontOrientation frontOrientation=CounterClockwise, bool autoEnable=true) |
Sets the culling settings, and enables it if requested. | |
virtual void | setDepthBufferStatus (bool newStatus) |
Enables or disables the use of the depth buffer. | |
virtual void | setViewPort (Length width, Length height, const TwoDimensional::Point2D &lowerLeftCorner=TwoDimensional::Point2D::Origin) |
Sets the OpenGL viewport, i.e.determines the transformation of x and y from normalized device coordinates to window coordinates. | |
virtual void | setOrthographicProjection (GLLength width, GLCoordinate near=-DefaultNearClippingPlaneFor3D, GLCoordinate far=-DefaultFarClippingPlaneFor3D) |
Sets an orthographic projection, so that the viewing volume is a box, whose sides are parallel to the main axes. | |
virtual void | setOrthographicProjectionFor2D (GLLength width, GLLength height) |
Sets an orthographic projection for 2D rendering, chosen to match the current OpenGL viewport size. | |
virtual void | setClearColor (const Video::Pixels::ColorDefinition &color) |
Sets the current clear color to the specified one. | |
virtual void | clearViewport () |
Clears the viewport with the current clear color. | |
virtual void | clearDepthBuffer () |
Clears the depth buffer within the viewport. | |
virtual void | pushAttribute (GLBitField attributeField) |
Pushes specified attribute field onto OpenGL attribute stack. | |
virtual void | popAttribute () |
Pops latest pushed attribute field from OpenGL attribute stack. | |
virtual const std::string | toString (Ceylan::VerbosityLevels level=Ceylan::high) const |
Uploads specified surface as an OpenGL texture in OpenGL context. | |
Static Public Member Functions | |
static void | SetUpForFlavour (OpenGL::Flavour flavour, bool safest=false) |
Prepares the OpenGL attributes appropriate for the flavour that will be used in a VideoModule::setMode call. | |
static void | EnableFeature (OpenGL::Feature feature) |
Enables specified feature in the OpenGL state machine. | |
static void | DisableFeature (OpenGL::Feature feature) |
Disables specified feature in the OpenGL state machine. | |
static bool | GetDoubleBufferStatus () |
Returns the current OpenGL double buffering status. | |
static void | SetDoubleBufferStatus (bool newStatus) |
Sets the OpenGL double buffering status (enabled or disabled). | |
static Ceylan::Uint8 | GetDepthBufferSize () |
Returns the size, in bits, of the OpenGL depth buffer. | |
static void | SetDepthBufferSize (Ceylan::Uint8 bitsNumber=16) |
Sets the size, in bits, of the OpenGL depth buffer. | |
static Ceylan::Uint8 | GetFullScreenAntialiasingStatus () |
Returns whether the OpenGL fullscreen antialiasing (FSAA) is available. | |
static void | SetFullScreenAntialiasingStatus (bool newStatus, Ceylan::Uint8 samplesPerPixelNumber=4) |
Sets the OpenGL fullscreen antialiasing (FSAA) status (enabled or disabled). | |
static bool | GetHardwareAccelerationStatus () |
Returns whether the OpenGL hardware-acceleration is available. | |
static void | SetHardwareAccelerationStatus (bool newStatus) |
Sets the OpenGL hardware-acceleration status (enabled or disabled). | |
static bool | GetVerticalBlankSynchronizationStatus () |
Returns whether the OpenGL synchronization with vertical blank retrace (VSYNC) is activated. | |
static void | SetVerticalBlankSynchronizationStatus (bool newStatus) |
Sets the OpenGL synchronization with vertical blank retrace (VSYNC). | |
static bool | TrySettingVerticalBlankSynchronizationStatus (bool newStatus) |
Tries to set the OpenGL synchronization with vertical blank retrace (VSYNC). | |
static OSDL::Video::BitsPerPixel | GetColorDepth (OSDL::Video::BitsPerPixel &redSize, OSDL::Video::BitsPerPixel &greenSize, OSDL::Video::BitsPerPixel &blueSize, OSDL::Video::BitsPerPixel &alphaSize) |
Gets the OpenGL color depth for each color component. | |
static void | SetColorDepth (OSDL::Video::BitsPerPixel plannedBpp) |
Sets the OpenGL color depth. | |
static void | SetColorDepth (OSDL::Video::BitsPerPixel redSize, OSDL::Video::BitsPerPixel greenSize, OSDL::Video::BitsPerPixel blueSize) |
Sets the OpenGL color depth. | |
static std::string | InterpretFeatureAvailability () |
Returns a textual description of the availability of the OpenGL features. | |
static std::string | ToString (OpenGL::Flavour flavour) |
Returns an user-friendly description of the specified OpenGL flavour. | |
Static Public Attributes | |
static const bool | ContextCanBeLost |
Tells whether the OpenGL context can be lost (and therefore must be reloaded) under certain unexpected circumstances (ex: window resize, going to fullscreen, switching to another application, etc. | |
static const bool | ContextIsLostOnResize |
Tells whether the OpenGL context is lost (and therefore must be reloaded) on resize. | |
static const bool | ContextIsLostOnApplicationSwitch |
Tells whether the OpenGL context is lost (and therefore must be reloaded) when switching application. | |
static const bool | ContextIsLostOnColorDepthChange |
Tells whether the OpenGL context is lost (and therefore must be reloaded) when changing the color depth. | |
static const GLLength | DefaultOrthographicWidth = 1000.0f |
Default width of the orthographic box is 1000 (1000.0f). | |
static const GLCoordinate | DefaultNearClippingPlaneFor2D = -1.0f |
Coordinate, along the -z axis, of the default near clipping plane in 2D is -1 (-1.0f). | |
static const GLCoordinate | DefaultFarClippingPlaneFor2D = 1.0f |
Coordinate, along the -z axis, of the default far clipping plane in 2D is 1 (1.0f). | |
static const GLCoordinate | DefaultNearClippingPlaneFor3D = 1.0f |
Coordinate, along the -z axis, of the default near clipping plane in 3D is 1 (1.0f). | |
static const GLCoordinate | DefaultFarClippingPlaneFor3D = 100000.0f |
Coordinate, along the -z axis, of the default far clipping plane in 3D is 100000 (100000.0f). | |
Protected Member Functions | |
virtual void | updateProjection () |
Updates the current projection so that its aspect ratio matches the one of the viewport. | |
Static Protected Member Functions | |
static bool | HasGLAttribute (GLAttribute attribute) |
Returns whether the specified OpenGL attribute is supported. | |
static int | GetGLAttribute (GLAttribute attribute) |
Gets the value of specified OpenGL attribute. | |
static void | SetGLAttribute (GLAttribute attribute, int value) |
Sets the specified OpenGL attribute. | |
static bool | TrySettingGLAttribute (GLAttribute attribute, int value) |
Tries to set the specified OpenGL attribute. | |
static std::string | GLAttributeToString (GLAttribute attribute) |
Returns a string describing the specified OpenGL attribute. | |
Protected Attributes | |
OpenGL::Flavour | _flavour |
Stores the current OpenGL flavour. | |
OSDL::Video::BitsPerPixel | _redSize |
Size in bits of the red component. | |
OSDL::Video::BitsPerPixel | _greenSize |
Size in bits of the green component. | |
OSDL::Video::BitsPerPixel | _blueSize |
Size in bits of the blue component. | |
OSDL::Video::BitsPerPixel | _alphaSize |
Size in bits of the alpha component. | |
Length | _viewportWidth |
Width of the viewport, useful to ensure aspect ratio is well managed. | |
Length | _viewportHeight |
Height of the viewport, useful to ensure aspect ratio is well managed. | |
ProjectionMode | _projectionMode |
Stores the current projection mode. | |
GLLength | _projectionWidth |
Width of the projection volume, so that projection can be automatically updated when the viewport area changes. | |
GLCoordinate | _nearClippingPlane |
The current z axis coordinate of the near clipping plane. | |
GLCoordinate | _farClippingPlane |
The current z axis coordinate of the far clipping plane. | |
Pixels::ColorDefinition | _clearColor |
The current clear color for the viewport. | |
Private Member Functions | |
OpenGLContext (const OpenGLContext &source) | |
Copy constructor made private to ensure that it will be never called. | |
OpenGLContext & | operator= (const OpenGLContext &source) |
Assignment operator made private to ensure that it will be never called. |
An OpenGL context corresponds to the state of a running OpenGL screen.
It can be managed on a per-application basis, or a per-window basis.
OpenGL context objects have to store settings, so that they can be reloaded when required, see OpenGL::Reload flavour.
Definition at line 428 of file OSDLOpenGL.h.
Describes which facets should be culled, i.e.
specifies whether front-facing or back-facing facets are culled, when facet culling is enabled.
Facets include triangles, quadrilaterals, polygons, and rectangles.
Front and back are defined according to the normal vector of a facet, which can be determined according to the dot product of ordered listed vertices.
Definition at line 491 of file OSDLOpenGL.h.
Determines how front-facing polygons are defined, depending on their winding.
The projection of a polygon to window coordinates is said to have clockwise winding if an imaginary object following the path from its first vertex, its second vertex, and so on, to its last vertex, and finally back to its first vertex, moves in a clockwise direction about the interior of the polygon.
On the contrary, the polygon's winding is said to be counterclockwise if the imaginary object following the same path moves in a counterclockwise direction about the interior of the polygon.
Definition at line 513 of file OSDLOpenGL.h.
Describes a projection mode:
Definition at line 445 of file OSDLOpenGL.h.
Describes a shading model.
Flat shading selects the computed color of just one vertex and assigns it to all the pixel fragments generated by rasterizing a single primitive.
Smooth shading, the default, causes the computed colors of vertices to be interpolated as the primitive is rasterized, typically assigning different colors to each resulting pixel fragment. Also known as Gouraud shading.
In either case, the computed color of a vertex is the result of lighting, if lighting is enabled, or it is the current color at the time the vertex was specified, if lighting is disabled.
Definition at line 468 of file OSDLOpenGL.h.
OpenGLContext::OpenGLContext | ( | OpenGL::Flavour | flavour, | |
BitsPerPixel | plannedBpp, | |||
Length | viewportWidth, | |||
Length | viewportHeight | |||
) |
Creates a new blank OpenGL context, according to the specified flavour and color depth.
The default projection mode is orthographic.
flavour | the OpenGL flavour to use. | |
plannedBpp | the color depth to use, in bits per pixel. | |
viewportWidth | the width of the viewport, in pixels. | |
viewportHeight | the height of the viewport, in pixels. |
OpenGLException | if the OpenGL state machine reports an error. |
Definition at line 190 of file OSDLOpenGL.cc.
References OSDL::Video::Pixels::Black, clearViewport(), selectFlavour(), and setClearColor().
OpenGLContext::~OpenGLContext | ( | ) | throw () [virtual] |
Virtual destructor.
Definition at line 228 of file OSDLOpenGL.cc.
OSDL::Video::OpenGL::OpenGLContext::OpenGLContext | ( | const OpenGLContext & | source | ) | [private] |
Copy constructor made private to ensure that it will be never called.
The compiler should complain whenever this undefined constructor is called, implicitly or not.
void OpenGLContext::blank | ( | ) | [virtual] |
Blanks the current settings in the actual OpenGL state machine.
OpenGLException | if the operation failed. |
Definition at line 436 of file OSDLOpenGL.cc.
void OpenGLContext::clearDepthBuffer | ( | ) | [virtual] |
Clears the depth buffer within the viewport.
OpenGLException | if this method is called between the execution of glBegin and the corresponding execution of glEnd. |
Definition at line 1029 of file OSDLOpenGL.cc.
Referenced by setDepthBufferStatus().
void OpenGLContext::clearViewport | ( | ) | [virtual] |
Clears the viewport with the current clear color.
OpenGLException | if this method is called between the execution of glBegin and the corresponding execution of glEnd. |
Definition at line 982 of file OSDLOpenGL.cc.
Referenced by OpenGLContext(), and reload().
void OpenGLContext::DisableFeature | ( | OpenGL::Feature | feature | ) | [static] |
Disables specified feature in the OpenGL state machine.
feature | the feature to disable. |
OpenGLException | if the operation failed. |
Definition at line 1357 of file OSDLOpenGL.cc.
References OSDL::Video::OpenGL::Alphablending, OSDL::Video::OpenGL::CullPolygons, OSDL::Video::OpenGL::DepthTests, OSDL::Video::OpenGL::Light_1, OSDL::Video::OpenGL::Light_2, OSDL::Video::OpenGL::Light_3, OSDL::Video::OpenGL::Light_4, OSDL::Video::OpenGL::Light_5, OSDL::Video::OpenGL::Light_6, OSDL::Video::OpenGL::Light_7, OSDL::Video::OpenGL::Light_8, OSDL::Video::OpenGL::Lighting, OSDL::Video::Pixels::toString(), and OSDL::Video::OpenGL::TwoDimensionalTexturing.
Referenced by set2DFlavour(), setCullingStatus(), and setDepthBufferStatus().
void OpenGLContext::EnableFeature | ( | OpenGL::Feature | feature | ) | [static] |
Enables specified feature in the OpenGL state machine.
feature | the feature to enable. |
OpenGLException | if the operation failed. |
Definition at line 1281 of file OSDLOpenGL.cc.
References OSDL::Video::OpenGL::Alphablending, OSDL::Video::OpenGL::CullPolygons, OSDL::Video::OpenGL::DepthTests, OSDL::Video::OpenGL::Light_1, OSDL::Video::OpenGL::Light_2, OSDL::Video::OpenGL::Light_3, OSDL::Video::OpenGL::Light_4, OSDL::Video::OpenGL::Light_5, OSDL::Video::OpenGL::Light_6, OSDL::Video::OpenGL::Light_7, OSDL::Video::OpenGL::Light_8, OSDL::Video::OpenGL::Lighting, OSDL::Video::Pixels::toString(), and OSDL::Video::OpenGL::TwoDimensionalTexturing.
Referenced by set2DFlavour(), set3DFlavour(), setCullingStatus(), setDepthBufferStatus(), and OSDL::Video::OpenGL::GLTexture::SetTextureFlavour().
Ceylan::Uint8 OpenGLContext::GetColorDepth | ( | OSDL::Video::BitsPerPixel & | redSize, | |
OSDL::Video::BitsPerPixel & | greenSize, | |||
OSDL::Video::BitsPerPixel & | blueSize, | |||
OSDL::Video::BitsPerPixel & | alphaSize | |||
) | [static] |
Gets the OpenGL color depth for each color component.
redSize | the variable where the size in bits of the red component will be written. | |
greenSize | the variable where the size in bits of the green component will be written. | |
blueSize | the variable where the size in bits of the blue component will be written. | |
alphaSize | the variable where the size in bits of the alpha component will be written. |
OpenGLException | if the operation failed. |
Definition at line 1720 of file OSDLOpenGL.cc.
References GetGLAttribute().
Referenced by InterpretFeatureAvailability(), and toString().
Ceylan::Uint8 OpenGLContext::GetDepthBufferSize | ( | ) | [static] |
Returns the size, in bits, of the OpenGL depth buffer.
OpenGLException | should an error occur. |
Definition at line 1474 of file OSDLOpenGL.cc.
References GetGLAttribute().
Referenced by InterpretFeatureAvailability().
bool OpenGLContext::GetDoubleBufferStatus | ( | ) | [static] |
Returns the current OpenGL double buffering status.
OpenGLException | should an error occur. |
Definition at line 1433 of file OSDLOpenGL.cc.
References GetGLAttribute().
Referenced by InterpretFeatureAvailability().
Ceylan::Uint8 OpenGLContext::GetFullScreenAntialiasingStatus | ( | ) | [static] |
Returns whether the OpenGL fullscreen antialiasing (FSAA) is available.
OpenGLException | should an error occur. |
Definition at line 1515 of file OSDLOpenGL.cc.
References GetGLAttribute().
Referenced by InterpretFeatureAvailability().
int OpenGLContext::GetGLAttribute | ( | GLAttribute | attribute | ) | [static, protected] |
Gets the value of specified OpenGL attribute.
attribute | the attribute whose value is wanted. |
OpenGLException | if the operation failed, including if on this platform the specified attribute is not supported. |
Definition at line 2130 of file OSDLOpenGL.cc.
References OSDL::Utils::getBackendLastError(), and GLAttributeToString().
Referenced by GetColorDepth(), GetDepthBufferSize(), GetDoubleBufferStatus(), GetFullScreenAntialiasingStatus(), GetHardwareAccelerationStatus(), GetVerticalBlankSynchronizationStatus(), and TrySettingGLAttribute().
bool OpenGLContext::GetHardwareAccelerationStatus | ( | ) | [static] |
Returns whether the OpenGL hardware-acceleration is available.
OpenGLException | should an error occur. |
Definition at line 1587 of file OSDLOpenGL.cc.
References GetGLAttribute().
Referenced by InterpretFeatureAvailability().
bool OpenGLContext::GetVerticalBlankSynchronizationStatus | ( | ) | [static] |
Returns whether the OpenGL synchronization with vertical blank retrace (VSYNC) is activated.
OpenGLException | should an error occur. |
Definition at line 1636 of file OSDLOpenGL.cc.
References GetGLAttribute().
Referenced by InterpretFeatureAvailability().
std::string OpenGLContext::GLAttributeToString | ( | GLAttribute | attribute | ) | [static, protected] |
Returns a string describing the specified OpenGL attribute.
attribute | the attribute to describe. |
OpenGLException | if the operation failed. |
Definition at line 2297 of file OSDLOpenGL.cc.
Referenced by GetGLAttribute(), SetGLAttribute(), and TrySettingGLAttribute().
bool OpenGLContext::HasGLAttribute | ( | GLAttribute | attribute | ) | [static, protected] |
Returns whether the specified OpenGL attribute is supported.
If not (i.e. if false is returned), then calling the GetGLAttribute function would throw an exception.
attribute | the attribute whose support is to be acknowledged. |
Definition at line 2095 of file OSDLOpenGL.cc.
Referenced by InterpretFeatureAvailability().
std::string OpenGLContext::InterpretFeatureAvailability | ( | ) | [static] |
Returns a textual description of the availability of the OpenGL features.
OpenGLException | if the operation failed. |
Definition at line 1877 of file OSDLOpenGL.cc.
References GetColorDepth(), GetDepthBufferSize(), GetDoubleBufferStatus(), GetFullScreenAntialiasingStatus(), GetHardwareAccelerationStatus(), GetVerticalBlankSynchronizationStatus(), and HasGLAttribute().
OpenGLContext& OSDL::Video::OpenGL::OpenGLContext::operator= | ( | const OpenGLContext & | source | ) | [private] |
Assignment operator made private to ensure that it will be never called.
The compiler should complain whenever this undefined operator is called, implicitly or not.
void OpenGLContext::popAttribute | ( | ) | [virtual] |
Pops latest pushed attribute field from OpenGL attribute stack.
OpenGLException | if the operation failed. |
Definition at line 1123 of file OSDLOpenGL.cc.
void OpenGLContext::pushAttribute | ( | GLBitField | attributeField | ) | [virtual] |
Pushes specified attribute field onto OpenGL attribute stack.
OpenGLException | if the operation failed. |
Definition at line 1076 of file OSDLOpenGL.cc.
void OpenGLContext::reload | ( | ) | [virtual] |
Requests the OpenGL context to reload the current settings in the actual OpenGL state machine.
It is notably useful for platforms that loose their OpenGL context under various circumstances, including resizing.
OpenGLException | if the operation failed. |
Definition at line 445 of file OSDLOpenGL.cc.
References _clearColor, clearViewport(), setClearColor(), and updateProjection().
Referenced by selectFlavour(), and OSDL::Video::VideoModule::setMode().
void OpenGLContext::selectFlavour | ( | OpenGL::Flavour | flavour | ) | [virtual] |
If OpenGL is to be used, allows to select a flavour, which provides convenient presets.
flavour | the selected flavour for OpenGL. |
OpenGLException | if the OpenGL state machine reports an error. |
Definition at line 238 of file OSDLOpenGL.cc.
References _flavour, _viewportHeight, _viewportWidth, OSDL::Video::OpenGL::None, OSDL::Video::OpenGL::OpenGLFor2D, OSDL::Video::OpenGL::OpenGLFor3D, reload(), OSDL::Video::OpenGL::Reload, set2DFlavour(), set3DFlavour(), and setViewPort().
Referenced by OpenGLContext(), and OSDL::Video::VideoModule::setMode().
void OpenGLContext::set2DFlavour | ( | ) | [virtual] |
Sets the OpenGL 2D flavour, i.e.
the settings deemed the most appropriate for 2D rendering.
Once called, all primitives can be rendered at integer positions.
OpenGLException | if the operation failed. |
Definition at line 297 of file OSDLOpenGL.cc.
References _flavour, OSDL::Video::OpenGL::Alphablending, OSDL::Video::OpenGL::CullPolygons, DisableFeature(), EnableFeature(), Flat, OSDL::Video::OpenGL::GLTexture::For2D, OSDL::Video::OpenGL::OpenGLFor2D, setBlendingFunction(), setDepthBufferStatus(), setShadingModel(), and OSDL::Video::OpenGL::GLTexture::SetTextureFlavour().
Referenced by selectFlavour().
void OpenGLContext::set3DFlavour | ( | ) | [virtual] |
Sets the OpenGL 3D flavour, i.e.
the settings deemed the most appropriate for 3D rendering.
OpenGLException | if the operation failed. |
Definition at line 375 of file OSDLOpenGL.cc.
References _flavour, _viewportHeight, _viewportWidth, OSDL::Video::OpenGL::Alphablending, OSDL::Video::OpenGL::DepthTests, EnableFeature(), OSDL::Video::OpenGL::GLTexture::For3D, OSDL::Video::OpenGL::OpenGLFor3D, setBlendingFunction(), setShadingModel(), OSDL::Video::OpenGL::GLTexture::SetTextureFlavour(), and Smooth.
Referenced by selectFlavour().
void OpenGLContext::setBlendingFunction | ( | GLEnumeration | sourceFactor, | |
GLEnumeration | destinationFactor | |||
) | [virtual] |
Sets the OpenGL blending function.
sourceFactor | specifies which of the nine methods is used to scale the source color components. | |
destinationFactor | specifies which of the eight methods is used to scale the destination color components. |
OpenGLException | should an error occur. |
Definition at line 459 of file OSDLOpenGL.cc.
Referenced by set2DFlavour(), and set3DFlavour().
void OpenGLContext::setClearColor | ( | const Video::Pixels::ColorDefinition & | color | ) | [virtual] |
Sets the current clear color to the specified one.
OpenGLException | if the operation failed. |
Definition at line 936 of file OSDLOpenGL.cc.
References _clearColor.
Referenced by OpenGLContext(), and reload().
void OpenGLContext::SetColorDepth | ( | OSDL::Video::BitsPerPixel | redSize, | |
OSDL::Video::BitsPerPixel | greenSize, | |||
OSDL::Video::BitsPerPixel | blueSize | |||
) | [static] |
Sets the OpenGL color depth.
redSize | the size of the red component, in bits per pixel. | |
greenSize | the size of the green component, in bits per pixel. | |
blueSize | the size of the blue component, in bits per pixel. |
OpenGLException | if the operation failed. |
Definition at line 1838 of file OSDLOpenGL.cc.
References SetGLAttribute().
void OpenGLContext::SetColorDepth | ( | OSDL::Video::BitsPerPixel | plannedBpp | ) | [static] |
Sets the OpenGL color depth.
plannedBpp | the planned color depth, in bits per pixel. |
OpenGLException | if the operation failed. |
Definition at line 1766 of file OSDLOpenGL.cc.
References SetGLAttribute().
void OpenGLContext::setCulling | ( | CulledFacet | culledFacet = Back , |
|
FrontOrientation | frontOrientation = CounterClockwise , |
|||
bool | autoEnable = true | |||
) | [virtual] |
Sets the culling settings, and enables it if requested.
culledFacet | tells whether front, or back, or front and back facets should be culled. | |
frontOrientation | defines what are front facing polygons, depending on their winding. | |
autoEnable | will specifically enable the use of culling iff true (it will not be only set). |
OpenGLException | should an error occur. |
Definition at line 609 of file OSDLOpenGL.cc.
References Back, Clockwise, CounterClockwise, Front, FrontAndBack, and setCullingStatus().
void OpenGLContext::setCullingStatus | ( | bool | newStatus | ) | [virtual] |
Sets the cullings status, i.e.
enable or disable culling.
newStatus | culling is activated iff true. |
OpenGLException | should an error occur. |
Definition at line 579 of file OSDLOpenGL.cc.
References OSDL::Video::OpenGL::CullPolygons, DisableFeature(), and EnableFeature().
Referenced by setCulling().
void OpenGLContext::SetDepthBufferSize | ( | Ceylan::Uint8 | bitsNumber = 16 |
) | [static] |
Sets the size, in bits, of the OpenGL depth buffer.
bitsNumber | the new depth buffer size. |
OpenGLException | should an error occur. |
Definition at line 1483 of file OSDLOpenGL.cc.
References SetGLAttribute().
Referenced by SetUpForFlavour().
void OpenGLContext::setDepthBufferStatus | ( | bool | newStatus | ) | [virtual] |
Enables or disables the use of the depth buffer.
newStatus | if true, will enable the depth buffer, if false will disable it. |
OpenGLException | should an error occur. |
Definition at line 718 of file OSDLOpenGL.cc.
References clearDepthBuffer(), OSDL::Video::OpenGL::DepthTests, DisableFeature(), and EnableFeature().
Referenced by set2DFlavour().
void OpenGLContext::SetDoubleBufferStatus | ( | bool | newStatus | ) | [static] |
Sets the OpenGL double buffering status (enabled or disabled).
newStatus,double | buffering will be enabled iff true (and available). |
OpenGLException | should an error occur. |
Definition at line 1442 of file OSDLOpenGL.cc.
References SetGLAttribute().
Referenced by SetUpForFlavour().
void OpenGLContext::SetFullScreenAntialiasingStatus | ( | bool | newStatus, | |
Ceylan::Uint8 | samplesPerPixelNumber = 4 | |||
) | [static] |
Sets the OpenGL fullscreen antialiasing (FSAA) status (enabled or disabled).
newStatus,FSAA | will be enabled iff true. | |
samplesPerPixelNumber | number of samples per pixel when multisampling (FSAA) is enabled. Is usually 2, 4, 16, etc. This parameter is ignored if newStatus is false. |
OpenGLException | should an error occur. |
Definition at line 1534 of file OSDLOpenGL.cc.
References SetGLAttribute().
Referenced by SetUpForFlavour().
void OpenGLContext::SetGLAttribute | ( | GLAttribute | attribute, | |
int | value | |||
) | [static, protected] |
Sets the specified OpenGL attribute.
attribute | the attribute to set. | |
value | the value to assign. |
OpenGLException | if the operation failed. |
Definition at line 2171 of file OSDLOpenGL.cc.
References OSDL::Utils::getBackendLastError(), GLAttributeToString(), and OSDL::Video::Pixels::toString().
Referenced by SetColorDepth(), SetDepthBufferSize(), SetDoubleBufferStatus(), SetFullScreenAntialiasingStatus(), SetHardwareAccelerationStatus(), and SetVerticalBlankSynchronizationStatus().
void OpenGLContext::SetHardwareAccelerationStatus | ( | bool | newStatus | ) | [static] |
Sets the OpenGL hardware-acceleration status (enabled or disabled).
newStatus,FSAA | will be enabled iff true. | |
samplesPerPixelNumber | number of samples per pixel when multisampling (FSAA) is enabled. |
OpenGLException | should an error occur. |
Definition at line 1602 of file OSDLOpenGL.cc.
References SetGLAttribute().
Referenced by SetUpForFlavour().
void OpenGLContext::setOrthographicProjection | ( | GLLength | width, | |
GLCoordinate | near = -DefaultNearClippingPlaneFor3D , |
|||
GLCoordinate | far = -DefaultFarClippingPlaneFor3D | |||
) | [virtual] |
Sets an orthographic projection, so that the viewing volume is a box, whose sides are parallel to the main axes.
The viewer is located at the origin, looking towards the negative z values, his up vector being (0;1;0).
The box will be set so that:
Therefore, for a box width of w, the box will range between -w/2 and w/2 on the x axis, and between -w*r/2 and w*r/2 on the y axis, where r is the viewport aspect ratio: r = (viewport height) / (viewport width).
width | the length of the box edge which is parallel to the x axis. | |
near | the z coordinate of the near clipping plane. | |
far | the z coordinate of the far clipping plane. |
OpenGLException | should an error occur. |
Definition at line 808 of file OSDLOpenGL.cc.
References _projectionMode, _projectionWidth, _viewportHeight, _viewportWidth, and Orthographic.
Sets an orthographic projection for 2D rendering, chosen to match the current OpenGL viewport size.
width | the viewport width. | |
height | the viewport height. |
OpenGLException | should an error occur. |
Definition at line 869 of file OSDLOpenGL.cc.
References _projectionMode, _projectionWidth, DefaultFarClippingPlaneFor2D, DefaultNearClippingPlaneFor2D, and Orthographic.
Referenced by updateProjection().
void OpenGLContext::setShadingModel | ( | ShadingModel | newShadingModel = Smooth |
) | [virtual] |
Sets the shading technique to be used.
newShadingModel | the new shading technique that shall be used. |
OpenGLException | should an error occur. |
Definition at line 507 of file OSDLOpenGL.cc.
Referenced by set2DFlavour(), and set3DFlavour().
void OpenGLContext::SetUpForFlavour | ( | OpenGL::Flavour | flavour, | |
bool | safest = false | |||
) | [static] |
Prepares the OpenGL attributes appropriate for the flavour that will be used in a VideoModule::setMode call.
flavour | the OpenGL flavour to aim at. | |
safest | tells whether we should use best settings (if true) or safest ones (if false), which are useful if the best just failed to be set properly. |
OpenGLException | if the operation failed. |
Definition at line 1212 of file OSDLOpenGL.cc.
References OSDL::Video::OpenGL::None, OSDL::Video::OpenGL::OpenGLFor2D, OSDL::Video::OpenGL::OpenGLFor3D, OSDL::Video::OpenGL::Reload, SetDepthBufferSize(), SetDoubleBufferStatus(), SetFullScreenAntialiasingStatus(), SetHardwareAccelerationStatus(), OSDL::Video::Pixels::toString(), and TrySettingVerticalBlankSynchronizationStatus().
void OpenGLContext::SetVerticalBlankSynchronizationStatus | ( | bool | newStatus | ) | [static] |
Sets the OpenGL synchronization with vertical blank retrace (VSYNC).
newStatus | vsync synchronization will be enabled iff true (and available). |
OpenGLException | should an error occur. |
Definition at line 1651 of file OSDLOpenGL.cc.
References SetGLAttribute().
void OpenGLContext::setViewPort | ( | Length | width, | |
Length | height, | |||
const TwoDimensional::Point2D & | lowerLeftCorner = TwoDimensional::Point2D::Origin | |||
) | [virtual] |
Sets the OpenGL viewport, i.e.determines the transformation of x and y from normalized device coordinates to window coordinates.
The recomputation of the projection is automatically triggered accordingly, to avoid distorted graphics: it ensures that the viewport aspect ratio is the same as the one of the viewing volume.
width | the width of the viewport. | |
height | the height of the viewport. | |
lowerLeftCorner | the coordinates of the lower left corner of the viewport rectangle in pixels. The default is the origin, (0,0). |
OpenGLException | if either width or height is negative, or if this method is called between the execution of glBegin and the corresponding execution of glEnd. |
Definition at line 747 of file OSDLOpenGL.cc.
References _viewportHeight, _viewportWidth, OSDL::Video::TwoDimensional::Point2D::getX(), OSDL::Video::TwoDimensional::Point2D::getY(), OSDL::Video::TwoDimensional::Point2D::toString(), OSDL::Video::Pixels::toString(), and updateProjection().
Referenced by selectFlavour(), and OSDL::Video::VideoModule::setMode().
string OpenGLContext::ToString | ( | OpenGL::Flavour | flavour | ) | [static] |
Returns an user-friendly description of the specified OpenGL flavour.
flavour | the flavour to describe. |
Definition at line 2024 of file OSDLOpenGL.cc.
References OSDL::Video::OpenGL::None, OSDL::Video::OpenGL::OpenGLFor2D, OSDL::Video::OpenGL::OpenGLFor3D, OSDL::Video::OpenGL::Reload, and toString().
Referenced by toString().
const string OpenGLContext::toString | ( | Ceylan::VerbosityLevels | level = Ceylan::high |
) | const [virtual] |
Uploads specified surface as an OpenGL texture in OpenGL context.
source | the surface that must be converted into texture. Its width and height must be a power of 2. |
It is no longer needed once the texture is loaded, hence it can be deallocated by the caller.
OpenGLException | if the operation failed. |
Texture & uploadTextureFrom( const Video::Surface & source ) Returns an user-friendly description of the state of this object.
level | the requested verbosity level. |
Definition at line 1172 of file OSDLOpenGL.cc.
References _flavour, GetColorDepth(), and ToString().
Referenced by OSDL::Video::VideoModule::setMode(), OSDL::Video::VideoModule::toString(), and ToString().
bool OpenGLContext::TrySettingGLAttribute | ( | GLAttribute | attribute, | |
int | value | |||
) | [static, protected] |
Tries to set the specified OpenGL attribute.
attribute | the attribute to set. | |
value | the value to assign. |
Definition at line 2209 of file OSDLOpenGL.cc.
References OSDL::Utils::getBackendLastError(), GetGLAttribute(), GLAttributeToString(), and OSDL::Video::Pixels::toString().
Referenced by TrySettingVerticalBlankSynchronizationStatus().
bool OpenGLContext::TrySettingVerticalBlankSynchronizationStatus | ( | bool | newStatus | ) | [static] |
Tries to set the OpenGL synchronization with vertical blank retrace (VSYNC).
attribute | the attribute to set. | |
value | the value to assign. |
Definition at line 1685 of file OSDLOpenGL.cc.
References TrySettingGLAttribute().
Referenced by SetUpForFlavour().
void OpenGLContext::updateProjection | ( | ) | [protected, virtual] |
Updates the current projection so that its aspect ratio matches the one of the viewport.
OpenGLException | if the current projection mode cannot be handled. |
Definition at line 2062 of file OSDLOpenGL.cc.
References _flavour, _viewportHeight, _viewportWidth, OSDL::Video::OpenGL::OpenGLFor2D, OSDL::Video::OpenGL::OpenGLFor3D, and setOrthographicProjectionFor2D().
Referenced by reload(), and setViewPort().
Size in bits of the alpha component.
Definition at line 1496 of file OSDLOpenGL.h.
Size in bits of the blue component.
Definition at line 1491 of file OSDLOpenGL.h.
The current clear color for the viewport.
Definition at line 1553 of file OSDLOpenGL.h.
Referenced by reload(), and setClearColor().
The current z axis coordinate of the far clipping plane.
Definition at line 1543 of file OSDLOpenGL.h.
Stores the current OpenGL flavour.
Definition at line 1476 of file OSDLOpenGL.h.
Referenced by selectFlavour(), set2DFlavour(), set3DFlavour(), toString(), and updateProjection().
Size in bits of the green component.
Definition at line 1486 of file OSDLOpenGL.h.
The current z axis coordinate of the near clipping plane.
Definition at line 1538 of file OSDLOpenGL.h.
Stores the current projection mode.
Definition at line 1519 of file OSDLOpenGL.h.
Referenced by setOrthographicProjection(), and setOrthographicProjectionFor2D().
Width of the projection volume, so that projection can be automatically updated when the viewport area changes.
Definition at line 1529 of file OSDLOpenGL.h.
Referenced by setOrthographicProjection(), and setOrthographicProjectionFor2D().
Size in bits of the red component.
Definition at line 1481 of file OSDLOpenGL.h.
Height of the viewport, useful to ensure aspect ratio is well managed.
Definition at line 1514 of file OSDLOpenGL.h.
Referenced by selectFlavour(), set3DFlavour(), setOrthographicProjection(), setViewPort(), and updateProjection().
Width of the viewport, useful to ensure aspect ratio is well managed.
Definition at line 1505 of file OSDLOpenGL.h.
Referenced by selectFlavour(), set3DFlavour(), setOrthographicProjection(), setViewPort(), and updateProjection().
const bool OpenGLContext::ContextCanBeLost [static] |
Ceylan::System::openGLContextsCanBeLost()
Tells whether the OpenGL context can be lost (and therefore must be reloaded) under certain unexpected circumstances (ex: window resize, going to fullscreen, switching to another application, etc.
).
Definition at line 1282 of file OSDLOpenGL.h.
const bool OpenGLContext::ContextIsLostOnApplicationSwitch [static] |
Ceylan::System::openGLContextsLostOnApplicationSwitch()
Tells whether the OpenGL context is lost (and therefore must be reloaded) when switching application.
Definition at line 1304 of file OSDLOpenGL.h.
const bool OpenGLContext::ContextIsLostOnColorDepthChange [static] |
Ceylan::System::openGLContextsLostOnColorDepthChange()
Tells whether the OpenGL context is lost (and therefore must be reloaded) when changing the color depth.
Definition at line 1316 of file OSDLOpenGL.h.
const bool OpenGLContext::ContextIsLostOnResize [static] |
Ceylan::System::openGLContextsLostOnResize()
Tells whether the OpenGL context is lost (and therefore must be reloaded) on resize.
Definition at line 1293 of file OSDLOpenGL.h.
const GLCoordinate OpenGLContext::DefaultFarClippingPlaneFor2D = 1.0f [static] |
Coordinate, along the -z axis, of the default far clipping plane in 2D is 1 (1.0f).
Definition at line 1344 of file OSDLOpenGL.h.
Referenced by setOrthographicProjectionFor2D().
const GLCoordinate OpenGLContext::DefaultFarClippingPlaneFor3D = 100000.0f [static] |
Coordinate, along the -z axis, of the default far clipping plane in 3D is 100000 (100000.0f).
Definition at line 1362 of file OSDLOpenGL.h.
const GLCoordinate OpenGLContext::DefaultNearClippingPlaneFor2D = -1.0f [static] |
Coordinate, along the -z axis, of the default near clipping plane in 2D is -1 (-1.0f).
Definition at line 1335 of file OSDLOpenGL.h.
Referenced by setOrthographicProjectionFor2D().
const GLCoordinate OpenGLContext::DefaultNearClippingPlaneFor3D = 1.0f [static] |
Coordinate, along the -z axis, of the default near clipping plane in 3D is 1 (1.0f).
Definition at line 1353 of file OSDLOpenGL.h.
const GLLength OpenGLContext::DefaultOrthographicWidth = 1000.0f [static] |
Default width of the orthographic box is 1000 (1000.0f).
Definition at line 1326 of file OSDLOpenGL.h.