• <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++高級(jí)工程師 Android高級(jí)軟件工程師 IT集成工程師 音頻工程師 熟悉c,c++,java,c#,py,js,asp等多種語(yǔ)言 程序猿
            設(shè)計(jì)引擎的時(shí)候一直在考慮什么時(shí)候才可以支持多渲染器,比如d3d9比如軟件渲染器
            為了盡可能的讓opengl的API盡可能的與引擎代碼分離
            我加上了一個(gè)初步封裝了opengl API的類VideoDriver
            當(dāng)前只是簡(jiǎn)單的封裝了很多opengl的函數(shù)
            代碼如下:

              1 public:
              2     ////////////////////////////////////////////////////////
              3     /// 構(gòu)造,析構(gòu)引擎視頻驅(qū)動(dòng)(渲染器)
              4     ////////////////////////////////////////////////////////    
              5     VideoDriver();
              6     virtual ~VideoDriver();
              7 public
              8     ////////////////////////////////////////////////////////
              9     /// 獲取當(dāng)前視頻驅(qū)動(dòng)器類型
             10     ////////////////////////////////////////////////////////      
             11     virtual ENGINE_VIDEODERIVER  GetVideoDriverType()const
             12     {
             13         return ENGINE_VIDEODERIVER_NULL;
             14     }
             15     
             16     ////////////////////////////////////////////////////////
             17     /// 設(shè)置,獲取是否啟用豎直同步
             18     ////////////////////////////////////////////////////////         
             19     virtual void UseVerticalSync(bool enabled) = 0
             20     virtual bool IsUseVerticalSync()const = 0
             21     
             22     ////////////////////////////////////////////////////////////
             23     /// 獲取當(dāng)前幀速  
             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     /// 設(shè)置,獲取視口
             35     ////////////////////////////////////////////////////////     
             36     virtual void SetViewPort(const Recti &rect) = 0
             37     virtual Recti GetViewPort()const = 0
             38     
             39     //////////////////////////////////////////////////////////
             40     /// 設(shè)置投影模式下的視景體 
             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     /// 平移,旋轉(zhuǎn),縮放
             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     /// 設(shè)置飛行模式參數(shù) 
             64     //////////////////////////////////////////////////////////     
             65     virtual void SetPilotView(float x,float y,float z,float roll,float pitch,float heading) = 0
             66         
             67     ////////////////////////////////////////////////////////
             68     /// 設(shè)置,獲取渲染器矩陣操作
             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     /// 設(shè)置當(dāng)前渲染模式
             86     //////////////////////////////////////////////////////////    
             87     virtual void SetRenderMode(RENDER_MODE mode) = 0;
             88 
             89     //////////////////////////////////////////////////////////
             90     /// 設(shè)置,獲取清屏色
             91     //////////////////////////////////////////////////////////         
             92     virtual void  SetClearColor(const Color& color) = 0;
             93     virtual Color GetClearColor()const = 0
             94 
             95     ////////////////////////////////////////////////////////////
             96     /// 設(shè)置要清理的緩存類型(見(jiàn):ENGINE_CLEAR_ACCUM,ENGINE_CLEAR_INDEX等) 
             97     ////////////////////////////////////////////////////////////      
             98     virtual void SetClearBuffer(long buffer_mask) = 0;
             99     
            100     //////////////////////////////////////////////////////////
            101     /// 渲染色設(shè)置
            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     /// 點(diǎn)繪制
            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     /// 繪制長(zhǎng)方體(參數(shù)紋理id,長(zhǎng)方體位置,變換矩陣,大小)
            163     //////////////////////////////////////////////////////////// 
            164     virtual void RenderCube(int texture,const float pos[3],const float mat[12],const float sides[3]) = 0;     
            165 public:    
            166     ////////////////////////////////////////////////////////////
            167     /// 設(shè)備預(yù)(后)更新 
            168     ////////////////////////////////////////////////////////////
            169     virtual void PreUpdate() = 0;
            170     virtual void PostUpdate() = 0;
            171 private:     
            172     
            173     DECLARE_OBJECT(VideoDriver)
            這是初步設(shè)計(jì)的結(jié)果
            以后估計(jì)會(huì)有software video driver
            當(dāng)然其他相關(guān)的函數(shù)會(huì)陸續(xù)加入的

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

              這樣才能給機(jī)會(huì)給那些為你的引擎開(kāi)發(fā)新渲染API支持的時(shí)候,不會(huì)因?yàn)槟惴庋b的問(wèn)題導(dǎo)致他們喪失了利用該API的最有效率的慣用法的權(quán)利。

              所以一般來(lái)說(shuō),你只需要在場(chǎng)景里面實(shí)現(xiàn)BSP樹(shù),然后讓model.Draw變虛就好了,全過(guò)程讓渲染插件自己處理。  回復(fù)  更多評(píng)論   
             
            久久久久久国产精品免费无码| 色综合合久久天天综合绕视看| 久久99精品国产| 一本久久a久久精品亚洲| 久久精品国产99国产精品| 久久亚洲国产精品一区二区| 久久香蕉超碰97国产精品| 久久久无码精品亚洲日韩京东传媒 | 国产成人精品久久一区二区三区| 中文无码久久精品| 无码国内精品久久人妻| 麻豆成人久久精品二区三区免费| 亚洲精品乱码久久久久久蜜桃不卡 | 国产激情久久久久影院老熟女| 1000部精品久久久久久久久| 久久人人爽人人爽人人AV东京热| 亚洲欧美日韩中文久久| 久久99国产精品尤物| 国产精品久久自在自线观看| 久久国产一区二区| 免费一级欧美大片久久网 | 久久精品国产精品亚洲| 久久久久成人精品无码| 久久天天躁狠狠躁夜夜2020老熟妇| 久久精品成人| 7777久久久国产精品消防器材| 无码国内精品久久人妻蜜桃| 久久九九亚洲精品| 久久综合成人网| 久久亚洲精品无码AV红樱桃| 婷婷久久综合九色综合98| 久久性生大片免费观看性| 精产国品久久一二三产区区别| 国产精品对白刺激久久久| 国产午夜福利精品久久| 久久久久久精品久久久久| 蜜桃麻豆WWW久久囤产精品| 欧美大香线蕉线伊人久久| 国产综合精品久久亚洲| 色欲久久久天天天综合网精品| 久久综合九色综合97_久久久|