OSDLOpenGL.h

Go to the documentation of this file.
00001 #ifndef OSDL_OPENGL_H_
00002 #define OSDL_OPENGL_H_
00003 
00004 
00005 #include "OSDLVideoTypes.h"  // for VideoException
00006 #include "OSDLPixel.h"       // for ColorElement, ColorMask
00007 #include "OSDLPoint2D.h"     // for Point2D::Origin
00008 
00009 #include "Ceylan.h"          // for Uint8, Uint32, inheritance
00010 
00011 #include "SDL_opengl.h"      // for GLfloat
00012 
00013 #include <string>
00014 
00015 
00016 
00017 namespace OSDL
00018 {
00019 
00020     
00021     namespace Video
00022     {
00023     
00024     
00025         
00037         namespace OpenGL
00038         {
00039 
00040         
00041         
00043             class OSDL_DLL OpenGLException : public VideoException
00044             {
00045             
00046                 public:
00047                 
00048                 
00050                     OpenGLException( const std::string & reason ) throw() ;
00051                     
00052                     
00054                     virtual ~OpenGLException() throw() ;
00055                                 
00056             } ;
00057             
00058             
00059         
00065             extern OSDL_DLL Pixels::ColorMask RedMask ;
00066             
00067             
00073             extern OSDL_DLL Pixels::ColorMask GreenMask ;
00074             
00075             
00081             extern OSDL_DLL Pixels::ColorMask BlueMask ;
00082             
00083             
00089             extern OSDL_DLL Pixels::ColorMask AlphaMask ;
00090         
00091         
00097             typedef GLfloat GLLength ;
00098     
00099     
00105             typedef GLfloat GLCoordinate ;  
00106             
00107             
00108 
00132             enum Flavour { None, OpenGLFor2D, OpenGLFor3D, Reload } ;
00133 
00134 
00135 
00150             class OSDL_DLL OpenGLContext : public Ceylan::TextDisplayable
00151             {
00152 
00153             
00154                 public:
00155                 
00156                     
00165                     enum ProjectionMode { Orthographic, Perspective } ;
00166                     
00167                     
00187                     enum ShadingModel { Flat, Smooth } ;
00188                     
00189                     
00209                     enum CulledFacet { Front, Back, FrontAndBack } ;
00210                      
00211                     
00230                     enum FrontOrientation { Clockwise, CounterClockwise } ;
00231                     
00232                       
00245                     OpenGLContext( OpenGL::Flavour flavour = OpenGL::None ) 
00246                         throw( OpenGLException) ;
00247         
00248                         
00250                     virtual ~OpenGLContext() throw() ;
00251                 
00252                 
00253                 
00277                     virtual void selectFlavour( OpenGL::Flavour flavour ) 
00278                         throw( OpenGLException ) ;
00279     
00280     
00285                     virtual void set2DFlavour() throw( OpenGLException ) ;
00286                 
00287                 
00292                     virtual void set3DFlavour() throw( OpenGLException ) ;
00293                 
00294                     
00303                     virtual void blank() throw( OpenGLException ) ;
00304                      
00305                 
00317                     virtual void reload() throw( OpenGLException ) ;
00318                     
00319                     
00335                      virtual OSDL::Video::BitsPerPixel getColorDepth( 
00336                             OSDL::Video::BitsPerPixel & redSize, 
00337                             OSDL::Video::BitsPerPixel & greenSize, 
00338                             OSDL::Video::BitsPerPixel & blueSize ) 
00339                         const throw( OpenGLException ) ;
00340                  
00341                  
00349                     virtual void setColorDepth( 
00350                             OSDL::Video::BitsPerPixel plannedBpp ) 
00351                         throw( OpenGLException ) ;
00352                 
00353                  
00369                     virtual void setColorDepth( 
00370                             OSDL::Video::BitsPerPixel redSize, 
00371                             OSDL::Video::BitsPerPixel greenSize, 
00372                             OSDL::Video::BitsPerPixel blueSize  ) 
00373                         throw( OpenGLException ) ;
00374                 
00375                 
00384                     virtual bool getDoubleBufferStatus() 
00385                         throw( OpenGLException ) ;
00386                     
00387                     
00400                     virtual bool setDoubleBufferStatus( bool newStatus ) 
00401                         throw( OpenGLException ) ;
00402                 
00403                 
00413                      virtual void setShadingModel( 
00414                             ShadingModel newShadingModel = Smooth ) 
00415                         throw( OpenGLException ) ;
00416     
00417                      
00425                     virtual void setCullingStatus( bool newStatus ) throw() ;
00426     
00427                 
00441                     virtual void setCulling( CulledFacet culledFacet = Back, 
00442                         FrontOrientation frontOrientation = CounterClockwise, 
00443                         bool autoEnable = true ) throw( OpenGLException ) ;
00444                         
00445                     
00446                     
00459                     virtual void setFullScreenAntialiasingStatus( 
00460                             bool newStatus,
00461                             Ceylan::Uint8 samplesPerPixelNumber = 1 ) 
00462                         throw( OpenGLException ) ;
00463                 
00464                 
00465                 
00473                     virtual void setDepthBufferStatus( bool newStatus ) 
00474                         throw() ;
00475                     
00476                     
00487                     virtual void setDepthBufferSize( 
00488                             Ceylan::Uint8 bitsNumber = 16,
00489                             bool autoEnable = true ) 
00490                         throw( OpenGLException ) ;
00491 
00492 
00493 
00494 
00495                     // Viewport section.
00496                     
00497                     
00522                     virtual void setViewPort( Length width, Length height, 
00523                             const TwoDimensional::Point2D & lowerLeftCorner = 
00524                                 TwoDimensional::Point2D::Origin ) 
00525                         throw( OpenGLException ) ;
00526                         
00527                         
00558                     virtual void setOrthographicProjection( GLLength width, 
00559                             GLCoordinate near = -DefaultNearClippingPlaneFor3D, 
00560                             GLCoordinate far  = -DefaultFarClippingPlaneFor3D ) 
00561                         throw ( OpenGLException ) ;
00562                         
00563             
00564                     // virtual void setClearColor() throw() ;
00565                     
00574                     virtual void clearViewport() throw( OpenGLException ) ;
00575                     
00576                     
00585                     virtual void clearDepthBuffer() throw( OpenGLException ) ;
00586                     
00587                         
00615                     virtual const std::string toString( 
00616                             Ceylan::VerbosityLevels level = Ceylan::high ) 
00617                         const throw() ;
00618                     
00619                     
00620                     
00629                     static std::string ToString( OpenGL::Flavour flavour )
00630                         throw() ;   
00631 
00632 
00633 
00634                     // OpenGL context behaviour.
00635 
00636 
00646                     static const bool ContextCanBeLost ;
00647             
00648             
00656                     static const bool ContextIsLostOnResize ;
00657             
00658 
00659             
00667                     static const bool ContextIsLostOnApplicationSwitch ;
00668             
00669             
00678                     static const bool ContextIsLostOnColorDepthChange ;
00679             
00680 
00681 
00682             
00688                     static const GLLength DefaultOrthographicWidth ;
00689                     
00690                     
00696                     static const GLCoordinate DefaultNearClippingPlaneFor2D ;
00697                     
00698                     
00704                     static const GLCoordinate DefaultFarClippingPlaneFor2D ;
00705                     
00706                     
00712                     static const GLCoordinate DefaultNearClippingPlaneFor3D ;
00713                     
00714                     
00720                     static const GLCoordinate DefaultFarClippingPlaneFor3D ;
00721                     
00722                     
00723                     
00724                     
00725                     
00726             protected:
00727             
00728                     
00737                     virtual void updateProjection() throw( OpenGLException ) ;
00738                     
00739                     
00740                     
00741                     // Internal OpenGL context state.
00742                     
00743                     
00745                     OpenGL::Flavour _flavour ;
00746                                             
00747                                                     
00749                     OSDL::Video::BitsPerPixel _redSize ; 
00750                     
00752                     OSDL::Video::BitsPerPixel _greenSize ;
00753                     
00755                     OSDL::Video::BitsPerPixel _blueSize ;
00756 
00757                     
00763                     Length _viewportWidth ;
00764                     
00765                     
00771                     Length _viewportHeight ;
00772                     
00773                     
00775                     ProjectionMode _projectionMode ;
00776                     
00777                     
00784                     GLLength _projectionWidth ;
00785                     
00786                     
00792                     GLCoordinate _nearClippingPlane ;
00793                     
00794                     
00796                     GLCoordinate _farClippingPlane ;
00797                     
00798                     
00799                     
00800             private:
00801                 
00802                                     
00811                     OpenGLContext( const OpenGLContext & source ) throw() ;
00812             
00813             
00822                     OpenGLContext & operator = ( const OpenGLContext & source )
00823                         throw() ;
00824             
00825             
00826             } ;
00827         
00828         
00829         
00847             namespace GLU
00848             {
00849             
00851                 typedef Ceylan::Uint32 Int ;
00852             
00853             }
00854             
00855                         
00856         }
00857         
00858     }
00859     
00860 }
00861 
00862 
00863 
00864 #endif // OSDL_OPENGL_H_
00865 

Generated on Fri Mar 30 14:46:59 2007 for OSDL by  doxygen 1.5.1