当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_GetDisplayForWindow函数代码示例

本文整理汇总了C++中SDL_GetDisplayForWindow函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_GetDisplayForWindow函数的具体用法?C++ SDL_GetDisplayForWindow怎么用?C++ SDL_GetDisplayForWindow使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SDL_GetDisplayForWindow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: KMSDRM_GLES_SetupCrtc

SDL_bool
KMSDRM_GLES_SetupCrtc(_THIS, SDL_Window * window) {
    SDL_WindowData *wdata = ((SDL_WindowData *) window->driverdata);
    SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
    SDL_VideoData *vdata = ((SDL_VideoData *)_this->driverdata);
    KMSDRM_FBInfo *fb_info;

    if (!(_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, wdata->egl_surface))) {
	SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "eglSwapBuffers failed on CRTC setup");
	return SDL_FALSE;
    }

    wdata->next_bo = KMSDRM_gbm_surface_lock_front_buffer(wdata->gs);
    if (wdata->next_bo == NULL) {
	SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not lock GBM surface front buffer on CRTC setup");
	return SDL_FALSE;
    }

    fb_info = KMSDRM_FBFromBO(_this, wdata->next_bo);
    if (fb_info == NULL) {
	return SDL_FALSE;
    }

    if(KMSDRM_drmModeSetCrtc(vdata->drm_fd, displaydata->crtc_id, fb_info->fb_id,
			    0, 0, &vdata->saved_conn_id, 1, &displaydata->cur_mode) != 0) {
       SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Could not set up CRTC to a GBM buffer");
       return SDL_FALSE;

    }
    
    wdata->crtc_ready = SDL_TRUE;
    return SDL_TRUE;
}
开发者ID:1vanK,项目名称:Urho3D,代码行数:33,代码来源:SDL_kmsdrmopengles.c

示例2: NDS_CreateRenderer

static SDL_Renderer *
NDS_CreateRenderer(SDL_Window * window, Uint32 flags)
{
    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    SDL_DisplayMode *displayMode = &display->current_mode;
    SDL_Renderer *renderer;
    NDS_RenderData *data;
    int bpp;
    Uint32 Rmask, Gmask, Bmask, Amask;

	if (displayMode->format != SDL_PIXELFORMAT_ABGR1555) {
		SDL_SetError("Unsupported pixel format (%x)", displayMode->format);
		return NULL;
	}

    if (!SDL_PixelFormatEnumToMasks(displayMode->format, &bpp,
                                    &Rmask, &Gmask, &Bmask, &Amask)) {
        SDL_SetError("Unknown display format");
        return NULL;
    }

    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
    if (!renderer) {
        SDL_OutOfMemory();
        return NULL;
    }

    data = (NDS_RenderData *) SDL_calloc(1, sizeof(*data));
    if (!data) {
        SDL_free(renderer);
        SDL_OutOfMemory();
        return NULL;
    }

    renderer->info.name = NDS_RenderDriver.info.name;
    renderer->info.flags = 0;
    renderer->info.num_texture_formats = NDS_RenderDriver.info.num_texture_formats;
    SDL_memcpy(renderer->info.texture_formats,
			   NDS_RenderDriver.info.texture_formats,
               sizeof(renderer->info.texture_formats));
    renderer->info.max_texture_width = NDS_RenderDriver.info.max_texture_width;
    renderer->info.max_texture_height = NDS_RenderDriver.info.max_texture_height;

	renderer->UpdateViewport = NDS_UpdateViewport;
    renderer->CreateTexture = NDS_CreateTexture;
	renderer->DestroyTexture = NDS_DestroyTexture;
	renderer->RenderCopy = NDS_RenderCopy;	
	renderer->UpdateTexture = NDS_UpdateTexture;
	renderer->LockTexture = NDS_LockTexture;
	renderer->UnlockTexture = NDS_UnlockTexture;
	renderer->RenderClear = NDS_RenderClear;
	renderer->RenderPresent = NDS_RenderPresent;
	renderer->RenderDrawPoints = NDS_RenderDrawPoints;
	renderer->RenderDrawLines = NDS_RenderDrawLines;
	renderer->RenderFillRects = NDS_RenderFillRects;

    return renderer;
}
开发者ID:0xD34D,项目名称:supermariowar-android,代码行数:58,代码来源:SDL_ndsrender.c

