diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2016-01-20 15:21:11 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2016-01-20 15:21:11 +0000 |
| commit | d34974ace7d9beeb991ef387a0b2e6b981659e47 (patch) | |
| tree | 91cfab3e8ac79b47e8c60a057428d25d9e1a20eb /src/Fl_Gl_Window.cxx | |
| parent | d3bd47073424e5288589fce59ab1dd39ccb1b42a (diff) | |
Reorganized all integer line and polygon drawing functions
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11016 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Gl_Window.cxx')
| -rw-r--r-- | src/Fl_Gl_Window.cxx | 77 |
1 files changed, 59 insertions, 18 deletions
diff --git a/src/Fl_Gl_Window.cxx b/src/Fl_Gl_Window.cxx index 52f91ed18..0336238a4 100644 --- a/src/Fl_Gl_Window.cxx +++ b/src/Fl_Gl_Window.cxx @@ -66,6 +66,32 @@ public: unsigned int c = (r<<24)|(g<<16)|(b<<8); gl_color(c); } + // --- implementation will eventually be in src/fl_rect.cxx which includes src/cfg_gfx/xlib_rect.cxx + // --- line and polygon drawing with integer coordinates + void point(int x, int y) { + glBegin(GL_POINTS); + glVertex2i(x, y); + glEnd(); + } + void rect(int x, int y, int w, int h) { + glBegin(GL_LINE_LOOP); + glVertex2i(x, y); + glVertex2i(x+w, y); + glVertex2i(x+w, y+h); + glVertex2i(x, y+h); + glEnd(); + } + void rectf(int x, int y, int w, int h) { + if (w<=0 || h<=0) return; + // OpenGL has the natural origin at the bottom left. Drawing in FLTK + // coordinates requires that we shift the rectangle one pixel up. + glBegin(GL_POLYGON); + glVertex2i(x, y-1); + glVertex2i(x+w, y-1); + glVertex2i(x+w, y+h-1); + glVertex2i(x, y+h-1); + glEnd(); + } void line(int x, int y, int x1, int y1) { glBegin(GL_LINE_STRIP); glVertex2i(x, y); @@ -73,6 +99,14 @@ public: glEnd(); point(x1, y1); } + void line(int x, int y, int x1, int y1, int x2, int y2) { + glBegin(GL_LINE_STRIP); + glVertex2i(x, y); + glVertex2i(x1, y1); + glVertex2i(x2, y2); + glEnd(); + point(x2, y2); + } void xyline(int x, int y, int x1) { glBegin(GL_LINE_STRIP); glVertex2i(x, y); @@ -121,29 +155,34 @@ public: glEnd(); point(x2, y3); } - // --- recently moved implementations (see FL_PORTING efforts) - void point(int x, int y) { - glBegin(GL_POINTS); - glVertex2i(x, y); + void loop(int x0, int y0, int x1, int y1, int x2, int y2) { + glBegin(GL_LINE_LOOP); + glVertex2i(x0, y0); + glVertex2i(x1, y1); + glVertex2i(x2, y2); glEnd(); } - void rect(int x, int y, int w, int h) { + void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) { glBegin(GL_LINE_LOOP); - glVertex2i(x, y); - glVertex2i(x+w, y); - glVertex2i(x+w, y+h); - glVertex2i(x, y+h); + glVertex2i(x0, y0); + glVertex2i(x1, y1); + glVertex2i(x2, y2); + glVertex2i(x3, y3); glEnd(); } - void rectf(int x, int y, int w, int h) { - if (w<=0 || h<=0) return; - // OpenGL has the natural origin at the bottom left. Drawing in FLTK - // coordinates requires that we shift the rectangle one pixel up. + void polygon(int x0, int y0, int x1, int y1, int x2, int y2) { glBegin(GL_POLYGON); - glVertex2i(x, y-1); - glVertex2i(x+w, y-1); - glVertex2i(x+w, y+h-1); - glVertex2i(x, y+h-1); + glVertex2i(x0, y0); + glVertex2i(x1, y1); + glVertex2i(x2, y2); + glEnd(); + } + void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) { + glBegin(GL_POLYGON); + glVertex2i(x0, y0); + glVertex2i(x1, y1); + glVertex2i(x2, y2); + glVertex2i(x3, y3); glEnd(); } }; @@ -681,7 +720,9 @@ void Fl_Gl_Window::draw() { glOrtho(-0.5, w()-0.5, h()-0.5, -0.5, -1, 1); // glOrtho(0, w(), h(), 0, -1, 1); glLineWidth(pixels_per_unit()); // should be 1 or 2 (2 if highres OpenGL) - + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // FIXME: push on state stack + glEnable(GL_BLEND); // FIXME: push on state stack + Fl_Window::draw(); glPopMatrix(); |
