• R/O
  • SSH
  • HTTPS

qrobosdk: コミット


コミットメタ情報

リビジョン1832 (tree)
日時2010-05-22 15:13:16
作者satofumi

ログメッセージ

remove Clip code

変更サマリ

差分

--- trunk/libs/gui/CanvasSurface.cpp (revision 1831)
+++ trunk/libs/gui/CanvasSurface.cpp (revision 1832)
@@ -6,14 +6,13 @@
66
77 $Id$
88
9- \todo setAlpha() を実行する
10- \todo 適切にクリッピングを行う
9+ \todo setAlpha() を実装する
1110 */
1211
1312 #define GL_GLEXT_PROTOTYPES
1413 #include "CanvasSurface.h"
1514 #include "Font.h"
16-#include "Screen.h"
15+//#include "Screen.h"
1716 #include <SDL_opengl.h>
1817 #include <vector>
1918 #include <cassert>
@@ -30,7 +29,8 @@
3029 GLenum mode;
3130 size_t size;
3231 GLfloat line_width;
33- //vector<GLfloat> intertwined;
32+ GLint stipple_factor;
33+ GLushort stipple_pattern;
3434 } draw_t;
3535
3636 typedef vector<draw_t> Draws;
@@ -42,6 +42,8 @@
4242 float alpha_;
4343 Color draw_color_;
4444 GLfloat line_width_;
45+ int line_stipple_factor_;
46+ unsigned short line_stipple_pattern_;
4547 Font* font_;
4648 vector<draw_t> draws_;
4749 draw_t clear_draw_;
@@ -49,7 +51,8 @@
4951
5052 pImpl(const Rect<long>& rect)
5153 : rect_(rect), alpha_(1.0), draw_color_(Color(1.0, 1.0, 1.0, 1.0)),
52- line_width_(1.0f), font_(NULL)
54+ line_width_(1.0f),
55+ line_stipple_factor_(1), line_stipple_pattern_(0xffff), font_(NULL)
5356 {
5457 clearBuffers();
5558 setClearColor(Color(0.0f, 0.0f, 0.0f));
@@ -111,9 +114,12 @@
111114 {
112115 draw.mode = mode;
113116 draw.line_width = line_width_;
117+ draw.stipple_factor = line_stipple_factor_;
118+ draw.stipple_pattern = line_stipple_pattern_;
114119 draw.buffer = createBuffer();
115120 draw.size = points.size();
116121
122+
117123 vector<GLfloat> intertwined;
118124 for (vector<Point<long> >::const_iterator it = points.begin();
119125 it != points.end(); ++it) {
@@ -133,25 +139,11 @@
133139 }
134140
135141
136- void drawLineStrip(const vector<Point<long> >& points)
137- {
138- draw_t draw;
139- registerPrimitive(draw, points, GL_LINE_STRIP);
140- draws_.push_back(draw);
141- }
142-
143-
144- void drawQuadsStrip(const vector<Point<long> >& points)
145- {
146- draw_t draw;
147- registerPrimitive(draw, points, GL_QUAD_STRIP);
148- draws_.push_back(draw);
149- }
150-
151-
152142 void drawPrimitive(const draw_t& draw)
153143 {
154144 glLineWidth(draw.line_width);
145+ glLineStipple(draw.stipple_factor, draw.stipple_pattern);
146+
155147 glBindBuffer(GL_ARRAY_BUFFER, draw.buffer);
156148 glInterleavedArrays(GL_C3F_V3F, 0, NULL);
157149 glDrawArrays(draw.mode, 0, draw.size);
@@ -163,6 +155,7 @@
163155 {
164156 glEnableClientState(GL_VERTEX_ARRAY);
165157 glEnableClientState(GL_COLOR_ARRAY);
158+ glEnable(GL_LINE_STIPPLE);
166159
167160 // 位置にオフセットを加えて描画する
168161 Point<long> offset(dest->x, dest->y);
@@ -177,7 +170,9 @@
177170 // !!! clip する領域の右側と下側が、場合によって狭くなるはず
178171 (void)src;
179172
180- Screen::setClipArea(*dest);
173+ // !!! 領域外に書き込みを行う場合には clip は必須だが、
174+ // !!! clip すると適切に動作しないのでコメントアウト
175+ //Screen::setClipArea(*dest);
181176
182177 drawPrimitive(clear_draw_);
183178
@@ -188,10 +183,11 @@
188183
189184 glPopMatrix();
190185
186+ glDisable(GL_LINE_STIPPLE);
191187 glDisableClientState(GL_COLOR_ARRAY);
192188 glDisableClientState(GL_VERTEX_ARRAY);
193189
194- Screen::disableClipArea();
190+ //Screen::disableClipArea();
195191 }
196192 };
197193
@@ -274,13 +270,32 @@
274270 }
275271
276272
273+void CanvasSurface::setLineStipple(int factor, unsigned short pattern)
274+{
275+ pimpl->line_stipple_factor_ = factor;
276+ pimpl->line_stipple_pattern_ = pattern;
277+}
278+
279+
277280 void CanvasSurface::drawLineStrip(const std::vector<qrk::Point<long> >& points)
278281 {
279282 if (points.empty()) {
280283 return;
281284 }
285+ draw_t draw;
286+ pimpl->registerPrimitive(draw, points, GL_LINE_STRIP);
287+ pimpl->draws_.push_back(draw);
288+}
282289
283- pimpl->drawLineStrip(points);
290+
291+void CanvasSurface::drawLineLoop(const std::vector<qrk::Point<long> >& points)
292+{
293+ if (points.empty()) {
294+ return;
295+ }
296+ draw_t draw;
297+ pimpl->registerPrimitive(draw, points, GL_LINE_LOOP);
298+ pimpl->draws_.push_back(draw);
284299 }
285300
286301
@@ -298,7 +313,9 @@
298313 return;
299314 }
300315
301- pimpl->drawQuadsStrip(points);
316+ draw_t draw;
317+ pimpl->registerPrimitive(draw, points, GL_QUAD_STRIP);
318+ pimpl->draws_.push_back(draw);
302319 }
303320
304321
--- trunk/libs/gui/Makefile (revision 1831)
+++ trunk/libs/gui/Makefile (revision 1832)
@@ -85,7 +85,7 @@
8585 CallbackEvent.o: CallbackEvent.h Event.h ../geometry/Point.h
8686 CallbackEvent.o: ../geometry/Rect.h ../geometry/RectUtils.h
8787 CanvasSurface.o: CanvasSurface.h Surface.h ../geometry/Rect.h
88-CanvasSurface.o: ../geometry/Point.h ../common/Color.h Font.h Screen.h
88+CanvasSurface.o: ../geometry/Point.h ../common/Color.h Font.h
8989 ChatMessage.o: ChatMessage.h Component.h ../geometry/Rect.h
9090 ChatMessage.o: ../geometry/Point.h Font.h ../common/Color.h TextSurface.h
9191 ChatMessage.o: Surface.h ../system/StopWatch.h
--- trunk/libs/gui/Component.h (revision 1831)
+++ trunk/libs/gui/Component.h (revision 1832)
@@ -41,6 +41,12 @@
4141
4242
4343 virtual Rect<long> rect(void) const = 0;
44+
45+ /*!
46+ \brief !!!
47+
48+ \todo このメソッドの意味を書く
49+ */
4450 virtual void setEventAcceptable(bool acceptable) = 0;
4551 virtual void setAlpha(float alpha) = 0;
4652 virtual float alpha(void) = 0;
--- trunk/libs/gui/samples/canvasDraw.cpp (revision 1831)
+++ trunk/libs/gui/samples/canvasDraw.cpp (revision 1832)
@@ -32,8 +32,26 @@
3232 canvas.setClearColor(Color(0.5, 0.5, 0.5));
3333 canvas.setColor(Color(0.0, 0.0, 1.0));
3434
35+ vector<Point<long> > points;
36+#if 1
37+ for (int i = 1; i < 5; ++i) {
38+ points.clear();
39+ points.push_back(Point<long>(10 * i, 10 * i));
40+ points.push_back(Point<long>(10 * i, canvas.rect().h - (10 * i)));
41+ points.push_back(Point<long>(canvas.rect().w - (10 * i),
42+ canvas.rect().h - (10 * i)));
43+ points.push_back(Point<long>(canvas.rect().w - (10 * i), 10 * i));
44+ canvas.drawLineLoop(points);
45+ }
46+
47+ Label label(canvas);
48+ label.setPosition(Point<long>(30, 30));
49+
50+ Rect<long> dest(label.rect());
51+ label.draw(dest);
52+
53+#else
3554 canvas.setLineWidth(1.0);
36- vector<Point<long> > points;
3755 points.push_back(Point<long>(30, 1));
3856 points.push_back(Point<long>(50, 1));
3957 points.push_back(Point<long>(50, 100));
@@ -59,6 +77,7 @@
5977 canvas.drawQuadStrip(points);
6078
6179 canvas.draw(NULL, &dest_rect);
80+#endif
6281
6382 SDL_GL_SwapBuffers();
6483 SDL_Delay(1000);
--- trunk/libs/gui/CanvasSurface.h (revision 1831)
+++ trunk/libs/gui/CanvasSurface.h (revision 1832)
@@ -41,8 +41,10 @@
4141 void clear(void);
4242 void setColor(const qrk::Color& color);
4343 void setLineWidth(float width);
44+ void setLineStipple(int factor, unsigned short pattern);
4445
4546 void drawLineStrip(const std::vector<qrk::Point<long> >& points);
47+ void drawLineLoop(const std::vector<qrk::Point<long> >& points);
4648 void drawCircle(const qrk::Point<long>& center, float radius);
4749 void drawQuadStrip(const std::vector<qrk::Point<long> >& points);
4850 void drawText(const char* text, const Point<long>& position);
旧リポジトリブラウザで表示