Mercurial > hg > aimc
comparison src/Modules/Output/Graphics/Devices/GraphicsOutputDevice.h @ 117:c5ac2f0c7fc5
- All \t to two spaces (style guide compliance)
author | tomwalters |
---|---|
date | Fri, 15 Oct 2010 05:46:53 +0000 |
parents | 47b009f2c936 |
children | 18237d55e346 |
comparison
equal
deleted
inserted
replaced
116:47b009f2c936 | 117:c5ac2f0c7fc5 |
---|---|
32 * GraphicsOutputDevice oOutput = static_cast<GraphicsOutputDevice>(new GraphicsOutputDeviceSomething()); | 32 * GraphicsOutputDevice oOutput = static_cast<GraphicsOutputDevice>(new GraphicsOutputDeviceSomething()); |
33 * unsigned int a=0; | 33 * unsigned int a=0; |
34 * ... | 34 * ... |
35 * oOutput->Start(); | 35 * oOutput->Start(); |
36 * while ( bIsRunning ) { | 36 * while ( bIsRunning ) { |
37 * // Start a drawing operation | 37 * // Start a drawing operation |
38 * oOutput->gGrab(); | 38 * oOutput->gGrab(); |
39 * // Draw five horizontal lines | 39 * // Draw five horizontal lines |
40 * for (int y=0; y<5; y++) { | 40 * for (int y=0; y<5; y++) { |
41 * // Start a new line | 41 * // Start a new line |
42 * oOutput->gBegin(); | 42 * oOutput->gBegin(); |
43 * // Give each line it's own colour | 43 * // Give each line it's own colour |
44 * oOutput->gColor3f( (a%255)/255, 0, 1-(a%255)/255 ); | 44 * oOutput->gColor3f( (a%255)/255, 0, 1-(a%255)/255 ); |
45 * // Draw the line | 45 * // Draw the line |
46 * oOutput->gVertex2f(0, y); | 46 * oOutput->gVertex2f(0, y); |
47 * oOutput->gVertex2f(1, y); | 47 * oOutput->gVertex2f(1, y); |
48 * // End the line | 48 * // End the line |
49 * oOutput->gEnd(); | 49 * oOutput->gEnd(); |
50 * } | 50 * } |
51 * oOutput->gRelease(); | 51 * oOutput->gRelease(); |
52 * Sleep(1); | 52 * Sleep(1); |
53 * a++; | 53 * a++; |
54 * } | 54 * } |
55 * oOutput->Stop(); | 55 * oOutput->Stop(); |
56 * \endcode | 56 * \endcode |
57 * | 57 * |
58 * This class includes some basic overloading definitions to ease the | 58 * This class includes some basic overloading definitions to ease the |
59 * children's implementation. Note that the basic operations that need | 59 * children's implementation. Note that the basic operations that need |
60 * implementation are glVertex3f(x,y,z) and glColor(r,g,b). | 60 * implementation are glVertex3f(x,y,z) and glColor(r,g,b). |
61 */ | 61 */ |
62 class GraphicsOutputDevice { | 62 class GraphicsOutputDevice { |
63 public: | 63 public: |
64 GraphicsOutputDevice(AimParameters *pParam); | 64 GraphicsOutputDevice(AimParameters *pParam); |
65 virtual ~GraphicsOutputDevice() { }; | 65 virtual ~GraphicsOutputDevice() { }; |
66 | 66 |
67 /*! \brief Initialize the module, sets up everything to Start(). | 67 /*! \brief Initialize the module, sets up everything to Start(). |
68 * \return true on success, false on error | 68 * \return true on success, false on error |
69 * | 69 * |
70 * Initialize() needs to be called before any other function. | 70 * Initialize() needs to be called before any other function. |
71 * | 71 * |
72 * This method is called in it's form as displayed here by the GraphicsView, | 72 * This method is called in it's form as displayed here by the GraphicsView, |
73 * but you may want to setup your own Initialize(...) function with | 73 * but you may want to setup your own Initialize(...) function with |
74 * different arguments and call it yourself. | 74 * different arguments and call it yourself. |
75 * | 75 * |
76 * Thus make sure you do all memory allocations here. They can be cleaned | 76 * Thus make sure you do all memory allocations here. They can be cleaned |
77 * up by the destructor. Because Initialize() may fail, it's not put in | 77 * up by the destructor. Because Initialize() may fail, it's not put in |
78 * the constructor, so it can return a value. | 78 * the constructor, so it can return a value. |
79 * | 79 * |
80 * \sa Module::Initialize() | 80 * \sa Module::Initialize() |
81 */ | 81 */ |
82 virtual bool Initialize(unsigned int iVerticesMax) { return true; }; | 82 virtual bool Initialize(unsigned int iVerticesMax) { return true; }; |
83 /*! \overload | 83 /*! \overload |
84 * This function reloads the parameters; make sure to have at least the | 84 * This function reloads the parameters; make sure to have at least the |
85 * function with maximum parameters called once. | 85 * function with maximum parameters called once. |
86 */ | 86 */ |
87 virtual bool Initialize() { return true; }; | 87 virtual bool Initialize() { return true; }; |
88 | 88 |
89 /*! \brief Create a new drawing | 89 /*! \brief Create a new drawing |
90 * Run this before any other drawing command. | 90 * Run this before any other drawing command. |
91 * \sa glRelease() | 91 * \sa glRelease() |
92 */ | 92 */ |
93 virtual void gGrab() = 0; | 93 virtual void gGrab() = 0; |
94 | 94 |
95 //! \brief Start a new vertex group for drawing a line strip | 95 //! \brief Start a new vertex group for drawing a line strip |
96 virtual void gBeginLineStrip() = 0; | 96 virtual void gBeginLineStrip() = 0; |
97 //! \brief Start a new vertex group for drawing a quad strip | 97 //! \brief Start a new vertex group for drawing a quad strip |
98 virtual void gBeginQuadStrip() = 0; | 98 virtual void gBeginQuadStrip() = 0; |
99 | 99 |
100 /*! \brief Specify a vertex to draw | 100 /*! \brief Specify a vertex to draw |
101 * \param[in] x X-coordinate of the vertex | 101 * \param[in] x X-coordinate of the vertex |
102 * \param[in] y Y-coordinate of the vertex | 102 * \param[in] y Y-coordinate of the vertex |
103 * \param[in] z Z-coordinate of the vertex | 103 * \param[in] z Z-coordinate of the vertex |
104 * \param[in] r Red component of colour | 104 * \param[in] r Red component of colour |
105 * \param[in] g Green component of colour | 105 * \param[in] g Green component of colour |
106 * \param[in] b Blue component of colour | 106 * \param[in] b Blue component of colour |
107 * | 107 * |
108 * Currently, only lines are implemented. | 108 * Currently, only lines are implemented. |
109 */ | 109 */ |
110 virtual void gVertex3f(float x, float y, float z, float r, float g, float b); | 110 virtual void gVertex3f(float x, float y, float z, float r, float g, float b); |
111 | 111 |
112 /*! \overload | 112 /*! \overload |
113 * This will add a vertex with the last specified colour. | 113 * This will add a vertex with the last specified colour. |
114 */ | 114 */ |
115 | 115 |
116 virtual void gVertex3f(float x, float y, float z) = 0; | 116 virtual void gVertex3f(float x, float y, float z) = 0; |
117 /*! \overload | 117 /*! \overload |
118 * This will add a vertex in the 2d-plane with z=0. | 118 * This will add a vertex in the 2d-plane with z=0. |
119 */ | 119 */ |
120 | 120 |
121 virtual void gVertex2f(float x, float y, float r, float g, float b); | 121 virtual void gVertex2f(float x, float y, float r, float g, float b); |
122 | 122 |
123 /*! \overload | 123 /*! \overload |
124 * This will add a vertex in the 2d-plane with z=0 with the last | 124 * This will add a vertex in the 2d-plane with z=0 with the last |
125 * specified colour. | 125 * specified colour. |
126 */ | 126 */ |
127 virtual void gVertex2f(float x, float y); | 127 virtual void gVertex2f(float x, float y); |
128 | 128 |
129 /*! \brief Sets the current colour | 129 /*! \brief Sets the current colour |
130 * \param[in] r Red component | 130 * \param[in] r Red component |
131 * \param[in] g Green component | 131 * \param[in] g Green component |
132 * \param[in] b Blue component | 132 * \param[in] b Blue component |
133 */ | 133 */ |
134 virtual void gColor3f(float r, float g, float b) = 0; | 134 virtual void gColor3f(float r, float g, float b) = 0; |
135 | 135 |
136 //! \brief End a vertex group | 136 //! \brief End a vertex group |
137 virtual void gEnd() = 0; | 137 virtual void gEnd() = 0; |
138 | 138 |
139 /*! \brief Render a text string | 139 /*! \brief Render a text string |
140 * \param[in] x X-coordinate of the text's alignment point | 140 * \param[in] x X-coordinate of the text's alignment point |
141 * \param[in] y Y-coordinate of the text's alignment point | 141 * \param[in] y Y-coordinate of the text's alignment point |
142 * \param[in] z Z-coordinate of the text's alignment point | 142 * \param[in] z Z-coordinate of the text's alignment point |
143 * \param[in] sStr Text to render | 143 * \param[in] sStr Text to render |
144 * \param[in] bRotated \c true for vertically rotated text | 144 * \param[in] bRotated \c true for vertically rotated text |
145 * | 145 * |
146 * Current alignment is horizontal:left and vertical:bottom | 146 * Current alignment is horizontal:left and vertical:bottom |
147 * \todo Allow multiple alignment points | 147 * \todo Allow multiple alignment points |
148 */ | 148 */ |
149 virtual void gText3f(float x, | 149 virtual void gText3f(float x, |
150 float y, | 150 float y, |
151 float z, | 151 float z, |
152 const char *sStr, | 152 const char *sStr, |
153 bool bRotated = false) = 0; | 153 bool bRotated = false) = 0; |
154 | 154 |
155 /*! \overload | 155 /*! \overload |
156 * This will render a text string in the 2d-plane with z=0. | 156 * This will render a text string in the 2d-plane with z=0. |
157 */ | 157 */ |
158 virtual void gText2f(float x, | 158 virtual void gText2f(float x, |
159 float y, | 159 float y, |
160 const char *sStr, | 160 const char *sStr, |
161 bool bRight = false); | 161 bool bRight = false); |
162 | 162 |
163 /*! \brief Finish drawing | 163 /*! \brief Finish drawing |
164 * Call this when a drawing is finished. It also makes sure that the | 164 * Call this when a drawing is finished. It also makes sure that the |
165 * rendering is actually done. | 165 * rendering is actually done. |
166 * \sa glGrab() | 166 * \sa glGrab() |
167 */ | 167 */ |
168 virtual void gRelease() = 0; | 168 virtual void gRelease() = 0; |
169 | 169 |
170 /*! \brief Called when animation starts | 170 /*! \brief Called when animation starts |
171 * | 171 * |
172 * You may wonder what Start() and Stop() do here. Some implementations | 172 * You may wonder what Start() and Stop() do here. Some implementations |
173 * may want to behave differently with respect to updating, if an | 173 * may want to behave differently with respect to updating, if an |
174 * animation is running or not (e.g. updating). | 174 * animation is running or not (e.g. updating). |
175 */ | 175 */ |
176 virtual void Start() { m_bRunning = true; } | 176 virtual void Start() { m_bRunning = true; } |
177 | 177 |
178 //! \brief Called when animation stops | 178 //! \brief Called when animation stops |
179 virtual void Stop() { m_bRunning = false; } | 179 virtual void Stop() { m_bRunning = false; } |
180 | 180 |
181 protected: | 181 protected: |
182 //! \brief True when animation is running | 182 //! \brief True when animation is running |
183 bool m_bRunning; | 183 bool m_bRunning; |
184 //! \brief Parameter store | 184 //! \brief Parameter store |
185 AimParameters *m_pParam; | 185 AimParameters *m_pParam; |
186 | 186 |
187 //! \brief Pixel Formats | 187 //! \brief Pixel Formats |
188 enum PixelFormat {AIM_PIX_FMT_RGB24_32, AIM_PIX_FMT_RGB24_24}; | 188 enum PixelFormat {AIM_PIX_FMT_RGB24_32, AIM_PIX_FMT_RGB24_24}; |
189 }; | 189 }; |
190 | 190 |
191 #endif /* __GRAPHICS_OUTPUT_DEVICE__ */ | 191 #endif /* __GRAPHICS_OUTPUT_DEVICE__ */ |