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


C++ SDL_GetVideoDevice函数代码示例

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


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

示例1: SDL_VideoModeOK

int
SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags)
{
    int i, actual_bpp = 0;

    if (!SDL_GetVideoDevice()) {
        return 0;
    }

    if (!(flags & SDL_FULLSCREEN)) {
        SDL_DisplayMode mode;
        SDL_GetDesktopDisplayMode(GetVideoDisplay(), &mode);
        return SDL_BITSPERPIXEL(mode.format);
    }

    for (i = 0; i < SDL_GetNumDisplayModes(GetVideoDisplay()); ++i) {
        SDL_DisplayMode mode;
        SDL_GetDisplayMode(GetVideoDisplay(), i, &mode);
        if (!mode.w || !mode.h || (width == mode.w && height == mode.h)) {
            if (!mode.format) {
                return bpp;
            }
            if (SDL_BITSPERPIXEL(mode.format) >= (Uint32) bpp) {
                actual_bpp = SDL_BITSPERPIXEL(mode.format);
            }
        }
    }
    return actual_bpp;
}
开发者ID:Blitzoreo,项目名称:pcsx2-online,代码行数:29,代码来源:SDL_compat.c

示例2: X11_SafetyNetErrHandler

static int
X11_SafetyNetErrHandler(Display * d, XErrorEvent * e)
{
    SDL_VideoDevice *device = NULL;
    /* if we trigger an error in our error handler, don't try again. */
    if (!safety_net_triggered) {
        safety_net_triggered = SDL_TRUE;
        device = SDL_GetVideoDevice();
        if (device != NULL) {
            int i;
            for (i = 0; i < device->num_displays; i++) {
                SDL_VideoDisplay *display = &device->displays[i];
                if (SDL_memcmp(&display->current_mode, &display->desktop_mode,
                               sizeof (SDL_DisplayMode)) != 0) {
                    X11_SetDisplayMode(device, display, &display->desktop_mode);
                }
            }
        }
    }

    if (orig_x11_errhandler != NULL) {
        return orig_x11_errhandler(d, e);  /* probably terminate. */
    }

    return 0;
}
开发者ID:inolen,项目名称:redream,代码行数:26,代码来源:SDL_x11video.c

示例3: X11_ShowCursor

static int
X11_ShowCursor(SDL_Cursor * cursor)
{
    Cursor x11_cursor = 0;

    if (cursor) {
        x11_cursor = (Cursor)cursor->driverdata;
    } else {
        x11_cursor = X11_CreateEmptyCursor();
    }

    /* FIXME: Is there a better way than this? */
    {
        SDL_VideoDevice *video = SDL_GetVideoDevice();
        Display *display = GetDisplay();
        SDL_Window *window;
        SDL_WindowData *data;

        for (window = video->windows; window; window = window->next) {
            data = (SDL_WindowData *)window->driverdata;
            if (x11_cursor != None) {
                X11_XDefineCursor(display, data->xwindow, x11_cursor);
            } else {
                X11_XUndefineCursor(display, data->xwindow);
            }
        }
        X11_XFlush(display);
    }
    return 0;
}
开发者ID:Daft-Freak,项目名称:vogl,代码行数:30,代码来源:SDL_x11mouse.c

示例4: Wayland_input_lock_pointer

int Wayland_input_lock_pointer(struct SDL_WaylandInput *input)
{
    SDL_VideoDevice *vd = SDL_GetVideoDevice();
    SDL_VideoData *d = input->display;
    SDL_Window *window;
    struct zwp_relative_pointer_v1 *relative_pointer;

    if (!d->relative_pointer_manager)
        return -1;

    if (!d->pointer_constraints)
        return -1;

    if (!input->relative_pointer) {
        relative_pointer =
            zwp_relative_pointer_manager_v1_get_relative_pointer(
                d->relative_pointer_manager,
                input->pointer);
        zwp_relative_pointer_v1_add_listener(relative_pointer,
                                             &relative_pointer_listener,
                                             input);
        input->relative_pointer = relative_pointer;
    }

    for (window = vd->windows; window; window = window->next)
        lock_pointer_to_window(window, input);

    d->relative_mouse_mode = 1;

    return 0;
}
开发者ID:inolen,项目名称:redream,代码行数:31,代码来源:SDL_waylandevents.c

