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


C++ SDL_arraysize函数代码示例

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


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

示例1: WIN_GL_LoadLibrary

int
WIN_GL_LoadLibrary(_THIS, const char *path)
{
    void *handle;

    if (path == NULL) {
        path = SDL_getenv("SDL_OPENGL_LIBRARY");
    }
    if (path == NULL) {
        path = DEFAULT_OPENGL;
    }
    _this->gl_config.dll_handle = SDL_LoadObject(path);
    if (!_this->gl_config.dll_handle) {
        return -1;
    }
    SDL_strlcpy(_this->gl_config.driver_path, path,
                SDL_arraysize(_this->gl_config.driver_path));

    /* Allocate OpenGL memory */
    _this->gl_data = (struct SDL_GLDriverData *) SDL_calloc(1, sizeof(struct SDL_GLDriverData));
    if (!_this->gl_data) {
        return SDL_OutOfMemory();
    }

    /* Load function pointers */
    handle = _this->gl_config.dll_handle;
    _this->gl_data->wglGetProcAddress = (void *(WINAPI *) (const char *))
        SDL_LoadFunction(handle, "wglGetProcAddress");
    _this->gl_data->wglCreateContext = (HGLRC(WINAPI *) (HDC))
        SDL_LoadFunction(handle, "wglCreateContext");
    _this->gl_data->wglDeleteContext = (BOOL(WINAPI *) (HGLRC))
        SDL_LoadFunction(handle, "wglDeleteContext");
    _this->gl_data->wglMakeCurrent = (BOOL(WINAPI *) (HDC, HGLRC))
        SDL_LoadFunction(handle, "wglMakeCurrent");
    _this->gl_data->wglShareLists = (BOOL(WINAPI *) (HGLRC, HGLRC))
        SDL_LoadFunction(handle, "wglShareLists");

    if (!_this->gl_data->wglGetProcAddress ||
        !_this->gl_data->wglCreateContext ||
        !_this->gl_data->wglDeleteContext ||
        !_this->gl_data->wglMakeCurrent) {
        return SDL_SetError("Could not retrieve OpenGL functions");
    }

    return 0;
}
开发者ID:rave-engine,项目名称:SDL,代码行数:46,代码来源:SDL_windowsopengl.c

示例2: cartman_mpd_add_fan_verts

//--------------------------------------------------------------------------------------------
int cartman_mpd_add_fan_verts(cartman_mpd_t *self, cartman_mpd_tile_t *pfan)
{
    // ZZ> This function allocates the vertices needed for a fan_idx

    int vertexlist[MAP_FAN_VERTICES_MAX + 1];

    int vert_count;

    Uint8 fan_type;

    tile_definition_t    * pdef;
    //Cartman::mpd_vertex_t * vrt_list;

    if ( NULL == pfan ) return -1;

    // grab the mesh
    if (!self) self = &mesh;
    //vrt_list = self->vrt2[0];

    fan_type = pfan->type;

    // get the tile definition
    pdef = TILE_DICT_PTR( tile_dict, fan_type );
    if ( NULL == pdef )
    {
        log_warning( "%s - tried to add invalid fan_idx type %d\n", __FUNCTION__, fan_type );
    }

    // check the vertex count
    vert_count = pdef->numvertices;
    if ( 0 == vert_count )
    {
        log_warning( "%s - tried to add undefined fan_idx type %d\n", __FUNCTION__, fan_type );
    }
    if ( vert_count > MAP_FAN_VERTICES_MAX )
    {
        log_error( "%s - fan_idx type %d is defined with too many vertices %d\n", __FUNCTION__, fan_type, vert_count );
    }

    cartman_mpd_allocate_vertex_list(self, vertexlist, SDL_arraysize(vertexlist), vert_count);

    // set the vertex posisions
    pfan->vrtstart = vertexlist[0];

    return pfan->vrtstart;
}
开发者ID:italoalesil,项目名称:egoboo,代码行数:47,代码来源:cartman_map.c

