mirror of
https://github.com/fltk/fltk.git
synced 2026-06-05 08:06:35 +08:00
More OpenGL under Windows changes - now keep track of window type and
select the corresponding color palette... git-svn-id: file:///fltk/svn/fltk/trunk@74 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+5
-2
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// "$Id: Fl_Gl_Window.H,v 1.3 1998/10/21 14:19:10 mike Exp $"
|
// "$Id: Fl_Gl_Window.H,v 1.4 1998/11/08 16:37:18 mike Exp $"
|
||||||
//
|
//
|
||||||
// OpenGL header file for the Fast Light Tool Kit (FLTK).
|
// OpenGL header file for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
@@ -27,6 +27,9 @@
|
|||||||
|
|
||||||
#include "Fl_Window.H"
|
#include "Fl_Window.H"
|
||||||
|
|
||||||
|
// type() value for OpenGL window...
|
||||||
|
#define FL_GL_WINDOW (FL_WINDOW + 1)
|
||||||
|
|
||||||
class Fl_Gl_Choice; // structure to hold result of glXChooseVisual
|
class Fl_Gl_Choice; // structure to hold result of glXChooseVisual
|
||||||
|
|
||||||
class Fl_Gl_Window : public Fl_Window {
|
class Fl_Gl_Window : public Fl_Window {
|
||||||
@@ -84,5 +87,5 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: Fl_Gl_Window.H,v 1.3 1998/10/21 14:19:10 mike Exp $".
|
// End of "$Id: Fl_Gl_Window.H,v 1.4 1998/11/08 16:37:18 mike Exp $".
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// "$Id: Fl_Gl_Window.cxx,v 1.8 1998/11/08 15:55:22 mike Exp $"
|
// "$Id: Fl_Gl_Window.cxx,v 1.9 1998/11/08 16:37:19 mike Exp $"
|
||||||
//
|
//
|
||||||
// OpenGL window code for the Fast Light Tool Kit (FLTK).
|
// OpenGL window code for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
@@ -150,6 +150,7 @@ void Fl_Gl_Window::make_current() {
|
|||||||
|
|
||||||
# if USE_COLORMAP
|
# if USE_COLORMAP
|
||||||
if (fl_gl_palette) {
|
if (fl_gl_palette) {
|
||||||
|
fl_GetDC(fl_xid(this));
|
||||||
SelectPalette(fl_gc, fl_gl_palette, FALSE);
|
SelectPalette(fl_gc, fl_gl_palette, FALSE);
|
||||||
RealizePalette(fl_gc);
|
RealizePalette(fl_gc);
|
||||||
}
|
}
|
||||||
@@ -314,6 +315,7 @@ Fl_Gl_Window::~Fl_Gl_Window() {
|
|||||||
void Fl_Gl_Window::init() {
|
void Fl_Gl_Window::init() {
|
||||||
end(); // we probably don't want any children
|
end(); // we probably don't want any children
|
||||||
box(FL_NO_BOX);
|
box(FL_NO_BOX);
|
||||||
|
type(FL_GL_WINDOW);
|
||||||
mode_ = FL_RGB | FL_DEPTH | FL_DOUBLE;
|
mode_ = FL_RGB | FL_DEPTH | FL_DOUBLE;
|
||||||
alist = 0;
|
alist = 0;
|
||||||
context = 0;
|
context = 0;
|
||||||
@@ -327,5 +329,5 @@ void Fl_Gl_Window::draw_overlay() {}
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: Fl_Gl_Window.cxx,v 1.8 1998/11/08 15:55:22 mike Exp $".
|
// End of "$Id: Fl_Gl_Window.cxx,v 1.9 1998/11/08 16:37:19 mike Exp $".
|
||||||
//
|
//
|
||||||
|
|||||||
+9
-6
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// "$Id: Fl_win32.cxx,v 1.14 1998/11/08 14:39:09 mike Exp $"
|
// "$Id: Fl_win32.cxx,v 1.15 1998/11/08 16:37:20 mike Exp $"
|
||||||
//
|
//
|
||||||
// WIN32-specific code for the Fast Light Tool Kit (FLTK).
|
// WIN32-specific code for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
@@ -227,7 +227,7 @@ static int ms2fltk(int vk, int extended) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if USE_COLORMAP
|
#if USE_COLORMAP
|
||||||
extern HPALETTE fl_select_palette(); // in fl_color_win32.C
|
extern HPALETTE fl_select_palette(int gl); // in fl_color_win32.C
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Fl_Window* resize_bug_fix;
|
static Fl_Window* resize_bug_fix;
|
||||||
@@ -388,17 +388,20 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||||||
#if USE_COLORMAP
|
#if USE_COLORMAP
|
||||||
case WM_QUERYNEWPALETTE :
|
case WM_QUERYNEWPALETTE :
|
||||||
fl_GetDC(hWnd);
|
fl_GetDC(hWnd);
|
||||||
if (fl_select_palette()) InvalidateRect(hWnd, NULL, FALSE);
|
if (fl_select_palette(window->type() == FL_GL_WINDOW))
|
||||||
|
InvalidateRect(hWnd, NULL, FALSE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_PALETTECHANGED:
|
case WM_PALETTECHANGED:
|
||||||
fl_GetDC(hWnd);
|
fl_GetDC(hWnd);
|
||||||
if ((HWND)wParam != hWnd && fl_select_palette()) UpdateColors(fl_gc);
|
if ((HWND)wParam != hWnd &&
|
||||||
|
fl_select_palette(window->type() == FL_GL_WINDOW))
|
||||||
|
UpdateColors(fl_gc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_CREATE :
|
case WM_CREATE :
|
||||||
fl_GetDC(hWnd);
|
fl_GetDC(hWnd);
|
||||||
fl_select_palette();
|
fl_select_palette(window->type() == FL_GL_WINDOW);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -813,5 +816,5 @@ void Fl_Window::flush() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: Fl_win32.cxx,v 1.14 1998/11/08 14:39:09 mike Exp $".
|
// End of "$Id: Fl_win32.cxx,v 1.15 1998/11/08 16:37:20 mike Exp $".
|
||||||
//
|
//
|
||||||
|
|||||||
+18
-8
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// "$Id: fl_color_win32.cxx,v 1.4 1998/11/08 15:55:23 mike Exp $"
|
// "$Id: fl_color_win32.cxx,v 1.5 1998/11/08 16:37:21 mike Exp $"
|
||||||
//
|
//
|
||||||
// WIN32 color functions for the Fast Light Tool Kit (FLTK).
|
// WIN32 color functions for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
@@ -187,10 +187,12 @@ void Fl::get_color(Fl_Color i, uchar &red, uchar &green, uchar &blue) {
|
|||||||
// Thanks to Michael Sweet @ Easy Software Products for this
|
// Thanks to Michael Sweet @ Easy Software Products for this
|
||||||
|
|
||||||
HPALETTE
|
HPALETTE
|
||||||
fl_select_palette(void)
|
fl_select_palette(int gl)
|
||||||
{
|
{
|
||||||
static char beenhere;
|
static char beenhere;
|
||||||
if (!beenhere) {
|
if (!beenhere) {
|
||||||
|
int i;
|
||||||
|
|
||||||
beenhere = 1;
|
beenhere = 1;
|
||||||
|
|
||||||
//if (GetDeviceCaps(fl_gc, BITSPIXEL) > 8) return NULL;
|
//if (GetDeviceCaps(fl_gc, BITSPIXEL) > 8) return NULL;
|
||||||
@@ -208,7 +210,7 @@ fl_select_palette(void)
|
|||||||
|
|
||||||
// Build 256 colors from the standard FLTK colormap...
|
// Build 256 colors from the standard FLTK colormap...
|
||||||
|
|
||||||
for (int i = 0; i < nColors; i ++) {
|
for (i = 0; i < nColors; i ++) {
|
||||||
pPal->palPalEntry[i].peRed = (fl_cmap[i] >> 24) & 255;
|
pPal->palPalEntry[i].peRed = (fl_cmap[i] >> 24) & 255;
|
||||||
pPal->palPalEntry[i].peGreen = (fl_cmap[i] >> 16) & 255;
|
pPal->palPalEntry[i].peGreen = (fl_cmap[i] >> 16) & 255;
|
||||||
pPal->palPalEntry[i].peBlue = (fl_cmap[i] >> 8) & 255;
|
pPal->palPalEntry[i].peBlue = (fl_cmap[i] >> 8) & 255;
|
||||||
@@ -223,7 +225,7 @@ fl_select_palette(void)
|
|||||||
// and doing OpenGL on anything less than 8-bits is just asking for
|
// and doing OpenGL on anything less than 8-bits is just asking for
|
||||||
// disappointment!
|
// disappointment!
|
||||||
|
|
||||||
for (int i = 0; i < nColors; i ++) {
|
for (i = 0; i < nColors; i ++) {
|
||||||
pPal->palPalEntry[i].peRed = 255 * ((i >> 5) & 7) / 7;
|
pPal->palPalEntry[i].peRed = 255 * ((i >> 5) & 7) / 7;
|
||||||
pPal->palPalEntry[i].peGreen = 255 * ((i >> 2) & 7) / 7;
|
pPal->palPalEntry[i].peGreen = 255 * ((i >> 2) & 7) / 7;
|
||||||
pPal->palPalEntry[i].peBlue = 255 * (i & 3) / 3;
|
pPal->palPalEntry[i].peBlue = 255 * (i & 3) / 3;
|
||||||
@@ -233,9 +235,17 @@ fl_select_palette(void)
|
|||||||
fl_gl_palette = CreatePalette(pPal);
|
fl_gl_palette = CreatePalette(pPal);
|
||||||
#endif // HAVE_GL
|
#endif // HAVE_GL
|
||||||
}
|
}
|
||||||
if (fl_palette) {
|
if (gl) {
|
||||||
SelectPalette(fl_gc, fl_palette, FALSE);
|
if (fl_gl_palette) {
|
||||||
RealizePalette(fl_gc);
|
SelectPalette(fl_gc, fl_gl_palette, FALSE);
|
||||||
|
RealizePalette(fl_gc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (fl_palette) {
|
||||||
|
SelectPalette(fl_gc, fl_palette, FALSE);
|
||||||
|
RealizePalette(fl_gc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return fl_palette;
|
return fl_palette;
|
||||||
}
|
}
|
||||||
@@ -243,5 +253,5 @@ fl_select_palette(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: fl_color_win32.cxx,v 1.4 1998/11/08 15:55:23 mike Exp $".
|
// End of "$Id: fl_color_win32.cxx,v 1.5 1998/11/08 16:37:21 mike Exp $".
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user