示例3: DirectFB_AcquireVidLayer

static int
DirectFB_AcquireVidLayer(SDL_Renderer * renderer, SDL_Texture * texture)
{
    //SDL_DFB_RENDERERDATA(renderer);
    SDL_Window *window = renderer->window;
    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    SDL_DFB_DEVICEDATA(display->device);
    DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
    DirectFB_TextureData *data = texture->driverdata;
    DFBDisplayLayerConfig layconf;
    DFBResult ret;

    if (devdata->use_yuv_direct && (dispdata->vidID >= 0)
        && (!dispdata->vidIDinuse)
        && SDL_ISPIXELFORMAT_FOURCC(data->format)) {
        layconf.flags =
            DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT |
            DLCONF_SURFACE_CAPS;
        layconf.width = texture->w;
        layconf.height = texture->h;
        layconf.pixelformat = DirectFB_SDLToDFBPixelFormat(data->format);
        layconf.surface_caps = DSCAPS_VIDEOONLY | DSCAPS_DOUBLE;

        SDL_DFB_CHECKERR(devdata->dfb->GetDisplayLayer(devdata->dfb,
                                                       dispdata->vidID,
                                                       &dispdata->vidlayer));
        SDL_DFB_CHECKERR(dispdata->
                         vidlayer->SetCooperativeLevel(dispdata->vidlayer,
                                                       DLSCL_EXCLUSIVE));

        if (devdata->use_yuv_underlays) {
            ret = dispdata->vidlayer->SetLevel(dispdata->vidlayer, -1);
            if (ret != DFB_OK)
                SDL_DFB_DEBUG("Underlay Setlevel not supported\n");
        }
        SDL_DFB_CHECKERR(dispdata->
                         vidlayer->SetConfiguration(dispdata->vidlayer,
                                                    &layconf));
        SDL_DFB_CHECKERR(dispdata->
                         vidlayer->GetSurface(dispdata->vidlayer,
                                              &data->surface));
        dispdata->vidIDinuse = 1;
        data->display = display;
        return 0;
    }
    return 1;
  error:
    if (dispdata->vidlayer) {
        SDL_DFB_RELEASE(data->surface);
        SDL_DFB_CHECKERR(dispdata->
                         vidlayer->SetCooperativeLevel(dispdata->vidlayer,
                                                       DLSCL_ADMINISTRATIVE));
        SDL_DFB_RELEASE(dispdata->vidlayer);
    }
    return 1;
}
开发者ID:AG-Dev,项目名称:wesnoth_ios,代码行数:56,代码来源:SDL_DirectFB_render.c

示例4: DirectFB_DestroyRenderer

static void
DirectFB_DestroyRenderer(SDL_Renderer * renderer)
{
    DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(data->window);
#if 0
    if (display->palette) {
        SDL_DelPaletteWatch(display->palette, DisplayPaletteChanged, data);
    }
#endif

    SDL_free(data);
    SDL_free(renderer);
}
开发者ID:mgerhardy,项目名称:caveexpress,代码行数:14,代码来源:SDL_DirectFB_render.c

示例5: DirectFB_WarpMouse

/* Warp the mouse to (x,y) */
static void
DirectFB_WarpMouse(SDL_Window * window, int x, int y)
{
    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
    DFB_WindowData *windata = (DFB_WindowData *) window->driverdata;
    int cx, cy;

    SDL_DFB_CHECKERR(windata->dfbwin->GetPosition(windata->dfbwin, &cx, &cy));
    SDL_DFB_CHECKERR(dispdata->layer->WarpCursor(dispdata->layer,
                                                 cx + x + windata->client.x,
                                                 cy + y + windata->client.y));

  error:
    return;
}
开发者ID:GWRon,项目名称:sdl.mod,代码行数:17,代码来源:SDL_DirectFB_mouse.c

示例6: SDL_IBus_UpdateTextRect

