• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            Cpper
            C/C++高級工程師 Android高級軟件工程師 IT集成工程師 音頻工程師 熟悉c,c++,java,c#,py,js,asp等多種語言 程序猿
            設計引擎的時候一直在考慮什么時候才可以支持多渲染器,比如d3d9比如軟件渲染器
            為了盡可能的讓opengl的API盡可能的與引擎代碼分離
            我加上了一個初步封裝了opengl API的類VideoDriver
            當前只是簡單的封裝了很多opengl的函數
            代碼如下:

              1 public:
              2     ////////////////////////////////////////////////////////
              3     /// 構造,析構引擎視頻驅動(渲染器)
              4     ////////////////////////////////////////////////////////    
              5     VideoDriver();
              6     virtual ~VideoDriver();
              7 public
              8     ////////////////////////////////////////////////////////
              9     /// 獲取當前視頻驅動器類型
             10     ////////////////////////////////////////////////////////      
             11     virtual ENGINE_VIDEODERIVER  GetVideoDriverType()const
             12     {
             13         return ENGINE_VIDEODERIVER_NULL;
             14     }
             15     
             16     ////////////////////////////////////////////////////////
             17     /// 設置,獲取是否啟用豎直同步
             18     ////////////////////////////////////////////////////////         
             19     virtual void UseVerticalSync(bool enabled) = 0
             20     virtual bool IsUseVerticalSync()const = 0
             21     
             22     ////////////////////////////////////////////////////////////
             23     /// 獲取當前幀速  
             24     ////////////////////////////////////////////////////////////
             25     virtual float GetFPS() const = 0;     
             26     
             27     /////////////////////////////////////////////////////////
             28     /// 獲取視頻模式列表,獲取桌面視頻模式
             29     /////////////////////////////////////////////////////////    
             30     virtual int GetVideoMode(VideoMode* mode, int number) = 0;
             31     virtual VideoMode GetDesktopVideoMode()const = 0;        
             32     
             33     ////////////////////////////////////////////////////////
             34     /// 設置,獲取視口
             35     ////////////////////////////////////////////////////////     
             36     virtual void SetViewPort(const Recti &rect) = 0
             37     virtual Recti GetViewPort()const = 0
             38     
             39     //////////////////////////////////////////////////////////
             40     /// 設置投影模式下的視景體 
             41     //////////////////////////////////////////////////////////     
             42     virtual void SetPerspective(float fov, float aspect, float near, float far) = 0;
             43     
             44     //////////////////////////////////////////////////////////
             45     /// 啟用,禁止和查詢剔除功能 
             46     //////////////////////////////////////////////////////////         
             47     virtual void EnableCulling() = 0;
             48     virtual void DisableCulling() = 0;
             49     virtual bool IsEnabledCulling() = 0;
             50     virtual void SetCulling(ENGEIN_CULLING_TYPE type) = 0;
             51     
             52     
             53     //////////////////////////////////////////////////////////
             54     /// 平移,旋轉,縮放
             55     //////////////////////////////////////////////////////////     
             56     virtual void Translate(float x, float y, float z) = 0;
             57     virtual void Translate(const Vector3f &offset) = 0;
             58     virtual void Rotate(float angle, float x, float y,float z) = 0;
             59     virtual void Scale(float x, float y, float z) = 0;
             60     virtual void Scale(const Vector3f& scale) = 0;    
             61   
             62     //////////////////////////////////////////////////////////
             63     /// 設置飛行模式參數 
             64     //////////////////////////////////////////////////////////     
             65     virtual void SetPilotView(float x,float y,float z,float roll,float pitch,float heading) = 0
             66         
             67     ////////////////////////////////////////////////////////
             68     /// 設置,獲取渲染器矩陣操作
             69     ////////////////////////////////////////////////////////    
             70     virtual void  SetTransform(const Matrix4f& mat, ENGINE_MATRIX_TYPE type) = 0;
             71     virtual const Matrix4f& GetTransform(ENGINE_MATRIX_TYPE type)const = 0
             72 
             73     ////////////////////////////////////////////////////////
             74     /// 矩陣保存 
             75     ////////////////////////////////////////////////////////        
             76     virtual void PushMatrix() = 0
             77     virtual void PopMatrix() = 0;
             78     
             79     ////////////////////////////////////////////////////////
             80     /// 啟用2d渲染 
             81     ////////////////////////////////////////////////////////     
             82     virtual void Ortho2D() = 0;     
             83     
             84     //////////////////////////////////////////////////////////
             85     /// 設置當前渲染模式
             86     //////////////////////////////////////////////////////////    
             87     virtual void SetRenderMode(RENDER_MODE mode) = 0;
             88 
             89     //////////////////////////////////////////////////////////
             90     /// 設置,獲取清屏色
             91     //////////////////////////////////////////////////////////         
             92     virtual void  SetClearColor(const Color& color) = 0;
             93     virtual Color GetClearColor()const = 0
             94 
             95     ////////////////////////////////////////////////////////////
             96     /// 設置要清理的緩存類型(見:ENGINE_CLEAR_ACCUM,ENGINE_CLEAR_INDEX等) 
             97     ////////////////////////////////////////////////////////////      
             98     virtual void SetClearBuffer(long buffer_mask) = 0;
             99     
            100     //////////////////////////////////////////////////////////
            101     /// 渲染色設置
            102     //////////////////////////////////////////////////////////         
            103     virtual void SetRenderColor(const Color& color) = 0
            104     void SetColor(const Color& color){SetRenderColor(color);}
            105     
            106     //////////////////////////////////////////////////////////
            107     /// 啟用,禁止混合
            108     //////////////////////////////////////////////////////////         
            109     virtual void SetBlending(bool blend) = 0;  
            110     virtual bool GetBlending()const = 0
            111     
            112     //////////////////////////////////////////////////////////
            113     /// 線寬
            114     //////////////////////////////////////////////////////////         
            115     virtual void  SetLineWidth(float width) = 0;
            116     virtual float GetMaxLineWidth()const = 0
            117     virtual float GetLineWidth()const = 0
            118     
            119     //////////////////////////////////////////////////////////
            120     /// 點繪制
            121     //////////////////////////////////////////////////////////     
            122     virtual void DrawPoint(const Vector3f &point) = 0
            123     virtual void DrawPoint(float x, float y, float z) = 0;
            124 
            125     //////////////////////////////////////////////////////////
            126     /// 線繪制
            127     //////////////////////////////////////////////////////////     
            128     virtual void DrawLine(const Point &from, const Point &to) = 0
            129     virtual void DrawLine(const Vector2f &p1, const Vector2f &p2)  =0;        
            130     virtual void DrawLine(float x1, float y1, float x2, float y2) = 0;         
            131     virtual void DrawLine(const Vector3f &p1, const Vector3f &p2) = 0
            132     
            133     //////////////////////////////////////////////////////////
            134     /// 矩形繪制 
            135     //////////////////////////////////////////////////////////         
            136     virtual void DrawRect(float x, float y, float width, float height) = 0
            137     virtual void DrawRect(const Rectf& rect) = 0
            138     virtual void DrawRect(const Recti& rect) = 0
            139     virtual void FillRect(float x, float y, float width, float height)= 0
            140     virtual void FillRect(const Rectf& rect) = 0
            141     virtual void FillRect(const Recti& rect) = 0;
            142    
            143     //////////////////////////////////////////////////////////
            144     /// 格子繪制 
            145     //////////////////////////////////////////////////////////    
            146     virtual void DrawGrid(const Point &pos, const Point &unit, const Point &num) = 0;  
            147     virtual void DrawGrid(const Point& pos, const int &row, const int &col, const Point &num) = 0;      
            148     
            149     //////////////////////////////////////////////////////////
            150     /// 三角形繪制
            151     //////////////////////////////////////////////////////////      
            152     virtual void DrawTriangle(const Trianglef& tri, bool filled) = 0
            153     virtual void DrawTriangle(const Vector2f& p1,const Vector2f& p2,const Vector2f& p3,bool filled) = 0;  
            154    
            155     //////////////////////////////////////////////////////////
            156     /// 園繪制
            157     //////////////////////////////////////////////////////////    
            158     virtual void DrawCircle(const Vector2f& center, float radius, float segments) = 0
            159     virtual void DrawCircleSegment(const Vector2f& center,float radius,float t1,float t2,float segments,bool filled) = 0
            160 
            161     ////////////////////////////////////////////////////////////
            162     /// 繪制長方體(參數紋理id,長方體位置,變換矩陣,大小)
            163     //////////////////////////////////////////////////////////// 
            164     virtual void RenderCube(int texture,const float pos[3],const float mat[12],const float sides[3]) = 0;     
            165 public:    
            166     ////////////////////////////////////////////////////////////
            167     /// 設備預(后)更新 
            168     ////////////////////////////////////////////////////////////
            169     virtual void PreUpdate() = 0;
            170     virtual void PostUpdate() = 0;
            171 private:     
            172     
            173     DECLARE_OBJECT(VideoDriver)
            這是初步設計的結果
            以后估計會有software video driver
            當然其他相關的函數會陸續加入的

            posted on 2010-04-01 21:05 ccsdu2009 閱讀(321) 評論(3)  編輯 收藏 引用 所屬分類: Game引擎
            Comments
            • # re: 蓋莫游戲引擎2.1.1之渲染器設計
              Davy.xu
              Posted @ 2010-04-01 22:56
              不支持RenderTarget?
              Shader怎么辦?  回復  更多評論   
            • # re: 蓋莫游戲引擎2.1.1之渲染器設計
              ccsdu2009
              Posted @ 2010-04-02 08:33
              先簡后難啊  回復  更多評論   
            • # re: 蓋莫游戲引擎2.1.1之渲染器設計
              陳梓瀚(vczh)
              Posted @ 2010-04-02 11:22
              我認為最嚴重的問題是不同的渲染API的最有效工作方法是不一樣的,你得連這些都抽象掉。不能僅僅抽象功能。

              這樣才能給機會給那些為你的引擎開發新渲染API支持的時候,不會因為你封裝的問題導致他們喪失了利用該API的最有效率的慣用法的權利。

              所以一般來說,你只需要在場景里面實現BSP樹,然后讓model.Draw變虛就好了,全過程讓渲染插件自己處理。  回復  更多評論   
             
            区久久AAA片69亚洲| 国产精品欧美亚洲韩国日本久久 | 亚洲精品午夜国产va久久 | 久久亚洲精品中文字幕| 手机看片久久高清国产日韩| 国产精品VIDEOSSEX久久发布| 国产精品久久影院| 久久国产亚洲精品麻豆| 久久九九青青国产精品| 久久久中文字幕| 国产精品99久久精品爆乳| 久久精品国产一区二区三区| 久久精品国产黑森林| 国产精品美女久久久久AV福利| 品成人欧美大片久久国产欧美| 久久天天日天天操综合伊人av| 一极黄色视频久久网站| 国内精品综合久久久40p| 欧美大香线蕉线伊人久久| 丰满少妇高潮惨叫久久久| 一本一道久久精品综合| 久久高清一级毛片| 亚洲精品第一综合99久久| 久久99精品国产自在现线小黄鸭| 韩国三级大全久久网站| 久久人人超碰精品CAOPOREN| 久久久久久久精品妇女99| 久久精品国产99久久无毒不卡| 国产无套内射久久久国产| 午夜福利91久久福利| 久久婷婷国产综合精品 | 久久久久久亚洲Av无码精品专口| 久久国产精品99久久久久久老狼| 久久精品视屏| 国产精品国色综合久久| 一本久久精品一区二区| 999久久久无码国产精品| 日日狠狠久久偷偷色综合96蜜桃| 久久久久亚洲精品天堂| 亚洲国产精品嫩草影院久久| 99999久久久久久亚洲|