OSDL::Video::OpenGL::OpenGLContext Class Reference

An OpenGL context corresponds to the state of a running OpenGL screen. More...

#include <OSDLOpenGL.h>

List of all members.

Public Types

enum  ProjectionMode { Orthographic, Perspective }
 

Describes a projection mode:

More...
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.
OpenGLContextoperator= (const OpenGLContext &source)
 Assignment operator made private to ensure that it will be never called.

Detailed Description

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.

Note:
For the moment, direct access is used to the only one OpenGL context provided by the SDL 1.2.x back-end.

Definition at line 428 of file OSDLOpenGL.h.


Member Enumeration Documentation

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.

Note:
If FrontAndBack is selected, then no facets are drawn, but other primitives such as points and lines are.

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.

See also:
FrontOrientation
Enumerator:
Front 
Back 
FrontAndBack 

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.

Enumerator:
Clockwise 
CounterClockwise 

Definition at line 513 of file OSDLOpenGL.h.

Describes a projection mode:

Enumerator:
Orthographic 
Perspective 

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.

Enumerator:
Flat 
Smooth 

Definition at line 468 of file OSDLOpenGL.h.


Constructor & Destructor Documentation

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.

Parameters:
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.
Exceptions:
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.


Member Function Documentation

void OpenGLContext::blank (  )  [virtual]

Blanks the current settings in the actual OpenGL state machine.

Note:
It is useful to reset the OpenGL state before applying a flavour.
Exceptions:
OpenGLException if the operation failed.

Definition at line 436 of file OSDLOpenGL.cc.

void OpenGLContext::clearDepthBuffer (  )  [virtual]

Clears the depth buffer within the viewport.

Note:
The color buffer will not be modified here.
Exceptions:
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.

Note:
The depth buffer will not be modified here.
Exceptions:
OpenGLException if this method is called between the execution of glBegin and the corresponding execution of glEnd.
See also:
setClearColor

Definition at line 982 of file OSDLOpenGL.cc.

Referenced by OpenGLContext(), and reload().

void OpenGLContext::DisableFeature ( OpenGL::Feature  feature  )  [static]
void OpenGLContext::EnableFeature ( OpenGL::Feature  feature  )  [static]
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.

Parameters:
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.
Returns:
the actual overall bits per pixel value.
Exceptions:
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.

Exceptions:
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.

Returns:
true iff double buffering is used.
Exceptions:
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.

Note:
Requires the GL_ARB_MULTISAMPLE extension.
Returns:
0 if the feature is not available, otherwise the non-null number of samples used (ex: 4 means 4x antialiasing).
Exceptions:
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.

Parameters:
attribute the attribute whose value is wanted.
Returns:
the attribute value.
Exceptions:
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.

Returns:
true iff the hardware acceleration is available.
Exceptions:
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.

Returns:
true iff OpenGL synchronizes with VSYNC.
Exceptions:
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.

Parameters:
attribute the attribute to describe.
Exceptions:
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.

Parameters:
attribute the attribute whose support is to be acknowledged.
Returns:
true iff the specified attribute is supported.

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.

Note:
The description is only useful after a VideoModule::setMode call; before it may even crash the program.
Exceptions:
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.

Exceptions:
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.

Exceptions:
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.

See also:
OpenGL::Reload
Exceptions:
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.

Parameters:
flavour the selected flavour for OpenGL.
Note:
OpenGL support cannot fully be encapsulated into Video renderers, since they may not be used, and OpenGL must be specified during the setMode phase.
See also:
OpenGLFlavour
Exceptions:
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.

Exceptions:
OpenGLException if the operation failed.
Note:
Calling selectFlavour should be preferred, as it performs additionally a viewport update.
Leaves the context in ModelView mode.

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.

Exceptions:
OpenGLException if the operation failed.
Note:
Calling selectFlavour should be preferred, as it performs additionally a viewport update.
Leaves the context in ModelView mode.

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.

Parameters:
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.
Exceptions:
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.

Exceptions:
OpenGLException if the operation failed.
See also:
clearViewport

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.

Note:
Will not take effect until the next call to VideoModule::setMode.
Parameters:
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.
Note:
Maybe alpha should be added.
Exceptions:
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.

Note:
Will not take effect until the next call to VideoModule::setMode.
Parameters:
plannedBpp the planned color depth, in bits per pixel.
Exceptions:
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.

Parameters:
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).
Exceptions:
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.

Parameters:
newStatus culling is activated iff true.
Exceptions:
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.

