Пример #1
0
void R_AntialiasStartFrame (void)
{
	if (r_antialias->modified)
	{
		int32_t aa = r_antialias->value;
		if (!glConfig.ext_framebuffer_object)
			aa = ANTIALIAS_NONE;
		else if (aa >= NUM_ANTIALIAS_MODES)
			aa = NUM_ANTIALIAS_MODES - 1;
		else if (aa < 0)
			aa = 0;

		Cvar_SetInteger("r_antialias", aa);

		r_antialias->modified = false;
		
		changed = true;
	}

	if (changed || glConfig.render_width != screenBounds.width || glConfig.render_height != screenBounds.height)
	{
		screenBounds.width = glConfig.render_width;
		screenBounds.height = glConfig.render_height;
		switch ((int) r_antialias->value)
		{
		case ANTIALIAS_4X_FSAA:
			offscreenBounds.width = screenBounds.width * 2;
			offscreenBounds.height = screenBounds.height * 2;
			break;
		case ANTIALIAS_FXAA_FSS:
			offscreenBounds.width = screenBounds.width * 1.3333;
			offscreenBounds.height = screenBounds.height * 1.3333;
			break;
		default:
		case ANTIALIAS_NONE:
			offscreenBounds.width = screenBounds.width;
			offscreenBounds.height = screenBounds.height;
			break;
		}
		VID_NewWindow(offscreenBounds.width, offscreenBounds.height);
		changed = false;
	}
}
Пример #2
0
static qboolean VID_CreateWindow( int *width, int *height, qboolean fullscreen )
{
	RECT r;
	cvar_t *vid_xpos, *vid_ypos;
	int stylebits;
	int x, y, w, h;
	int exstyle;
#define WITH_UTF8 // FIXME: turn non-Unicode code into a runtime fallback for Win9x
#ifndef WITH_UTF8
	WNDCLASS  wc;
#else
	WNDCLASSW wc;
	HWND parentHWND = glw_state.parenthWnd;

	/* determine buffer size required for the unicode string */
	WCHAR windowClassName[sizeof(WINDOW_CLASS_NAME)] = L"";
	MultiByteToWideChar( CP_ACP, 0, WINDOW_CLASS_NAME, -1, windowClassName, sizeof( windowClassName )-1 );
#endif

	assert( width && height );

	/* Register the frame class */
	wc.style         = 0;
	wc.lpfnWndProc   = (WNDPROC)glw_state.wndproc;
	wc.cbClsExtra    = 0;
	wc.cbWndExtra    = 0;
	wc.hInstance     = glw_state.hInstance;
	wc.hIcon         = LoadIcon( glw_state.hInstance, MAKEINTRESOURCE( IDI_APPICON_VALUE ) );
	wc.hCursor       = LoadCursor( NULL, IDC_ARROW );
	wc.hbrBackground = (HBRUSH)GetStockObject( GRAY_BRUSH );
	wc.lpszMenuName  = 0;
#ifdef WITH_UTF8
	wc.lpszClassName = (LPCWSTR)windowClassName;
	if( !RegisterClassW( &wc ) )
#else
	wc.lpszClassName = (LPCSTR)WINDOW_CLASS_NAME;
	if( !RegisterClass( &wc ) )
#endif
		Com_Error( ERR_FATAL, "Couldn't register window class" );

	r.left = 0;
	r.top = 0;
	r.right  = *width;
	r.bottom = *height;

	if( fullscreen )
	{
		exstyle = WS_EX_TOPMOST;
		stylebits = ( WS_POPUP|WS_VISIBLE );
		parentHWND = NULL;
	}
	else if( parentHWND )
	{
		RECT parentWindowRect;

		GetWindowRect( parentHWND, &parentWindowRect );
		r.right = /*min( *width, (parentWindowRect.right - parentWindowRect.left) )*/parentWindowRect.right - parentWindowRect.left;
		r.bottom = /*min( *height, (parentWindowRect.bottom - parentWindowRect.top) )*/parentWindowRect.bottom - parentWindowRect.top;

		exstyle = 0;
		stylebits = WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_VISIBLE;
	}
	else
	{
		exstyle = 0;
		stylebits = WINDOW_STYLE;
	}

	AdjustWindowRect( &r, stylebits, FALSE );

	w = r.right - r.left;
	h = r.bottom - r.top;

	if( fullscreen )
	{
		x = 0;
		y = 0;
	}
	else if( parentHWND )
	{
		RECT parentWindowRect;

		*width = w;
		*height = h;

		GetWindowRect( parentHWND, &parentWindowRect );

		// share centre with the parent window
		x = (parentWindowRect.right - parentWindowRect.left - w) / 2;
		y = (parentWindowRect.bottom - parentWindowRect.top - h) / 2;

		Cvar_ForceSet( "vid_xpos", va( "%i", x ) );
		Cvar_ForceSet( "vid_ypos", va( "%y", y ) );
	}
	else
	{
		vid_xpos = Cvar_Get( "vid_xpos", "0", 0 );
		vid_ypos = Cvar_Get( "vid_ypos", "0", 0 );
		x = vid_xpos->integer;
		y = vid_ypos->integer;
	}

	glw_state.hWnd = CreateWindowEx(
	        exstyle,
	        WINDOW_CLASS_NAME,
	        APPLICATION,
	        stylebits,
	        x, y, w, h,
	        parentHWND,
	        NULL,
	        glw_state.hInstance,
	        NULL );

	if( !glw_state.hWnd )
		Com_Error( ERR_FATAL, "Couldn't create window" );

	ShowWindow( glw_state.hWnd, SW_SHOW );
	UpdateWindow( glw_state.hWnd );

	// init all the gl stuff for the window
	if( !GLimp_InitGL() )
	{
		Com_Printf( "VID_CreateWindow() - GLimp_InitGL failed\n" );
		return qfalse;
	}

	SetForegroundWindow( glw_state.hWnd );
	SetFocus( glw_state.hWnd );

	if( glw_state.parenthWnd )
		PostMessage( glw_state.parenthWnd, UWM_APPACTIVE, WA_ACTIVE, 0 );

	// let the sound and input subsystems know about the new window
	VID_NewWindow( *width, *height );

	return qtrue;
}
Пример #3
0
LONG WINAPI MainWndProc (
    HWND    hWnd,
    UINT    uMsg,
    WPARAM  wParam,
    LPARAM  lParam)
{
	LONG		lRet = 0;
	static qboolean newwindow = true;
	static qboolean minimized = false;

	if (uMsg == MSH_MOUSEWHEEL)
	{
		if (((int)wParam) > 0)
		{
			Key_Event(K_MWHEELUP, true, sys_msg_time);
			Key_Event(K_MWHEELUP, false, sys_msg_time);
		}
		else
		{
			Key_Event(K_MWHEELDOWN, true, sys_msg_time);
			Key_Event(K_MWHEELDOWN, false, sys_msg_time);
		}
        return DefWindowProc(hWnd, uMsg, wParam, lParam);
	}

	//Com_Printf("%x\n", uMsg);

	switch (uMsg)
	{
	case WM_MOUSEWHEEL:
		/*
		** this chunk of code theoretically only works under NT4 and Win98
		** since this message doesn't exist under Win95
		*/
		if ((short)HIWORD(wParam) > 0)
		{
			Key_Event(K_MWHEELUP, true, sys_msg_time);
			Key_Event(K_MWHEELUP, false, sys_msg_time);
		}
		else
		{
			Key_Event(K_MWHEELDOWN, true, sys_msg_time);
			Key_Event(K_MWHEELDOWN, false, sys_msg_time);
		}
		break;

	case WM_HOTKEY:
		return 0;

	case WM_CREATE:
		cl_hwnd = hWnd;
		newwindow = true;
		MSH_MOUSEWHEEL = RegisterWindowMessage("MSWHEEL_ROLLMSG"); 
        return DefWindowProc (hWnd, uMsg, wParam, lParam);

	case WM_PAINT:
		SCR_DirtyScreen();	// force entire screen to update next frame
        return DefWindowProc(hWnd, uMsg, wParam, lParam);

	case WM_DESTROY:
		// let sound and input know about this?
		cl_hwnd = NULL;
        return DefWindowProc(hWnd, uMsg, wParam, lParam);
/*
	case WM_KILLFOCUS: // jit - make sure mouse is deactivated if another window takes focus
		AppActivate(false, minimized, newwindow);

		if (reflib_active)
			re.AppActivate(false);

		return DefWindowProc(hWnd, uMsg, wParam, lParam);

	case WM_NCACTIVATE:
		AppActivate(wParam, minimized, newwindow);

		if (reflib_active)
			re.AppActivate(wParam);

		return DefWindowProc(hWnd, uMsg, wParam, lParam);
*/
	/*case WM_ACTIVATEAPP:
		AppActivate(wParam, minimized, newwindow);

		if (reflib_active)
			re.AppActivate(wParam);

		return DefWindowProc(hWnd, uMsg, wParam, lParam);*/
/* jit - disabled this because we run CheckActive() every frame because we aren't getting appropriate events when the game loses focus/foreground, sometimes.
	case WM_ACTIVATE:
		{
			int	fActive;
			qboolean active;
			HWND foregroundWindow = GetForegroundWindow();

			// KJB: Watch this for problems in fullscreen modes with Alt-tabbing.
			fActive = LOWORD(wParam);
			minimized = (BOOL)HIWORD(wParam); 
			active = (fActive != WA_INACTIVE);

			//if (foregroundWindow != hWnd)
			//	active = false;

			Com_Printf("\nForeground: %d hWnd: %d\n\n", foregroundWindow, hWnd);
			AppActivate(active, minimized, newwindow);

			if (reflib_active)
				re.AppActivate(active);

			newwindow = false;
			return DefWindowProc(hWnd, uMsg, wParam, lParam);
		}
/*
	case WM_WINDOWPOSCHANGED: // jit - handle another case of losing app focus
		{
			LPWINDOWPOS windowpos = (LPWINDOWPOS)lParam;

			if (windowpos->flags & 0x800) // SWP_STATECHANGED
			{
				HWND foregroundWindow = GetForegroundWindow();
				qboolean active = (foregroundWindow == hWnd);

				AppActivate(active, minimized, newwindow);

				if (reflib_active)
					re.AppActivate(active);
			}

			Com_Printf("\nWindowposchanged flags %x\n", windowpos->flags);
			return DefWindowProc(hWnd, uMsg, wParam, lParam);
		}
*/
	case WM_MOVE:
		{
			int		xPos, yPos;
			RECT	r;
			int		style;

			if (!vid_fullscreen->value)
			{
				xPos = (short)LOWORD(lParam);    // horizontal position 
				yPos = (short)HIWORD(lParam);    // vertical position 
				r.left   = 0;
				r.top    = 0;
				r.right  = 1;
				r.bottom = 1;
				style = GetWindowLong(hWnd, GWL_STYLE);
				AdjustWindowRect(&r, style, FALSE);
				Cvar_SetValue("vid_xpos", xPos + r.left);
				Cvar_SetValue("vid_ypos", yPos + r.top);
				vid_xpos->modified = false;
				vid_ypos->modified = false;
			}

			// jitmouse - force mouse to recenter properly
			if (ActiveApp)
				IN_Activate(true);
		}

        return DefWindowProc(hWnd, uMsg, wParam, lParam);

// this is complicated because Win32 seems to pack multiple mouse events into
// one update sometimes, so we always check all states and look for events
	case WM_LBUTTONDOWN:
	case WM_LBUTTONUP:
	case WM_RBUTTONDOWN:
	case WM_RBUTTONUP:
	case WM_MBUTTONDOWN:
	case WM_MBUTTONUP:
	case WM_MOUSEMOVE:
	case WM_XBUTTONDOWN: // jitmouse
	case WM_XBUTTONUP: // jitmouse
		{
			int	temp = 0;

			if (wParam & MK_LBUTTON)
				temp |= 1;

			if (wParam & MK_RBUTTON)
				temp |= 2;

			if (wParam & MK_MBUTTON)
				temp |= 4;

			// === jitmouse
			if (wParam & MK_XBUTTON1)
				temp |= 8;

			if (wParam & MK_XBUTTON2)
				temp |= 16;
			// ===

			IN_MouseEvent(temp);

			// ++ ARTHUR [9/04/03] - Mouse movement emulates keystroke
			Key_Event(K_MOUSEMOVE, true, sys_msg_time);
			// -- ARTHUR	
		}
		break;

	case WM_INPUT: // jitmouse
		if (m_rawinput->value && !(cls.key_dest == key_console || g_windowed && M_MenuActive())) // Don't accumulate in-game mouse input when at the console or menu
		{
			UINT dwSize = 40;
			static BYTE lpb[40];
			RAWINPUT *raw;
			GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER));
			raw = (RAWINPUT*)lpb;

			if (raw->header.dwType == RIM_TYPEMOUSE) 
			{
				extern int g_raw_mouse_x, g_raw_mouse_y;

				g_raw_mouse_x += raw->data.mouse.lLastX;
				g_raw_mouse_y += raw->data.mouse.lLastY;
			}
		}
		break;

	case WM_SYSCOMMAND:
		if (wParam == SC_SCREENSAVE)
			return 0;

        return DefWindowProc(hWnd, uMsg, wParam, lParam);

	case WM_SYSKEYDOWN:

		if (wParam == 13) // alt-enter toggles fullscreen
		{
			if (!win_noaltenter || !win_noaltenter->value) // jitkeyboard
			{
				if (vid_fullscreen)
					Cvar_SetValue("vid_fullscreen", !vid_fullscreen->value);

				return 0;
			}
		}

		// fall through

	case WM_KEYDOWN:
		Key_Event(Sys_MapKeyModified(wParam, lParam), true, sys_msg_time);
		break;

	case WM_SYSKEYUP:
	case WM_KEYUP:
		Key_Event(Sys_MapKeyModified(wParam, lParam), false, sys_msg_time);
		break;

	case WM_SIZE:
		if (lParam) // This is 0 when minimized?
		{
			M_RefreshMenu(); // jitmenu
			re.DrawResizeWindow(LOWORD(lParam), HIWORD(lParam));
			VID_NewWindow(LOWORD(lParam), HIWORD(lParam));
		}

		if (wParam == SIZE_MINIMIZED) // jit
			minimized = true;
		else
			minimized = false;
		break;

	case WM_CLOSE:
	case WM_QUIT:
		Com_Quit();
		break;

	case WM_APPCOMMAND:

	#ifdef OGG_SUPPORT
		if(ogg_started)
			switch(GET_APPCOMMAND_LPARAM(lParam))
			{
			case APPCOMMAND_MEDIA_PLAY_PAUSE:
				Cbuf_AddText("ogg_playpause\n");
				return 1;
			case APPCOMMAND_MEDIA_NEXTTRACK:
				Cbuf_AddText("ogg_play >\n");
				return 1;
			case APPCOMMAND_MEDIA_PREVIOUSTRACK:
				Cbuf_AddText("ogg_play <\n");
				return 1;
			case APPCOMMAND_MEDIA_STOP:
				Cbuf_AddText("ogg_stop\n");
				return 1;
			}
		break;
	#endif

	case MM_MCINOTIFY:
		{
			LONG CDAudio_MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
			lRet = CDAudio_MessageHandler(hWnd, uMsg, wParam, lParam);
		}
		break;

	default:	// pass all unhandled messages to DefWindowProc
        return DefWindowProc(hWnd, uMsg, wParam, lParam);
    }

	//CheckActive(hWnd);

    // return 0 if handled message, 1 if not
    return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