示例3: Android_Vulkan_GetInstanceExtensions

SDL_bool Android_Vulkan_GetInstanceExtensions(_THIS,
                                          SDL_Window *window,
                                          unsigned *count,
                                          const char **names)
{
    static const char *const extensionsForAndroid[] = {
        VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_ANDROID_SURFACE_EXTENSION_NAME
    };
    if(!_this->vulkan_config.loader_handle)
    {
        SDL_SetError("Vulkan is not loaded");
        return SDL_FALSE;
    }
    return SDL_Vulkan_GetInstanceExtensions_Helper(
            count, names, SDL_arraysize(extensionsForAndroid),
            extensionsForAndroid);
}
开发者ID:Evengard,项目名称:UniMod,代码行数:17,代码来源:SDL_androidvulkan.c

示例4: HandleKeyEvent

/* FIXME
   Mir still needs to implement its IM API, for now we assume
   a single key press produces a character.
*/
static void
HandleKeyEvent(MirKeyEvent const ev, SDL_Window* window)
{
    uint32_t scancode = SDL_SCANCODE_UNKNOWN;
    Uint8 key_state = ev.action == mir_key_action_up ? SDL_RELEASED : SDL_PRESSED;

    CheckKeyboardFocus(window);

    if (ev.scan_code < SDL_arraysize(xfree86_scancode_table2))
        scancode = xfree86_scancode_table2[ev.scan_code];

    if (scancode != SDL_SCANCODE_UNKNOWN)
        SDL_SendKeyboardKey(key_state, scancode);

    if (key_state == SDL_PRESSED)
        HandleKeyText(ev.key_code);
}
开发者ID:ArkyRomania,项目名称:ufoai,代码行数:21,代码来源:SDL_mirevents.c

示例5: SDL_DUMMY_DestroyRenderer

static void
SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer)
{
    SDL_DUMMY_RenderData *data =
        (SDL_DUMMY_RenderData *) renderer->driverdata;
    int i;

    if (data) {
        for (i = 0; i < SDL_arraysize(data->screens); ++i) {
            if (data->screens[i]) {
                SDL_FreeSurface(data->screens[i]);
            }
        }
        SDL_free(data);
    }
    SDL_free(renderer);
}
开发者ID:Alexander--,项目名称:Wesnoth-1.8-for-Android,代码行数:17,代码来源:SDL_nullrender.c

示例6: DirectFB_GL_LoadLibrary

int
DirectFB_GL_LoadLibrary(_THIS, const char *path)
{
    //SDL_DFB_DEVICEDATA(_this);

    void *handle = NULL;

    SDL_DFB_DEBUG("Loadlibrary : %s\n", path);

    if (_this->gl_data->gl_active) {
        SDL_SetError("OpenGL context already created");
        return -1;
    }


    if (path == NULL) {
        path = SDL_getenv("SDL_VIDEO_GL_DRIVER");
        if (path == NULL) {
            path = "libGL.so";
        }
    }

    handle = GL_LoadObject(path);
    if (handle == NULL) {
        SDL_DFB_ERR("Library not found: %s\n", path);
        /* SDL_LoadObject() will call SDL_SetError() for us. */
        return -1;
    }

    SDL_DFB_DEBUG("Loaded library: %s\n", path);

    _this->gl_config.dll_handle = handle;
    _this->gl_config.driver_loaded = 1;
    if (path) {
        SDL_strlcpy(_this->gl_config.driver_path, path,
                    SDL_arraysize(_this->gl_config.driver_path));
    } else {
        *_this->gl_config.driver_path = '\0';
    }

    _this->gl_data->glFinish = DirectFB_GL_GetProcAddress(_this, "glFinish");
    _this->gl_data->glFlush = DirectFB_GL_GetProcAddress(_this, "glFlush");

    return 0;
}
开发者ID:AG-Dev,项目名称:wesnoth_ios,代码行数:45,代码来源:SDL_DirectFB_opengl.c

示例7: LoadALSALibrary