void
SDL_IBus_UpdateTextRect(SDL_Rect *rect)
{
    SDL_Window *focused_win;
    SDL_SysWMinfo info;
    int x = 0, y = 0;
    SDL_DBusContext *dbus;

    if (rect) {
        SDL_memcpy(&ibus_cursor_rect, rect, sizeof(ibus_cursor_rect));
    }

    focused_win = SDL_GetKeyboardFocus();
    if (!focused_win) {
        return;
    }

    SDL_VERSION(&info.version);
    if (!SDL_GetWindowWMInfo(focused_win, &info)) {
        return;
    }

    SDL_GetWindowPosition(focused_win, &x, &y);
   
#if SDL_VIDEO_DRIVER_X11    
    if (info.subsystem == SDL_SYSWM_X11) {
        SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayForWindow(focused_win)->driverdata;
            
        Display *x_disp = info.info.x11.display;
        Window x_win = info.info.x11.window;
        int x_screen = displaydata->screen;
        Window unused;
            
        X11_XTranslateCoordinates(x_disp, x_win, RootWindow(x_disp, x_screen), 0, 0, &x, &y, &unused);
    }
#endif

    x += ibus_cursor_rect.x;
    y += ibus_cursor_rect.y;
        
    dbus = SDL_DBus_GetContext();
    
    if (IBus_CheckConnection(dbus)) {
        SDL_DBus_CallVoidMethodOnConnection(ibus_conn, IBUS_SERVICE, input_ctx_path, IBUS_INPUT_INTERFACE, "SetCursorLocation",
                DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, DBUS_TYPE_INT32, &ibus_cursor_rect.w, DBUS_TYPE_INT32, &ibus_cursor_rect.h, DBUS_TYPE_INVALID);
    }
}
开发者ID:jfiguinha,项目名称:Regards,代码行数:47,代码来源:SDL_ibus.c

示例7: WIN_CreateWindow

int
WIN_CreateWindow(_THIS, SDL_Window * window)
{
    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    HWND hwnd;
    RECT rect;
    DWORD style = STYLE_BASIC;
    int x, y;
    int w, h;
    
    style |= GetWindowStyle(window);

    /* Figure out what the window area will be */
    rect.left = window->x;
    rect.top = window->y;
    rect.right = window->x + window->w;
    rect.bottom = window->y + window->h;
    AdjustWindowRectEx(&rect, style, FALSE, 0);
    x = rect.left;
    y = rect.top;
    w = (rect.right - rect.left);
    h = (rect.bottom - rect.top);

    hwnd =
        CreateWindow(SDL_Appname, TEXT(""), style, x, y, w, h, NULL, NULL,
                     SDL_Instance, NULL);
    if (!hwnd) {
        WIN_SetError("Couldn't create window");
        return -1;
    }

    WIN_PumpEvents(_this);

    if (SetupWindowData(_this, window, hwnd, SDL_TRUE) < 0) {
        DestroyWindow(hwnd);
        return -1;
    }
#if SDL_VIDEO_OPENGL_WGL
    if (window->flags & SDL_WINDOW_OPENGL) {
        if (WIN_GL_SetupWindow(_this, window) < 0) {
            WIN_DestroyWindow(_this, window);
            return -1;
        }
    }
#endif
    return 0;
}
开发者ID:Blitzoreo,项目名称:pcsx2-online,代码行数:47,代码来源:SDL_windowswindow.c

示例8: WIN_SetWindowPosition

