コード例 #1
0
ファイル: video_player_smk.cpp プロジェクト: Nitrus/twin
void VideoPlayerSmacker::play(Common::SeekableReadStream *stream) {
	 // TODO skip video events
	while (!_smkDecoder->endOfVideo()) {

		if (_smkDecoder->needsUpdate()) {
			const Graphics::Surface *frame = _smkDecoder->decodeNextFrame();

			if (!frame) {
				continue;
			}

			if (_smkDecoder->hasDirtyPalette()) {
				setupPalette();
			}

			// TODO update frame to screen
			//((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h)

			g_system->updateScreen();
		}
		g_system->delayMillis(10);
	}

	_smkDecoder->close();
}
コード例 #2
0
ファイル: screen.cpp プロジェクト: jk-ozlabs/fbterm
void Screen::switchVc(bool enter)
{
	mOffsetCur = 0;
	setupOffset();

	setupPalette(!enter);
	if (enter && mPalette) eraseMargin(true, mRows);
}
コード例 #3
0
ファイル: btgGL.cpp プロジェクト: Almamu/homeworld
void btgGLInit3D(CView *pView)
{
	oldRect = drawRect;

	pView->GetClientRect(&drawRect);

	if (oldRect != drawRect)
	{
		if (hGLDeviceContext != NULL)
		{
			wglMakeCurrent(NULL, NULL);
			wglDeleteContext(hGLRenderContext);
			hGLRenderContext = 0;
		}
	}

	hGLDeviceContext = wglGetCurrentDC();
	if (hGLDeviceContext == NULL || hGLRenderContext == 0)
	{
		hGLDeviceContext = ::GetDC(pView->GetSafeHwnd());

		setupPixelFormat(hGLDeviceContext);
		setupPalette(hGLDeviceContext);
		hGLRenderContext = wglCreateContext(hGLDeviceContext);
		wglMakeCurrent(hGLDeviceContext, hGLRenderContext);

		auxInitPosition(0, 0, drawRect.right - drawRect.left, drawRect.bottom - drawRect.top);
		auxInitDisplayMode(AUX_RGB);
	}
	else
	{
		//wglMakeCurrent(hGLDeviceContext, hGLRenderContext);
	}

	CBTGDoc* pDoc = (CBTGDoc*)pView->GetDocument();
	glClearColor((GLfloat)pDoc->mBGRed / 255.0f,
				 (GLfloat)pDoc->mBGGreen / 255.0f,
				 (GLfloat)pDoc->mBGBlue / 255.0f,
				 1.0f);
	glClear(GL_COLOR_BUFFER_BIT);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(50.0, (float)(drawRect.right - drawRect.left) / (float)(drawRect.bottom - drawRect.top), 1.0, 2000.0);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	btgGLRecalc3DCamera();
	gluLookAt(eye[0], eye[1], eye[2],
			  look[0], look[1], look[2],
			  0.0, 0.0, 1.0);

	glDisable(GL_LIGHTING);
	glDisable(GL_CULL_FACE);
	glDisable(GL_DEPTH_TEST);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
}
コード例 #4
0
ファイル: btgGL.cpp プロジェクト: Almamu/homeworld
void btgGLInit(CView *pView)
{
	oldRect = drawRect;

	pView->GetClientRect(&drawRect);

	if(oldRect != drawRect)
	{
		if (hGLDeviceContext != NULL)
		{
			wglMakeCurrent(NULL, NULL);
			wglDeleteContext(hGLRenderContext);
			hGLRenderContext = 0;
		}
	}

	hGLDeviceContext = wglGetCurrentDC();
	if (hGLDeviceContext == NULL || hGLRenderContext == 0)
	{
		hGLDeviceContext = ::GetDC(pView->GetSafeHwnd());

		setupPixelFormat(hGLDeviceContext);
		setupPalette(hGLDeviceContext);
		hGLRenderContext = wglCreateContext(hGLDeviceContext);  //create GL render context and select into window
		wglMakeCurrent(hGLDeviceContext, hGLRenderContext);

		//create the viewport for rendering
		auxInitPosition(0, 0, drawRect.right - drawRect.left, drawRect.bottom - drawRect.top);
		//set mode (direct color)
		auxInitDisplayMode(AUX_RGB);
	}
	else
	{
		//wglMakeCurrent(hGLDeviceContext, hGLRenderContext);
	}

	CBTGDoc* pDoc = (CBTGDoc*)pView->GetDocument();
	glClearColor((GLfloat)pDoc->mBGRed / 255.0f,
				 (GLfloat)pDoc->mBGGreen / 255.0f,
				 (GLfloat)pDoc->mBGBlue / 255.0f,
				 1.0f);
	glClear(GL_COLOR_BUFFER_BIT);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	gluOrtho2D(0, drawRect.right - drawRect.left, 0, drawRect.bottom - drawRect.top);
	glDisable(GL_LIGHTING);
	glDisable(GL_CULL_FACE);
	glDisable(GL_DEPTH_TEST);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
}
コード例 #5
0
	void OGLWindow::createContexts(HWND hWnd, bool StencilBufferEnabled)
	{
		hWND_ = hWnd;

		hDC_ = GetDC(hWND_);
		SetupPixelFormat(hDC_, StencilBufferEnabled);
		setupPalette();

		// create rendering context and make it current
		if(! (hRC_ = wglCreateContext(hDC_)))
			throw CantInitialize ();

		if(! wglMakeCurrent(hDC_, hRC_))
			throw CantInitialize ();

		OnCreate();
	}
