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


C++ SDL_getenv函数代码示例

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


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

示例1: SDL_SetError

SDL_Overlay *SDL_CreateYUVOverlay(int w, int h, Uint32 format,
                                  SDL_Surface *display)
{
 SDL_VideoDevice *video = current_video;
 SDL_VideoDevice *this  = current_video;
 const char *yuv_hwaccel;
 SDL_Overlay *overlay;

 if ( (display->flags & SDL_OPENGL) == SDL_OPENGL ) {
   SDL_SetError("YUV overlays are not supported in OpenGL mode");
   return NULL;
 }

 /* Display directly on video surface, if possible */
 if ( SDL_getenv("SDL_VIDEO_YUV_DIRECT") ) {
   if ( (display == SDL_PublicSurface) &&
        ((SDL_VideoSurface->format->BytesPerPixel == 2) ||
         (SDL_VideoSurface->format->BytesPerPixel == 4)) ) {
     display = SDL_VideoSurface;
   }
 }
 overlay = NULL;
        yuv_hwaccel = SDL_getenv("SDL_VIDEO_YUV_HWACCEL");
 if ( ((display == SDL_VideoSurface) && video->CreateYUVOverlay) &&
      (!yuv_hwaccel || (SDL_atoi(yuv_hwaccel) > 0)) ) {
   overlay = video->CreateYUVOverlay(this, w, h, format, display);
 }
 /* If hardware YUV overlay failed ... */
 if ( overlay == NULL ) {
   overlay = SDL_CreateYUV_SW(this, w, h, format, display);
 }
 return overlay;
}
开发者ID:iMacG4Projects,项目名称:Warmux-2,代码行数:33,代码来源:SDL_yuv.c

示例2: Audio_Available

static int Audio_Available(void)
{
	pa_sample_spec paspec;
	pa_simple *connection;
	int available;

	available = 0;
	if ( LoadPulseLibrary() < 0 ) {
		return available;
	}
	
	/* Connect with a dummy format. */
	paspec.format = PA_SAMPLE_U8;
	paspec.rate = 11025;
	paspec.channels = 1;
	connection = SDL_NAME(pa_simple_new)(
		SDL_getenv("PASERVER"),      /* server */
		"Test stream",               /* application name */
		PA_STREAM_PLAYBACK,          /* playback mode */
		SDL_getenv("PADEVICE"),      /* device on the server */
		"Simple DirectMedia Layer",  /* stream description */
		&paspec,                     /* sample format spec */
		NULL,                        /* channel map */
		NULL,                        /* buffering attributes */
		NULL                         /* error code */
	);
	if ( connection != NULL ) {
		available = 1;
		SDL_NAME(pa_simple_free)(connection);
	}
	
	UnloadPulseLibrary();
	return(available);
}
开发者ID:cuttl,项目名称:wii2600,代码行数:34,代码来源:SDL_pulseaudio.c

示例3: post_main_loop

static void post_main_loop(void)
{
    /* We want to improve the transitioning from FS-UAE back to e.g.
     * FS-UAE Game Center - avoid blinking cursor - so we try to move it (to
     * the bottom right of the screen). This probably requires that the
     * cursor is not grabbed (SDL often keeps the cursor in the center of the
     * screen then). */
    if (g_fs_emu_video_fullscreen) {
        if (SDL_getenv("FSGS_RETURN_CURSOR_TO") &&
                SDL_getenv("FSGS_RETURN_CURSOR_TO")[0]) {
            int x = -1; int y = -1;
            sscanf(SDL_getenv("FSGS_RETURN_CURSOR_TO"), "%d,%d", &x, &y);
            if (x != -1 && y != -1) {
#if 0
                fs_log("trying to move mouse cursor to x=%d y=%d\n", x, y);
#endif
                Uint8 data[] = "\0";
                SDL_SetWindowGrab(g_fs_ml_window, SDL_FALSE);
                /* Setting invisible cursor so we won't see it when we
                 * enable the cursor in order to move it. */
                SDL_Cursor *cursor = SDL_CreateCursor(data, data, 8, 1, 0, 0);
                SDL_SetCursor(cursor);
                SDL_ShowCursor(SDL_ENABLE);
                SDL_WarpMouseInWindow(g_fs_ml_window, x, y);
            }
        }
    }
}
开发者ID:alpine9000,项目名称:fs-uae,代码行数:28,代码来源:sdl.c

示例4: PND_gl_loadlibrary

