-/*
-===================
-VID_Init
-===================
-*/
-void VID_Init (void)
-{
- int i;
-// int existingmode;
- int basenummodes, width, height, bpp, findbpp, done;
- HDC hdc;
- DEVMODE devmode;
-
- memset(&devmode, 0, sizeof(devmode));
-
-// Cvar_RegisterVariable (&_vid_default_mode);
-// Cvar_RegisterVariable (&_vid_default_mode_win);
-
- Cmd_AddCommand ("vid_nummodes", VID_NumModes_f);
- Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f);
- Cmd_AddCommand ("vid_describemode", VID_DescribeMode_f);
- Cmd_AddCommand ("vid_describemodes", VID_DescribeModes_f);
-
- VID_GetSystemGamma();
-
- hIcon = LoadIcon (global_hInstance, MAKEINTRESOURCE (IDI_ICON2));
-
- InitCommonControls();
-
- VID_InitDIB (global_hInstance);
- basenummodes = nummodes = 1;
-
- VID_InitFullDIB (global_hInstance);
-
- if (COM_CheckParm("-window"))
- {
- hdc = GetDC (NULL);
-
- if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE)
- Sys_Error ("Can't run in non-RGB mode");
-
- ReleaseDC (NULL, hdc);
-
- windowed = true;
-
- vid_default = MODE_WINDOWED;
- }
- else
- {
- if (nummodes == 1)
- Sys_Error ("No RGB fullscreen modes available");
-
- windowed = false;
-
- if (COM_CheckParm("-mode"))
- vid_default = atoi(com_argv[COM_CheckParm("-mode")+1]);
- else
- {
- if (COM_CheckParm("-current"))
- {
- modelist[MODE_FULLSCREEN_DEFAULT].width = GetSystemMetrics (SM_CXSCREEN);
- modelist[MODE_FULLSCREEN_DEFAULT].height = GetSystemMetrics (SM_CYSCREEN);
- vid_default = MODE_FULLSCREEN_DEFAULT;
- leavecurrentmode = 1;
- }
- else
- {
- if (COM_CheckParm("-width"))
- width = atoi(com_argv[COM_CheckParm("-width")+1]);
- else
- width = 640;
-
- if (COM_CheckParm("-bpp"))
- {
- bpp = atoi(com_argv[COM_CheckParm("-bpp")+1]);
- findbpp = 0;
- }
- else
- {
- bpp = 15;
- findbpp = 1;
- }
-
- if (COM_CheckParm("-height"))
- height = atoi(com_argv[COM_CheckParm("-height")+1]);
-
- // if they want to force it, add the specified mode to the list
- if (COM_CheckParm("-force") && (nummodes < MAX_MODE_LIST))
- VID_AddMode(MS_FULLDIB, width, height, 0, 0, 1, 1, bpp);
- /*
- {
- modelist[nummodes].type = MS_FULLDIB;
- modelist[nummodes].width = width;
- modelist[nummodes].height = height;
- modelist[nummodes].modenum = 0;
- modelist[nummodes].halfscreen = 0;
- modelist[nummodes].dib = 1;
- modelist[nummodes].fullscreen = 1;
- modelist[nummodes].bpp = bpp;
- sprintf (modelist[nummodes].modedesc, "%dx%dx%d", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode.dmBitsPerPel);
-
- for (i=nummodes, existingmode = 0 ; i<nummodes ; i++)
- {
- if ((modelist[nummodes].width == modelist[i].width) && (modelist[nummodes].height == modelist[i].height) && (modelist[nummodes].bpp == modelist[i].bpp))
- {
- existingmode = 1;
- break;
- }
- }
-
- if (!existingmode)
- nummodes++;
- }
- */
-
- done = 0;
-
- do
- {
- if (COM_CheckParm("-height"))
- {
- height = atoi(com_argv[COM_CheckParm("-height")+1]);
-
- for (i=1, vid_default=0 ; i<nummodes ; i++)
- {
- if ((modelist[i].width == width) && (modelist[i].height == height) && (modelist[i].bpp == bpp))
- {
- vid_default = i;
- done = 1;
- break;
- }
- }
- }
- else
- {
- for (i=1, vid_default=0 ; i<nummodes ; i++)
- {
- if ((modelist[i].width == width) && (modelist[i].bpp == bpp))
- {
- vid_default = i;
- done = 1;
- break;
- }
- }
- }
-
- if (!done)
- {
- if (findbpp)
- {
- switch (bpp)
- {
- case 15: bpp = 16;break;
- case 16: bpp = 32;break;
- case 32: bpp = 24;break;
- case 24: done = 1;break;
- }
- }
- else
- done = 1;
- }
- }
- while (!done);
-
- if (!vid_default)
- Sys_Error ("Specified video mode not available");
- }
- }
- }
-
- vid_initialized = true;
-
- if ((i = COM_CheckParm("-conwidth")) != 0)
- vid.conwidth = atoi(com_argv[i+1]);
- else
- vid.conwidth = 640;
-
- vid.conwidth &= 0xfff8; // make it a multiple of eight
-
- if (vid.conwidth < 320)
- vid.conwidth = 320;
-
- // pick a conheight that matches with correct aspect
- vid.conheight = vid.conwidth*3 / 4;
-
- if ((i = COM_CheckParm("-conheight")) != 0)
- vid.conheight = atoi(com_argv[i+1]);
- if (vid.conheight < 200)
- vid.conheight = 200;
-
- VID_SetMode (vid_default);
-
- maindc = GetDC(mainwindow);
- bSetupPixelFormat(maindc);
-
- baseRC = wglCreateContext( maindc );
- if (!baseRC)
- Sys_Error ("Could not initialize GL (wglCreateContext failed).\n\nMake sure you are in 65536 color mode, and try running -window.");
- if (!wglMakeCurrent( maindc, baseRC ))
- Sys_Error ("wglMakeCurrent failed");
-
- GL_Init ();
-
- // LordHavoc: special differences for ATI (broken 8bit color when also using 32bit? weird!)
- if (strncasecmp(gl_vendor,"ATI",3)==0)
- {
- if (strncasecmp(gl_renderer,"Rage Pro",8)==0)
- isRagePro = true;
- }
- if (strncasecmp(gl_renderer,"Matrox G200 Direct3D",20)==0) // a D3D driver for GL? sigh...
- isG200 = true;
-
-// sprintf (gldir, "%s/glquake", com_gamedir);
-// Sys_mkdir (gldir);
-
- vid_realmode = vid_modenum;
-
- vid_menudrawfn = VID_MenuDraw;
- vid_menukeyfn = VID_MenuKey;
-
- strcpy (badmode.modedesc, "Bad mode");
- vid_canalttab = true;
-}
-
-