コード例 #6
0
ファイル: medit.c プロジェクト: arthurlevy/FreeFempp
int medit1() {
  pScene   scene;
  pMesh    mesh;
  int      k;
  clock_t  ct;

  /* create grafix */
  fprintf(stdout,"\n medit1() \n");
  fprintf(stdout,"\n Building scene(s)\n");
  ct = clock();
  for (k=0; k<cv.nbs; k++) {
    if ( !cv.scene[k] ) {
      cv.scene[k] = (pScene)M_calloc(1,sizeof(Scene),"medit1.scene");
      if ( !cv.scene[k] )  return(0);
    }
    scene = cv.scene[k];
    if ( !cv.mesh[k] ) {
      cv.mesh[k] = (pMesh)M_calloc(1,sizeof(Mesh),"medit1.mesh");
      if ( !cv.mesh[k] )  return(0);
    }
    mesh  = cv.mesh[k];

    fprintf(stdout,"  Creating scene %d\n",k+1);
    parsop(scene,mesh);
    meshRef(scene,mesh);
    matSort(scene);
    
    if ( option == ISOSURF ) {
	  if ( !mesh->nbb ) return(0);
      setupPalette(scene,mesh);
	  tetraIsoPOVray(scene,mesh);
	}
    else if ( !createScene(scene,k) ) {
      fprintf(stderr,"  ## Unable to create scene\n");
      return(0);
    }
  }
  ct = difftime(clock(),ct);
  fprintf(stdout,"  Scene seconds:     %.2f\n",(double)ct/(double)CLOCKS_PER_SEC);

  return(1);
}
コード例 #7
0
    Canvas( QwtPlot *plot = NULL ):
        QwtPlotCanvas( plot )
    {
        // The backing store is important, when working with widget
        // overlays ( f.e rubberbands for zooming ).
        // Here we don't have them and the internal
        // backing store of QWidget is good enough.

        setPaintAttribute( QwtPlotCanvas::BackingStore, false );
        setBorderRadius( 10 );

        if ( QwtPainter::isX11GraphicsSystem() )
        {
#if QT_VERSION < 0x050000
            // Even if not liked by the Qt development, Qt::WA_PaintOutsidePaintEvent
            // works on X11. This has a nice effect on the performance.

            setAttribute( Qt::WA_PaintOutsidePaintEvent, true );
#endif

            // Disabling the backing store of Qt improves the performance
            // for the direct painter even more, but the canvas becomes
            // a native window of the window system, receiving paint events
            // for resize and expose operations. Those might be expensive
            // when there are many points and the backing store of
            // the canvas is disabled. So in this application
            // we better don't disable both backing stores.

            if ( testPaintAttribute( QwtPlotCanvas::BackingStore ) )
            {
                setAttribute( Qt::WA_PaintOnScreen, true );
                setAttribute( Qt::WA_NoSystemBackground, true );
            }
        }

        setupPalette();
    }
