📄 graphicengine.h
字号:
{ protected: GLuint m_List; int m_ListCount; virtual bool init ( ); public: TOpenGLQuadric ( ); virtual ~ TOpenGLQuadric ( ); int getListCount ( ) const; virtual bool update ( ) = 0; virtual bool render ( ) = 0; };/*********************************************************************************************//************************************ Class TOpenGLScene ***********************************//*********************************************************************************************//*! This class manages updating and rendering all the visible objects in a scene */class TOpenGLScene{ protected: deque<POpenGLObject> m_Objects; /*!< This is the list of every object in scene */ public: TOpenGLScene ( ); virtual ~ TOpenGLScene ( ); bool addObject ( POpenGLObject obj ); bool removeObject ( POpenGLObject obj ); bool clear ( ); int update ( ); int render ( );};/*********************************************************************************************//************************************* Class TOpenGLEngine *********************************//*********************************************************************************************//*! This class is the main module that creates, initializes and renders everything on the world! */class TOpenGLEngine{ protected: TOpenGLScene* m_Scene; /*!< This is the scene */ TOpenGLCamera m_Camera; /*!< This is the camera */ TOpenGLLight m_Lights[MAX_LIGHTING]; /*!< These are the lightings */ int m_WindowID; /*!< Window identifier */ double m_ScreenWidth; /*!< Screen width */ double m_ScreenHeight; /*!< Screen Height */ public: TOpenGLEngine ( const char * strTitle ); virtual ~ TOpenGLEngine ( ); void updateAll ( ); void renderAll ( ); /// Scene related methods bool addObject ( POpenGLObject obj ); bool removeObject ( POpenGLObject obj ); bool clearScene ( ); /// Camera related methods VecPosition getCameraPosition ( ) const; bool setCameraPosition ( double dx, double dy, double dz ); VecPosition getCameraDirection ( ) const; bool setCameraDirection ( double dx, double dy, double dz ); VecPosition getCameraUpDirection( ) const; bool setCameraUpDirection( double dx, double dy, double dz ); /// Lighting related methods bool getLightPosition ( VecPosition &pos, int iNr ) const; bool setLightPosition ( const VecPosition & pos, int iNr ); bool getLightDirection ( VecPosition &pos, int iNr ) const; bool setLightDirection ( const VecPosition & pos, int iNr ); /// Screen methods double getScreenWidth ( ) const; double getScreenHeight ( ) const; /// Events void setOnMouseDrag ( void (*drag)(int x, int y) ); void setOnMouse ( void (*mouse)(int button, int state, int x, int y) ) const; void setOnKeyPressed ( void (*keyboard)( unsigned char c, int x, int y ) ) const; void setOnResize ( void(*resize)(int w, int h) ); void setOnIdle ( void(*idle)(void) ); void setOnDisplay ( void (*display)(void) ); void resizeEvent ( int width, int height ); /// Others int getWindowID ( ) const; void startEngine ( ) const;};/*********************************************************************************************//************************************** Class TOpenGLCube **********************************//*********************************************************************************************//*! This class represents a cube, cube has only one parameter (added to the position and direction): edge size of the cube*/class TOpenGLCube : public TOpenGLObject{ protected: double m_Size; public: double getSize ( ) const; bool setSize ( double new_size ); virtual bool update ( ); virtual bool render ( );};/*********************************************************************************************//*********************************** Class TOpenGLSphere ***********************************//*********************************************************************************************//*! This class represents a sphere, sphee like the cube has only one parameter added to it's base class: it's diameter */class TOpenGLSphere : public TOpenGLObject{ protected: double m_Radius; public: double getRadius ( ) const; bool setRadius ( double new_size ); virtual bool update ( ); virtual bool render ( );};/*********************************************************************************************//*********************************** Class TOpenGLCylinder *********************************//*********************************************************************************************//*! This class represents a cylinder, a cylinder can have two radius's (for the circle surface of start and it's end), and a height */class TOpenGLCylinder : public TOpenGLQuadric{ protected: double m_TopRadius; double m_BottomRadius; double m_Height; GLUquadricObj*m_Quad; bool initQuadric ( ); public: TOpenGLCylinder ( ); ~ TOpenGLCylinder ( ); double getTopRadius ( ) const; bool setTopRadius ( double new_size ); double getBottomRadius ( ) const; bool setBottomRadius ( double new_size ); double getHeight ( ) const; bool setHeight ( double new_size ); virtual bool update ( ); virtual bool render ( );};/*********************************************************************************************//*********************************** Class TOpenGLCapsule **********************************//*********************************************************************************************//*! This class represents a capsule, which is a cylinder which has two semi-spheres attached to it's ends */class TOpenGLCapsule : public TOpenGLCylinder{ protected: TOpenGLSphere *head_top; TOpenGLSphere *head_bottom; public: TOpenGLCapsule ( ); ~ TOpenGLCapsule ( ); virtual bool update ( ); virtual bool render ( );};static TOpenGLCapsule e_Capsule;/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/ void InitializeOpenGLEngine ( const char * strTitle );void FinalizeOpenGLEngine ( );#endif // _GRAPHIC_ENGINE_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -