Removed OpenGL graphics driver from public view. For the parts that are implemented, it will 'just work' by allowing fl_* rendering into OpenGL contexts (such as widgets, etc.)

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11022 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher
2016-01-21 16:38:14 +00:00
parent 5ff6efd529
commit 42845966d1
3 changed files with 33 additions and 199 deletions
+28
View File
@@ -17,6 +17,7 @@
// //
#include <config.h> #include <config.h>
#include "config_lib.h"
#include <FL/Fl_Printer.H> #include <FL/Fl_Printer.H>
#include <FL/Fl_Gl_Window.H> #include <FL/Fl_Gl_Window.H>
#include "Fl_Gl_Choice.H" #include "Fl_Gl_Choice.H"
@@ -29,6 +30,33 @@
#else #else
#endif #endif
// ------ this should be in a separate file! -----------------------------------
#ifdef FL_CFG_GFX_OPENGL
#include <FL/Fl_Device.H>
#include <FL/gl.h>
#include "src/cfg_gfx/opengl.H"
Fl_OpenGL_Display_Device *Fl_OpenGL_Display_Device::display_device() {
static Fl_OpenGL_Display_Device *display = new Fl_OpenGL_Display_Device(new Fl_OpenGL_Graphics_Driver());
return display;
};
Fl_OpenGL_Display_Device::Fl_OpenGL_Display_Device(Fl_OpenGL_Graphics_Driver *graphics_driver)
: Fl_Surface_Device(graphics_driver)
{
}
const char *Fl_OpenGL_Display_Device::class_id = "Fl_OpenGL_Display_Device";
#endif
// ------ end of separate file! ------------------------------------------------
#include "cfg_gfx/opengl_rect.cxx"
#if defined(__APPLE__) #if defined(__APPLE__)
uchar *convert_BGRA_to_RGB(uchar *baseAddress, int w, int h, int mByteWidth) uchar *convert_BGRA_to_RGB(uchar *baseAddress, int w, int h, int mByteWidth)
{ {
-199
View File
@@ -41,205 +41,6 @@ extern int fl_gl_load_plugin;
#endif #endif
// ------ this should be in a separate file! -----------------------------------
#ifdef FL_CFG_GFX_OPENGL
#include <FL/Fl_Device.H>
#include <FL/gl.h>
/**
\brief OpenGL pecific graphics class.
*
This class is implemented only on the Mac OS X platform.
*/
class FL_EXPORT Fl_OpenGL_Graphics_Driver : public Fl_Graphics_Driver {
public:
static const char *class_id;
const char *class_name() {return class_id;};
void draw(const char* str, int n, int x, int y) {
gl_draw(str, n, x, y);
}
void color(Fl_Color c) {
gl_color(c);
}
void color(uchar r, uchar g, uchar b) {
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);
glVertex2i(x1, y1);
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);
glVertex2i(x1, y);
glEnd();
point(x1, y);
}
void xyline(int x, int y, int x1, int y2) {
glBegin(GL_LINE_STRIP);
glVertex2i(x, y);
glVertex2i(x1, y);
glVertex2i(x1, y2);
glEnd();
point(x1, y2);
}
void xyline(int x, int y, int x1, int y2, int x3) {
glBegin(GL_LINE_STRIP);
glVertex2i(x, y);
glVertex2i(x1, y);
glVertex2i(x1, y2);
glVertex2i(x3, y2);
glEnd();
point(x3, y2);
}
void yxline(int x, int y, int y1) {
glBegin(GL_LINE_STRIP);
glVertex2i(x, y);
glVertex2i(x, y1);
glEnd();
point(x, y1);
}
void yxline(int x, int y, int y1, int x2) {
glBegin(GL_LINE_STRIP);
glVertex2i(x, y);
glVertex2i(x, y1);
glVertex2i(x2, y1);
glEnd();
point(x2, y1);
}
void yxline(int x, int y, int y1, int x2, int y3) {
glBegin(GL_LINE_STRIP);
glVertex2i(x, y);
glVertex2i(x, y1);
glVertex2i(x2, y1);
glVertex2i(x2, y3);
glEnd();
point(x2, y3);
}
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 loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) {
glBegin(GL_LINE_LOOP);
glVertex2i(x0, y0);
glVertex2i(x1, y1);
glVertex2i(x2, y2);
glVertex2i(x3, y3);
glEnd();
}
void polygon(int x0, int y0, int x1, int y1, int x2, int y2) {
glBegin(GL_POLYGON);
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();
}
void push_clip(int x, int y, int w, int h) {
// TODO: implement OpenGL clipping
if (rstackptr < region_stack_max) rstack[++rstackptr] = 0L;
else Fl::warning("Fl_OpenGL_Graphics_Driver::push_clip: clip stack overflow!\n");
}
int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H) {
// TODO: implement OpenGL clipping
X = x; Y = y; W = w, H = h;
return 0;
}
int not_clipped(int x, int y, int w, int h) {
// TODO: implement OpenGL clipping
return 1;
}
void push_no_clip() {
// TODO: implement OpenGL clipping
if (rstackptr < region_stack_max) rstack[++rstackptr] = 0;
else Fl::warning("Fl_OpenGL_Graphics_Driver::push_no_clip: clip stack overflow!\n");
restore_clip();
}
void pop_clip() {
// TODO: implement OpenGL clipping
if (rstackptr > 0) {
rstackptr--;
} else Fl::warning("Fl_OpenGL_Graphics_Driver::pop_clip: clip stack underflow!\n");
restore_clip();
}
void restore_clip() {
// TODO: implement OpenGL clipping
fl_clip_state_number++;
}
};
const char *Fl_OpenGL_Graphics_Driver::class_id = "Fl_OpenGL_Graphics_Driver";
Fl_OpenGL_Display_Device *Fl_OpenGL_Display_Device::display_device() {
static Fl_OpenGL_Display_Device *display = new Fl_OpenGL_Display_Device(new Fl_OpenGL_Graphics_Driver());
return display;
};
Fl_OpenGL_Display_Device::Fl_OpenGL_Display_Device(Fl_OpenGL_Graphics_Driver *graphics_driver)
: Fl_Surface_Device(graphics_driver)
{
}
const char *Fl_OpenGL_Display_Device::class_id = "Fl_OpenGL_Display_Device";
#endif
// ------ end of separate file! ------------------------------------------------
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// The symbol SWAP_TYPE defines what is in the back buffer after doing // The symbol SWAP_TYPE defines what is in the back buffer after doing
+5
View File
@@ -50,6 +50,7 @@ void Fl_Graphics_Driver::restore_clip() {
fl_clip_state_number++; fl_clip_state_number++;
} }
void Fl_Graphics_Driver::clip_region(Fl_Region r) { void Fl_Graphics_Driver::clip_region(Fl_Region r) {
Fl_Region oldr = rstack[rstackptr]; Fl_Region oldr = rstack[rstackptr];
if (oldr) XDestroyRegion(oldr); if (oldr) XDestroyRegion(oldr);
@@ -57,6 +58,7 @@ void Fl_Graphics_Driver::clip_region(Fl_Region r) {
fl_restore_clip(); fl_restore_clip();
} }
Fl_Region Fl_Graphics_Driver::clip_region() { Fl_Region Fl_Graphics_Driver::clip_region() {
return rstack[rstackptr]; return rstack[rstackptr];
} }
@@ -87,14 +89,17 @@ Fl_Region Fl_Graphics_Driver::clip_region() {
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
#ifdef FL_CFG_GFX_QUARTZ #ifdef FL_CFG_GFX_QUARTZ
# include "cfg_gfx/quartz_rect.cxx" # include "cfg_gfx/quartz_rect.cxx"
#endif #endif
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifdef FL_CFG_GFX_GDI #ifdef FL_CFG_GFX_GDI
// --- line and polygon drawing with integer coordinates // --- line and polygon drawing with integer coordinates