From d1322a9f9793edeb1f642743f980effcac5c4d64 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 30 Nov 2018 20:04:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Axis,BlendMode,Light,Material?= =?UTF-8?q?=E7=AD=89=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/hgl/graph/Axis.h | 23 ++++++++ inc/hgl/graph/BlendMode.h | 21 ++++++++ inc/hgl/graph/Light.h | 106 +++++++++++++++++++++++++++++++++++++ inc/hgl/graph/Material.h | 52 ++++++++++++++++++ inc/hgl/graph/Renderable.h | 21 ++++++++ 5 files changed, 223 insertions(+) create mode 100644 inc/hgl/graph/Axis.h create mode 100644 inc/hgl/graph/BlendMode.h create mode 100644 inc/hgl/graph/Light.h create mode 100644 inc/hgl/graph/Material.h create mode 100644 inc/hgl/graph/Renderable.h diff --git a/inc/hgl/graph/Axis.h b/inc/hgl/graph/Axis.h new file mode 100644 index 00000000..fadaaede --- /dev/null +++ b/inc/hgl/graph/Axis.h @@ -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 diff --git a/inc/hgl/graph/BlendMode.h b/inc/hgl/graph/BlendMode.h new file mode 100644 index 00000000..58ade4e8 --- /dev/null +++ b/inc/hgl/graph/BlendMode.h @@ -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 diff --git a/inc/hgl/graph/Light.h b/inc/hgl/graph/Light.h new file mode 100644 index 00000000..824228d8 --- /dev/null +++ b/inc/hgl/graph/Light.h @@ -0,0 +1,106 @@ +#ifndef HGL_GRAPH_LIGHT_INCLUDE +#define HGL_GRAPH_LIGHT_INCLUDE + +#include +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; /// +#include +#include +#include +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; /// +namespace hgl +{ + namespace graph + { + /** + * 可渲染对象 + */ + class Renderable + { + protected: + + VertexArray *va; + Material *mtl; + };//class Renderable + }//namespace graph +}//namespace hgl +#endif//HGL_GRAPH_RENDERABLE_INCLUDE