• <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變虛就好了,全過程讓渲染插件自己處理。  回復  更多評論   
             
            精品久久久无码人妻中文字幕豆芽 | 国产91色综合久久免费| 久久夜色撩人精品国产小说| 伊人丁香狠狠色综合久久| 久久99精品国产99久久6男男| 性色欲网站人妻丰满中文久久不卡| 99蜜桃臀久久久欧美精品网站| 欧美亚洲国产精品久久久久| 久久青青草视频| 亚洲国产另类久久久精品小说| 色婷婷综合久久久中文字幕| 久久国产高清字幕中文| 国产成人精品久久综合| 亚洲精品成人久久久| 久久天天躁狠狠躁夜夜avapp| 综合网日日天干夜夜久久| 亚洲精品无码久久久久去q| 九九精品99久久久香蕉| 美女写真久久影院| 天天影视色香欲综合久久| 亚洲AV无码久久精品狠狠爱浪潮| AV无码久久久久不卡蜜桃| 国产高潮国产高潮久久久91| 精品久久久久成人码免费动漫| 久久久亚洲欧洲日产国码aⅴ| 97精品国产97久久久久久免费| 人妻无码久久精品| 2021久久精品国产99国产精品| 久久精品亚洲福利| 久久天堂AV综合合色蜜桃网| 久久成人精品| 久久精品亚洲中文字幕无码麻豆| 久久国产精品偷99| 久久久久久国产精品免费无码| 国产精品免费久久| 欧美熟妇另类久久久久久不卡| 99久久精品费精品国产| 伊人久久大香线蕉亚洲五月天| 精品无码久久久久久国产| 久久久久99精品成人片试看| 午夜视频久久久久一区 |