示例5: MIR_ShowCursor

static int
MIR_ShowCursor(SDL_Cursor* cursor)
{
    MIR_Data* mir_data      = (MIR_Data*)SDL_GetVideoDevice()->driverdata;
    MIR_Window* mir_window  = mir_data->current_window;

    if (cursor && cursor->driverdata) {
        if (mir_window && MIR_mir_window_is_valid(mir_window->window)) {
            MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->driverdata;

            if (mir_cursor->name != NULL) {
                MirWindowSpec* spec = MIR_mir_create_window_spec(mir_data->connection);
                MIR_mir_window_spec_set_cursor_name(spec, mir_cursor->name);
                MIR_mir_window_apply_spec(mir_window->window, spec);
                MIR_mir_window_spec_release(spec);
            }

            if (mir_cursor->conf) {
                MIR_mir_window_configure_cursor(mir_window->window, mir_cursor->conf);
            }
        }
    }
    else if(mir_window && MIR_mir_window_is_valid(mir_window->window)) {
        MIR_mir_window_configure_cursor(mir_window->window, NULL);
    }

    return 0;
}
开发者ID:inolen,项目名称:redream,代码行数:28,代码来源:SDL_mirmouse.c

示例6: MIR_CreateCursor

static SDL_Cursor*
MIR_CreateCursor(SDL_Surface* surface, int hot_x, int hot_y)
{
    MirCursorConfiguration* conf;
    MirBufferStream*        stream;

    int s_w = surface->w;
    int s_h = surface->h;

    MIR_Data* mir_data     = (MIR_Data*)SDL_GetVideoDevice()->driverdata;
    SDL_Cursor* cursor     = MIR_CreateDefaultCursor();
    MIR_Cursor* mir_cursor;

    if (!cursor) {
        return NULL;
    }

    mir_cursor = (MIR_Cursor*)cursor->driverdata;

    stream = MIR_mir_connection_create_buffer_stream_sync(mir_data->connection,
                                                          s_w, s_h, mir_data->pixel_format,
                                                          mir_buffer_usage_software);

    conf = MIR_mir_cursor_configuration_from_buffer_stream(stream, hot_x, hot_y);

    CopySurfacePixelsToMirStream(surface, stream);
    MIR_mir_buffer_stream_swap_buffers_sync(stream);

    mir_cursor->conf   = conf;
    mir_cursor->stream = stream;

    return cursor;
}
开发者ID:inolen,项目名称:redream,代码行数:33,代码来源:SDL_mirmouse.c

示例7: SDL_GetGammaRamp

int
SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue)
{
    SDL_VideoDevice *_this = SDL_GetVideoDevice();
    if (!_this) {
        SDL_UninitializedVideo();
        return -1;
    }
    return SDL_GetGammaRampForDisplay(SDL_CurrentDisplay, red, green, blue);
}
开发者ID:Alexander--,项目名称:Wesnoth-1.8-for-Android,代码行数:10,代码来源:SDL_gamma.c

示例8: SDL_PumpEvents

/* Run the system dependent event loops */
void SDL_PumpEvents(void)
{
    if (!SDL_EventThread) {
        SDL_VideoDevice *_this = SDL_GetVideoDevice();

        /* Get events from the video subsystem */
        if (_this) {
            _this->PumpEvents(_this);
        }
    }
}
开发者ID:heyfluke,项目名称:dolphin-player,代码行数:12,代码来源:b.c

示例9: DirectFB_CreateDefaultCursor