コード例 #8
0
ファイル: videolib.c プロジェクト: fniephaus/squeak
BOOLEAN setupDevice(Device device) {
   BOOLEAN change;
   fprintf(stdout, "- Seting up device %p\n", device);


   /* check (again) for a valid device */
   if (!(device->vcapability.type & VID_TYPE_CAPTURE)) {
      fprintf(stdout, "    * The device can't capture video\n");
      return FALSE;
   }

   if (device->vcapability.channels == 0) {
      fprintf(stdout, "    * The device hasn't inputs\n");
      return FALSE;
   }


   /* ---------------------------------------------------------------------- */
   /* let's try to change the capture width & height */
   change = FALSE;
   if (EINTR_RETRY(xioctl(device->fd, VIDIOCGWIN, &device->vwindow)) < 0) {
      perror("VIDIOCGWIN1");
      return FALSE;
   }

   if (device->desiredWidth && (device->vwindow.width != device->desiredWidth)) {
     fprintf(stdout, "    - Changing the width from %d to %d\n", device->vwindow.width, device->desiredWidth);

     device->vwindow.width = device->desiredWidth;
     change = TRUE;
   }
   if (device->desiredHeight && (device->vwindow.height != device->desiredHeight)) {
     fprintf(stdout, "    - Changing the height from %d to %d\n", device->vwindow.height, device->desiredHeight);

     device->vwindow.height = device->desiredHeight;
     change = TRUE;
   }

   if (change) {
      if (EINTR_RETRY(xioctl(device->fd, VIDIOCSWIN, &device->vwindow)) < 0) {
         perror("VIDIOCGWIN2");
         return FALSE;
      }

      if (EINTR_RETRY(xioctl(device->fd, VIDIOCGWIN, &device->vwindow)) < 0) {
         perror("VIDIOCGWIN3");
         return FALSE;
      }
      if (device->desiredWidth != device->vwindow.width) {
         fprintf(stdout,
                 "    * The device can't change the capture width (now=%d)\n",
                 device->vwindow.width);
         return FALSE;
      }
      if (device->desiredHeight != device->vwindow.height) {
         fprintf(stdout,
                 "    * The device can't change the capture height (now=%d)\n",
                 device->vwindow.height);
         return FALSE;
      }

   }

   fprintf(stdout,
           "    - Extent=%d@%d\n",
           device->vwindow.width,
           device->vwindow.height);

   if (EINTR_RETRY(xioctl(device->fd, VIDIOCGPICT, &device->vpicture)) < 0) {
      perror("VIDIOCGPICT");
      return FALSE;
   }

   fprintf(stdout,
           "    - Brightness=%d, Contrast=%d, Saturation=%d, Hue=%d\n",
           getBrightness(device),
           getContrast(device),
           getSaturation(device),
           getHue(device));
   /* ---------------------------------------------------------------------- */


   /* ---------------------------------------------------------------------- */
   if (!setupPalette(device)) {
      return FALSE;
   }
   /* ---------------------------------------------------------------------- */


   device->imageSize = (int) device->vwindow.width * device->vwindow.height * (paletteBytesPerPixel(device->vpicture.palette));
   device->buffer24  = (char*) malloc(device->vwindow.width * device->vwindow.height * 3);

   if (device->forceRead) {
      fprintf(stdout, "    - Capturing using (forced) read()\n");
      if (!switchToRead(device)) {
         return FALSE;
      }
   }
   else {
      setupMMap(device);

      if (device->usingMMap) {
         fprintf(stdout, "    - Capturing using mmap()\n");
         if (!startCaptureInBuffers(device)) {
            fprintf(stdout, "    * Falling back to read()\n");
            if (!switchToRead(device)) {
               return FALSE;
            }
         }
      }
      else {
         fprintf(stdout, "    - Capturing using read()\n");
         if (!switchToRead(device)) {
            return FALSE;
         }
      }
   }

   return TRUE;
}
コード例 #9
0
ファイル: indextex.c プロジェクト: OS2World/LIB-VIDEO-MGL
LRESULT APIENTRY
WndProc(
    HWND hWnd,
    UINT message,
    WPARAM wParam,
    LPARAM lParam)
{
    switch (message) {
    case WM_CREATE:
	/*
	** Set up for OpenGL rendering.  Bind the rendering context to
	** the same device context that the palette will be selected into.
	*/
	hDC = GetDC(hWnd);
	setupPixelFormat(hDC);
	setupPalette(hDC);
	hGLRC = wglCreateContext(hDC);
	wglMakeCurrent(hDC, hGLRC);
	if (!checkExtension("SGI_index_texture")) {
	    char message[1024];

	    sprintf(message,
		"SGI_index_texture is required by this application\n"
		"but is not supported by the current OpenGL renderer.\n\n"
		"Vendor: %s\nRenderer: %s\nVersion: %s",
		glGetString(GL_VENDOR),
		glGetString(GL_RENDERER),
		glGetString(GL_VERSION));

	    wglMakeCurrent(NULL, NULL);
	    wglDeleteContext(hGLRC);
	    hGLRC = NULL;

	    MessageBox(hWnd, message, "OpenGL Extension Required",
		    MB_ICONERROR | MB_OK);
	    exit(1);
	}
	init();
	idleFunc = doRedraw;
	return 0;
    case WM_DESTROY:
	/*
	** Finish OpenGL rendering.
	*/
	idleFunc = NULL;
	if (hGLRC) {
	    wglMakeCurrent(NULL, NULL);
	    wglDeleteContext(hGLRC);
	}
	ReleaseDC(hWnd, hDC);
	PostQuitMessage(0);
	return 0;
    case WM_SIZE:
	if (hGLRC) {
	    winWidth = (int) LOWORD(lParam);
	    winHeight = (int) HIWORD(lParam);
	    resize();
	    return 0;
	}
    case WM_PALETTECHANGED:
	/*
	** Update palette mapping if this *is not* the active window.
	*/
	if (hGLRC && hPalette && (HWND) wParam != hWnd) {
	    UnrealizeObject(hPalette);
	    SelectPalette(hDC, hPalette, FALSE);
	    RealizePalette(hDC);
	    redraw();
	    return 0;
	}
	break;
    case WM_QUERYNEWPALETTE:
	/*
	** Update palette mapping if this *is* the active window.
	*/
	if (hGLRC && hPalette) {
	    UnrealizeObject(hPalette);
	    SelectPalette(hDC, hPalette, FALSE);
	    RealizePalette(hDC);
	    redraw();
	    return TRUE;
	}
	break;
    case WM_PAINT:
	/*
	** Update the window.  Don't use the device context returned by
	** BeginPaint as it won't have the right palette selected into it.
	*/
	if (hGLRC) {
	    PAINTSTRUCT ps;

	    BeginPaint(hWnd, &ps);
	    redraw();
	    EndPaint(hWnd, &ps);
	    return 0;
	}
	break;
    case WM_CHAR:
	switch ((int)wParam) {
	case VK_ESCAPE:
	    DestroyWindow(hWnd);
	    return 0;
	default:
	    break;
	}
	break;
    default:
	break;
    }

    /* Deal with any unprocessed messages */
    return DefWindowProc(hWnd, message, wParam, lParam);
}
コード例 #10
0
ファイル: gui_hof.cpp プロジェクト: CatalystG/scummvm
int GUI_HoF::optionsButton(Button *button) {
	PauseTimer pause(*_vm->_timer);

	_restartGame = false;
	_reloadTemporarySave = false;

	updateButton(&_vm->_inventoryButtons[0]);

	if (!_screen->isMouseVisible() && button)
		return 0;

	_vm->showMessage(0, 0xCF);

	if (_vm->_mouseState < -1) {
		_vm->_mouseState = -1;
		_screen->setMouseCursor(1, 1, _vm->getShapePtr(0));
		return 0;
	}

	int oldHandItem = _vm->_itemInHand;
	_screen->setMouseCursor(0, 0, _vm->getShapePtr(0));
	_vm->displayInvWsaLastFrame();
	_displayMenu = true;

	for (uint i = 0; i < ARRAYSIZE(_menuButtons); ++i) {
		_menuButtons[i].data0Val1 = _menuButtons[i].data1Val1 = _menuButtons[i].data2Val1 = 4;
		_menuButtons[i].data0Callback = _redrawShadedButtonFunctor;
		_menuButtons[i].data1Callback = _menuButtons[i].data2Callback = _redrawButtonFunctor;
	}

	initMenuLayout(_mainMenu);
	initMenuLayout(_gameOptions);
	initMenuLayout(_audioOptions);
	initMenuLayout(_choiceMenu);
	_loadMenu.numberOfItems = 6;
	initMenuLayout(_loadMenu);
	initMenuLayout(_saveMenu);
	initMenuLayout(_savenameMenu);
	initMenuLayout(_deathMenu);

	_currentMenu = &_mainMenu;

	if (_vm->_menuDirectlyToLoad) {
		backUpPage1(_vm->_screenBuffer);
		setupPalette();

		_loadedSave = false;

		loadMenu(0);

		if (_loadedSave) {
			if (_restartGame)
				_vm->_itemInHand = kItemNone;
		} else {
			restorePage1(_vm->_screenBuffer);
			restorePalette();
		}

		resetState(-1);
		_vm->_menuDirectlyToLoad = false;
		return 0;
	}

	if (!button) {
		_currentMenu = &_deathMenu;
		_isDeathMenu = true;
	} else {
		_isDeathMenu = false;
	}

	backUpPage1(_vm->_screenBuffer);
	setupPalette();
	initMenu(*_currentMenu);
	_madeSave = false;
	_loadedSave = false;
	updateAllMenuButtons();

	if (_isDeathMenu) {
		while (!_screen->isMouseVisible())
			_screen->showMouse();
	}

	while (_displayMenu) {
		processHighlights(*_currentMenu);
		getInput();
	}

	if (_vm->_runFlag && !_loadedSave && !_madeSave) {
		restorePalette();
		restorePage1(_vm->_screenBuffer);
	}

	if (_vm->_runFlag)
		updateMenuButton(&_vm->_inventoryButtons[0]);

	resetState(oldHandItem);

	if (!_loadedSave && _reloadTemporarySave) {
		_vm->_unkSceneScreenFlag1 = true;
		_vm->loadGameStateCheck(999);
		//_vm->_saveFileMan->removeSavefile(_vm->getSavegameFilename(999));
		_vm->_unkSceneScreenFlag1 = false;
	}

	return 0;
}
コード例 #11
0
ファイル: scene.c プロジェクト: zzyatlantise/FreeFem-sources
/* new scene */
int createScene (pScene sc, int idmesh) {
	pMesh mesh;
	char data[128];

	/* default */
	mesh = cv.mesh[idmesh];
	if (!quiet) fprintf(stdout, "   Computing 3D scene\n");

	/* set default mode */
	sc->idmesh = idmesh;
	sc->par.xi = sc->par.yi = 10;
	if (option == SCHNAUZER) {
		sc->par.xs = schw;
		sc->par.ys = schh;
	} else {
		if (sc->par.xs == 0) sc->par.xs = 600;

		if (sc->par.ys == 0) sc->par.ys = 600;
	}

	if (!sc->mode) sc->mode = HIDDEN;

	sc->item = 0;
	sc->shrink = 1.0;
	sc->slave = sc->master = -1;
	sc->picked = 0;
	if (mesh->nvn == 0) sc->type ^= S_FLAT;

	if (mesh->ne == 0) sc->item |= S_GEOM;

	/* compute scene depth */
	sc->dmax = sc->dmin = mesh->xmax - mesh->xmin;
	sc->dmax = max(sc->dmax, mesh->ymax - mesh->ymin);
	sc->dmin = min(sc->dmin, mesh->ymax - mesh->ymin);
	if (mesh->dim == 3) {
		sc->dmax = max(sc->dmax, mesh->zmax - mesh->zmin);
		sc->dmin = min(sc->dmin, mesh->zmax - mesh->zmin);
	}

	sc->dmax = fabs(sc->dmax);
	sc->dmin = fabs(sc->dmin);
	if (!sc->par.sunp) {
		sc->par.sunpos[0] *= 2.0 * sc->dmax;
		sc->par.sunpos[1] *= 2.0 * sc->dmax;
		sc->par.sunpos[2] *= 2.0 * sc->dmax;
	}

	sc->par.sunpos[3] = 1.0;

	/* create window */
	glutInitWindowSize(sc->par.xs, sc->par.ys);
	sc->idwin = glutCreateWindow("");
	assert(sc->idwin != 0);
	if (fullscreen) {
		glutFullScreen();
		sc->par.xs = glutGet(GLUT_SCREEN_WIDTH);
		sc->par.ys = glutGet(GLUT_SCREEN_HEIGHT);
	}

	/* set window name */
	sprintf(data, "Medit - [%s] #%d", mesh->name, sc->idwin);
	glutSetWindowTitle(data);
	glutSetIconTitle(data);

	/* required! to change background color */
	glClearColor(sc->par.back[0], sc->par.back[1],
	             sc->par.back[2], sc->par.back[3]);

	/* init perspective */
	sc->persp = initPersp(0, sc->dmax);
	sc->camera = (pCamera)initCamera(sc, Y_AXIS);
	if (mesh->typ == 2) {
		sc->persp->pmode = CAMERA;
		sc->persp->depth *= 0.5;
	}

	/* create default view */
	sc->view = (pTransform)createTransform();
	if (!sc->view) return (0);

	sc->type |= S_RESET + S_DECO;
	sc->clip = (pClip)createClip(sc, mesh);
	if (!sc->clip) return (0);

	sc->cube = (pCube)createCube(sc, mesh);
	if (!sc->cube) return (0);

	/* create menus */
	if (!createMenus(sc, mesh)) return (0);

	/* assign callbacks */
	if (sc->type & S_SCISSOR) {
		glutDisplayFunc(scissorScene);
	} else if (option == SCHNAUZER) {
		glutDisplayFunc(redrawSchnauzer);
	} else if (sc->persp->pmode == CAMERA) {
		glutMouseFunc(mouseCamera);
		glutMotionFunc(motionCamera);
		glutDisplayFunc(redrawScene);
	} else {
		glutMouseFunc(mouse);
		glutMotionFunc(motion);
		glutDisplayFunc(redrawScene);
	}

	glutReshapeFunc(reshapeScene);
	glutKeyboardFunc(keyScene);
	glutSpecialFunc(special);
	glutAttachMenu(GLUT_RIGHT_BUTTON);

	/* create display lists by geom type */
	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
	doLists(sc, mesh);
	sc->glist = geomList(sc, mesh);
	sc->type |= S_FOLLOW;

	/* local stack */
	if (!pilmat) {
		pilmat = (int *)calloc(sc->par.nbmat + 2, sizeof(int));
		if (!pilmat) return (0);
	}

	/* color list */
	setupPalette(sc, mesh);
	sc->stream = NULL;

	initGrafix(sc, mesh);
	return (1);
}
コード例 #12
0
ファイル: cube.c プロジェクト: yangguang-ecnu/smisdk
LRESULT APIENTRY
WndProc(
    HWND hWnd,
    UINT message,
    WPARAM wParam,
    LPARAM lParam)
{
    switch (message) {
    case WM_CREATE:
	/* initialize OpenGL rendering */
	hDC = GetDC(hWnd);
	setupPixelFormat(hDC);
	setupPalette(hDC);
	hGLRC = wglCreateContext(hDC);
	wglMakeCurrent(hDC, hGLRC);
	init();
	return 0;
    case WM_DESTROY:
	/* finish OpenGL rendering */
	if (hGLRC) {
	    wglMakeCurrent(NULL, NULL);
	    wglDeleteContext(hGLRC);
	}
	if (hPalette) {
	    DeleteObject(hPalette);
	}
	ReleaseDC(hWnd, hDC);
	PostQuitMessage(0);
	return 0;
    case WM_SIZE:
	/* track window size changes */
	if (hGLRC) {
	    winWidth = (int) LOWORD(lParam);
	    winHeight = (int) HIWORD(lParam);
	    resize();
	    return 0;
	}
    case WM_PALETTECHANGED:
	/* realize palette if this is *not* the current window */
	if (hGLRC && hPalette && (HWND) wParam != hWnd) {
	    UnrealizeObject(hPalette);
	    SelectPalette(hDC, hPalette, FALSE);
	    RealizePalette(hDC);
	    redraw();
	    break;
	}
	break;
    case WM_QUERYNEWPALETTE:
	/* realize palette if this is the current window */
	if (hGLRC && hPalette) {
	    UnrealizeObject(hPalette);
	    SelectPalette(hDC, hPalette, FALSE);
	    RealizePalette(hDC);
	    redraw();
	    return TRUE;
	}
	break;
    case WM_PAINT:
	{
	    PAINTSTRUCT ps;
	    BeginPaint(hWnd, &ps);
	    if (hGLRC) {
		redraw();
	    }
	    EndPaint(hWnd, &ps);
	    return 0;
	}
	break;
    case WM_CHAR:
	/* handle keyboard input */
	switch ((int)wParam) {
	case VK_ESCAPE:
	    DestroyWindow(hWnd);
	    return 0;
	default:
	    break;
	}
	break;
    default:
	break;
    }
    return DefWindowProc(hWnd, message, wParam, lParam);
}