增加RenderStatus/Driver等设计
This commit is contained in:
parent
d506bd100a
commit
f3065b26af
25
inc/hgl/render/RenderDriver.h
Normal file
25
inc/hgl/render/RenderDriver.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef HGL_RENDER_DRIVER_INCLUDE
|
||||
#define HGL_RENDER_DRIVER_INCLUDE
|
||||
|
||||
#include<hgl/render/RenderStatus.h>
|
||||
namespace hgl
|
||||
{
|
||||
/**
|
||||
* 渲染驱动
|
||||
* 用于对真实渲染API的交接管理
|
||||
*/
|
||||
class RenderDriver
|
||||
{
|
||||
private:
|
||||
|
||||
RenderStatus current_status;
|
||||
|
||||
public:
|
||||
|
||||
virtual void SetCurStatus(const RenderStatus &)=0;
|
||||
|
||||
virtual void ClearColorBuffer()=0;
|
||||
virtual void ClearDepthBuffer()=0;
|
||||
};//class RenderDriver
|
||||
}//namespace hgl
|
||||
#endif//HGL_RENDER_DRIVER_INCLUDE
|
47
inc/hgl/render/RenderStatus.h
Normal file
47
inc/hgl/render/RenderStatus.h
Normal file
@ -0,0 +1,47 @@
|
||||
#ifndef HGL_RENDER_STATUS_INCLUDE
|
||||
#define HGL_RENDER_STATUS_INCLUDE
|
||||
|
||||
#include<hgl/type/Color4f.h>
|
||||
#include<hgl/CompOperator.h>
|
||||
namespace hgl
|
||||
{
|
||||
enum DEPTH_TEST_FUNC
|
||||
{
|
||||
DEPTH_TEST_NEVER=0,
|
||||
DEPTH_TEST_LESS,
|
||||
DEPTH_TEST_EQUAL,
|
||||
DEPTH_TEST_LEQUAL,
|
||||
DEPTH_TEST_GREATER,
|
||||
DEPTH_TEST_NOTEQUAL,
|
||||
DEPTH_TEST_GEQUAL,
|
||||
DEPTH_TEST_ALWAYS
|
||||
};//
|
||||
|
||||
struct DepthStatus
|
||||
{
|
||||
float near_depth =0,
|
||||
far_depth =1;
|
||||
|
||||
bool depth_mask =true;
|
||||
float clear_depth =far_depth;
|
||||
|
||||
DEPTH_TEST_FUNC depth_func =DEPTH_TEST_LESS;
|
||||
bool depth_test;
|
||||
|
||||
public:
|
||||
|
||||
CompOperatorMemcmp(struct DepthStatus &);
|
||||
};//
|
||||
|
||||
/**
|
||||
* 渲染状态
|
||||
*/
|
||||
struct RenderStatus
|
||||
{
|
||||
bool color_mask[4];
|
||||
Color4f clear_color;
|
||||
|
||||
DepthStatus depth;
|
||||
};//class RenderStatus
|
||||
}//namespace hgl
|
||||
#endif//HGL_RENDER_STATUS_INCLUDE
|
244
inc/hgl/type/Color.h
Normal file
244
inc/hgl/type/Color.h
Normal file
@ -0,0 +1,244 @@
|
||||
#ifndef HGL_COLOR_TABLE_INCLUDE
|
||||
#define HGL_COLOR_TABLE_INCLUDE
|
||||
|
||||
#include<hgl/platform/Platform.h>
|
||||
namespace hgl
|
||||
{
|
||||
/**
|
||||
* 颜色数据定义
|
||||
*/
|
||||
struct COLOR_DEF ///颜色数据定义
|
||||
{
|
||||
int red,green,blue; ///<三原色
|
||||
int yum; ///<亮度
|
||||
|
||||
float r,g,b; ///<三原色浮点值
|
||||
float y; ///<亮度浮点值
|
||||
|
||||
char eng_name[32]; ///<英文名称
|
||||
u16char chs_name[16]; ///<中文名称
|
||||
};
|
||||
|
||||
/**
|
||||
* 颜色枚举
|
||||
*/
|
||||
enum COLOR_ENUM ///颜色枚举
|
||||
{
|
||||
ceNone,
|
||||
|
||||
ceAliceBlue, ///<艾利斯兰
|
||||
ceAndroidGreen, ///<安卓绿
|
||||
ceAntiqueWhite, ///<古董白
|
||||
ceAppleGreen, ///<苹果绿
|
||||
ceAqua, ///<浅绿色
|
||||
ceAquaMarine, ///<碧绿色
|
||||
|
||||
ceArdenRed, ///<雅顿红(注:商业使用需获得Elizabeth Arden公司授权)
|
||||
|
||||
ceAzure, ///<天蓝色
|
||||
ceBananaMania, ///<香蕉黄(芯)
|
||||
ceBananaYellow, ///<香蕉黄(皮)
|
||||
ceBeige, ///<米色
|
||||
ceBisque, ///<桔黄色
|
||||
ceBlack, ///<黑色
|
||||
ceBlanchedAlmond, ///<白杏色
|
||||
ceBlue, ///<蓝色
|
||||
ceBlueViolet, ///<紫罗兰色
|
||||
ceBrown, ///<褐色
|
||||
ceBurlyWood, ///<实木色
|
||||
ceCadetBlue, ///<军兰色
|
||||
ceCaribbeanGreen, ///<加勒比海绿
|
||||
ceChartreuse, ///<黄绿色
|
||||
ceCherryBlossomPink, ///<樱桃花粉
|
||||
ceChocolate, ///<巧克力色
|
||||
ceCoral, ///<珊瑚色
|
||||
ceCornflowerBlue, ///<菊花兰
|
||||
ceCornsilk, ///<米绸色
|
||||
ceCrimson, ///<暗深红
|
||||
ceCyan, ///<青色
|
||||
ceDarkBlue, ///<暗蓝色
|
||||
ceDarkCyan, ///<暗青色
|
||||
ceDarkGoldenrod, ///<暗金黄
|
||||
ceDarkGray, ///<暗灰色
|
||||
ceDarkGreen, ///<暗绿色
|
||||
ceDarkGrey, ///<暗白色
|
||||
ceDarkKhaki, ///<暗黄褐色
|
||||
ceDarkMagenta, ///<暗洋红
|
||||
ceDarkOliveGreen, ///<暗橄榄绿
|
||||
ceDarkOrange, ///<暗桔黄
|
||||
ceDarkOrchid, ///<暗紫色
|
||||
ceDarkRed, ///<暗红色
|
||||
ceDarkSalmon, ///<暗肉色
|
||||
ceDarkSeaGreen, ///<暗海兰
|
||||
ceDarkSlateBlue, ///<暗灰兰
|
||||
ceDarkSlateGray, ///<墨绿色
|
||||
ceDarkSlateGrey, ///<暗灰绿
|
||||
ceDarkTurquoise, ///<暗宝石绿
|
||||
ceDarkViolet, ///<暗紫罗兰
|
||||
ceDeepPink, ///<深粉红
|
||||
ceDeepSkyBlue, ///<深天蓝
|
||||
ceDimGray, ///<暗灰色
|
||||
ceDimGrey, ///<暗灰白
|
||||
ceDodgerBlue, ///<闪兰色
|
||||
ceFireBrick, ///<火砖色
|
||||
ceFloralWhite, ///<花白色
|
||||
ceForestGreen, ///<森林绿
|
||||
ceFrenchBeige, ///<法国米色
|
||||
ceFrenchBlue, ///<法国兰
|
||||
ceFrenchLilac, ///<法国丁香色
|
||||
ceFuchsia, ///<紫红色
|
||||
ceGainsboro, ///<淡灰色
|
||||
ceGhostWhite, ///<幽灵白
|
||||
ceGold, ///<金色
|
||||
ceGoldenrod, ///<金麒麟色
|
||||
ceGoldenYellow, ///<金黄
|
||||
ceGray, ///<灰色
|
||||
ceGreen, ///<绿色
|
||||
ceGreenYellow, ///<蓝绿色
|
||||
ceGrey, ///<灰白色
|
||||
ceHollywoodCerise, ///<好莱坞樱桃红
|
||||
ceHoneydew, ///<蜜色
|
||||
ceHotPink, ///<火热粉
|
||||
ceHunterGreen, ///<猎人绿
|
||||
ceIndianGreen, ///<印度绿
|
||||
ceIndianRed, ///<印度红
|
||||
ceIndianYellow, ///<印度黄
|
||||
ceIndigo, ///<靛青色
|
||||
ceIvory, ///<象牙白
|
||||
ceKhaki, ///<黄褐色
|
||||
ceLavender, ///<淡紫色
|
||||
ceLavenderBlush, ///<淡紫红
|
||||
ceLawnGreen, ///<草绿色
|
||||
ceLemon, ///<柠檬色
|
||||
ceLemonYellow, ///<柠檬黄
|
||||
ceLemonChiffon, ///<柠檬绸
|
||||
ceLightBlue, ///<亮蓝色
|
||||
ceLightCoral, ///<亮珊瑚色
|
||||
ceLightCyan, ///<亮青色
|
||||
ceLightGoldenrodYellow, ///<亮金黄
|
||||
ceLightGray, ///<亮灰色
|
||||
ceLightGreen, ///<亮绿色
|
||||
ceLightGrey, ///<亮灰白
|
||||
ceLightPink, ///<亮粉红
|
||||
ceLightSalmon, ///<亮肉色
|
||||
ceLightSeaGreen, ///<亮海蓝
|
||||
ceLightSkyBlue, ///<亮天蓝
|
||||
ceLightSlateGray, ///<亮蓝灰
|
||||
ceLightSlateGrey, ///<亮蓝白
|
||||
ceLightSteelBlue, ///<亮钢兰
|
||||
ceLightYellow, ///<亮黄色
|
||||
ceLime, ///<酸橙色
|
||||
ceLimeGreen, ///<橙绿色
|
||||
ceLinen, ///<亚麻色
|
||||
ceLion, ///<獅子棕
|
||||
ceMagenta, ///<红紫色
|
||||
ceMaroon, ///<粟色
|
||||
ceMediumAquamarine, ///<间绿色
|
||||
ceMediumBlue, ///<间兰色
|
||||
ceMediumOrchid, ///<间淡紫
|
||||
ceMediumPurple, ///<间紫色
|
||||
ceMediumSeaGreen, ///<间海蓝
|
||||
ceMediumSlateBlue, ///<间暗蓝
|
||||
ceMediumSpringGreen, ///<间春绿
|
||||
ceMediumTurquoise, ///<间绿宝石
|
||||
ceMediumVioletRed, ///<间紫罗兰
|
||||
ceMidNightBlue, ///<中灰蓝
|
||||
ceMint, ///<薄荷色
|
||||
ceMintCream, ///<薄荷霜
|
||||
ceMintGreen, ///<薄荷绿
|
||||
ceMistyRose, ///<浅玫瑰
|
||||
ceMoccasin, ///<鹿皮色
|
||||
|
||||
ceMozillaBlue, ///<Mozilla Firefox Blue
|
||||
ceMozillaCharcoal, ///<Mozilla charcoal
|
||||
ceMozillaLightBlue, ///<Mozilla Firefox Light Blue
|
||||
ceMozillaLightOrange, ///<Mozilla Firefox Light orange
|
||||
ceMoziilaNightBlue, ///<Mozilla Nightly Blue
|
||||
ceMozillaOrange, ///<Mozilla Firefox Orange
|
||||
ceMozillaRed, ///<Mozilla red
|
||||
ceMozillaSand, ///<Mozilla sand
|
||||
ceMozillaYellow, ///<Mozilla Firefox Yellow
|
||||
|
||||
ceNavajoWhite, ///<纳瓦白
|
||||
ceNavy, ///<海军色
|
||||
|
||||
ceNiveaBlue, ///<妮维雅蓝(注:商业使用需获得Beiersdorf AG授权)
|
||||
|
||||
ceNokiaBlue, ///<诺基亚蓝
|
||||
|
||||
ceOldLace, ///<老花色
|
||||
ceOlive, ///<橄榄色
|
||||
ceOlivedrab, ///<深绿褐色
|
||||
ceOrange, ///<橙色
|
||||
ceOrangeRed, ///<红橙色
|
||||
ceOrchid, ///<淡紫色
|
||||
cePaleGoldenrod, ///<苍麒麟色
|
||||
cePaleGreen, ///<苍绿色
|
||||
cePaleTurquoise, ///<苍宝石绿
|
||||
cePaleVioletRed, ///<苍紫罗兰色
|
||||
cePapayawhip, ///<番木色
|
||||
cePeachpuff, ///<桃色
|
||||
cePear, ///<梨色
|
||||
cePeru, ///<秘鲁色
|
||||
cePink, ///<粉红色
|
||||
|
||||
//SONY PlayStation 商标用配色(注:商业使用需获得SONY授权)
|
||||
cePlayStationBlue,
|
||||
cePlayStationLightBlue,
|
||||
|
||||
cePlum, ///<洋李色
|
||||
cePowderBlue, ///<粉蓝色
|
||||
cePurple, ///<紫色
|
||||
ceRed, ///<红色
|
||||
ceRose, ///<玫瑰红
|
||||
ceRosyBrown, ///<褐玫瑰红
|
||||
ceRoyalBlue, ///<皇家蓝
|
||||
ceRuby, ///<宝石红
|
||||
ceSaddleBrown, ///<重褐色
|
||||
ceSalmon, ///<鲜肉色
|
||||
|
||||
ceSamsungBlue, ///<三星蓝
|
||||
|
||||
ceSandyBrown, ///<沙褐色
|
||||
ceSeaGreen, ///<海绿色
|
||||
ceSeaShell, ///<海贝色
|
||||
ceSienna, ///<赭色
|
||||
ceSilver, ///<银色
|
||||
ceSkyBlue, ///<天蓝色
|
||||
ceSlateBlue, ///<石蓝色
|
||||
ceSlateGray, ///<灰石色
|
||||
ceSlateGrey, ///<白灰石色
|
||||
ceSnow, ///<雪白色
|
||||
ceSpringGreen, ///<春绿色
|
||||
ceSteelBlue, ///<钢兰色
|
||||
|
||||
ceSUSEBlack, ///<SUSE黑
|
||||
ceSUSEGreen, ///<SUSE绿
|
||||
|
||||
ceTan, ///<茶色
|
||||
ceTeal, ///<水鸭色
|
||||
ceThistle, ///<蓟色
|
||||
|
||||
ceTiffanyBlue, ///<蒂芙尼蓝(知更鸟蛋蓝/勿忘我蓝)(注:商业使用需获取Tiffany公司授权)
|
||||
|
||||
ceTomato, ///<西红柿色
|
||||
ceTurquoise, ///<青绿色
|
||||
|
||||
ceUbuntuOrange, ///<Ubuntu橙色
|
||||
ceUbuntuLightAubergine,
|
||||
ceUbuntuMidAubergine,
|
||||
ceUbuntuDarkAubergine,
|
||||
|
||||
ceViolet, ///<紫罗兰色
|
||||
ceWheat, ///<浅黄色
|
||||
ceWhite, ///<白色
|
||||
ceWhiteSmoke, ///<烟白色
|
||||
ceYellow, ///<黄色
|
||||
ceYellowGreen, ///<黄绿色
|
||||
|
||||
ceEnd
|
||||
};//enum COLOR_ENUM
|
||||
|
||||
extern COLOR_DEF prv_color[ceEnd+1];
|
||||
}//namespace hgl
|
||||
#endif//HGL_COLOR_TABLE_INCLUDE
|
91
inc/hgl/type/Color3f.h
Normal file
91
inc/hgl/type/Color3f.h
Normal file
@ -0,0 +1,91 @@
|
||||
#ifndef HGL_COLOR_3_FLOAT_INCLUDE
|
||||
#define HGL_COLOR_3_FLOAT_INCLUDE
|
||||
|
||||
#include<hgl/type/Color.h>
|
||||
namespace hgl
|
||||
{
|
||||
/**
|
||||
* r,g,b三原色类
|
||||
*/
|
||||
class Color3f ///RGB三原色类
|
||||
{
|
||||
void Clamp();
|
||||
|
||||
public:
|
||||
|
||||
float r,g,b; ///<rgb 三原色
|
||||
|
||||
public:
|
||||
|
||||
Color3f(){r=0,g=0,b=0;} ///<本类构造函数
|
||||
Color3f(COLOR_ENUM ce){Use(ce);} ///<本类构造函数
|
||||
Color3f(float l){r=l,g=l,b=l;Clamp();} ///<本类构造函数
|
||||
Color3f(float vr,float vg,float vb){r=vr,g=vg,b=vb;Clamp();} ///<本类构造函数
|
||||
Color3f(const Color3f &v){r=v.r;g=v.g;b=v.b;Clamp();} ///<本类构造函数
|
||||
|
||||
void Use(COLOR_ENUM);
|
||||
void Zero(){r=0,g=0,b=0;} ///<全清为0
|
||||
void One() {r=1,g=1,b=1;} ///<全清为1
|
||||
void Rand(); ///<全随机
|
||||
|
||||
void Set(float vr,float vg,float vb){r=vr,g=vg,b=vb;Clamp();} ///<设置颜色
|
||||
void Set3i(int vr,int vg,int vb) ///<按0-255的范围值设置颜色
|
||||
{r=float(vr)/255.0f,g=float(vg)/255.0f,b=float(vb)/255.0f;Clamp();}
|
||||
|
||||
void SetLum(float v){if(v<0)Zero();else if(v>1)One();else{r=g=b=v;}} ///<设置颜色
|
||||
|
||||
void To(float,float,float,float); ///<转换到另一颜色
|
||||
void To(const float *rgb,float v){To(*rgb,*(rgb+1),*(rgb+2),v);} ///<转换到另一颜色
|
||||
void To(Color3f &c,float v){To(c.r,c.g,c.b,v);} ///<转换到另一颜色
|
||||
|
||||
void Black(){r=0,g=0,b=0;} ///<黑色
|
||||
void White(){r=1,g=1,b=1;} ///<白色
|
||||
|
||||
void Red(){r=1,g=0,b=0;} ///<红色
|
||||
void Green(){r=0,g=1,b=0;} ///<绿色
|
||||
void Blue(){r=0,g=0,b=1;} ///<蓝色
|
||||
|
||||
void Yellow(){r=1,g=1,b=0;} ///<黄色
|
||||
void Purple(){r=1,g=0,b=1;} ///<紫色
|
||||
|
||||
void Grey(float v){r=v,g=v,b=v;Clamp();} ///<灰色
|
||||
void Grey(float,float,float); ///<指彩色变成灰色
|
||||
void Grey(); ///<将当前色彩变成灰色
|
||||
|
||||
//操作符重载
|
||||
void operator = (const float *v){r=*v++;g=*v++;b=*v;}
|
||||
void operator = (COLOR_ENUM ce){Use(ce);}
|
||||
|
||||
bool operator == (const Color3f &);
|
||||
bool operator != (const Color3f &);
|
||||
|
||||
void operator += (const Color3f &v){r+=v.r;g+=v.g;b+=v.b;Clamp();}
|
||||
void operator -= (const Color3f &v){r-=v.r;g-=v.g;b-=v.b;Clamp();}
|
||||
void operator *= (const Color3f &v){r*=v.r;g*=v.g;b*=v.b;Clamp();}
|
||||
void operator /= (const Color3f &v){r/=v.r;g/=v.g;b/=v.b;Clamp();}
|
||||
|
||||
void operator *= (float v){r*=v;g*=v;b*=v;Clamp();}
|
||||
void operator /= (float v){r/=v;g/=v;b/=v;Clamp();}
|
||||
|
||||
Color3f operator + (const Color3f &v){return(Color3f(r+v.r,g+v.g,b+v.b));}
|
||||
Color3f operator - (const Color3f &v){return(Color3f(r-v.r,g-v.g,b-v.b));}
|
||||
Color3f operator * (const Color3f &v){return(Color3f(r*v.r,g*v.g,b*v.b));}
|
||||
Color3f operator / (const Color3f &v){return(Color3f(r/v.r,g/v.g,b/v.b));}
|
||||
|
||||
Color3f operator * (float v){return(Color3f(r*v,g*v,b*v));}
|
||||
Color3f operator / (float v){return(Color3f(r/v,g/v,b/v));}
|
||||
|
||||
operator float *() const {return((float *)this);} //使得本类可以直接当做float *使用
|
||||
operator const float *() const {return((const float *)this);} //使得本类可以直接当做const float *使用
|
||||
};//class Color3f
|
||||
|
||||
const Color3f BlackColor3f(0,0,0);
|
||||
const Color3f WhiteColor3f(1,1,1);
|
||||
const Color3f RedColor3f(1,1,0);
|
||||
const Color3f GreenColor3f(0,1,0);
|
||||
const Color3f BlueColor3f(0,0,1);
|
||||
const Color3f YellowColor3f(1,1,0);
|
||||
|
||||
#define DEF_RGB_U8_TO_COLOR3F(r,g,b) Color3f(float(r)/255.0f,float(g)/255.0f,float(b)/255.0f)
|
||||
}//namespace hgl
|
||||
#endif//HGL_COLOR_3_FLOAT_INCLUDE
|
100
inc/hgl/type/Color4f.h
Normal file
100
inc/hgl/type/Color4f.h
Normal file
@ -0,0 +1,100 @@
|
||||
#ifndef HGL_COLOR_4_FLOAT_INCLUDE
|
||||
#define HGL_COLOR_4_FLOAT_INCLUDE
|
||||
|
||||
#include<hgl/type/Color3f.h>
|
||||
namespace hgl
|
||||
{
|
||||
#define HGL_FLOAT_TO_U32(c1,c2,c3,c4) uint32( \
|
||||
(uint8(c1 * 255) << 24 ) | \
|
||||
(uint8(c2 * 255) << 16 ) | \
|
||||
(uint8(c3 * 255) << 8 ) | \
|
||||
(uint8(c4 * 255) ) )
|
||||
|
||||
#define HGL_FLOAT_TO_RGBA8(r,g,b,a) HGL_FLOAT_TO_U32(r,g,b,a)
|
||||
#define HGL_FLOAT_TO_BGRA8(r,g,b,a) HGL_FLOAT_TO_U32(b,g,r,a)
|
||||
#define HGL_FLOAT_TO_ARGB8(r,g,b,a) HGL_FLOAT_TO_U32(a,r,g,b)
|
||||
#define HGL_FLOAT_TO_ABGR8(r,g,b,a) HGL_FLOAT_TO_U32(a,b,g,r)
|
||||
|
||||
/**
|
||||
* r,g,b,a四原色类
|
||||
*/
|
||||
class Color4f ///RGBA四原色类
|
||||
{
|
||||
void Clamp();
|
||||
|
||||
public:
|
||||
|
||||
float r,g,b,a; ///<rgba 4原色
|
||||
|
||||
public:
|
||||
|
||||
Color4f(){r=0,g=0,b=0,a=1;} ///<本类构造函数
|
||||
Color4f(COLOR_ENUM ce){Use(ce,1);} ///<本类构造函数
|
||||
Color4f(COLOR_ENUM ce,float ta){Use(ce,ta);} ///<本类构造函数
|
||||
Color4f(float v){r=v,g=v,b=v,a=1;Clamp();} ///<本类构造函数
|
||||
Color4f(float vr,float vg,float vb,float va){r=vr,g=vg,b=vb;a=va;Clamp();} ///<本类构造函数
|
||||
Color4f(const Color3f &v,float va=1){Set(v,va);} ///<本类构造函数
|
||||
|
||||
void Use(COLOR_ENUM,float);
|
||||
void Zero(){r=0,g=0,b=0,a=0;} ///<全清为0
|
||||
void One() {r=1,g=1,b=1,a=1;} ///<全清为1
|
||||
|
||||
void MergeAlpha(const Color4f &v,float va){r=v.r;g=v.g;b=v.b;a=v.a*va;Clamp();} ///<混合Alpha
|
||||
|
||||
void Set(const float *rgba){r=rgba[0];g=rgba[1];b=rgba[2];a=rgba[3];Clamp();}
|
||||
void Set(const Color3f &v,float va=1){r=v.r;g=v.g;b=v.b;a=va;Clamp();} ///<设置颜色
|
||||
void Set(float vr,float vg,float vb){r=vr,g=vg,b=vb;Clamp();} ///<设置颜色
|
||||
void Set(float vr,float vg,float vb,float va){r=vr,g=vg,b=vb;a=va;Clamp();} ///<设置颜色
|
||||
void Set4i(int vr,int vg,int vb,int va) ///<按0-255的范围值设置颜色
|
||||
{r=float(vr)/255.0f,g=float(vg)/255.0f,b=float(vb)/255.0f;a=float(va)/255.0f;Clamp();}
|
||||
|
||||
void SetLum(float v){if(v<0)Zero();else if(v>1)One();else{r=v;g=v;b=v;}} ///<设置颜色
|
||||
|
||||
void To(float,float,float,float); ///<转换到另一颜色
|
||||
void To(const Color4f &c,float v){To(c.r,c.g,c.b,v);} ///<转换到另一颜色
|
||||
void To(const Color3f &c,float v){To(c.r,c.g,c.b,v);} ///<转换到另一颜色
|
||||
|
||||
uint32 ToRGBA8()const{ return HGL_FLOAT_TO_RGBA8(r, g, b, a); } ///<输出一个rgba8格式的颜色数据
|
||||
uint32 ToBGRA8()const{ return HGL_FLOAT_TO_BGRA8(r, g, b, a); } ///<输出一个bgra8格式的颜色数据
|
||||
uint32 ToARGB8()const{ return HGL_FLOAT_TO_ARGB8(r, g, b, a); } ///<输出一个argb8格式的颜色数据
|
||||
uint32 ToABGR8()const{ return HGL_FLOAT_TO_ABGR8(r, g, b, a); } ///<输出一个abgr8格式的颜色数据
|
||||
|
||||
void Grey(); ///<将当前色彩变成灰色
|
||||
|
||||
//操作符重载
|
||||
void operator = (const float *v){r=*v++;g=*v++;b=*v++;a=*v;}
|
||||
void operator = (const Color3f &v){r=v.r;g=v.g;b=v.b;a=1;}
|
||||
void operator = (const Color4f &v){r=v.r;g=v.g;b=v.b;a=v.a;}
|
||||
void operator = (COLOR_ENUM ce){Use(ce,a);}
|
||||
|
||||
bool operator == (const Color4f &);
|
||||
bool operator != (const Color4f &);
|
||||
|
||||
void operator += (const Color4f &v){r+=v.r;g+=v.g;b+=v.b;a+=v.a;Clamp();}
|
||||
void operator -= (const Color4f &v){r-=v.r;g-=v.g;b-=v.b;a-=v.a;Clamp();}
|
||||
void operator *= (const Color4f &v){r*=v.r;g*=v.g;b*=v.b;a*=v.a;Clamp();}
|
||||
void operator /= (const Color4f &v){r/=v.r;g/=v.g;b/=v.b;a/=v.a;Clamp();}
|
||||
|
||||
void operator += (const Color3f &v){r+=v.r;g+=v.g;b+=v.b;Clamp();}
|
||||
void operator -= (const Color3f &v){r-=v.r;g-=v.g;b-=v.b;Clamp();}
|
||||
void operator *= (const Color3f &v){r*=v.r;g*=v.g;b*=v.b;Clamp();}
|
||||
void operator /= (const Color3f &v){r/=v.r;g/=v.g;b/=v.b;Clamp();}
|
||||
|
||||
void operator *= (float v){r*=v;g*=v;b*=v;a*=v;Clamp();}
|
||||
void operator /= (float v){r/=v;g/=v;b/=v;a/=v;Clamp();}
|
||||
|
||||
Color4f operator + (const Color4f &v){return(Color4f(r+v.r,g+v.g,b+v.b,a+v.a));}
|
||||
Color4f operator - (const Color4f &v){return(Color4f(r-v.r,g-v.g,b-v.b,a-v.a));}
|
||||
Color4f operator * (const Color4f &v){return(Color4f(r*v.r,g*v.g,b*v.b,a*v.a));}
|
||||
Color4f operator / (const Color4f &v){return(Color4f(r/v.r,g/v.g,b/v.b,a/v.a));}
|
||||
|
||||
Color4f operator * (float v){return(Color4f(r*v,g*v,b*v,a*v));}
|
||||
Color4f operator / (float v){return(Color4f(r/v,g/v,b/v,a/v));}
|
||||
|
||||
operator float *() const {return((float *)this);} //使得本类可以直接当做float *使用
|
||||
operator const float *() const {return((const float *)this);} //使得本类可以直接当做const float *使用
|
||||
};//class Color4f
|
||||
|
||||
#define DEF_RGBA_U8_TO_COLOR4F(r,g,b,a) Color4f(float(r)/255.0f,float(g)/255.0f,float(b)/255.0f,float(a)/255.0f)
|
||||
}//namespace hgl
|
||||
#endif//HGL_COLOR_4_FLOAT_INCLUDE
|
22
src/RenderDriver/GLCore/RenderDriverGLCore.cpp
Normal file
22
src/RenderDriver/GLCore/RenderDriverGLCore.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include<hgl/render/RenderDriver.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
class RenderDriverGLCore:public RenderDriver
|
||||
{
|
||||
public:
|
||||
|
||||
void SetCurStatus(const RenderStatus &rs) override
|
||||
{
|
||||
if(rs.color
|
||||
}
|
||||
|
||||
void ClearColorBuffer() override
|
||||
{
|
||||
}
|
||||
|
||||
void ClearDepthBuffer() override
|
||||
{
|
||||
}
|
||||
};//class RenderDriverGLCore:public RenderDriver
|
||||
}//namespace hgl
|
Loading…
x
Reference in New Issue
Block a user