int
PND_gl_loadlibrary(_THIS, const char *path)
{
    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;

    /* Check if OpenGL ES library is specified for GF driver */
    if (path == NULL) {
        path = SDL_getenv("SDL_OPENGL_LIBRARY");
        if (path == NULL) {
            path = SDL_getenv("SDL_OPENGLES_LIBRARY");
        }
    }

    /* Check if default library loading requested */
    if (path == NULL) {
        /* Already linked with GF library which provides egl* subset of  */
        /* functions, use Common profile of OpenGL ES library by default */
        path = "/usr/lib/libGLES_CM.so";
    }

    /* Load dynamic library */
    _this->gl_config.dll_handle = SDL_LoadObject(path);
    if (!_this->gl_config.dll_handle) {
        /* Failed to load new GL ES library */
        SDL_SetError("PND: Failed to locate OpenGL ES library");
        return -1;
    }

    /* Store OpenGL ES library path and name */
    SDL_strlcpy(_this->gl_config.driver_path, path,
                SDL_arraysize(_this->gl_config.driver_path));

    /* New OpenGL ES library is loaded */
    return 0;
}
开发者ID:g-truc,项目名称:shooter,代码行数:35,代码来源:SDL_pandora.c

示例5: GetVideoDisplay

static int GetVideoDisplay()
{
	const char *variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_DISPLAY");
	if (!variable)
		variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_HEAD");

	if (variable)
		return SDL_atoi(variable);
	else
		return 0;
}
开发者ID:HaohaoLau,项目名称:vdrift,代码行数:11,代码来源:window.cpp

示例6: SelectVideoDisplay

static void
SelectVideoDisplay()
{
    const char *variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_DISPLAY");
    if ( !variable ) {
        variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_HEAD");
    }
    if ( variable ) {
        SDL_SelectVideoDisplay(SDL_atoi(variable));
    }
}
开发者ID:Qua1iaq,项目名称:onscripter-engine-android,代码行数:11,代码来源:SDL_compat.c

示例7: get_classname

/* Find out what class name we should use
 * Based on src/video/x11/SDL_x11video.c */
static char *
get_classname()
{
/* !!! FIXME: this is probably wrong, albeit harmless in many common cases. From protocol spec:
    "The surface class identifies the general class of applications
    to which the surface belongs. A common convention is to use the
    file name (or the full path if it is a non-standard location) of
    the application's .desktop file as the class." */

    char *spot;
#if defined(__LINUX__) || defined(__FREEBSD__)
    char procfile[1024];
    char linkfile[1024];
    int linksize;
#endif

    /* First allow environment variable override */
    spot = SDL_getenv("SDL_VIDEO_WAYLAND_WMCLASS");
    if (spot) {
        return SDL_strdup(spot);
    } else {
        /* Fallback to the "old" envvar */
        spot = SDL_getenv("SDL_VIDEO_X11_WMCLASS");
        if (spot) {
            return SDL_strdup(spot);
        }
    }

    /* Next look at the application's executable name */
#if defined(__LINUX__) || defined(__FREEBSD__)
#if defined(__LINUX__)
    SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/exe", getpid());
#elif defined(__FREEBSD__)
    SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/file",
                 getpid());
#else
#error Where can we find the executable name?
#endif
    linksize = readlink(procfile, linkfile, sizeof(linkfile) - 1);
    if (linksize > 0) {
        linkfile[linksize] = '\0';
        spot = SDL_strrchr(linkfile, '/');
        if (spot) {
            return SDL_strdup(spot + 1);
        } else {
            return SDL_strdup(linkfile);
        }
    }
#endif /* __LINUX__ || __FREEBSD__ */

    /* Finally use the default we've used forever */
    return SDL_strdup("SDL_App");
}
开发者ID:ibachar,项目名称:firecube,代码行数:55,代码来源:SDL_waylandvideo.c

示例8: X11_CheckMouseModeNoLock