Note:
Will not take effect until the next call to VideoModule::setMode.
Does not enable the depth buffer, see setDepthBufferStatus.
Parameters:
bitsNumber the new depth buffer size.
Exceptions:
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.

Parameters:
newStatus if true, will enable the depth buffer, if false will disable it.
Exceptions:
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).

Note:
Will not take effect until the next call to VideoModule::setMode.
Parameters:
newStatus,double buffering will be enabled iff true (and available).
Exceptions:
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).

Note:
Will not take effect until the next call to VideoModule::setMode.
Requires the GL_ARB_MULTISAMPLE extension.
Parameters:
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.
Exceptions:
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.

Note:
the set attributes do not take effect until VideoModule::setMode is called.
Parameters:
attribute the attribute to set.
value the value to assign.
Exceptions:
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).

Note:
Will not take effect until the next call to VideoModule::setMode.
Requires the GL_ARB_MULTISAMPLE extension.
Parameters:
newStatus,FSAA will be enabled iff true.
samplesPerPixelNumber number of samples per pixel when multisampling (FSAA) is enabled.
Exceptions:
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:

  • the viewport ratio is preserved, to avoid distorted graphics
  • the box is cut in two equal parts by the axes x=0 and y=0
  • the box will lie between the two planes z=-near and z=-far

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).

Parameters:
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.
Exceptions:
OpenGLException should an error occur.

Definition at line 808 of file OSDLOpenGL.cc.

References _projectionMode, _projectionWidth, _viewportHeight, _viewportWidth, and Orthographic.

void OpenGLContext::setOrthographicProjectionFor2D ( GLLength  width,
GLLength  height 
) [virtual]

Sets an orthographic projection for 2D rendering, chosen to match the current OpenGL viewport size.

Parameters:
width the viewport width.
height the viewport height.
Note:
Near and far clipping planes are set to default values for 2D.
Exceptions:
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.

Parameters:
newShadingModel the new shading technique that shall be used.
Exceptions:
OpenGLException should an error occur.

Definition at line 507 of file OSDLOpenGL.cc.

References Flat, and Smooth.

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.

Parameters:
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.
Note:
The corresponding attributes will not be taken into account until the next call to VideoModule::setMode.
Exceptions:
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).

Note:
Will not take effect until the next call to VideoModule::setMode.
Parameters:
newStatus vsync synchronization will be enabled iff true (and available).
Exceptions:
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.

Parameters:
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).
Exceptions:
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.

Parameters:
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.

Parameters:
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.

Exceptions:
OpenGLException if the operation failed.

Texture & uploadTextureFrom( const Video::Surface & source ) Returns an user-friendly description of the state of this object.

Parameters:
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
Ceylan::TextDisplayable

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.

Note:
Any set attribute does not take effect until VideoModule::setMode is called.
Parameters:
attribute the attribute to set.
value the value to assign.
Returns:
true iff this attribute could be set on this platform; if it failed, no exception is thrown, only false is returned.

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).

Note:
Any set attribute does not take effect until VideoModule::setMode is called.
Parameters:
attribute the attribute to set.
value the value to assign.
Returns:
true iff this feature could be set on this platform, i.e. the setting reported a success and reading back the value confirmed it; if it failed, no exception is thrown, only false is returned.

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.

Exceptions:
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().


Member Data Documentation

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.

Note:
Default is pure black.

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]
Initial value:
    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.

).

See also:
OpenGL::Flavour, for Reload.

Definition at line 1282 of file OSDLOpenGL.h.

Initial value:
    Ceylan::System::openGLContextsLostOnApplicationSwitch()

Tells whether the OpenGL context is lost (and therefore must be reloaded) when switching application.

See also:
OpenGL::Flavour, for Reload.

Definition at line 1304 of file OSDLOpenGL.h.

Initial value:
    Ceylan::System::openGLContextsLostOnColorDepthChange()

Tells whether the OpenGL context is lost (and therefore must be reloaded) when changing the color depth.

See also:
OpenGL::Flavour, for Reload.

Definition at line 1316 of file OSDLOpenGL.h.

Initial value:
 
    Ceylan::System::openGLContextsLostOnResize()

Tells whether the OpenGL context is lost (and therefore must be reloaded) on resize.

See also:
OpenGL::Flavour, for Reload.

Definition at line 1293 of file OSDLOpenGL.h.

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().

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.

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().

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.

Default width of the orthographic box is 1000 (1000.0f).

Definition at line 1326 of file OSDLOpenGL.h.


The documentation for this class was generated from the following files:
Generated on Mon Nov 29 14:06:09 2010 for OSDL by  doxygen 1.6.3