static int LoadALSALibrary(void) {
	int i, retval = -1;

	alsa_handle = SDL_LoadObject(alsa_library);
	if (alsa_handle) {
		alsa_loaded = 1;
		retval = 0;
		for (i = 0; i < SDL_arraysize(alsa_functions); i++) {
			*alsa_functions[i].func = SDL_LoadFunction(alsa_handle,alsa_functions[i].name);
			if (!*alsa_functions[i].func) {
				retval = -1;
				UnloadALSALibrary();
				break;
			}
		}
	}
	return retval;
}
开发者ID:3bu1,项目名称:crossbridge,代码行数:18,代码来源:SDL_alsa_audio.c

示例8: add_object_to_table

//--------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
void add_object_to_table( treasure_table_t table[], const char *name )
{
    //ZF> Adds a new treasure object to the specified treasure table

    //Avoid null pointers
    if ( table == NULL ) return;

    //Make sure there is enough size to add one more
    if ( table->size + 1 >= TREASURE_TABLE_SIZE )
    {
        log_warning( "No more room to add object (%s) to table, consider increasing TREASURE_TABLE_SIZE (currently %i)\n", name, TREASURE_TABLE_SIZE );
        return;
    }

    //Add the element to the list
    strncpy( table->object_list[ table->size ], name, SDL_arraysize( table->object_list[ table->size ] ) );
    table->size++;
}
开发者ID:wangeek,项目名称:Egoboo,代码行数:20,代码来源:treasure_table_file.c

示例9: _name

LoadPlayerElement::LoadPlayerElement(std::shared_ptr<ObjectProfile> profile) :
    _name("*NONE*"),
    _profile(profile),
    _skinRef(profile->getSkinOverride()),
    _selectedByPlayer(-1),
    _inputDevice(INPUT_DEVICE_UNKNOWN),
    _isSelected(false)
{
    // load the quest info from "quest.txt" so we can determine the valid modules
    quest_log_download_vfs(_questLog, SDL_arraysize(_questLog), profile->getPathname().c_str());

    // load the chop data from "naming.txt" to generate the character name (kinda silly how it's done currently)
    RandomName randomName;
    randomName.loadFromFile(profile->getPathname() + "/naming.txt");
    
    // generate the name from the chop
    _name = randomName.generateRandomName();
}
开发者ID:italoalesil,项目名称:egoboo,代码行数:18,代码来源:LoadPlayerElement.cpp

示例10:

static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym) {
	/* Sanity check */
	if (scancode >= SDL_arraysize(keymap))
		scancode = KEYCODE_UNKNOWN;

	/* Set the keysym information */
	keysym->scancode = scancode;
	keysym->sym = keymap[scancode];
	keysym->mod = KMOD_NONE;

	/* If UNICODE is on, get the UNICODE value for the key */
	keysym->unicode = 0;
	if (SDL_TranslateUNICODE) {
		/* Populate the unicode field with the ASCII value */
		keysym->unicode = scancode;
	}
	return (keysym);
}
开发者ID:Deltafire,项目名称:MilkyTracker,代码行数:18,代码来源:SDL_androidvideo.c

示例11: load_SDL_md2_vertex_RW

//--------------------------------------------------------------------------------------------
SDL_md2_vertex_t * load_SDL_md2_vertex_RW( SDL_RWops * rw, SDL_md2_vertex_t * pdata, size_t count )
{
    if ( NULL == pdata ) return pdata;

    memset( pdata, 0, count * sizeof( SDL_md2_vertex_t ) );

    if ( NULL == rw ) return pdata;

    for (size_t i = 0; i < count; ++i)
    {
        SDL_md2_vertex_t * pvrt = pdata + i;

        read_SDL_vecuc_RW( rw, pvrt->v, SDL_arraysize( pdata->v ) );
        SDL_RWread( rw, &( pvrt->normalIndex ), 1, 1 );
    }

    return pdata;
}
开发者ID:italoalesil,项目名称:egoboo,代码行数:19,代码来源:SDL_md2.c

