}
bool OpenGLDisplay::initialize(){  sizeX = 240;  sizeY = 160;  switch(videoOption) {  case VIDEO_1X:    surfaceSizeX = sizeX;    surfaceSizeY = sizeY;    break;  case VIDEO_2X:    surfaceSizeX = sizeX * 2;    surfaceSizeY = sizeY * 2;    break;  case VIDEO_3X:    surfaceSizeX = sizeX * 3;    surfaceSizeY = sizeY * 3;    break;  case VIDEO_4X:    surfaceSizeX = sizeX * 4;    surfaceSizeY = sizeY * 4;    break;  case VIDEO_320x240:  case VIDEO_640x480:  case VIDEO_800x600:  case VIDEO_OTHER:    {      RECT r;      GetWindowRect(GetDesktopWindow(), &r);      fsWidth = r.right - r.left;      fsHeight = r.bottom - r.top;            int scaleX = (fsWidth / sizeX);      int scaleY = (fsHeight / sizeY);      int min = scaleX < scaleY ? scaleX : scaleY;      surfaceSizeX = sizeX * min;      surfaceSizeY = sizeY * min;      if(fullScreenStretch) {        surfaceSizeX = fsWidth;        surfaceSizeY = fsHeight;      }    }    break;  }    rect.left = 0;  rect.top = 0;  rect.right = sizeX;  rect.bottom = sizeY;  dest.left = 0;  dest.top = 0;  dest.right = surfaceSizeX;  dest.bottom = surfaceSizeY;  DWORD style = WS_POPUP | WS_VISIBLE;  DWORD styleEx = 0;    if(videoOption <= VIDEO_4X)    style |= WS_OVERLAPPEDWINDOW;  else    styleEx = WS_EX_TOPMOST;  if(videoOption <= VIDEO_4X)    AdjustWindowRectEx(&dest, style, TRUE, styleEx);  else    AdjustWindowRectEx(&dest, style, FALSE, styleEx);      int winSizeX = dest.right-dest.left;  int winSizeY = dest.bottom-dest.top;  if(videoOption > VIDEO_4X) {    winSizeX = fsWidth;    winSizeY = fsHeight;  }    int x = 0;  int y = 0;  if(videoOption <= VIDEO_4X) {    x = windowPositionX;    y = windowPositionY;  }    // Create a window  hWindow = CreateWindowEx(styleEx,                           "GBA",                           "VisualBoyAdvance",                           style,                           x,                           y,                           winSizeX,                           winSizeY,                           NULL,                           NULL,                           hInstance,                           NULL);    if (!hWindow) {    winlog("Error creating Window %08x\n", GetLastError());    //    errorMessage(myLoadString(IDS_ERROR_DISP_FAILED));    return FALSE;  }    updateMenuBar();    adjustDestRect();    mode320Available = FALSE;  mode640Available = FALSE;  mode800Available = FALSE;  hDC = GetDC(hWindow);   PIXELFORMATDESCRIPTOR pfd = {     sizeof(PIXELFORMATDESCRIPTOR),  //  size of this pfd     1,                     // version number     PFD_DRAW_TO_WINDOW |   // support window     PFD_SUPPORT_OPENGL |   // support OpenGL     PFD_DOUBLEBUFFER,      // double buffered     PFD_TYPE_RGBA,         // RGBA type     16,                    // 16-bit color depth     0, 0, 0, 0, 0, 0,      // color bits ignored     0,                     // no alpha buffer     0,                     // shift bit ignored     0,                     // no accumulation buffer     0, 0, 0, 0,            // accum bits ignored     32,                    // 32-bit z-buffer         0,                     // no stencil buffer     0,                     // no auxiliary buffer     PFD_MAIN_PLANE,        // main layer     0,                     // reserved     0, 0, 0                // layer masks ignored   };   int  iPixelFormat;     if(!(iPixelFormat = ChoosePixelFormat(hDC, &pfd))) {    winlog("Failed ChoosePixelFormat\n");    return false;  }  // obtain detailed information about   // the device context's first pixel format  if(!(DescribePixelFormat(hDC, iPixelFormat,                             sizeof(PIXELFORMATDESCRIPTOR), &pfd))) {    winlog("Failed DescribePixelFormat\n");    return false;  }  if(!SetPixelFormat(hDC, iPixelFormat, &pfd)) {    winlog("Failed SetPixelFormat\n");    return false;  }  if(!(hglrc = wglCreateContext(hDC))) {    winlog("Failed wglCreateContext\n");    return false;  }  if(!wglMakeCurrent(hDC, hglrc)) {    winlog("Failed wglMakeCurrent\n");    return false;  }  // setup 2D gl environment  glPushAttrib(GL_ENABLE_BIT);  glDisable(GL_DEPTH_TEST);  glDisable(GL_CULL_FACE);  glEnable(GL_TEXTURE_2D);  glViewport(0, 0, surfaceSizeX, surfaceSizeY);  glMatrixMode(GL_PROJECTION);  glLoadIdentity();  glOrtho(0.0, (GLdouble)(surfaceSizeX), (GLdouble)(surfaceSizeY),          0.0, 0.0,1.0);  glMatrixMode(GL_MODELVIEW);  glLoadIdentity();  systemRedShift = 3;  systemGreenShift = 11;  systemBlueShift = 19;  systemColorDepth = 32;  fsColorDepth = 32;    if(ddrawDebug) {    winlog("R shift: %d\n", systemRedShift);    winlog("G shift: %d\n", systemGreenShift);    winlog("B shift: %d\n", systemBlueShift);  }           switch(systemColorDepth) {  case 16:    {      for(int i = 0; i < 0x10000; i++) {        systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |          (((i & 0x3e0) >> 5) << systemGreenShift) |          (((i & 0x7c00) >> 10) << systemBlueShift);      }    }    break;  case 24:  case 32:    {      for(int i = 0; i < 0x10000; i++) {        systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |          (((i & 0x3e0) >> 5) << systemGreenShift) |          (((i & 0x7c00) >> 10) << systemBlueShift);      }          }    break;  }  for(int i = 0; i < 24;) {    systemGbPalette[i++] = (0x1f) | (0x1f << 5) | (0x1f << 10);    systemGbPalette[i++] = (0x15) | (0x15 << 5) | (0x15 << 10);    systemGbPalette[i++] = (0x0c) | (0x0c << 5) | (0x0c << 10);    systemGbPalette[i++] = 0;  }  updateFilter();  updateIFB();  if(failed)    return false;    DragAcceptFiles(hWindow, TRUE);    return TRUE;  }