Esempio n. 1
0
static M4Err DD_Resize(VideoOutput *dr, u32 width, u32 height)
{
	DDCONTEXT;

	if (dd->is_3D_out) {
		dd->width = width;
		dd->height = height;
		return DD_SetupOpenGL(dr);
	}
	if (!dd->ddraw_init) 
		return InitDirectDraw(dr, width, height);
	else
		return CreateBackBuffer(dr, width, height);
}
Esempio n. 2
0
static M4Err DD_SetFullScreen(VideoOutput *dr, Bool bOn, u32 *outWidth, u32 *outHeight)
{
	M4Err e;
	char *sOpt;
	u32 MaxWidth, MaxHeight;
	DDCONTEXT;

	if (!dd->width ||!dd->height) return M4BadParam;
	if (bOn == dd->fullscreen) return M4OK;
	dd->fullscreen = bOn;

	
	/*whenever changing card display mode relocate fastest YUV format for blit (since it depends
	on the dest pixel format)*/
	dd->yuv_init = 0;
	if (dd->fullscreen) {
		char *sOpt = PMI_GetOpt(dr, "Video", "SwitchResolution");
		if (sOpt && !stricmp(sOpt, "yes")) dd->switch_res = 1;
		/*get current or best fitting mode*/
		if (GetDisplayMode(dd) != M4OK) return M4IOErr;
	}

	MaxWidth = MaxHeight = 0;
	sOpt = PMI_GetOpt(dr, "Video", "MaxResolution");
	if (sOpt) sscanf(sOpt, "%dx%d", &MaxWidth, &MaxHeight);

	dd->is_resizing = 1;

	if (dd->is_3D_out) {
		DEVMODE settings;
		e = M4OK;

		/*recreate the GL context whenever changing display settings, it's safer...*/
		DestroyObjects(dd);
		/*Setup FS*/
		if (dd->fullscreen) {
			/*change display mode*/
			if (dd->switch_res) {
				/*when switching res weird messages are sent to parent -> store current rect and post
				a size/pos message on restore */
				if (!dd->owns_hwnd) {
					HWND hWnd = GetParent(dd->hWnd);
					if (!hWnd) hWnd = dd->hWnd;
					GetWindowRect(hWnd, &dd->rcWnd);
				}
			}

			if ((MaxWidth && (dd->fs_width >= MaxWidth)) || (MaxHeight && (dd->fs_height >= MaxHeight)) ) {
				dd->fs_width = MaxWidth;
				dd->fs_height = MaxHeight;
			}

			/*force size change (we do it whether we own or not the window)*/
			dd->prev_styles = GetWindowLong(dd->hWnd, GWL_STYLE);
			GetWindowRect(dd->hWnd, &dd->rcChildWnd);
			SetWindowLong(dd->hWnd, GWL_STYLE, WS_POPUP);
			SetWindowPos(dd->hWnd, NULL, 0, 0, dd->fs_width, dd->fs_height, SWP_NOZORDER | SWP_SHOWWINDOW);
			SetForegroundWindow(dd->hWnd);

			memset(&settings, 0, sizeof(DEVMODE));
			settings.dmSize = sizeof(DEVMODE);
			settings.dmPelsWidth = dd->fs_width;
			settings.dmPelsHeight = dd->fs_height;
			settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
			if ( ChangeDisplaySettings(&settings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL ) {
				fprintf(stdout, "cannot change display settings...\n");
				e = M4IOErr;
			} 

			dd->NeedRestore = 1;
			dd->fs_store_width = dd->fs_width;
			dd->fs_store_height = dd->fs_height;
		}
		if (!e) e = DD_SetupOpenGL(dr);
		
	} else {
		e = InitDirectDraw(dr, dd->width, dd->height);
	}
	
	dd->is_resizing = 0;

	if (bOn) {
		dd->store_width = *outWidth;
		dd->store_height = *outHeight;
		*outWidth = dd->fs_width;
		*outHeight = dd->fs_height;
	} else {
		*outWidth = dd->store_width;
		*outHeight = dd->store_height;
	}
	return e;
}
Esempio n. 3
0
GF_Err DD_ProcessEvent(GF_VideoOutput*dr, GF_Event *evt)
{
	DDContext *ctx = (DDContext *)dr->opaque;
	if (!evt) return GF_OK;

	switch (evt->type) {
	case GF_EVENT_SET_CURSOR:
		DD_SetCursor(dr, evt->cursor.cursor_type);
		break;
	case GF_EVENT_SET_CAPTION:
		if (evt->caption.caption) SetWindowText(ctx->os_hwnd, evt->caption.caption);
		break;
	case GF_EVENT_MOVE:
		if (evt->move.relative == 2) {
			u32 x, y, fsw, fsh;
			x = y = 0;
			fsw = GetSystemMetrics(SM_CXSCREEN);
			fsh = GetSystemMetrics(SM_CYSCREEN);

			if (evt->move.align_x==1) x = (fsw - ctx->width) / 2;
			else if (evt->move.align_x==2) x = fsw - ctx->width;

			if (evt->move.align_y==1) y = (fsh - ctx->height) / 2;
			else if (evt->move.align_y==2) y = fsh - ctx->height;

			SetWindowPos(ctx->os_hwnd, NULL, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
		}
		else if (evt->move.relative) {
			POINT pt;
			pt.x = pt.y = 0;
			MapWindowPoints(ctx->os_hwnd, NULL, &pt, 1);
			SetWindowPos(ctx->os_hwnd, NULL, evt->move.x + pt.x, evt->move.y + pt.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
		} else {
			SetWindowPos(ctx->os_hwnd, NULL, evt->move.x, evt->move.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
		}
		break;
	case GF_EVENT_SHOWHIDE:
		ShowWindow(ctx->os_hwnd, evt->show.show_type ? SW_SHOW : SW_HIDE);
		break;
	/*if scene resize resize window*/
	case GF_EVENT_SIZE:
		if (ctx->owns_hwnd) {
			if (ctx->windowless)
				SetWindowPos(ctx->os_hwnd, NULL, 0, 0, evt->size.width, evt->size.height, SWP_NOZORDER | SWP_NOMOVE);
			else 
				SetWindowPos(ctx->os_hwnd, NULL, 0, 0, evt->size.width + ctx->off_w, evt->size.height + ctx->off_h, SWP_NOZORDER | SWP_NOMOVE);

			if (ctx->fullscreen) {
				ctx->store_width = evt->size.width;
				ctx->store_height = evt->size.height;
			}
		}
		break;
	/*HW setup*/
	case GF_EVENT_VIDEO_SETUP:
		if (ctx->is_3D_out) {
			ctx->width = evt->size.width;
			ctx->height = evt->size.height;
			return DD_SetupOpenGL(dr);
		}
		return DD_SetBackBufferSize(dr, evt->size.width, evt->size.height);
	}
	return GF_OK;
}