Exemple #1
0
int
GGI_directx_DDMatchMode(struct ggi_visual *vis, ggi_mode *mode,
	    int *depth, int *defwidth, int *defheight)
{
	directx_priv *priv = GGIDIRECTX_PRIV(vis);
	HRESULT hr;
	matchmode mm;
	int result = 1;

	mm.vis = vis;
	mm.mode = mode;
	mm.bestx = mm.besty = mm.bits = 0;
	mm.x = mode->visible.x;
	mm.y = mode->visible.y;
	if (mm.x == GGI_AUTO)
		mm.x = mode->virt.x;
	if (mm.y == GGI_AUTO)
		mm.y = mode->virt.y;

	hr = IDirectDraw2_EnumDisplayModes(priv->lpddext,
		0, NULL, &mm, ModeCallback);

	*depth = mm.bits;
	*defwidth = mm.bestx;
	*defheight = mm.besty;

	return result;
}
Exemple #2
0
//
// Application call here to enumerate display modes
//
BOOL EnumDirectDrawDisplayModes (APPENUMMODESCALLBACK appFunc)
{
	LPVOID lpappFunc = appFunc;

	if (DDr2 == NULL)
		return FALSE;

	// enumerate display modes
	// Carl: DirectX 3.x apparently does not support VGA modes. Who cares. :)
	// faB: removed DDEDM_REFRESHRATES, detects too many modes, plus we don't care of refresh rate.
	if (bDX0300)
		IDirectDraw2_EnumDisplayModes (DDr2, 0 /*| DDEDM_REFRESHRATES*/,
		                               NULL, lpappFunc, myEnumModesCallback);
	else
		IDirectDraw2_EnumDisplayModes (DDr2, DDEDM_STANDARDVGAMODES /*| DDEDM_REFRESHRATES*/,
		                               NULL, lpappFunc, myEnumModesCallback);
	return TRUE;
}
Exemple #3
0
int directdraw_init(HWND hwndp)
{
    int                 width = 320, height = 200;
    RECT                rect;
    DDPIXELFORMAT       format;
    DDSURFACEDESC       descriptor;
    DIRECTDRAWCREATE    DirectDrawCreate;

	if(lpDDS) return 0;
	if(!hwndp) return 0;
	if(video_window) return 0; /* you gotta uninitialize it first */

    library = (HMODULE) LoadLibrary(uni("ddraw.dll"));
    if(!library) return 0;

    DirectDrawCreate = (DIRECTDRAWCREATE) GetProcAddress(library, "DirectDrawCreate");
    if(!DirectDrawCreate) return 0;

    if(FAILED(DirectDrawCreate(0,&lpDD,0))) return 0;

    wc.style         = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
    wc.lpfnWndProc   = WndProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = 0;
    wc.hIcon         = 0;
    wc.hCursor       = LoadCursor(0, IDC_ARROW);
    wc.hbrBackground = 0;
    wc.lpszMenuName  = 0;
    wc.lpszClassName = window_class_name;

    RegisterClass(&wc);

    video_window = CreateWindow(window_class_name, uni("Video"), WS_CHILD, 0, 0, width, height, hwndp, 0, 0, 0);

    ShowWindow(video_window, SW_NORMAL);

    if(FAILED(IDirectDraw2_SetCooperativeLevel(lpDD, video_window, DDSCL_NORMAL))) return 0;


    descriptor.dwSize         = sizeof(descriptor);
    descriptor.dwFlags        = DDSD_CAPS;
    descriptor.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_VIDEOMEMORY;

    if(FAILED(IDirectDraw2_CreateSurface(lpDD, &descriptor, &lpDDS, 0))) return 0;

    descriptor.dwFlags        = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
	descriptor.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
    descriptor.dwWidth        = d_width ;
    descriptor.dwHeight       = d_height;

    if(FAILED(IDirectDraw2_CreateSurface(lpDD, &descriptor, &lpDDS_secondary, 0))) return 0;
    
    if(FAILED(IDirectDraw2_CreateClipper(lpDD, 0, &lpDDC, 0))) return 0;

    if(FAILED(IDirectDrawClipper_SetHWnd(lpDDC, 0, video_window))) return 0;

    if(FAILED(IDirectDrawSurface2_SetClipper(lpDDS, lpDDC))) return 0;
    
    lpDDS_back    = lpDDS_secondary;
    format.dwSize = sizeof(format);

    if(FAILED(IDirectDrawSurface2_GetPixelFormat(lpDDS, &format))) return 0;

    if(!(format.dwFlags & DDPF_RGB)) return 0;


	IDirectDraw2_EnumDisplayModes(lpDD, DDEDM_STANDARDVGAMODES, 0, 0, EnumDisplayModesCallback);


	osd_initialize();
	osd_created = 0;

    return 1;
}
Exemple #4
0
/* init DirectX */
static int InitDD(int fullscreen)
{
    HRESULT ddrval;
    HDC hDC;
    directX = fullscreen ? DXFULLSCREEN : DXWINDOWED;

    if (!hModule)
	hModule = LoadLibrary("ddraw");
    if (!hModule) {
	/*x_error ("Unable to load DirectX (ddraw.dll)"); */
	return 0;
    }
    /* DirectDraw don't support 16 color modes. Don't even try to initialize
       it then. Also avoid unsupported bit depths in the windowed driver */
    hDC = CreateDC("DISPLAY", NULL, NULL, NULL);
    bitDepth = GetDeviceCaps(hDC, BITSPIXEL);
    DeleteDC(hDC);

    if (!DXSUPPORTEDDEPTH(fullscreen, bitDepth))
	return 0;


    DirectDrawCreatePtr =
	(ddrawcreateptr) GetProcAddress(hModule, "DirectDrawCreate");
    if (!DirectDrawCreatePtr) {
	x_error
	    ("Unable to get hook DirectDrawCreate in ddraw.dll. Check your DirectX installation");
	return 0;
    }

    lpDD = NULL;
    lpDD2 = NULL;
    lpSurfaces[0] = NULL;
    lpSurfaces[1] = NULL;
    buffer1 = buffer2 = NULL;

    bitDepth = 8;

    InitWindow();
    UpdateWindow(hWnd);
    SetFocus(hWnd);


    /* contact DirectX */
    ddrval = DirectDrawCreatePtr(NULL, &lpDD, NULL);
    if (ddrval != DD_OK) {
	DeInitDD();
	x_error("Failed to create DirectDraw object");
	return 0;
    }

    /* get IDirectDraw2 interface */
    ddrval =
	IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw2,
				   (LPVOID *) & lpDD2);
    if (ddrval != DD_OK) {
	DeInitDD();
	x_error("Failed to get DirectDraw2 object");
	return 0;
    }
    /* enumerate modes */
#ifdef DDRAW_DRIVER
    if (!nresolutions && directX == DXFULLSCREEN)
	IDirectDraw2_EnumDisplayModes(lpDD2, 0, NULL, NULL,
				      EnumModesCallback);
#endif


    if (!ResizeDD(fullscreen))
	return 0;
    if (fullscreen) {
	SetCapture(hWnd);	// make sure no other windows get mouse messages

	captured = 1;
    }

    return 1;
}