static SDL_Cursor *
DirectFB_CreateDefaultCursor(void)
{
    SDL_VideoDevice *dev = SDL_GetVideoDevice();

    SDL_DFB_DEVICEDATA(dev);
    DFB_CursorData *curdata;
    DFBResult ret;
    DFBSurfaceDescription dsc;
    SDL_Cursor *cursor;
    Uint32 *dest;
    Uint32 *p;
    int pitch, i, j;

    SDL_DFB_ALLOC_CLEAR( cursor, sizeof(*cursor));
    SDL_DFB_ALLOC_CLEAR(curdata, sizeof(*curdata));

    dsc.flags =
        DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS;
    dsc.caps = DSCAPS_VIDEOONLY;
    dsc.width = 32;
    dsc.height = 32;
    dsc.pixelformat = DSPF_ARGB;

    SDL_DFB_CHECKERR(devdata->dfb->CreateSurface(devdata->dfb, &dsc,
                                                 &curdata->surf));
    curdata->hotx = 0;
    curdata->hoty = 0;
    cursor->driverdata = curdata;

    SDL_DFB_CHECKERR(curdata->surf->Lock(curdata->surf, DSLF_WRITE,
                                         (void *) &dest, &pitch));

    /* Relies on the fact that this is only called with ARGB surface. */
    for (i = 0; i < 32; i++)
    {
        for (j = 0; j < 32; j++)
        {
            switch (arrow[i][j])
            {
            case ' ': dest[j] = 0x00000000; break;
            case '.': dest[j] = 0xffffffff; break;
            case 'X': dest[j] = 0xff000000; break;
            }
        }
        dest += (pitch >> 2);
    }

    curdata->surf->Unlock(curdata->surf);
    return cursor;
  error:
    return NULL;
}
开发者ID:Derek-OBrien,项目名称:DsdlEngine,代码行数:53,代码来源:SDL_DirectFB_mouse.c

示例10: AndroidPreCreateWindow

void AndroidPreCreateWindow() {
  // Apply scaler setting prior creating surface
  if (g_android_scaler_resolution.x() && g_android_scaler_resolution.y()) {
    // Initialize OpenGL function pointers inside SDL
    if (SDL_GL_LoadLibrary(NULL) < 0) {
      SDL_LogError(SDL_LOG_CATEGORY_ERROR,
                   "couldn't initialize OpenGL library\n");
    }

    // Hook eglCreateWindowSurface call
    SDL_VideoDevice* device = SDL_GetVideoDevice();
    device->egl_data->eglCreateWindowSurface = HookEglCreateWindowSurface;
  }
}
开发者ID:DavidLeeEvans,项目名称:pienoon,代码行数:14,代码来源:renderer_android.cpp

示例11: SDL_GetGammaRampForDisplay

int
SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue)
{
    SDL_VideoDevice *_this = SDL_GetVideoDevice();

    if (!_this) {
        SDL_UninitializedVideo();
        return -1;
    }

    /* Lazily allocate the gamma table */
    if (!display->gamma) {
        size_t rampsize = (3 * 256 * sizeof(*display->gamma));

        display->gamma = SDL_malloc(rampsize * 2);
        if (!display->gamma) {
            SDL_OutOfMemory();
            return -1;
        }
        if (_this && _this->GetDisplayGammaRamp) {
            /* Get the real hardware gamma */
            _this->GetDisplayGammaRamp(_this, display, display->gamma);
        } else {
            /* Assume an identity gamma */
            int i;
            for (i = 0; i < 256; ++i) {
                display->gamma[0 * 256 + i] = (i << 8) | i;
                display->gamma[1 * 256 + i] = (i << 8) | i;
                display->gamma[2 * 256 + i] = (i << 8) | i;
            }
        }
        display->saved_gamma = display->gamma + (3 * 256);
        SDL_memcpy(display->saved_gamma, display->gamma, rampsize);
    }

    /* Just copy from our internal table */
    if (red) {
        SDL_memcpy(red, &display->gamma[0 * 256], 256 * sizeof(*red));
    }
    if (green) {
        SDL_memcpy(green, &display->gamma[1 * 256], 256 * sizeof(*green));
    }
    if (blue) {
        SDL_memcpy(blue, &display->gamma[2 * 256], 256 * sizeof(*blue));
    }
    return 0;
}
开发者ID:Alexander--,项目名称:Wesnoth-1.8-for-Android,代码行数:47,代码来源:SDL_gamma.c

