src/video/win32_v.cpp
changeset 9470 08424e2e79e4
parent 9117 87f472043e9e
child 9533 e8b86b70c5f6
equal deleted inserted replaced
9469:520cbe2f5d14 9470:08424e2e79e4
    57 		pal->palPalEntry[i].peBlue  = _cur_palette[i].b;
    57 		pal->palPalEntry[i].peBlue  = _cur_palette[i].b;
    58 		pal->palPalEntry[i].peFlags = 0;
    58 		pal->palPalEntry[i].peFlags = 0;
    59 
    59 
    60 	}
    60 	}
    61 	_wnd.gdi_palette = CreatePalette(pal);
    61 	_wnd.gdi_palette = CreatePalette(pal);
    62 	if (_wnd.gdi_palette == NULL) error("CreatePalette failed!\n");
    62 	if (_wnd.gdi_palette == NULL) usererror("CreatePalette failed!\n");
    63 }
    63 }
    64 
    64 
    65 static void UpdatePalette(HDC dc, uint start, uint count)
    65 static void UpdatePalette(HDC dc, uint start, uint count)
    66 {
    66 {
    67 	RGBQUAD rgb[256];
    67 	RGBQUAD rgb[256];
   290 			TCHAR Windowtitle[50];
   290 			TCHAR Windowtitle[50];
   291 
   291 
   292 			_sntprintf(Windowtitle, sizeof(Windowtitle), _T("OpenTTD %s"), MB_TO_WIDE(_openttd_revision));
   292 			_sntprintf(Windowtitle, sizeof(Windowtitle), _T("OpenTTD %s"), MB_TO_WIDE(_openttd_revision));
   293 
   293 
   294 			_wnd.main_wnd = CreateWindow(_T("OTTD"), Windowtitle, style, x, y, w, h, 0, 0, GetModuleHandle(NULL), 0);
   294 			_wnd.main_wnd = CreateWindow(_T("OTTD"), Windowtitle, style, x, y, w, h, 0, 0, GetModuleHandle(NULL), 0);
   295 			if (_wnd.main_wnd == NULL) error("CreateWindow failed");
   295 			if (_wnd.main_wnd == NULL) usererror("CreateWindow failed");
   296 			ShowWindow(_wnd.main_wnd, showstyle);
   296 			ShowWindow(_wnd.main_wnd, showstyle);
   297 		}
   297 		}
   298 	}
   298 	}
   299 	GameSizeChanged(); // invalidate all windows, force redraw
   299 	GameSizeChanged(); // invalidate all windows, force redraw
   300 	return true; // the request succedded
   300 	return true; // the request succedded
   669 			0,
   669 			0,
   670 			_T("OTTD")
   670 			_T("OTTD")
   671 		};
   671 		};
   672 
   672 
   673 		registered = true;
   673 		registered = true;
   674 		if (!RegisterClass(&wnd)) error("RegisterClass failed");
   674 		if (!RegisterClass(&wnd)) usererror("RegisterClass failed");
   675 	}
   675 	}
   676 }
   676 }
   677 
   677 
   678 static bool AllocateDibSection(int w, int h)
   678 static bool AllocateDibSection(int w, int h)
   679 {
   679 {
   682 	int bpp = BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth();
   682 	int bpp = BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth();
   683 
   683 
   684 	w = max(w, 64);
   684 	w = max(w, 64);
   685 	h = max(h, 64);
   685 	h = max(h, 64);
   686 
   686 
   687 	if (bpp == 0) error("Can't use a blitter that blits 0 bpp for normal visuals");
   687 	if (bpp == 0) usererror("Can't use a blitter that blits 0 bpp for normal visuals");
   688 
   688 
   689 	if (w == _screen.width && h == _screen.height)
   689 	if (w == _screen.width && h == _screen.height)
   690 		return false;
   690 		return false;
   691 
   691 
   692 	_screen.width = w;
   692 	_screen.width = w;
   705 
   705 
   706 	if (_wnd.dib_sect) DeleteObject(_wnd.dib_sect);
   706 	if (_wnd.dib_sect) DeleteObject(_wnd.dib_sect);
   707 
   707 
   708 	dc = GetDC(0);
   708 	dc = GetDC(0);
   709 	_wnd.dib_sect = CreateDIBSection(dc, bi, DIB_RGB_COLORS, (VOID**)&_wnd.buffer_bits, NULL, 0);
   709 	_wnd.dib_sect = CreateDIBSection(dc, bi, DIB_RGB_COLORS, (VOID**)&_wnd.buffer_bits, NULL, 0);
   710 	if (_wnd.dib_sect == NULL) error("CreateDIBSection failed");
   710 	if (_wnd.dib_sect == NULL) usererror("CreateDIBSection failed");
   711 	ReleaseDC(0, dc);
   711 	ReleaseDC(0, dc);
   712 
   712 
   713 	return true;
   713 	return true;
   714 }
   714 }
   715 
   715