void
WIN_SetWindowPosition(_THIS, SDL_Window * window)
{
    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
    RECT rect;
    SDL_Rect bounds;
    DWORD style;
    HWND top;
    BOOL menu;
    int x, y;
    int w, h;

    /* Figure out what the window area will be */
    if (window->flags & SDL_WINDOW_FULLSCREEN) {
        top = HWND_TOPMOST;
    } else {
        top = HWND_NOTOPMOST;
    }
    style = GetWindowLong(hwnd, GWL_STYLE);
    rect.left = 0;
    rect.top = 0;
    rect.right = window->w;
    rect.bottom = window->h;
#ifdef _WIN32_WCE
    menu = FALSE;
#else
    menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
#endif
    AdjustWindowRectEx(&rect, style, menu, 0);
    w = (rect.right - rect.left);
    h = (rect.bottom - rect.top);

    WIN_GetDisplayBounds(_this, display, &bounds);
    if (SDL_WINDOWPOS_ISCENTERED(window->x)) {
        x = bounds.x + (bounds.w - w) / 2;
    } else {
        x = window->x + rect.left;
    }
    if (SDL_WINDOWPOS_ISCENTERED(window->y)) {
        y = bounds.y + (bounds.h - h) / 2;
    } else {
        y = window->y + rect.top;
    }

    SetWindowPos(hwnd, top, x, y, 0, 0, (SWP_NOCOPYBITS | SWP_NOSIZE));
}
开发者ID:Blitzoreo,项目名称:pcsx2-online,代码行数:47,代码来源:SDL_windowswindow.c

示例9: MIR_SetWindowGammaRamp

int
MIR_SetWindowGammaRamp(_THIS, SDL_Window* window, Uint16 const* ramp)
{
    MirOutput* output = SDL_GetDisplayForWindow(window)->driverdata;
    Uint32 ramp_size = 256;

    // FIXME Need to apply the changes to the output, once that public API function is around
    if (MIR_mir_output_is_gamma_supported(output) == mir_output_gamma_supported) {
        MIR_mir_output_set_gamma(output,
                                 ramp + ramp_size * 0,
                                 ramp + ramp_size * 1,
                                 ramp + ramp_size * 2,
                                 ramp_size);
        return 0;
    }

    return -1;
}
开发者ID:Antokolos,项目名称:instead-android-ng,代码行数:18,代码来源:SDL_mirwindow.c

示例10: WIN_GetWindowGammaRamp

int
WIN_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp)
{
    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
    HDC hdc;
    BOOL succeeded = FALSE;

    hdc = CreateDC(data->DeviceName, NULL, NULL, NULL);
    if (hdc) {
        succeeded = GetDeviceGammaRamp(hdc, (LPVOID)ramp);
        if (!succeeded) {
            WIN_SetError("GetDeviceGammaRamp()");
        }
        DeleteDC(hdc);
    }
    return succeeded ? 0 : -1;
}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:18,代码来源:SDL_windowswindow.c

示例11: DirectFB_SetContext

void
DirectFB_SetContext(_THIS, SDL_Window *window)
{
#if (DFB_VERSION_ATLEAST(1,0,0))
    /* FIXME: does not work on 1.0/1.2 with radeon driver
     *        the approach did work with the matrox driver
     *        This has simply no effect.
     */

    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;

	/* FIXME: should we handle the error */
    if (dispdata->vidIDinuse)
        SDL_DFB_CHECK(dispdata->vidlayer->SwitchContext(dispdata->vidlayer,
                                                           DFB_TRUE));
#endif
}
开发者ID:0xD34D,项目名称:supermariowar-android,代码行数:18,代码来源:SDL_DirectFB_modes.c

示例12: Android_SetScreenResolution

void
Android_SetScreenResolution(int width, int height, Uint32 format, float rate)
{
	static int times = 0;
	posix_print("#%i, Android_SetScreenResolution------(%ix%i), format: 0x%08x, rate: %7.2f, Android_Window: %p\n", 
		times, width, height, format, rate, Android_Window);

	SDL_VideoDevice* device;
	SDL_VideoDisplay *display;
    Android_ScreenWidth = width;
    Android_ScreenHeight = height;
    Android_ScreenFormat = format;
    Android_ScreenRate = rate;

    /*
      Update the resolution of the desktop mode, so that the window
      can be properly resized. The screen resolution change can for
      example happen when the Activity enters or exists immersive mode,
      which can happen after VideoInit().
    */
    device = SDL_GetVideoDevice();
    if (device && device->num_displays > 0)
    {
        display = &device->displays[0];
        display->desktop_mode.format = Android_ScreenFormat;
        display->desktop_mode.w = Android_ScreenWidth;
        display->desktop_mode.h = Android_ScreenHeight;
        display->desktop_mode.refresh_rate  = Android_ScreenRate;
    }

    if (Android_Window) {
        SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, width, height);

        /* Force the current mode to match the resize otherwise the SDL_WINDOWEVENT_RESTORED event
         * will fall back to the old mode */
        display = SDL_GetDisplayForWindow(Android_Window);

        display->current_mode.format = format;
        display->current_mode.w = width;
        display->current_mode.h = height;
        display->current_mode.refresh_rate = rate;
    }
	times ++;
}
开发者ID:freeors,项目名称:SDL,代码行数:44,代码来源:SDL_androidvideo.c

