示例#1
0
文件: rw_imp.c 项目: Slipyx/r1q2
/*
** SWimp_InitGraphics
**
** This initializes the software refresh's implementation specific
** graphics subsystem.  In the case of Windows it creates DIB or
** DDRAW surfaces.
**
** The necessary width and height parameters are grabbed from
** vid.width and vid.height.
*/
static qboolean SWimp_InitGraphics( qboolean fullscreen )
{
	// free resources in use
	SWimp_Shutdown ();

	// create a new window
	VID_CreateWindow (vid.width, vid.height, WINDOW_STYLE);

	// initialize the appropriate subsystem
	if ( !fullscreen )
	{
		if ( !DIB_Init( &vid.buffer, &vid.rowbytes ) )
		{
			vid.buffer = 0;
			vid.rowbytes = 0;

			return false;
		}
	}
	else
	{
		if ( !DDRAW_Init( &vid.buffer, &vid.rowbytes ) )
		{
			vid.buffer = 0;
			vid.rowbytes = 0;

			return false;
		}
	}

	return true;
}
示例#2
0
/*
** SWimp_InitGraphics
**
** This initializes the software refresh's implementation specific
** graphics subsystem.  In the case of Windows it creates DIB or
** DDRAW surfaces.
**
** The necessary width and height parameters are grabbed from
** vid.width and vid.height.
*/
static qboolean SWimp_InitGraphics( qboolean fullscreen )
{
	int bsize, zsize, tsize;

	SWimp_Shutdown();

	current_mode = get_mode(vid.width, vid.height);

	if (current_mode < 0) {
		ri.Con_Printf (PRINT_ALL, "Mode %d %d not found\n", vid.width, vid.height);
		return false; // mode not found
	}

	// let the sound and input subsystems know about the new window
	ri.Vid_NewWindow (vid.width, vid.height);

	ri.Con_Printf (PRINT_ALL, "Setting VGAMode: %d\n", current_mode );

//	Cvar_SetValue ("vid_mode", (float)modenum);
	
	VGA_width = modes[current_mode].width;
	VGA_height = modes[current_mode].height;
	VGA_planar = modes[current_mode].bytesperpixel == 0;
	VGA_rowbytes = modes[current_mode].linewidth;

	vid.rowbytes = modes[current_mode].linewidth;

	if (VGA_planar) {
		VGA_bufferrowbytes = modes[current_mode].linewidth * 4;
		vid.rowbytes = modes[current_mode].linewidth*4;
	}

// get goin'

	vga_setmode(current_mode);

	VGA_pagebase = framebuffer_ptr = (char *) vga_getgraphmem();
//		if (vga_setlinearaddressing()>0)
//			framebuffer_ptr = (char *) vga_getgraphmem();
	if (!framebuffer_ptr)
		Sys_Error("This mode isn't hapnin'\n");

	vga_setpage(0);

	vid.buffer = malloc(vid.rowbytes * vid.height);
	if (!vid.buffer)
		Sys_Error("Unabled to alloc vid.buffer!\n");

	return true;
}
示例#3
0
/*
** SWimp_InitGraphics
**
** This initializes the software refresh's implementation specific
** graphics subsystem.  In the case of Windows it creates DIB or
** DDRAW surfaces.
**
** The necessary width and height parameters are grabbed from
** vid.width and vid.height.
*/
static qboolean SWimp_InitGraphics( qboolean fullscreen){
	int pnum, i;
	long template_mask;
	
	srandom(getpid());
	
	
	// free resources in use
	SWimp_Shutdown();
	
	// let the sound and input subsystems know about the new window
	ri.Vid_NewWindow(vid.width, vid.height);
	
	// for debugging only
	//	XSynchronize(x_disp, True);
	
	// check for command-line window size
	template_mask = 0;
	
	
	// setup attributes for main window
	{
		int attribmask = CWEventMask | CWBorderPixel;
		XSetWindowAttributes attribs;
		
		window_width = vid.width;
		window_height = vid.height;
		
		attribs.event_mask = STD_EVENT_MASK;
		attribs.border_pixel = 0;
		
		// create the main window
		x_win = XCreateWindow( x_disp,
							   XRootWindow( x_disp, DefaultScreen( x_disp)),
							   0, 0, 	// x, y
							   window_width, window_height,
							   0,  // borderwidth
							   CopyFromParent,
							   InputOutput,
							   CopyFromParent,
							   attribmask,
							   &attribs);
		XStoreName( x_disp, x_win, "Quake II");
		
	}
	
	// inviso cursor
	XDefineCursor( x_disp, x_win, CreateNullCursor( x_disp, x_win));
	
	// create the GC
	{
		XGCValues xgcvalues;
		int valuemask = GCGraphicsExposures;
		xgcvalues.graphics_exposures = False;
		x_gc = XCreateGC( x_disp, x_win, valuemask, &xgcvalues);
	}
	
	/* set the icon */
	{
		Pixmap icon;
		XWMHints hints;
		icon = XCreateBitmapFromData( x_disp, DefaultRootWindow( x_disp),
									  q2_bits, q2_width, q2_height);
		/*				  BlackPixel( x_disp, DefaultScreen( x_disp)),
		WhitePixel( x_disp, DefaultScreen( x_disp)),
		1);*/
		hints.icon_pixmap = icon;
		hints.flags = IconPixmapHint;
		XSetWMHints( x_disp, x_win, &hints);
	}
	
	// map the window
	XMapWindow( x_disp, x_win);
	
	// wait for first exposure event
	{
		XEvent event;
		do {
			XNextEvent( x_disp, &event);
		} while( event.type != Expose || event.xexpose.count != 0);
	}
	// now safe to draw
	
	ResetNEWTFrameBuffers();
	
	//	XSynchronize(x_disp, False);
	
	old_windowed_mouse = 0;
	X11_active = true;
	
	return true;
}
示例#4
0
文件: rw_sdl.c 项目: AJenbo/Quake-2
void GLimp_Shutdown( void )
{
	SWimp_Shutdown();
}