Пример #4
0
/*
 * Initializes the OpenGL window
 */
static qboolean
GLimp_InitGraphics(qboolean fullscreen)
{
	int flags;
	int msaa_samples;
	int stencil_bits;
	int width, height;
	char title[24];

	if (GetWindowSize(&width, &height) && (width == vid.width) && (height == vid.height))
	{
		/* If we want fullscreen, but aren't */
		if (fullscreen != IsFullscreen())
		{
			GLimp_ToggleFullscreen();
		}

		/* Are we now? */
		if (fullscreen == IsFullscreen())
		{
			return true;
		}
	}

	/* Is the surface used? */
	if (window)
	{
#if SDL_VERSION_ATLEAST(2, 0, 0)
		SDL_GL_DeleteContext(context);
		SDL_DestroyWindow(window);
#else
		SDL_FreeSurface(window);
#endif
	}

	/* Create the window */
	VID_NewWindow(vid.width, vid.height);

	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
	SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);

	if (gl_msaa_samples->value)
	{
		msaa_samples = gl_msaa_samples->value;

		if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1) == -1)
		{
			Com_Printf("MSAA is unsupported: %s\n", SDL_GetError());
			Cvar_SetValue ("gl_msaa_samples", 0);
			SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
			SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
		}
		else if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, msaa_samples) == -1)
		{
			Com_Printf("MSAA %ix is unsupported: %s\n", msaa_samples, SDL_GetError());
			Cvar_SetValue("gl_msaa_samples", 0);
			SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
			SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
		}
	}

	/* Initiate the flags */
	flags = SDL_OPENGL;

	if (fullscreen)
	{
		flags |= SDL_FULLSCREEN;
	}

