Skip to content

Commit

Permalink
More OpenGL under Windows changes - now keep track of window type and
Browse files Browse the repository at this point in the history
select the corresponding color palette...


git-svn-id: file:///fltk/svn/fltk/trunk@74 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
michaelrsweet committed Nov 8, 1998
1 parent 32d18a3 commit dfa8c05
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 18 deletions.
7 changes: 5 additions & 2 deletions FL/Fl_Gl_Window.H
@@ -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).
//
Expand Down Expand Up @@ -27,6 +27,9 @@

#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_Window : public Fl_Window {
Expand Down Expand Up @@ -84,5 +87,5 @@ public:
#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 $".
//
6 changes: 4 additions & 2 deletions src/Fl_Gl_Window.cxx
@@ -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).
//
Expand Down Expand Up @@ -150,6 +150,7 @@ void Fl_Gl_Window::make_current() {

# if USE_COLORMAP
if (fl_gl_palette) {
fl_GetDC(fl_xid(this));
SelectPalette(fl_gc, fl_gl_palette, FALSE);
RealizePalette(fl_gc);
}
Expand Down Expand Up @@ -314,6 +315,7 @@ Fl_Gl_Window::~Fl_Gl_Window() {
void Fl_Gl_Window::init() {
end(); // we probably don't want any children
box(FL_NO_BOX);
type(FL_GL_WINDOW);
mode_ = FL_RGB | FL_DEPTH | FL_DOUBLE;
alist = 0;
context = 0;
Expand All @@ -327,5 +329,5 @@ void Fl_Gl_Window::draw_overlay() {}
#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 $".
//
15 changes: 9 additions & 6 deletions src/Fl_win32.cxx
@@ -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).
//
Expand Down Expand Up @@ -227,7 +227,7 @@ static int ms2fltk(int vk, int extended) {
}

#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

static Fl_Window* resize_bug_fix;
Expand Down Expand Up @@ -388,17 +388,20 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
#if USE_COLORMAP
case WM_QUERYNEWPALETTE :
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;

case WM_PALETTECHANGED:
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;

case WM_CREATE :
fl_GetDC(hWnd);
fl_select_palette();
fl_select_palette(window->type() == FL_GL_WINDOW);
break;

#endif
Expand Down Expand Up @@ -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 $".
//
26 changes: 18 additions & 8 deletions src/fl_color_win32.cxx
@@ -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).
//
Expand Down Expand Up @@ -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

HPALETTE
fl_select_palette(void)
fl_select_palette(int gl)
{
static char beenhere;
if (!beenhere) {
int i;

beenhere = 1;

//if (GetDeviceCaps(fl_gc, BITSPIXEL) > 8) return NULL;
Expand All @@ -208,7 +210,7 @@ fl_select_palette(void)

// 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].peGreen = (fl_cmap[i] >> 16) & 255;
pPal->palPalEntry[i].peBlue = (fl_cmap[i] >> 8) & 255;
Expand All @@ -223,7 +225,7 @@ fl_select_palette(void)
// and doing OpenGL on anything less than 8-bits is just asking for
// 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].peGreen = 255 * ((i >> 2) & 7) / 7;
pPal->palPalEntry[i].peBlue = 255 * (i & 3) / 3;
Expand All @@ -233,15 +235,23 @@ fl_select_palette(void)
fl_gl_palette = CreatePalette(pPal);
#endif // HAVE_GL
}
if (fl_palette) {
SelectPalette(fl_gc, fl_palette, FALSE);
RealizePalette(fl_gc);
if (gl) {
if (fl_gl_palette) {
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;
}

#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 $".
//

0 comments on commit dfa8c05

Please sign in to comment.