增加Axis,BlendMode,Light,Material等定义

This commit is contained in:
hyzboy 2018-11-30 20:04:00 +08:00
parent 8ea38d734d
commit d1322a9f97
5 changed files with 223 additions and 0 deletions

23
inc/hgl/graph/Axis.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef HGL_GRAPH_AXIS_INCLUDE
#define HGL_GRAPH_AXIS_INCLUDE
namespace hgl
{
namespace graph
{
/**
*
*/
enum Axis
{
HGL_AXIS_NONE=0,
HGL_AXIS_X,
HGL_AXIS_Y,
HGL_AXIS_Z,
HGL_AXIS_END
};//enum Axis
}//namespace graph
}//namespace hgl
#endif//HGL_GRAPH_AXIS_INCLUDE

21
inc/hgl/graph/BlendMode.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef HGL_GRAPH_BLEND_MODE_INCLUDE
#define HGL_GRAPH_BLEND_MODE_INCLUDE
namespace hgl
{
namespace graph
{
/**
*
*/
struct BlendMode ///混合模式
{
struct
{
unsigned int src,dst; ///<混合因子
unsigned int func; ///<混合方式
}rgb,alpha;
};//struct BlendMode
//namespace graph
}//namespace hgl
#endif//HGL_GRAPH_BLEND_MODE_INCLUDE

106
inc/hgl/graph/Light.h Normal file
View File

@ -0,0 +1,106 @@
#ifndef HGL_GRAPH_LIGHT_INCLUDE
#define HGL_GRAPH_LIGHT_INCLUDE
#include<hgl/math/Math.h>
namespace hgl
{
namespace graph
{
enum LightMode
{
lmNone = 0,
lmVertex,
lmPixel,
lmEnd
};//enum LightMode
/**
*
*/
enum LightType
{
ltNone=0, ///<起始定义,无意义
ltSunLight, ///<太阳光
ltPoint, ///<点光源
ltDirection, ///<方向光
ltSpot, ///<聚光灯
ltInfiniteSpotLight,///<无尽聚光灯
ltAreaQuad, ///<四边形面光源
ltEnd ///<结束定义,无意义
};//enum LightType
/**
*
*/
struct Light
{
LightType type; ///<光源类型
bool enabled; ///<是否开启
Color4f ambient; ///<环境光
Color4f specular; ///<镜面光
Color4f diffuse; ///<漫反射
};//struct Light
/**
*
*/
struct SunLight :public Light
{
Vector3f direction;
};
/**
*
*/
struct DirectionLight:public Light
{
Vector3f direction; ///<方向
float nDotVP; ///<normal . light direction
float nDotHV; ///<normal . half vector
};//struct DirectionLight
/**
*
*/
struct PointLight:public Light
{
Vector3f position; ///<光源位置
Vector3f attenuation; ///<constant,linear,quadratic
};//struct PointLight
/**
*
*/
struct SpotLight:public Light
{
Vector3f position; ///<位置
Vector3f direction; ///<方向
Vector3f attenuation; ///<constant,linear,quadratic
float coscutoff;
float exponent;
};//struct SpotLight
/**
*
*/
struct InfiniteSpotLight:public Light
{
Vector3f position;
Vector3f direction;
Vector3f exponent;
};//struct InfiniteSpotLight
}//namespace graph
}//namespace hgl
#endif//HGL_GRAPH_LIGHT_INCLUDE

52
inc/hgl/graph/Material.h Normal file
View File

@ -0,0 +1,52 @@
#ifndef HGL_GRAPH_MATERIAL_INCLUDE
#define HGL_GRAPH_MATERIAL_INCLUDE
#include<hgl/type/Color4f.h>
#include<hgl/graph/Shader.h>
#include<hgl/graph/Axis.h>
#include<hgl/graph/BlendMode.h>
namespace hgl
{
namespace graph
{
/**
*
*/
class Material
{
protected:
Shader *shader;
protected:
// Color4f Color; ///<颜色
//
// uint draw_face; ///<绘制的面
// uint fill_mode; ///<填充方式
//
// uint cull_face; ///<裁剪面,0:不裁(双面材质),FACE_FRONT:正面,FACE_BACK:背面
//
// bool depth_test; ///<深度测试
// uint depth_func; ///<深度处理方式
// bool depth_mask; ///<深度遮罩
//
// float alpha_test; ///<alpha测试值,0:全部不显示,1:全部显示
//
// bool outside_discard; ///<贴图出界放弃
//
// bool smooth; ///<是否平滑(未用)
//
// bool color_material; ///<是否使用颜色追踪材质
//
// bool blend; ///<是否开启混合
//
// BlendMode blend_mode; ///<混合模式
//
// Axis up_axis; ///<高度图向上轴
public:
};//class Material
}//namespace graph
}//namespace hgl
#endif//HGL_GRAPH_MATERIAL_INCLUDE

View File

@ -0,0 +1,21 @@
#ifndef HGL_GRAPH_RENDERABLE_INCLUDE
#define HGL_GRAPH_RENDERABLE_INCLUDE
#include<hgl/graph/Shader.h>
namespace hgl
{
namespace graph
{
/**
*
*/
class Renderable
{
protected:
VertexArray *va;
Material *mtl;
};//class Renderable
}//namespace graph
}//namespace hgl
#endif//HGL_GRAPH_RENDERABLE_INCLUDE