Пример #1
0
int
VIVANTE_GLES_LoadLibrary(_THIS, const char *path)
{
    SDL_DisplayData *displaydata;

    displaydata = SDL_GetDisplayDriverData(0);

    return SDL_EGL_LoadLibrary(_this, path, displaydata->native_display);
}
Пример #2
0
void
SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex )
{
	void *pDXGIDLL;
	IDXGIFactory *pDXGIFactory;

	*adapterIndex = -1;
	*outputIndex = -1;

	if (!DXGI_LoadDLL(&pDXGIDLL, &pDXGIFactory)) {
		SDL_SetError("Unable to create DXGI interface");
	} else {
		SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex);

		if (!pData) {
			SDL_SetError("Invalid display index");
		} else {
			char *displayName = WIN_StringToUTF8(pData->DeviceName);
			int nAdapter = 0, nOutput = 0;
			IDXGIAdapter* pDXGIAdapter;
			while ( *adapterIndex == -1 && IDXGIFactory_EnumAdapters(pDXGIFactory, nAdapter, &pDXGIAdapter) != DXGI_ERROR_NOT_FOUND ) {
				IDXGIOutput* pDXGIOutput;
				while ( *adapterIndex == -1 && IDXGIAdapter_EnumOutputs(pDXGIAdapter, nOutput, &pDXGIOutput) != DXGI_ERROR_NOT_FOUND ) {
					DXGI_OUTPUT_DESC outputDesc;
					if (SUCCEEDED(IDXGIOutput_GetDesc(pDXGIOutput, &outputDesc))) {
						char *outputName = WIN_StringToUTF8(outputDesc.DeviceName);

						if(!SDL_strcmp(outputName, displayName)) {
							*adapterIndex = nAdapter;
							*outputIndex = nOutput;
						}

						SDL_free( outputName );
					}

					IDXGIOutput_Release( pDXGIOutput );
					nOutput++;
				}

				IDXGIAdapter_Release( pDXGIAdapter );
				nAdapter++;
			}
			SDL_free(displayName);
		}

		/* free up the D3D stuff we inited */
		IDXGIFactory_AddRef( pDXGIFactory );
		SDL_UnloadObject(pDXGIDLL);
	}
}
Пример #3
0
SDL_bool
VIVANTE_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
{
    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    SDL_DisplayData *displaydata = SDL_GetDisplayDriverData(0);

    if (info->version.major == SDL_MAJOR_VERSION &&
        info->version.minor == SDL_MINOR_VERSION) {
        info->subsystem = SDL_SYSWM_VIVANTE;
        info->info.vivante.display = displaydata->native_display;
        info->info.vivante.window = data->native_window;
        return SDL_TRUE;
    } else {
        SDL_SetError("Application not compiled with SDL %d.%d\n",
                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
        return SDL_FALSE;
    }
}
Пример #4
0
int
VIVANTE_CreateWindow(_THIS, SDL_Window * window)
{
    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
    SDL_DisplayData *displaydata;
    SDL_WindowData *data;

    displaydata = SDL_GetDisplayDriverData(0);

    /* Allocate window internal data */
    data = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
    if (data == NULL) {
        return SDL_OutOfMemory();
    }

    /* Setup driver data for this window */
    window->driverdata = data;

#if SDL_VIDEO_DRIVER_VIVANTE_VDK
    data->native_window = vdkCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
#else
    data->native_window = videodata->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
#endif
    if (!data->native_window) {
        return SDL_SetError("VIVANTE: Can't create native window");
    }

#if SDL_VIDEO_OPENGL_EGL
    if (window->flags & SDL_WINDOW_OPENGL) {
        data->egl_surface = SDL_EGL_CreateSurface(_this, data->native_window);
        if (data->egl_surface == EGL_NO_SURFACE) {
            return SDL_SetError("VIVANTE: Can't create EGL surface");
        }
    } else {
        data->egl_surface = EGL_NO_SURFACE;
    }
#endif

    /* Window has been successfully created */
    return 0;
}
Пример #5
0
int
SDL_Direct3D9GetAdapterIndex( int displayIndex )
{
	void *pD3DDLL;
	IDirect3D9 *pD3D;
	if (!D3D_LoadDLL(&pD3DDLL, &pD3D)) {
		SDL_SetError("Unable to create Direct3D interface");
		return D3DADAPTER_DEFAULT;
	} else {
		SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex);
		int adapterIndex = D3DADAPTER_DEFAULT;

		if (!pData) {
			SDL_SetError("Invalid display index");
			adapterIndex = -1; /* make sure we return something invalid */
		} else {
			char *displayName = WIN_StringToUTF8(pData->DeviceName);
			unsigned int count = IDirect3D9_GetAdapterCount(pD3D);
			unsigned int i;
			for (i=0; i<count; i++) {
				D3DADAPTER_IDENTIFIER9 id;
				IDirect3D9_GetAdapterIdentifier(pD3D, i, 0, &id);

				if (SDL_strcmp(id.DeviceName, displayName) == 0) {
					adapterIndex = i;
					break;
				}
			}
			SDL_free(displayName);
		}

		/* free up the D3D stuff we inited */
		IDirect3D9_Release(pD3D);
		SDL_UnloadObject(pD3DDLL);

		return adapterIndex;
	}
}
Пример #6
0
static Uint32
X11_GetGlobalMouseState(int *x, int *y)
{
    Display *display = GetDisplay();
    const int num_screens = SDL_GetNumVideoDisplays();
    int i;

    /* !!! FIXME: should we XSync() here first? */

    for (i = 0; i < num_screens; i++) {
        SDL_DisplayData *data = (SDL_DisplayData *) SDL_GetDisplayDriverData(i);
        if (data != NULL) {
            Window root, child;
            int rootx, rooty, winx, winy;
            unsigned int mask;
            if (X11_XQueryPointer(display, RootWindow(display, data->screen), &root, &child, &rootx, &rooty, &winx, &winy, &mask)) {
                XWindowAttributes root_attrs;
                Uint32 retval = 0;
                retval |= (mask & Button1Mask) ? SDL_BUTTON_LMASK : 0;
                retval |= (mask & Button2Mask) ? SDL_BUTTON_MMASK : 0;
                retval |= (mask & Button3Mask) ? SDL_BUTTON_RMASK : 0;
                /* SDL_DisplayData->x,y point to screen origin, and adding them to mouse coordinates relative to root window doesn't do the right thing
                 * (observed on dual monitor setup with primary display being the rightmost one - mouse was offset to the right).
                 *
                 * Adding root position to root-relative coordinates seems to be a better way to get absolute position. */
                X11_XGetWindowAttributes(display, root, &root_attrs);
                *x = root_attrs.x + rootx;
                *y = root_attrs.y + rooty;
                return retval;
            }
        }
    }

    SDL_assert(0 && "The pointer wasn't on any X11 screen?!");

    return 0;
}
Пример #7
0
SDL_bool
SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputIndex)
{
#if !HAVE_DXGI_H
    if (adapterIndex) *adapterIndex = -1;
    if (outputIndex) *outputIndex = -1;
    SDL_SetError("SDL was compiled without DXGI support due to missing dxgi.h header");
    return SDL_FALSE;
#else
    SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex);
    void *pDXGIDLL;
    char *displayName;
    int nAdapter, nOutput;
    IDXGIFactory *pDXGIFactory;
    IDXGIAdapter *pDXGIAdapter;
    IDXGIOutput* pDXGIOutput;

    if (!adapterIndex) {
        SDL_InvalidParamError("adapterIndex");
        return SDL_FALSE;
    }

    if (!outputIndex) {
        SDL_InvalidParamError("outputIndex");
        return SDL_FALSE;
    }

    *adapterIndex = -1;
    *outputIndex = -1;

    if (!pData) {
        SDL_SetError("Invalid display index");
        return SDL_FALSE;
    }

    if (!DXGI_LoadDLL(&pDXGIDLL, &pDXGIFactory)) {
        SDL_SetError("Unable to create DXGI interface");
        return SDL_FALSE;
    }

    displayName = WIN_StringToUTF8(pData->DeviceName);
    nAdapter = 0;
    while (*adapterIndex == -1 && SUCCEEDED(IDXGIFactory_EnumAdapters(pDXGIFactory, nAdapter, &pDXGIAdapter))) {
        nOutput = 0;
        while (*adapterIndex == -1 && SUCCEEDED(IDXGIAdapter_EnumOutputs(pDXGIAdapter, nOutput, &pDXGIOutput))) {
            DXGI_OUTPUT_DESC outputDesc;
            if (SUCCEEDED(IDXGIOutput_GetDesc(pDXGIOutput, &outputDesc))) {
                char *outputName = WIN_StringToUTF8(outputDesc.DeviceName);
                if (SDL_strcmp(outputName, displayName) == 0) {
                    *adapterIndex = nAdapter;
                    *outputIndex = nOutput;
                }
                SDL_free(outputName);
            }
            IDXGIOutput_Release(pDXGIOutput);
            nOutput++;
        }
        IDXGIAdapter_Release(pDXGIAdapter);
        nAdapter++;
    }
    SDL_free(displayName);

    /* free up the DXGI factory */
    IDXGIFactory_Release(pDXGIFactory);
    SDL_UnloadObject(pDXGIDLL);

    if (*adapterIndex == -1) {
        return SDL_FALSE;
    } else {
        return SDL_TRUE;
    }
#endif
}