示例12: SDL_GetScancodeFromName

SDL_Scancode SDL_GetScancodeFromName(const char *name)
{
    unsigned int i;

    if (!name || !*name) {
        return SDL_SCANCODE_UNKNOWN;
    }

    for (i = 0; i < SDL_arraysize(SDL_scancode_names); ++i) {
        if (!SDL_scancode_names[i]) {
            continue;
        }
        if (SDL_strcasecmp(name, SDL_scancode_names[i]) == 0) {
            return static_cast<SDL_Scancode>(i);
        }
    }

    return SDL_SCANCODE_UNKNOWN;
}
开发者ID:Heark,项目名称:wesnoth,代码行数:19,代码来源:keyboard.cpp

示例13: LoadESDLibrary

static int LoadESDLibrary(void)
{
	int i, retval = -1;

	esd_handle = SDL_LoadObject(esd_library);
	if ( esd_handle ) {
		esd_loaded = 1;
		retval = 0;
		for ( i=0; i<SDL_arraysize(esd_functions); ++i ) {
			*esd_functions[i].func = SDL_LoadFunction(esd_handle, esd_functions[i].name);
			if ( !*esd_functions[i].func ) {
				retval = -1;
				UnloadESDLibrary();
				break;
			}
		}
	}
	return retval;
}
开发者ID:3bu1,项目名称:crossbridge,代码行数:19,代码来源:SDL_esdaudio.c

示例14: LoadPulseLibrary

static int LoadPulseLibrary(void)
{
	int i, retval = -1;

	pulse_handle = SDL_LoadObject(pulse_library);
	if ( pulse_handle ) {
		pulse_loaded = 1;
		retval = 0;
		for ( i=0; i<SDL_arraysize(pulse_functions); ++i ) {
			*pulse_functions[i].func = SDL_LoadFunction(pulse_handle, pulse_functions[i].name);
			if ( !*pulse_functions[i].func ) {
				retval = -1;
				UnloadPulseLibrary();
				break;
			}
		}
	}
	return retval;
}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:19,代码来源:SDL_pulseaudio.c

示例15: D3D_AddRenderDriver

void
D3D_AddRenderDriver(_THIS)
{
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    SDL_RendererInfo *info = &D3D_RenderDriver.info;
    SDL_DisplayMode *mode = &SDL_CurrentDisplay.desktop_mode;

    if (data->d3d) {
        int i;
        int formats[] = {
            SDL_PIXELFORMAT_INDEX8,
            SDL_PIXELFORMAT_RGB332,
            SDL_PIXELFORMAT_RGB444,
            SDL_PIXELFORMAT_RGB555,
            SDL_PIXELFORMAT_ARGB4444,
            SDL_PIXELFORMAT_ARGB1555,
            SDL_PIXELFORMAT_RGB565,
            SDL_PIXELFORMAT_RGB888,
            SDL_PIXELFORMAT_ARGB8888,
            SDL_PIXELFORMAT_ARGB2101010,
        };

        for (i = 0; i < SDL_arraysize(formats); ++i) {
            if (D3D_IsTextureFormatAvailable
                (data->d3d, mode->format, formats[i])) {
                info->texture_formats[info->num_texture_formats++] =
                    formats[i];
            }
        }
        info->texture_formats[info->num_texture_formats++] =
            SDL_PIXELFORMAT_YV12;
        info->texture_formats[info->num_texture_formats++] =
            SDL_PIXELFORMAT_IYUV;
        info->texture_formats[info->num_texture_formats++] =
            SDL_PIXELFORMAT_YUY2;
        info->texture_formats[info->num_texture_formats++] =
            SDL_PIXELFORMAT_UYVY;
        info->texture_formats[info->num_texture_formats++] =
            SDL_PIXELFORMAT_YVYU;

        SDL_AddRenderDriver(0, &D3D_RenderDriver);
    }
}
开发者ID:dodikk,项目名称:iWesnoth,代码行数:43,代码来源:SDL_d3drender.c


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