示例12: DirectFB_CreateCursor

/* Create a cursor from a surface */
static SDL_Cursor *
DirectFB_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
{
    SDL_VideoDevice *dev = SDL_GetVideoDevice();

    SDL_DFB_DEVICEDATA(dev);
    DFB_CursorData *curdata;
    DFBResult ret;
    DFBSurfaceDescription dsc;
    SDL_Cursor *cursor;
    Uint32 *dest;
    Uint32 *p;
    int pitch, i;

    SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888);
    SDL_assert(surface->pitch == surface->w * 4);

    SDL_DFB_ALLOC_CLEAR( cursor, sizeof(*cursor));
    SDL_DFB_ALLOC_CLEAR(curdata, sizeof(*curdata));

    dsc.flags =
        DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS;
    dsc.caps = DSCAPS_VIDEOONLY;
    dsc.width = surface->w;
    dsc.height = surface->h;
    dsc.pixelformat = DSPF_ARGB;

    SDL_DFB_CHECKERR(devdata->dfb->CreateSurface(devdata->dfb, &dsc,
                                                 &curdata->surf));
    curdata->hotx = hot_x;
    curdata->hoty = hot_y;
    cursor->driverdata = curdata;

    SDL_DFB_CHECKERR(curdata->surf->Lock(curdata->surf, DSLF_WRITE,
                                         (void *) &dest, &pitch));

    p = surface->pixels;
    for (i = 0; i < surface->h; i++)
        memcpy((char *) dest + i * pitch,
               (char *) p + i * surface->pitch, 4 * surface->w);

    curdata->surf->Unlock(curdata->surf);
    return cursor;
  error:
    return NULL;
}
开发者ID:Derek-OBrien,项目名称:DsdlEngine,代码行数:47,代码来源:SDL_DirectFB_mouse.c

示例13: SDL_MoveCursor

void
SDL_MoveCursor(int x, int y)
{
    SDL_VideoDevice *_this = SDL_GetVideoDevice();

    /* Erase and update the current mouse position */
    if (SHOULD_DRAWCURSOR(SDL_cursorstate)) {
        /* Erase and redraw mouse cursor in new position */
        SDL_LockCursor();
        SDL_EraseCursor(SDL_VideoSurface);
        SDL_cursor->area.x = (x - SDL_cursor->hot_x);
        SDL_cursor->area.y = (y - SDL_cursor->hot_y);
        SDL_DrawCursor(SDL_VideoSurface);
        SDL_UnlockCursor();
    } else if (_this->MoveWMCursor) {
        _this->MoveWMCursor(_this, x, y);
    }
}
开发者ID:Blitzoreo,项目名称:pcsx2-online,代码行数:18,代码来源:SDL_compat.c

示例14: SDL_PumpEvents

/* Run the system dependent event loops */
void
SDL_PumpEvents(void)
{
    if (!SDL_EventThread) {
        SDL_VideoDevice *_this = SDL_GetVideoDevice();

        /* Get events from the video subsystem */
        if (_this) {
            _this->PumpEvents(_this);
        }
#if !SDL_JOYSTICK_DISABLED
        /* Check for joystick state change */
        if (SDL_numjoysticks && (SDL_eventstate & SDL_JOYEVENTMASK)) {
            SDL_JoystickUpdate();
        }
#endif
    }
}
开发者ID:Bergasms,项目名称:N64iOS,代码行数:19,代码来源:SDL_events.c

示例15: 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


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