#if !SDL_VERSION_ATLEAST(2, 0, 0)
	/* For SDL1.2, these things must be done before creating the window */

	/* Set the icon */
	SetSDLIcon();

	/* Set vsync */
	SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, gl_swapinterval->value ? 1 : 0);
#endif

	while (1)
	{
		if (!CreateSDLWindow(flags))
		{
			if (gl_msaa_samples->value)
			{
				VID_Printf(PRINT_ALL, "SDL SetVideoMode failed: %s\n",
						SDL_GetError());
				VID_Printf(PRINT_ALL, "Reverting to %s gl_mode %i (%ix%i) without MSAA.\n",
						(flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed",
						(int)Cvar_VariableValue("gl_mode"), vid.width, vid.height);

				/* Try to recover */
				Cvar_SetValue("gl_msaa_samples", 0);
				SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
				SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
			}
			else if (vid.width != 640 || vid.height != 480 || (flags & SDL_FULLSCREEN))
			{
				VID_Printf(PRINT_ALL, "SDL SetVideoMode failed: %s\n",
						SDL_GetError());
				VID_Printf(PRINT_ALL, "Reverting to windowed gl_mode 4 (640x480).\n");

				/* Try to recover */
				Cvar_SetValue("gl_mode", 4);
				Cvar_SetValue("vid_fullscreen", 0);
				vid.width = 640;
				vid.height = 480;
				flags &= ~SDL_FULLSCREEN;
			}
			else
			{
				VID_Error(ERR_FATAL, "Failed to revert to gl_mode 4. Exiting...\n");
				return false;
			}
		}
		else
		{
			break;
		}
	}

#if SDL_VERSION_ATLEAST(2, 0, 0)
	/* For SDL2, these things must be done after creating the window */

	/* Set the icon */
	SetSDLIcon();

	/* Set vsync - TODO: -1 could be set for "late swap tearing" */
	SDL_GL_SetSwapInterval(gl_swapinterval->value ? 1 : 0);
#endif

	/* Initialize the stencil buffer */
	if (!SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil_bits))
	{
		VID_Printf(PRINT_ALL, "Got %d bits of stencil.\n", stencil_bits);

		if (stencil_bits >= 1)
		{
			have_stencil = true;
		}
	}

	/* Initialize hardware gamma */
	InitGamma();

	/* Window title */
	snprintf(title, sizeof(title), "Yamagi Quake II %s", YQ2VERSION);
