Ejemplo n.º 1
0
/*
** GLimp_SetMode
*/
rserr_t GLimp_SetMode( int x, int y, int width, int height, int displayFrequency, bool fullscreen, bool stereo, bool borderless )
{
    if( width == glConfig.width && height == glConfig.height && glConfig.fullScreen != fullscreen )
    {
#ifdef __ANDROID__
        return rserr_ok; // The window is always fullscreen on Android
#endif
    }

    ri.Com_Printf( "Initializing OpenGL display\n" );

    GLimp_Shutdown();

    glConfig.width = width;
    glConfig.height = height;
    glConfig.fullScreen = fullscreen;
    glConfig.borderless = borderless;

    if( !GLimp_InitGL() )
    {
        ri.Com_Printf( "GLimp_SetMode() - GLimp_InitGL failed\n" );
        GLimp_Shutdown();
        return rserr_unknown;
    }

    return rserr_ok;
}
Ejemplo n.º 2
0
/*
** GLimp_SetMode
*/
rserr_t GLimp_SetMode( int x, int y, int width, int height, int displayFrequency, bool fullscreen, bool stereo )
{
	ri.Com_Printf( "Initializing OpenGL display\n" );
	GLimp_Shutdown();
	glConfig.width = width;
	glConfig.height = height;
	glConfig.fullScreen = fullscreen;
	glConfig.stereoEnabled = stereo;
	if( !GLimp_InitGL() )
	{
		ri.Com_Printf( "GLimp_SetMode() - GLimp_InitGL failed\n" );
		GLimp_Shutdown();
		return rserr_unknown;
	}
	return rserr_ok;
}
Ejemplo n.º 3
0
/*
** GLimp_SetMode
*/
rserr_t GLimp_SetMode( int x, int y, int width, int height, int displayFrequency, bool fullscreen, bool stereo, bool borderless )
{
	const char *win_fs[] = { "W", "FS" };

	ri.Com_Printf( "Setting video mode:" );

	// disable fullscreen if rendering to a parent window
	if( glw_state.parenthWnd ) {
		RECT parentWindowRect;

		fullscreen = false;

		GetWindowRect( glw_state.parenthWnd, &parentWindowRect );
		width = parentWindowRect.right - parentWindowRect.left;
		height = parentWindowRect.bottom - parentWindowRect.top;
	}

	ri.Com_Printf( " %d %d %s\n", width, height, win_fs[fullscreen] );

	// destroy the existing window
	if( glw_state.hWnd )
	{
		GLimp_Shutdown();
	}

	glw_state.win_x = x;
	glw_state.win_y = y;

	glConfig.width = width;
	glConfig.height = height;
	glConfig.fullScreen = ( fullscreen ? GLimp_SetFullscreenMode( displayFrequency, fullscreen ) == rserr_ok : false );
	glConfig.stereoEnabled = stereo;
	glConfig.borderless = borderless;

	GLimp_CreateWindow();

	// init all the gl stuff for the window
	if( !GLimp_InitGL() ) {
		ri.Com_Printf( "GLimp_CreateWindow() - GLimp_InitGL failed\n" );
		return false;
	}

	return ( fullscreen == glConfig.fullScreen ? rserr_ok : rserr_invalid_fullscreen );
}
Ejemplo n.º 4
0
/**
 * Set video mode.
 * @param mode number of the mode to set
 * @param fullscreen <code>true</code> for a fullscreen mode,
 *     <code>false</code> otherwise
 */
rserr_t GLimp_SetMode( int x, int y, int width, int height, int displayFrequency, bool fullscreen, bool stereo, bool borderless )
{
	const char *win_fs[] = {"W", "FS"};

#ifdef __APLE__
	if( fullscreen ) {
		borderless = true;
	}
	else {
		borderless = false;
	}
#endif

	ri.Com_Printf( "Initializing OpenGL display\n" );
	ri.Com_Printf( "...setting mode:" );
	ri.Com_Printf( " %d %d %s\n", width, height, win_fs[fullscreen] );

	// destroy the existing window
	if( glw_state.sdl_window ) {
		GLimp_Shutdown();
	}

	GLimp_CreateWindow( x, y, width, height );

	// init all the gl stuff for the window
	if( !GLimp_InitGL( r_stencilbits->integer, stereo ) ) {
		ri.Com_Printf( "VID_CreateWindow() - GLimp_InitGL failed\n" );
		return rserr_invalid_mode;
	}

	glConfig.width = width;
	glConfig.height = height;
	glConfig.borderless = borderless;
	glConfig.fullScreen = fullscreen;
	if( GLimp_SetFullscreenMode( displayFrequency, fullscreen ) == rserr_ok ) {
		glConfig.fullScreen = fullscreen;
	}
	else {
		glConfig.fullScreen = !fullscreen;
	}

    return glConfig.fullScreen == fullscreen ? rserr_ok : rserr_invalid_fullscreen;
}
Ejemplo n.º 5
0
/**
 * Set video mode.
 * @param mode number of the mode to set
 * @param fullscreen <code>true</code> for a fullscreen mode,
 *     <code>false</code> otherwise
 */
