35 #ifdef G4VIS_BUILD_OPENGLWIN32_DRIVER    51 void G4OpenGLWin32Viewer::SetView (
    58   ::wglMakeCurrent(fHDC,fHGLRC);
    59   G4OpenGLViewer::SetView ();  
    63 void G4OpenGLWin32Viewer::ShowView (
    72   while ( ::PeekMessage(&event, NULL, 0, 0, PM_REMOVE) ) {
    73     ::TranslateMessage(&event);
    74     ::DispatchMessage (&event);
    79 void G4OpenGLWin32Viewer::GetWin32Connection (
    87 void G4OpenGLWin32Viewer::CreateGLWin32Context (
    95 void G4OpenGLWin32Viewer::CreateMainWindow (
   103   static const char className[] = 
"G4OpenGLWin32";
   104   static bool done = 
false;
   107     wc.style = CS_HREDRAW | CS_VREDRAW;
   108     wc.lpfnWndProc = (WNDPROC)WindowProc;
   111     wc.hInstance = ::GetModuleHandle(NULL);
   112     wc.hIcon = LoadIcon  (NULL, IDI_APPLICATION);
   113     wc.hCursor = LoadCursor(NULL,IDC_CROSS);
   114     wc.hbrBackground = NULL;
   115     wc.lpszMenuName = className;
   116     wc.lpszClassName = className;
   117     ::RegisterClass(&wc);
   121   ResizeWindow(fVP.GetWindowSizeHintX(),fVP.GetWindowSizeHintY());
   123   int x_res=GetSystemMetrics(SM_CXSCREEN);
   124   int y_res=GetSystemMetrics(SM_CYSCREEN);
   127   fWindow = ::CreateWindow(className,
fName.c_str(), 
   131                            fVP.GetWindowAbsoluteLocationHintX(x_res),
   132                            fVP.GetWindowAbsoluteLocationHintY(y_res),
   133                getWinWidth(), getWinHeight(),
   135                ::GetModuleHandle(NULL),
   139   ::SetWindowLongPtr(fWindow,GWLP_USERDATA,LONG_PTR(
this));
   142   fHDC = ::GetDC(fWindow);
   143   if( fHDC && (SetWindowPixelFormat(fHDC)==
TRUE) ) {
   144     fHGLRC = ::wglCreateContext(fHDC);
   148     ::wglMakeCurrent(fHDC,fHGLRC);
   151   ::SetForegroundWindow(fWindow);
   152   ::ShowWindow(fWindow,SW_SHOWDEFAULT);
   153   ::UpdateWindow(fWindow);
   154   ::DrawMenuBar(fWindow);
   158 G4OpenGLWin32Viewer::G4OpenGLWin32Viewer (
   159  G4OpenGLSceneHandler& scene
   162 ,G4OpenGLViewer (scene)
   172 G4OpenGLWin32Viewer::~G4OpenGLWin32Viewer (
   179     if(wglGetCurrentContext()!=NULL) wglMakeCurrent(NULL,NULL);
   181       wglDeleteContext(fHGLRC);
   186       ::SetWindowLongPtr(fWindow,GWLP_USERDATA,LONG(NULL));
   187       if(fHDC) ::ReleaseDC(fWindow,fHDC);
   188       ::DestroyWindow(fWindow);
   194 LRESULT CALLBACK G4OpenGLWin32Viewer::WindowProc ( 
   233   return DefWindowProc(aWindow,aMessage,aWParam,aLParam);
   237 bool G4OpenGLWin32Viewer::SetWindowPixelFormat(
   245   PIXELFORMATDESCRIPTOR pfd;
   246   pfd.nSize = 
sizeof(PIXELFORMATDESCRIPTOR);
   253   pfd.iPixelType = PFD_TYPE_RGBA;
   264   pfd.cAccumRedBits = 16;
   265   pfd.cAccumGreenBits = 16;
   266   pfd.cAccumBlueBits = 16;
   267   pfd.cAccumAlphaBits = 0;
   269   pfd.cStencilBits = 8;
   271   pfd.iLayerType = PFD_MAIN_PLANE;
   274   pfd.dwVisibleMask = 0;
   275   pfd.dwDamageMask = 0;
   277   int pixelIndex = ::ChoosePixelFormat(aHdc,&pfd);
   280     if (::DescribePixelFormat(aHdc, 
   282                   sizeof(PIXELFORMATDESCRIPTOR), 
   287   if (::SetPixelFormat(aHdc,pixelIndex,&pfd)==
FALSE) 
return false;