MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
RenderAttr.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGRenderAttr_HH_
6 #define _MGRenderAttr_HH_
7 
8 #include "mgGL/Color.h"
9 
10 class MGMaterial;
11 class MGOfstream;
12 class MGIfstream;
13 
14 //
15 //Define MGRenderAttr Class.
16 
21 
28 class MG_DLL_DECLR MGRenderAttr:public MGGLAttrib{
29 
30 public:
31 
35  FRONT=GL_FRONT,
36  BACK=GL_BACK,
37  FRONT_AND_BACK=GL_FRONT_AND_BACK
38 };
39 
40 MG_DLL_DECLR friend GLenum GLrender_side(RENDERSIDE rs){return static_cast<GLenum>(rs);};
41 
44  RENDERSIDE rs=FRONT
45 ):MGGLAttrib(static_cast<int>(rs)),m_color(MGColor::UNDEFINED),
46 m_material(0),m_back_material(0){;};
47 
50  const MGColor& solid_color
51 ):MGGLAttrib(static_cast<int>(FRONT)),m_color(solid_color),
52 m_material(0),m_back_material(0){;};
53 
55 MGRenderAttr(const MGRenderAttr& attr);
56 
58 ~MGRenderAttr();
59 
61 MGRenderAttr& operator=(const MGGel& gel2);
62 MGRenderAttr& operator=(const MGRenderAttr& gel2);
63 
65 bool operator<(const MGRenderAttr& gel2)const;
66 bool operator<(const MGGel& gel2)const;
67 
69 
71 MGRenderAttr* clone()const;
72 
74 void exec(mgVBO& vbo)const;
75 
77 bool is_color_shading()const;
78 
80 bool is_highlight_attrib()const{return true;};
81 
83 bool is_texture_shading()const;
84 
86 bool material_defined()const;
87 const MGMaterial* material()const{return m_material;};
88 
92 void set_material(
93  RENDERSIDE rs,
94  const float ambient[3],
95  const float diffuse[3],
96  const float specular[3],
97  const float emission[3],
98  float shininess=0.,
99  float transparency=0.
100 );
101 
106 void set_back_material(
107  const float ambient[3],
108  const float diffuse[3],
109  const float specular[3],
110  const float emission[3],
111  float shininess=0.,
112  float transparency=0.
113 );
114 
116 void set_render_side(RENDERSIDE side=FRONT){m_flag=static_cast<int>(side);};
117 
123 const MGMaterial* back_material()const;
124 
127 RENDERSIDE render_side()const{return static_cast<RENDERSIDE>(m_flag);};
128 GLenum GLrender_side()const{return static_cast<GLenum>(render_side());};
129 
132 void set_color_shading(const MGColor& colr);
133 
136  mgVBO& vbo,
137  bool no_color=false
138 )const{exec(vbo);};
139 
141 void render(mgVBO& vbo)const{exec(vbo);};
142 
144 void set_draw_attrib_mask(unsigned int& mask)const;
145 
147 void reset_draw_attrib_mask(unsigned int& mask)const{;};
148 
150 void set_render_attrib_mask(unsigned int& mask)const;
151 
153 void reset_render_attrib_mask(unsigned int& mask)const;
154 
156 long identify_type() const{return MGRENDER_ATTR_TID;};
157 
158 std::string whoami()const{return "RenderAttr";};
159 
161 void ReadMembers(MGIfstream& buf);
163 void WriteMembers(MGOfstream& buf)const;
164 
166 std::ostream& out(std::ostream&) const;
167 
168 private:
169 
170  MGColor m_color;
171 
176  MGMaterial* m_material;
177  MGMaterial* m_back_material;
186 
187  friend class MGAppearance;
188 
189 };
190  // end of GLAttrib group
192 #endif
MGRenderAttr(const MGColor &solid_color)
Defines a solid color MGRenderAttr(that is, no texture mapping) of solid_color.
Definition: RenderAttr.h:49
virtual void set_draw_attrib_mask(unsigned int &mask) const =0
Turn on the appropriate mask bit for this attribute. See glPushAttrib().
RENDERSIDE render_side() const
Definition: RenderAttr.h:127
MGGLAttrib is an abstract class which defines the enum of undefined or disabled.
Definition: GLAttrib.h:35
Definition: GLAttrib.h:41
virtual bool operator<(const MGGel &gel2) const
virtual MGGLAttrib * clone() const =0
Generate a newed clone object.
virtual void WriteMembers(MGOfstream &buf) const
Write all member data.
void render(mgVBO &vbo) const
render GLAttribute process.
Definition: RenderAttr.h:141
RENDERSIDE
Definition: RenderAttr.h:32
MGRenderAttr(RENDERSIDE rs=FRONT)
Defines context solid color MGRenderAttr(that is, no texture mapping).
Definition: RenderAttr.h:43
virtual void ReadMembers(MGIfstream &buf)
Read all member data.
MGIfstream is a class to read the serialized data generated by MGOfstream.
Definition: Ifstream.h:30
virtual MGGLAttrib & operator=(const MGGLAttrib &gel2)
Definition: GLAttrib.h:70
MG_DLL_DECLR friend GLenum GLrender_side(RENDERSIDE rs)
Definition: RenderAttr.h:40
long identify_type() const
Return This object's typeID.
Definition: RenderAttr.h:156
Definition: GLAttrib.h:40
void set_render_side(RENDERSIDE side=FRONT)
Set the render side.
Definition: RenderAttr.h:116
MGRenderAttr defines the attributes of rendering attributes.
Definition: RenderAttr.h:28
MGColor defines the OpenGL color (R,G,B,A).
Definition: Color.h:26
virtual void reset_render_attrib_mask(unsigned int &mask) const =0
Turn off the appropriate mask bit for this attribute. See glPushAttrib().
void reset_draw_attrib_mask(unsigned int &mask) const
Turn off the appropriate mask bit for this attribute. See glPushAttrib().
Definition: RenderAttr.h:147
MGGel is an abstract class which represents a group element.
Definition: Gel.h:53
bool is_highlight_attrib() const
Test if this is highlight attrib or not.
Definition: RenderAttr.h:80
virtual std::ostream & out(std::ostream &) const
Output virtual function.
const MGMaterial * material() const
Definition: RenderAttr.h:87
MGOfstream is a class to serialize all of the subclasses of MGGel.
Definition: Ofstream.h:31
virtual void set_render_attrib_mask(unsigned int &mask) const =0
Turn on the appropriate mask bit for this attribute. See glPushAttrib().
MGMaterial defines OpenGL's Material attributes.
Definition: Material.h:24
int m_flag
Definition: GLAttrib.h:129
GLenum GLrender_side() const
Definition: RenderAttr.h:128
A container class to hold MGGLAttrib objects.
Definition: Appearance.h:33
OpenGL 4 用描画のためのクラス, in other words, display list.
Definition: VBO.h:76
void drawAttrib(mgVBO &vbo, bool no_color=false) const
draw GLAttribute process.
Definition: RenderAttr.h:135
std::string whoami() const
Definition: RenderAttr.h:158