/* Check to see if we need to enter or leave mouse relative mode */
void X11_CheckMouseModeNoLock(_THIS)
{
	const Uint8 full_focus = (SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
	char *env_override;
	int enable_relative = 1;

	/* Allow the user to override the relative mouse mode.
	   They almost never want to do this, as it seriously affects
	   applications that rely on continuous relative mouse motion.
	*/
	env_override = SDL_getenv("SDL_MOUSE_RELATIVE");
	if ( env_override ) {
		enable_relative = atoi(env_override);
	}

	/* If the mouse is hidden and input is grabbed, we use relative mode */
	if ( enable_relative &&
	     !(SDL_cursorstate & CURSOR_VISIBLE) &&
	     (this->input_grab != SDL_GRAB_OFF) &&
             (SDL_GetAppState() & full_focus) == full_focus ) {
		if ( ! mouse_relative ) {
			X11_EnableDGAMouse(this);
			if ( ! (using_dga & DGA_MOUSE) ) {
				char *xmouse_accel;

				SDL_GetMouseState(&mouse_last.x, &mouse_last.y);
				/* Use as raw mouse mickeys as possible */
				XGetPointerControl(SDL_Display,
						&mouse_accel.numerator, 
						&mouse_accel.denominator,
						&mouse_accel.threshold);
				xmouse_accel=SDL_getenv("SDL_VIDEO_X11_MOUSEACCEL");
				if ( xmouse_accel ) {
					SetMouseAccel(this, xmouse_accel);
				}
			}
			mouse_relative = 1;
		}
	} else {
		if ( mouse_relative ) {
			if ( using_dga & DGA_MOUSE ) {
				X11_DisableDGAMouse(this);
			} else {
				XChangePointerControl(SDL_Display, True, True,
						mouse_accel.numerator, 
						mouse_accel.denominator,
						mouse_accel.threshold);
			}
			mouse_relative = 0;
		}
	}
}
开发者ID:BITINT,项目名称:DEFCON2,代码行数:53,代码来源:SDL_x11mouse.c

示例9: SDL_OpenAudioPath

int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
{
	const char *audiodev;
	int audio_fd;
	char audiopath[1024];

	/* Figure out what our audio device is */
	if ( ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) &&
	     ((audiodev=SDL_getenv("AUDIODEV")) == NULL) ) {
		if ( classic ) {
			audiodev = _PATH_DEV_AUDIO;
		} else {
			struct stat sb;

			/* Added support for /dev/sound/\* in Linux 2.4 */
			if ( ((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) &&
				 ((stat(_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode)) ) {
				audiodev = _PATH_DEV_DSP24;
			} else {
				audiodev = _PATH_DEV_DSP;
			}
		}
	}
	audio_fd = open(audiodev, flags, 0);

	/* If the first open fails, look for other devices */
	if ( (audio_fd < 0) && (SDL_strlen(audiodev) < (sizeof(audiopath)-3)) ) {
		int exists, instance;
		struct stat sb;

		instance = 1;
		do { /* Don't use errno ENOENT - it may not be thread-safe */
			SDL_snprintf(audiopath, SDL_arraysize(audiopath),
			             "%s%d", audiodev, instance++);
			exists = 0;
			if ( stat(audiopath, &sb) == 0 ) {
				exists = 1;
				audio_fd = open(audiopath, flags, 0); 
			}
		} while ( exists && (audio_fd < 0) );
		audiodev = audiopath;
	}
	if ( path != NULL ) {
		SDL_strlcpy(path, audiodev, maxlen);
		path[maxlen-1] = '\0';
	}
	return(audio_fd);
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:48,代码来源:SDL_audiodev.c

示例10: SDL_OpenAudioPath

int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
{
	const char *audiodev;
	int audio_fd;
	char audiopath[1024];

	
	if ( ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) &&
	     ((audiodev=SDL_getenv("AUDIODEV")) == NULL) ) {
		if ( classic ) {
			audiodev = _PATH_DEV_AUDIO;
		} else {
			struct stat sb;

			
			if ( ((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) &&
				 ((stat(_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode)) ) {
				audiodev = _PATH_DEV_DSP24;
			} else {
				audiodev = _PATH_DEV_DSP;
			}
		}
	}
	audio_fd = open(audiodev, flags, 0);

	
	if ( (audio_fd < 0) && (SDL_strlen(audiodev) < (sizeof(audiopath)-3)) ) {
		int exists, instance;
		struct stat sb;

		instance = 1;
		do { 
			SDL_snprintf(audiopath, SDL_arraysize(audiopath),
			             "%s%d", audiodev, instance++);
			exists = 0;
			if ( stat(audiopath, &sb) == 0 ) {
				exists = 1;
				audio_fd = open(audiopath, flags, 0); 
			}
		} while ( exists && (audio_fd < 0) );
		audiodev = audiopath;
	}
	if ( path != NULL ) {
		SDL_strlcpy(path, audiodev, maxlen);
		path[maxlen-1] = '\0';
	}
	return(audio_fd);
}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:48,代码来源:SDL_audiodev.c

示例11: SDL_memset

static SDL_AudioDevice *DISKAUD_CreateDevice(int devindex)
{
	SDL_AudioDevice *this;
	const char *envr;

	/* Initialize all variables that we clean on shutdown */
	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
	if ( this ) {
		SDL_memset(this, 0, (sizeof *this));
		this->hidden = (struct SDL_PrivateAudioData *)
				SDL_malloc((sizeof *this->hidden));
	}
	if ( (this == NULL) || (this->hidden == NULL) ) {
		SDL_OutOfMemory();
		if ( this ) {
			SDL_free(this);
		}
		return(0);
	}
	SDL_memset(this->hidden, 0, (sizeof *this->hidden));

	envr = SDL_getenv(DISKENVR_WRITEDELAY);
	this->hidden->write_delay = (envr) ? SDL_atoi(envr) : DISKDEFAULT_WRITEDELAY;

	/* Set the function pointers */
	this->OpenAudio = DISKAUD_OpenAudio;
	this->WaitAudio = DISKAUD_WaitAudio;
	this->PlayAudio = DISKAUD_PlayAudio;
	this->GetAudioBuf = DISKAUD_GetAudioBuf;
	this->CloseAudio = DISKAUD_CloseAudio;

	this->free = DISKAUD_DeleteDevice;

	return this;
}
开发者ID:cuttl,项目名称:wii2600,代码行数:35,代码来源:SDL_diskaudio.c

示例12: SDL_ChooseBlitFunc

static SDL_BlitFunc
SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags,
                   SDL_BlitFuncEntry * entries)
{
    int i, flagcheck;
    static Uint32 features = 0xffffffff;

    /* Get the available CPU features */
    if (features == 0xffffffff) {
        const char *override = SDL_getenv("SDL_BLIT_CPU_FEATURES");

        features = SDL_CPU_ANY;

        /* Allow an override for testing .. */
        if (override) {
            SDL_sscanf(override, "%u", &features);
        } else {
            if (SDL_HasMMX()) {
                features |= SDL_CPU_MMX;
            }
            if (SDL_HasSSE()) {
                features |= SDL_CPU_SSE;
            }
            if (SDL_HasSSE2()) {
                features |= SDL_CPU_SSE2;
            }
        }
    }
开发者ID:Blitzoreo,项目名称:pcsx2-online,代码行数:28,代码来源:SDL_blit.c

示例13: GetDisplayNumber

static int
GetDisplayNumber()
{
    const char *display = SDL_getenv("DISPLAY");
    const char *p = NULL;;
    int number = 0;

    if (display == NULL)
        return 0;

    display = SDL_strchr(display, ':');
    if (display == NULL)
        return 0;

    display++;
    p = SDL_strchr(display, '.');
    if (p == NULL && display != NULL) {
        number = SDL_strtod(display, NULL);
    } else {
        char *buffer = SDL_strdup(display);
        buffer[p - display] = '\0';
        number = SDL_strtod(buffer, NULL);
        SDL_free(buffer);
    }

    return number;
}
开发者ID:daya-prac,项目名称:SDL-fcitx,代码行数:27,代码来源:SDL_fcitx.c

示例14: nfile_cachePath

/**
 * @brief Gets Naev's cache path (for cached data such as generated textures)
 *
 *    @return The xdg cache path.
 */
const char* nfile_cachePath (void)
{
    char *path;

    if (naev_cachePath[0] == '\0') {
#if HAS_UNIX
        path = xdgGetRelativeHome( "XDG_CACHE_HOME", "/.cache" );
        if (path == NULL) {
            WARN("$XDG_CACHE_HOME isn't set, using current directory.");
            path = strdup(".");
        }

        nsnprintf( naev_cachePath, PATH_MAX, "%s/naev/", path );

        if (path != NULL) {
            free (path);
        }
#elif HAS_WIN32
      path = SDL_getenv("APPDATA");
      if (path == NULL) {
         WARN("%%APPDATA%% isn't set, using current directory.");
         path = ".";
      }
      nsnprintf( naev_cachePath, PATH_MAX, "%s/naev/", path );
#else
#error "Feature needs implementation on this Operating System for Naev to work."
#endif
    }

    return naev_cachePath;
}
开发者ID:darkoneko,项目名称:naev,代码行数:36,代码来源:nfile.c

示例15: Audio_Available

static int Audio_Available(void)
{
	long dummy;
	const char *envr = SDL_getenv("SDL_AUDIODRIVER");

	/* Check if user asked a different audio driver */
	if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
		DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n"));
		return(0);
	}

	/* Cookie _MCH present ? if not, assume ST machine */
	if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
		cookie_mch = MCH_ST;
	}

	/* Cookie _SND present ? if not, assume ST machine */
	if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
		cookie_snd = SND_PSG;
	}

	/* Cookie STFA present ? */
	if (Getcookie(C_STFA, &dummy) != C_FOUND) {
		DEBUG_PRINT((DEBUG_NAME "no STFA audio\n"));
		return(0);
	}
	cookie_stfa = (cookie_stfa_t *) dummy;

	DEBUG_PRINT((DEBUG_NAME "STFA audio available!\n"));
	return(1);
}
开发者ID:Templier,项目名称:scummvm-libs,代码行数:31,代码来源:SDL_mintaudio_stfa.c


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