示例13: MIR_GetWindowGammaRamp

int
MIR_GetWindowGammaRamp(_THIS, SDL_Window* window, Uint16* ramp)
{
    MirOutput* output = SDL_GetDisplayForWindow(window)->driverdata;
    Uint32 ramp_size = 256;

    if (MIR_mir_output_is_gamma_supported(output) == mir_output_gamma_supported) {
        if (MIR_mir_output_get_gamma_size(output) == ramp_size) {
            MIR_mir_output_get_gamma(output,
                                     ramp + ramp_size * 0,
                                     ramp + ramp_size * 1,
                                     ramp + ramp_size * 2,
                                     ramp_size);
            return 0;
        }
    }

    return -1;
}
开发者ID:Antokolos,项目名称:instead-android-ng,代码行数:19,代码来源:SDL_mirwindow.c

示例14: FB_CreateWindow

int
FB_CreateWindow(_THIS, SDL_Window * window)
{
    SDL_WindowData *wdata;
    SDL_VideoDisplay *display;

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

    /* Windows have one size for now */
    window->w = display->desktop_mode.w;
    window->h = display->desktop_mode.h;

    /* OpenGL ES is the law here, buddy */
    window->flags |= SDL_WINDOW_OPENGL;

    if (!_this->egl_data) {
        if (SDL_GL_LoadLibrary(NULL) < 0) {
            return -1;
        }
    }

    wdata->egl_surface = SDL_EGL_CreateSurface(_this, 0);
    if (wdata->egl_surface == EGL_NO_SURFACE) {
        return SDL_SetError("Could not create GLES window surface");
    }

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

    /* One window, it always has focus */
    SDL_SetMouseFocus(window);
    SDL_SetKeyboardFocus(window);

    /* Window has been successfully created */
    return 0;
}
开发者ID:pcercuei,项目名称:SDL2,代码行数:41,代码来源:SDL_fbvideo.c

示例15: DirectFB_ShowCursor

/* Show the specified cursor, or hide if cursor is NULL */
static int
DirectFB_ShowCursor(SDL_Cursor * cursor)
{
    SDL_DFB_CURSORDATA(cursor);
    DFBResult ret;
    SDL_Window *window;

    window = SDL_GetFocusWindow();
    if (!window)
        return -1;
    else {
        SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);

        if (display) {
            DFB_DisplayData *dispdata =
                (DFB_DisplayData *) display->driverdata;
            DFB_WindowData *windata = (DFB_WindowData *) window->driverdata;

            if (cursor)
                SDL_DFB_CHECKERR(windata->dfbwin->
                                 SetCursorShape(windata->dfbwin,
                                                curdata->surf, curdata->hotx,
                                                curdata->hoty));

            SDL_DFB_CHECKERR(dispdata->layer->
                             SetCooperativeLevel(dispdata->layer,
                                                 DLSCL_ADMINISTRATIVE));
            SDL_DFB_CHECKERR(dispdata->layer->
                             SetCursorOpacity(dispdata->layer,
                                              cursor ? 0xC0 : 0x00));
            SDL_DFB_CHECKERR(dispdata->layer->
                             SetCooperativeLevel(dispdata->layer,
                                                 DLSCL_SHARED));
        }
    }

    return 0;
  error:
    return -1;
}
开发者ID:Derek-OBrien,项目名称:DsdlEngine,代码行数:41,代码来源:SDL_DirectFB_mouse.c


注:本文中的SDL_GetDisplayForWindow函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。