#if SDL_VERSION_ATLEAST(2, 0, 0)
	SDL_SetWindowTitle(window, title);
#else
	SDL_WM_SetCaption(title, title);
#endif

	/* No cursor */
	SDL_ShowCursor(0);

	return true;
}
Пример #5
0
/*
 * Initializes the OpenGL window
 */
static qboolean
GLimp_InitGraphics(qboolean fullscreen)
{
	int counter = 0;
	int flags;
	int stencil_bits;
	char title[24];

	//QUAKETOON: forcing window
	fullscreen = false;

	if (surface && (surface->w == vid.width) && (surface->h == vid.height))
	{
		/* Are we running fullscreen? */
		int isfullscreen = (surface->flags & SDL_FULLSCREEN) ? 1 : 0;

		/* We should, but we don't */
		if (fullscreen != isfullscreen)
		{
			SDL_WM_ToggleFullScreen(surface);
		}

		/* Do we now? */
		isfullscreen = (surface->flags & SDL_FULLSCREEN) ? 1 : 0;

		if (fullscreen == isfullscreen)
		{
			return true;
		}
	}

	/* Is the surface used? */
	if (surface)
	{
		SDL_FreeSurface(surface);
	}

	/* Create the window */
	VID_NewWindow(vid.width, vid.height);

	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
	SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);

	/* Initiate the flags */
	flags = SDL_OPENGL;

	if (fullscreen)
	{
		flags |= SDL_FULLSCREEN;
	}

	/* Set the icon */
	SetSDLIcon();

	/* Enable vsync */
	/*
	if (gl_swapinterval->value)
	{
		SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
	}
	*/

	while (1)
	{
		if ((surface = SDL_SetVideoMode(vid.width, vid.height, 0, flags)) == NULL)
		{
			if (counter == 1)
			{
				VID_Error(ERR_FATAL, "Failed to revert to gl_mode 4. Exiting...\n");
				return false;
			}

			VID_Printf(PRINT_ALL, "SDL SetVideoMode failed: %s\n",
					SDL_GetError());
			VID_Printf(PRINT_ALL, "Reverting to gl_mode 4 (640x480) and windowed mode.\n");

			/* Try to recover */
			Cvar_SetValue("gl_mode", 4);
			Cvar_SetValue("vid_fullscreen", 0);
			vid.width = 640;
			vid.height = 480;

			counter++;
			continue;
		}
		else
		{
			break;
		}
	}

	/* Initialize the stencil buffer */
	if (!SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil_bits))
	{
		VID_Printf(PRINT_ALL, "Got %d bits of stencil.\n", stencil_bits);

		if (stencil_bits >= 1)
		{
			have_stencil = true;
		}
	}

	/* Initialize hardware gamma */