rserr_t GLimp_SetMode( int x, int y, int width, int height, int displayFrequency, bool fullscreen, bool stereo )
{
	const char *win_fs[] = {"W", "FS"};

	if( width == glConfig.width && height == glConfig.height && glConfig.fullScreen != fullscreen ) {
		if( GLimp_SetWindowFullscreen( fullscreen ) ) {
			glConfig.fullScreen = fullscreen;
			return rserr_ok;
		}
		return rserr_restart_required;
	}

	ri.Com_Printf( "Initializing OpenGL display\n" );
	ri.Com_Printf( "...setting mode:" );
	ri.Com_Printf( " %d %d %s\n", width, height, win_fs[fullscreen] );

	// destroy the existing window
	if( glw_state.sdl_window ) {
		GLimp_Shutdown();
	}

	GLimp_CreateWindow( x, y, width, height );

	// init all the gl stuff for the window
	if( !GLimp_InitGL( r_stencilbits->integer, stereo ) ) {
		ri.Com_Printf( "VID_CreateWindow() - GLimp_InitGL failed\n" );
		return rserr_invalid_mode;
	}

	if( fullscreen && !GLimp_SetWindowFullscreen( fullscreen ) ) {
		return rserr_invalid_fullscreen;
	}

	glConfig.width = width;
	glConfig.height = height;
	glConfig.fullScreen = fullscreen;
	return rserr_ok;
}
Ejemplo n.º 6
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;
}
Ejemplo n.º 7
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;
    wc.hIcon         = 0;
    wc.hCursor       = LoadCursor (NULL,IDC_ARROW);
	wc.hbrBackground = (void *)COLOR_GRAYTEXT;
    wc.lpszMenuName  = 0;
    wc.lpszClassName = WINDOW_CLASS_NAME;

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

	if (fullscreen)
	{
		exstyle = WS_EX_TOPMOST;
		stylebits = WS_POPUP|WS_VISIBLE;
	}
	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;

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

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

	if (!glw_state.hWnd)
		ri.Sys_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 ())
	{
		ri.Con_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
	ri.Vid_NewWindow (width, height);

	return true;
}
Ejemplo n.º 8
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;
    wc.hIcon         = LoadIcon(GetModuleHandle(NULL), 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))
		ri.Sys_Error(ERR_FATAL, "Couldn't register window class.");

	if (fullscreen)
	{
		exstyle = WS_EX_TOPMOST;
		stylebits = WS_POPUP|WS_VISIBLE;
	}
	else
	{
		exstyle = 0;
		stylebits = WS_OVERLAPPEDWINDOW;
	}

	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
	{
		POINT pt1, pt2;

		vid_xpos = ri.Cvar_Get("vid_xpos", "0", 0);
		vid_ypos = ri.Cvar_Get("vid_ypos", "0", 0);
		x = vid_xpos->value;
		y = vid_ypos->value;

		// === jit - make sure the window is visible on a monitor so it doesn't get stuck off-screen somewhere.
		pt1.x = x;
		pt1.y = y;
		pt2.x = x + 100;
		pt2.y = x + 100;
		
		if (!(MonitorFromPoint(pt1, MONITOR_DEFAULTTONULL) && MonitorFromPoint(pt2, MONITOR_DEFAULTTONULL)))
		{
			x = 3;
			y = 22;
		}
		// jit ===
	}

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

	if (!glw_state.hWnd)
		ri.Sys_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())
	{
		ri.Con_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
	ri.Vid_NewWindow(width, height);

	return true;
}
Ejemplo n.º 9
0
static bool VID_CreateWindow( void )
{
	bool fullscreen = glConfig.fullScreen;
	HWND parentHWND = glw_state.parenthWnd;
#ifdef WITH_UTF8
	WNDCLASSW wc;
#else
	WNDCLASS  wc;
#endif

	Q_snprintfz( glw_state.windowClassName, sizeof( glw_state.windowClassName ), "%sWndClass", glw_state.applicationName );
#ifdef WITH_UTF8
	MultiByteToWideChar( CP_UTF8, 0, glw_state.windowClassName, -1, glw_state.windowClassNameW, sizeof( glw_state.windowClassNameW ) );
	glw_state.windowClassNameW[sizeof( glw_state.windowClassNameW )/sizeof( glw_state.windowClassNameW[0] ) - 1] = 0;
#endif

	/* 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( glw_state.applicationIconResourceID ) );
	wc.hCursor       = LoadCursor( NULL, IDC_ARROW );
	wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
	wc.lpszMenuName  = 0;
#ifdef WITH_UTF8
	wc.lpszClassName = (LPCWSTR)glw_state.windowClassNameW;
	if( !RegisterClassW( &wc ) )
#else
	wc.lpszClassName = (LPCSTR)glw_state.windowClassName;
	if( !RegisterClass( &wc ) )
#endif
		Sys_Error( "Couldn't register window class" );

	glw_state.hWnd =
#ifdef WITH_UTF8
		CreateWindowExW(
#else
		CreateWindowEx(
#endif
	        0,
#ifdef WITH_UTF8
	        glw_state.windowClassNameW,
	        glw_state.applicationNameW,
#else
	        glw_state.windowClassName,
	        glw_state.applicationName,
#endif
			0,
	        0, 0, 0, 0,
	        parentHWND,
	        NULL,
	        glw_state.hInstance,
	        NULL );

	if( !glw_state.hWnd )
		Sys_Error( "Couldn't create window" );

	VID_SetWindowSize( fullscreen );

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

	return true;
}
Ejemplo n.º 10
0
static qboolean VID_CreateWindow( void )
{
#define WITH_UTF8 // FIXME: turn non-Unicode code into a runtime fallback for Win9x
#ifndef WITH_UTF8
	WNDCLASS  wc;
#else
	WNDCLASSW wc;
	qboolean fullscreen = glState.fullScreen;
	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

	/* 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" );

	glw_state.hWnd = CreateWindowEx(
	        0,
	        WINDOW_CLASS_NAME,
	        APPLICATION,
			0,
	        0, 0, 0, 0,
	        parentHWND,
	        NULL,
	        glw_state.hInstance,
	        NULL );

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

	VID_SetWindowSize( fullscreen );

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

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

	return qtrue;
}
Ejemplo n.º 11
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;
}
Ejemplo n.º 12
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;
}
Ejemplo n.º 13
0
bool GLimp_SetMode(unsigned *pwidth, unsigned *pheight, int mode, bool fullscreen)
{
	int		width, height, colorBits;

	if (!Vid_GetModeInfo(&width, &height, mode))
	{
		appWPrintf("Invalid mode: %d\n", mode);
		return false;
	}

	appPrintf("Mode %d: %dx%d (%s)\n", mode, width, height, fullscreen ? "fullscreen" : "windowed");

	// destroy the existing window
	if (gl_hWnd)
		GLimp_Shutdown(false);

	colorBits = gl_bitdepth->integer;
	gl_bitdepth->modified = false;

	// do a CDS if needed
	if (fullscreen)
	{
		DEVMODE dm;
		memset(&dm, 0, sizeof(dm));
		dm.dmSize       = sizeof(dm);
		dm.dmPelsWidth  = width;
		dm.dmPelsHeight = height;
		dm.dmFields     = DM_PELSWIDTH|DM_PELSHEIGHT;

		if (colorBits)
		{
			dm.dmBitsPerPel = colorBits;
			dm.dmFields |= DM_BITSPERPEL;
			appPrintf("...using color depth of %d\n", colorBits);
		}
		else
		{
			HDC hdc = GetDC(NULL);
			int bitspixel = GetDeviceCaps(hdc, BITSPIXEL);
			ReleaseDC(0, hdc);
			appPrintf("...using desktop color depth of %d\n", bitspixel);
		}

		MSGLOG(("CDS(%dx%d, FS)\n", dm.dmPelsWidth, dm.dmPelsHeight));
		if (ChangeDisplaySettings(&dm, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
		{
			appWPrintf("...fullscreen unavailable in this mode\n");
			appPrintf("...setting windowed mode\n");
			fullscreen = false;

			MSGLOG(("CDS(NULL)\n"));
			ChangeDisplaySettings(NULL, 0);
		}
	}
	else	// not fullscreen
	{
		appPrintf("...setting windowed mode\n");
		MSGLOG(("CDS(NULL)\n"));
		ChangeDisplaySettings(NULL, 0);
	}

	*pwidth  = width;
	*pheight = height;
	gl_config.fullscreen = fullscreen;

	gl_hWnd = (HWND) Vid_CreateWindow(width, height, fullscreen);
	if (!gl_hWnd) return false;
	if (!GLimp_InitGL()) return false;	//?? may try to DestroyWindow(force) + CreateWindow() again

	// init gamma
	ReadGamma();
	appPrintf("Gamma: %s\n", gammaStored ? "hardware" : "software");

	return true;
}