MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
GLAttrib.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 
6 #ifndef _MGGLAttrib_HH_
7 #define _MGGLAttrib_HH_
8 
9 #include <afxwin.h>
10 #include <gl\gl.h>
11 #include <iosfwd>
12 #include "mg/MGCL.h"
13 #include "mg/Attrib.h"
14 
15 //
16 //Define MGGLAttrib Class.
17 
18 class MGOfstream;
19 class MGIfstream;
20 class MGColor;
21 class MGLight;
22 class MGRenderAttr;
23 class MGLineStipple;
24 class MGLights;
25 class MGLineWidth;
26 
31 
35 class MG_DLL_DECLR MGGLAttrib:public MGAttrib{
36 
37 public:
38 
39 enum FLAG{
40  UNDEFINED=-3,
41  DISABLED=-2
42 };
43 
45  CURRENT_BIT= GL_CURRENT_BIT,
46  POINT_BIT= GL_POINT_BIT,
47  LINE_BIT= GL_LINE_BIT,
48  POLYGON_BIT= GL_POLYGON_BIT,
49  POLYGON_STIPPLE_BIT= GL_POLYGON_STIPPLE_BIT,
50  PIXEL_MODE_BIT= GL_PIXEL_MODE_BIT,
51  LIGHTING_BIT= GL_LIGHTING_BIT,
52  FOG_BIT= GL_FOG_BIT,
53  DEPTH_BUFFER_BIT= GL_DEPTH_BUFFER_BIT,
54  ACCUM_BUFFER_BIT= GL_ACCUM_BUFFER_BIT,
55  STENCIL_BUFFER_BIT= GL_STENCIL_BUFFER_BIT,
56  VIEWPORT_BIT= GL_VIEWPORT_BIT,
57  TRANSFORM_BIT= GL_TRANSFORM_BIT,
58  ENABLE_BIT= GL_ENABLE_BIT,
59  COLOR_BUFFER_BIT= GL_COLOR_BUFFER_BIT,
60  HINT_BIT= GL_HINT_BIT,
61  EVAL_BIT= GL_EVAL_BIT,
62  LIST_BIT= GL_LIST_BIT,
63  TEXTURE_BIT= GL_TEXTURE_BIT,
64  SCISSOR_BIT= GL_SCISSOR_BIT
65 };
66 
67 MGGLAttrib(int flag=UNDEFINED):m_flag(flag){;};
68 
70 virtual MGGLAttrib& operator=(const MGGLAttrib& gel2){set_glattrib(gel2);return *this;};
71 
73 
75 virtual MGGLAttrib* clone()const=0;
76 
77 bool undefined()const{return m_flag==UNDEFINED;};
78 bool defined()const{return m_flag!=UNDEFINED;};
79 bool disabled()const{return m_flag==DISABLED;};
80 bool enabled()const{return m_flag!=UNDEFINED && m_flag!=DISABLED;};
81 
82 void set_undefined(){m_flag=UNDEFINED;};
83 void set_disabled(){m_flag=DISABLED;};
84 
86 int data()const{return m_flag;};
87 int& data(){return m_flag;};
88 
90 virtual void drawAttrib(
91  mgVBO& vbo,
92  bool no_color=false
93 )const=0;
94 
96 virtual bool is_highlight_attrib()const{return false;};
97 
99 virtual void render(mgVBO& vbo)const=0;
100 
102 virtual void set_draw_attrib_mask(unsigned int& mask)const=0;
103 
105 virtual void reset_draw_attrib_mask(unsigned int& mask)const=0;
106 
108 virtual void set_render_attrib_mask(unsigned int& mask)const=0;
109 
111 virtual void reset_render_attrib_mask(unsigned int& mask)const=0;
112 
114 virtual long identify_type() const{return MGGLATTRIBUTE_TID;};
115 
117 virtual void ReadMembers(MGIfstream& buf);
119 virtual void WriteMembers(MGOfstream& buf)const;
120 
122 virtual std::ostream& out(std::ostream&) const;
123 
125 bool same_type(const MGGLAttrib& at2)const;
126 
127 protected:
128 
129 int m_flag;
130 
134 MGGLAttrib& set_glattrib(const MGGLAttrib& gel2);
135 
136 };
137 
139 void set_Amask(unsigned int& mask, MGGLAttrib::ATTRIB_MASK bit);
140 void reset_Amask(unsigned int& mask, MGGLAttrib::ATTRIB_MASK bit);
141 
143 MGGLAttrib* MGNullGLAttrib(long TID);
144  // end of GLAttrib group
146 #endif //#ifndef _MGGLAttrib_HH_
147 
void reset_Amask(unsigned int &mask, MGGLAttrib::ATTRIB_MASK bit)
bool disabled() const
Definition: GLAttrib.h:79
MGGLAttrib is an abstract class which defines the enum of undefined or disabled.
Definition: GLAttrib.h:35
void set_Amask(unsigned int &mask, MGGLAttrib::ATTRIB_MASK bit)
Set or reset the bit of mask.
int data() const
retrieve the data.
Definition: GLAttrib.h:86
virtual long identify_type() const
Return This object's typeID.
Definition: GLAttrib.h:114
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
int & data()
Definition: GLAttrib.h:87
virtual void ReadMembers(MGIfstream &buf)
Read all member data.
FLAG
Definition: GLAttrib.h:39
MGRenderAttr defines the attributes of rendering attributes.
Definition: RenderAttr.h:28
MGColor defines the OpenGL color (R,G,B,A).
Definition: Color.h:26
MGLight is an abstract base class for light sources.
Definition: Light.h:27
virtual std::ostream & out(std::ostream &) const =0
Output virtual function.
void set_undefined()
Definition: GLAttrib.h:82
bool enabled() const
Definition: GLAttrib.h:80
MGOfstream is a class to serialize all of the subclasses of MGGel.
Definition: Ofstream.h:31
void set_disabled()
Definition: GLAttrib.h:83
virtual void WriteMembers(MGOfstream &buf) const
Write all member data.
MGGLAttrib(int flag=UNDEFINED)
Definition: GLAttrib.h:67
ATTRIB_MASK
Definition: GLAttrib.h:44
bool defined() const
Definition: GLAttrib.h:78
int m_flag
Definition: GLAttrib.h:129
virtual bool is_highlight_attrib() const
Test if this is highlight attrib or not.
Definition: GLAttrib.h:96
a container class for light sources(MGDirectionalLight, MGPointLight, or MGSpotLight).
Definition: Lights.h:23
OpenGL 4 用描画のためのクラス, in other words, display list.
Definition: VBO.h:76
virtual MGGel * clone() const =0
MGLineWidth defines line width of a curve.
Definition: LineWidth.h:24
virtual void drawAttrib(mgVBO &vbo, bool no_color=false) const
draw attribute data.
Definition: Gel.h:106
MGGLAttrib * MGNullGLAttrib(long TID)
Construct a null newed MGAttrib from the type id TID.
bool undefined() const
Definition: GLAttrib.h:77
MGAttrib is an abstract class that defines attribute elements of MGGel.
Definition: Attrib.h:28
MGLineStipple defines line stipple patters.
Definition: LineStipple.h:24