#ifdef X11GAMMA
	if ((dpy = XOpenDisplay(displayname)) == NULL)
	{
		VID_Printf(PRINT_ALL, "Unable to open display.\n");
	}
	else
	{
		if (screen == -1)
		{
			screen = DefaultScreen(dpy);
		}

		gl_state.hwgamma = true;
		vid_gamma->modified = true;

		XF86VidModeGetGamma(dpy, screen, &x11_oldgamma);

		VID_Printf(PRINT_ALL, "Using hardware gamma via X11.\n");
	}
#else
	//gl_state.hwgamma = true;
	vid_gamma->modified = true;
	VID_Printf(PRINT_ALL, "Using hardware gamma via SDL.\n");
#endif

	/* Window title */
	snprintf(title, sizeof(title), "QuakeToon %f", (float) VERSION);
	SDL_WM_SetCaption(title, title);

	/* No cursor */
	SDL_ShowCursor(0);

	return true;
}
Пример #6
0
qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
{
	WNDCLASS		wc;
	RECT			r;
	cvar_t			*vid_xpos, *vid_ypos;
	int				stylebits;
	int				x, y, w, h;
	int				exstyle;

	/* Register the frame class */
    wc.style         = 0;
    wc.lpfnWndProc   = (WNDPROC)glw_state.wndproc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = glw_state.hInstance;

	if (modType("xatrix")) { // q2mp1
		wc.hIcon         = LoadIcon(glw_state.hInstance, MAKEINTRESOURCE(IDI_ICON2));
		//wc.lpszClassName = WINDOW_CLASS_NAME2;
	}
	else if (modType("rogue"))  { // q2mp2
		wc.hIcon         = LoadIcon(glw_state.hInstance, MAKEINTRESOURCE(IDI_ICON3));
		//wc.lpszClassName = WINDOW_CLASS_NAME3;
	}
	else {
		wc.hIcon         = LoadIcon(glw_state.hInstance, MAKEINTRESOURCE(IDI_ICON1));
	}

    wc.hCursor       = LoadCursor (NULL,IDC_ARROW);
	wc.hbrBackground = (void *)COLOR_GRAYTEXT;
    wc.lpszMenuName  = 0;
	wc.lpszClassName = WINDOW_CLASS_NAME;

    if (!RegisterClass (&wc) )
		VID_Error (ERR_FATAL, "Couldn't register window class");

	if (fullscreen)
	{
		exstyle = WS_EX_TOPMOST;
		//stylebits = WS_POPUP|WS_VISIBLE;
		stylebits = WS_POPUP|WS_SYSMENU|WS_VISIBLE;
	}
	else
	{
		exstyle = 0;
		//stylebits = WS_OVERLAPPED|WS_BORDER|WS_CAPTION|WS_VISIBLE;
		stylebits = WS_OVERLAPPED|WS_BORDER|WS_CAPTION|WS_SYSMENU|WS_VISIBLE;
	}

	r.left = 0;
	r.top = 0;
	r.right  = width;
	r.bottom = height;

	AdjustWindowRect (&r, stylebits, FALSE);

	w = r.right - r.left;
	h = r.bottom - r.top;

	if (fullscreen)
	{
		x = 0;
		y = 0;
	}
	else
	{
		vid_xpos = Cvar_Get ("vid_xpos", "0", 0);
		vid_ypos = Cvar_Get ("vid_ypos", "0", 0);
		x = vid_xpos->value;
		y = vid_ypos->value;
	}

	glw_state.hWnd = CreateWindowEx (
		 exstyle, 
		 WINDOW_CLASS_NAME,
		 "Thirty Flights of Loving",		//Knightmare changed
		 stylebits,
		 x, y, w, h,
		 NULL,
		 NULL,
		 glw_state.hInstance,
		 NULL);

	if (!glw_state.hWnd)
		VID_Error (ERR_FATAL, "Couldn't create window");
	
	ShowWindow( glw_state.hWnd, SW_SHOW );
	UpdateWindow( glw_state.hWnd );

	// init all the gl stuff for the window
	if (!GLimp_InitGL ())
	{
		VID_Printf( PRINT_ALL, "VID_CreateWindow() - GLimp_InitGL failed\n");
		return false;
	}

	SetForegroundWindow( glw_state.hWnd );
	SetFocus( glw_state.hWnd );

	// let the sound and input subsystems know about the new window
	VID_NewWindow (width, height);

	return true;
}
Пример #7
0
static qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
{
    RECT			r;
    int				stylebits;
    int				x, y, w, h, exstyle;

    /* Register the frame class */
    if (!s_classRegistered)
    {
        WNDCLASS wc;

        memset( &wc, 0, sizeof( wc ) );
        wc.style         = 0;
        wc.lpfnWndProc   = (WNDPROC)glw_state.wndproc;
        wc.cbClsExtra    = 0;
        wc.cbWndExtra    = 0;
        wc.hInstance     = glw_state.hInstance;
        wc.hIcon         = LoadIcon(glw_state.hInstance, MAKEINTRESOURCE(IDI_ICON1));
        wc.hCursor       = LoadCursor (NULL, IDC_ARROW);
        wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
        wc.lpszMenuName  = 0;
        wc.lpszClassName = WINDOW_CLASS_NAME;

        if (!RegisterClass(&wc)) {
            PrintWinError("VID_CreateWindow: RegisterClass", true);
            return false;
        }

        s_classRegistered = true;
    }

    if (fullscreen) {
        exstyle = WS_EX_TOPMOST;
        stylebits = WS_POPUP|WS_VISIBLE;

        w = width;
        h = height;
        x = 0;
        y = 0;
    }
    else {
        exstyle = 0;
        stylebits = WINDOW_STYLE;

        r.left = 0;
        r.top = 0;
        r.right  = width;
        r.bottom = height;

        AdjustWindowRect (&r, stylebits, FALSE);

        w = r.right - r.left;
        h = r.bottom - r.top;
        x = vid_xpos->integer;
        y = vid_ypos->integer;
    }

    glw_state.hWnd = CreateWindowEx (
                         exstyle,
                         WINDOW_CLASS_NAME,
                         APPLICATION,
                         stylebits,
                         x, y, w, h,
                         NULL,
                         NULL,
                         glw_state.hInstance,
                         NULL);

    if (!glw_state.hWnd) {
        PrintWinError("VID_CreateWindow: CreateWindowEx", true);
        return false;
    }

    ShowWindow( glw_state.hWnd, SW_SHOW );
    UpdateWindow( glw_state.hWnd );

    // init all the gl stuff for the window
    if (!GLimp_InitGL())
    {
        Com_Printf ( "VID_CreateWindow() - GLimp_InitGL failed\n");

        if (glw_state.hGLRC) {
            qwglDeleteContext( glw_state.hGLRC );
            glw_state.hGLRC = NULL;
        }
        if (glw_state.hDC) {
            ReleaseDC( glw_state.hWnd, glw_state.hDC );
            glw_state.hDC = NULL;
        }

        ShowWindow( glw_state.hWnd, SW_HIDE );
        DestroyWindow( glw_state.hWnd );
        glw_state.hWnd = NULL;
        return false;
    }

    SetForegroundWindow( glw_state.hWnd );
    SetFocus( glw_state.hWnd );

    vid_scaled_width = (int)ceilf((float)width / gl_scale->value);
    vid_scaled_height = (int)ceilf((float)height / gl_scale->value);

    //round to powers of 8/2 to avoid blackbars
    width = (vid_scaled_width+7)&~7;
    height = (vid_scaled_height+1)&~1;

    // let the sound and input subsystems know about the new window
    VID_NewWindow( width, height );
    //VID_NewWindow( width / gl_scale->value, height / gl_scale->value);

    return true;
}