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


C++ SDL_putenv函数代码示例

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


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

示例1: init_sdl

static void init_sdl()
{
	SDL_putenv("SDL_NOMOUSE=1");
	SDL_putenv("SDL_VIDEO_CENTERED=1");

	SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE);
	atexit(SDL_Quit);
	signal(SIGINT, SIG_DFL);
	SDL_EnableUNICODE(1);
	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);

	SDL_AudioSpec desired = {.freq = 8000, .format = AUDIO_U8, .channels = 1, .callback = snd_callback, .samples=128};
	if(SDL_OpenAudio(&desired, NULL)) {
		fprintf(stderr, "%s\n", SDL_GetError());
		sound_playing = -1;
	}

	SDL_initFramerate(&fps);
	SDL_setFramerate(&fps, 60);

	inited_sdl = 1;
}

static void button_change(int up, SDLKey keysym)
{
	const uint32_t key_map[SDLK_LAST] = {
		[SDLK_LEFT] = KEY_LF,
		[SDLK_RIGHT] = KEY_RT,
		[SDLK_UP] = KEY_UP,
		[SDLK_DOWN] = KEY_DN,
		[SDLK_RETURN] = KEY_A,
		[SDLK_SPACE] = KEY_A,
		[SDLK_z] = KEY_A,
		[SDLK_x] = KEY_B,
		[SDLK_LSHIFT] = KEY_B,
		[SDLK_RSHIFT] = KEY_A
	};

	/* Don't invoke undefined behavior if they've added keysyms
	 * since this was compiled.
	 */
	if(keysym > SDLK_LAST)
		return;
	
	if(!key_map[keysym])
		return;

	if(up) {
		buttons &= ~key_map[keysym];
	} else {
		buttons |= key_map[keysym];
	}
}
开发者ID:pikhq,项目名称:cmako,代码行数:53,代码来源:main.c

示例2: SDL_GL_SetAttribute

/**
 * Sets up all the internal display flags depending on
 * the current video settings.
 */
void Screen::makeVideoFlags()
{
	_flags = SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_HWPALETTE;
	if (Options::asyncBlit)
	{
		_flags |= SDL_ASYNCBLIT;
	}
	if (isOpenGLEnabled())
	{
		_flags = SDL_OPENGL;
		SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
		SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
		SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
		SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
		SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
	}
	if (Options::allowResize)
	{
		_flags |= SDL_RESIZABLE;
	}
	
	// Handle window positioning
	if (Options::windowedModePositionX != -1 || Options::windowedModePositionY != -1)
	{
		std::ostringstream ss;
		ss << "SDL_VIDEO_WINDOW_POS=" << std::dec << Options::windowedModePositionX << "," << Options::windowedModePositionY;
		SDL_putenv(const_cast<char*>(ss.str().c_str()));
		SDL_putenv(const_cast<char*>("SDL_VIDEO_CENTERED="));
	}
	else if (Options::borderless)
	{
		SDL_putenv(const_cast<char*>("SDL_VIDEO_WINDOW_POS="));
		SDL_putenv(const_cast<char*>("SDL_VIDEO_CENTERED=center"));
	}
	else
	{
		SDL_putenv(const_cast<char*>("SDL_VIDEO_WINDOW_POS="));
		SDL_putenv(const_cast<char*>("SDL_VIDEO_CENTERED="));
	}

	// Handle display mode
	if (Options::fullscreen)
	{
		_flags |= SDL_FULLSCREEN;
	}
	if (Options::borderless)
	{
		_flags |= SDL_NOFRAME;
		SDL_putenv(const_cast<char*>("SDL_VIDEO_CENTERED=center"));
	}
	else
	{
		SDL_putenv(const_cast<char*>("SDL_VIDEO_CENTERED="));
	}

	_bpp = (is32bitEnabled() || isOpenGLEnabled()) ? 32 : 8;
	_baseWidth = Options::baseXResolution;
	_baseHeight = Options::baseYResolution;
}
开发者ID:Xracer,项目名称:OXCHD,代码行数:63,代码来源:Screen.cpp

示例3: OglInitWindow

int OglInitWindow (int w, int h, int bForce)
{
	int			bRebuild = 0;
	GLint			i;

if (gameStates.ogl.bInitialized) {
	if (!bForce && (w == nCurWidth) && (h == nCurHeight) && (bCurFullScr == gameStates.ogl.bFullScreen))
		return -1;
	if ((w != nCurWidth) || (h != nCurHeight) || (bCurFullScr != gameStates.ogl.bFullScreen)) {
		OglSmashTextureListInternal ();//if we are or were fullscreen, changing vid mode will invalidate current textures
		bRebuild = 1;
		}
	}
if (w < 0)
	w = nCurWidth;
if (h < 0)
	h = nCurHeight;
if ((w < 0) || (h < 0))
	return -1;
D2SetCaption ();
OglInitAttributes ();
/***/LogErr ("setting SDL video mode (%dx%dx%d, %s)\n",
				 w, h, gameStates.ogl.nColorBits, gameStates.ogl.bFullScreen ? "fullscreen" : "windowed");
#if 1//def RELEASE
SDL_putenv ("SDL_VIDEO_CENTERED=1");
#endif
if (!OglVideoModeOK (w, h) ||
	 !SDL_SetVideoMode (w, h, gameStates.ogl.nColorBits, SDL_VIDEO_FLAGS)) {
	Error ("Could not set %dx%dx%d opengl video mode\n", w, h, gameStates.ogl.nColorBits);
	return 0;
	}
gameStates.ogl.nColorBits = 0;
glGetIntegerv (GL_RED_BITS, &i);
gameStates.ogl.nColorBits += i;
glGetIntegerv (GL_GREEN_BITS, &i);
gameStates.ogl.nColorBits += i;
glGetIntegerv (GL_BLUE_BITS, &i);
gameStates.ogl.nColorBits += i;
glGetIntegerv (GL_ALPHA_BITS, &i);
gameStates.ogl.nColorBits += i;
glGetIntegerv (GL_DEPTH_BITS, &gameStates.ogl.nDepthBits);
glGetIntegerv (GL_STENCIL_BITS, &gameStates.ogl.nStencilBits);
gameStates.render.bHaveStencilBuffer = (gameStates.ogl.nStencilBits > 0);
SDL_ShowCursor (0);
nCurWidth = w;
nCurHeight = h;
bCurFullScr = gameStates.ogl.bFullScreen;
if (gameStates.ogl.bInitialized && bRebuild) {
	glViewport (0, 0, w, h);
	if (gameStates.app.bGameRunning) {
		GrPaletteStepLoad (NULL);
		RebuildGfxFx (1, 1);
		}
	else
		GrRemapMonoFonts ();
	//FreeInventoryIcons ();
	}
gameStates.ogl.bInitialized = 1;
return 1;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:60,代码来源:sdlgl.c

示例4: env

Manager::Manager() :
  env( SDL_putenv(const_cast<char*>("SDL_VIDEO_CENTERED=center")) ),
  io( IOManager::getInstance() ),
  clock( Clock::getInstance() ),
  screen( io.getScreen() ),
  world("back", Gamedata::getInstance().getXmlInt("back/factor") ),
  world2("back2", Gamedata::getInstance().getXmlInt("back2/factor") ),
  viewport( Viewport::getInstance() ),
  sprites(),
  currentSprite(0),

  makeVideo( false ),
  frameCount( 0 ),
  username(  Gamedata::getInstance().getXmlStr("username") ),
  title( Gamedata::getInstance().getXmlStr("screenTitle") ),
  frameMax( Gamedata::getInstance().getXmlInt("frameMax") )
{
  if (SDL_Init(SDL_INIT_VIDEO) != 0) {
    throw string("Unable to initialize SDL: ");
  }
  SDL_WM_SetCaption(title.c_str(), NULL);
  atexit(SDL_Quit);
  sprites.push_back( new Hero("pet2") );
  sprites.push_back( new Hero("pet4") );
  sprites.push_back( new TwoWayMultiSprite("pet1") );
  sprites.push_back( new TwoWayMultiSprite("pet3") );
  sprites.push_back( new Sprite("ufo") );
  
  dynamic_cast<Hero*>(sprites[0])->addSpecialEffect(new MultiSprite("sp2"));
  dynamic_cast<Hero*>(sprites[1])->addSpecialEffect(new MultiSprite("sp1"));
  viewport.setObjectToTrack(sprites[currentSprite]);
}
开发者ID:renmaoting,项目名称:616,代码行数:32,代码来源:manager.cpp

示例5: initGUI

void initGUI () {
   // Initialise SDL library
   if (SDL_Init (SDL_INIT_VIDEO) == -1) {
      throw "Error loading SDL";
   }

   // Initialise SDL_ttf
   if (TTF_Init () == -1) {
      throw "Error loading SDL_ttf";
   }

   // Set SDL settings
   // Make window open at the centre of the screen
   SDL_putenv ((char*)"SDL_VIDEO_WINDOW_POS=center");
   
   // Set window caption
   SDL_WM_SetCaption (WINDOW_NAME, NULL);
   SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);

   // Set up screen
   screen = SDL_SetVideoMode (DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_BPP, 
                              SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE |
                              SDL_HWSURFACE);

   if (screen == NULL) {
      throw "Error while setting up SDL";
   }
}
开发者ID:abbychau,项目名称:BEATMAX,代码行数:28,代码来源:Game.cpp

示例6: SDL_GetError

bool Graphics::InitSDL()
{
    // Init video
    if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
    {
		std::cout << "Couldn't initialize SDL: " << SDL_GetError() << std::endl;
		SDL_Quit();
		return false;
	}

	// Set window position to center
	SDL_putenv((char*)"SDL_VIDEO_CENTERED=center");

    // Set video mode
    if ((mScreen = SDL_SetVideoMode(mScreenWidth, mScreenHeight, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL)) == NULL)
    {
		std::cout << "Couldn't set " << mScreenWidth << "x" << mScreenHeight <<  " video mode: " << SDL_GetError() << std::endl;
		SDL_Quit();
		return false;
	}

    std::cout << "SDL initialization OK\n";

    return true;
}
开发者ID:mandyedi,项目名称:tetrisin3d,代码行数:25,代码来源:Graphics.cpp

示例7: ui_init

int ui_init()
{
    int width, height;

    font_init();

    width = config_get_int("width");
    height = config_get_int("height");

    SDL_putenv("SDL_VIDEO_WINDOW_POS=center");

    if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
    {
        fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
        return -1;
    }

    atexit(SDL_Quit);

    screen = SDL_SetVideoMode(width, height, 32,
                              SDL_HWSURFACE | SDL_DOUBLEBUF);
    if (screen == NULL)
    {
        fprintf(stderr, "Unable to set %dx%d video: %s\n",
                width, height, SDL_GetError());
        return -1;
    }

    scripting_init_ui();
    SDL_Flip(screen);

    return 0;
}
开发者ID:jjgod,项目名称:legend,代码行数:33,代码来源:ui.c

示例8: set_video_mode

static void set_video_mode() {
    int flags = 0;
#ifndef HAVE_GLES
    flags |= SDL_DOUBLEBUF;
    flags |= SDL_OPENGL;
#endif
    if (g_fs_emu_video_fullscreen == 1) {
        g_fs_ml_video_width = g_fullscreen_width;
        g_fs_ml_video_height = g_fullscreen_height;
        if (g_fs_emu_video_fullscreen_window) {
            fs_log("using fullscreen window mode\n");
            SDL_putenv("SDL_VIDEO_WINDOW_POS=0,0");
            flags |= SDL_NOFRAME;
            fs_ml_set_fullscreen_extra();
        }
        else {
            fs_log("using SDL_FULLSCREEN mode\n");
            flags |= SDL_FULLSCREEN;
        }
        fs_log("setting (fullscreen) video mode %d %d\n", g_fs_ml_video_width,
                g_fs_ml_video_height);
        g_sdl_screen = SDL_SetVideoMode(g_fs_ml_video_width,
                g_fs_ml_video_height, 0, flags);
        //update_viewport();
    }
    else {
        fs_log("using windowed mode\n");
        SDL_putenv("SDL_VIDEO_WINDOW_POS=");
        g_fs_ml_video_width = g_window_width;
        g_fs_ml_video_height = g_window_height;
        if (g_window_resizable) {
        	flags |= SDL_RESIZABLE;
        }
        fs_log("setting (windowed) video mode %d %d\n", g_fs_ml_video_width,
                g_fs_ml_video_height);
        g_sdl_screen = SDL_SetVideoMode(g_fs_ml_video_width,
                g_fs_ml_video_height, 0, flags);
        //update_viewport();
    }

    fs_ml_configure_window();

    // FIXME: this can be removed
    g_fs_ml_opengl_context_stamp++;

    log_opengl_information();
}
开发者ID:lunixbochs,项目名称:fs-uae-gles,代码行数:47,代码来源:sdl.c

示例9: init_win32

void init_win32()
{
	SDL_Cursor *cursor = SDL_GetCursor();

	HINSTANCE handle = GetModuleHandle(NULL);
	//((struct zWMcursor *)cursor->wm_cursor)->curs = (void *)LoadCursorA(NULL, IDC_ARROW);
	((struct zWMcursor *)cursor->wm_cursor)->curs = (void *)LoadCursor(NULL, IDC_ARROW);
	SDL_SetCursor(cursor);

	icon = LoadIcon(handle, (char *)101);
	SDL_GetWMInfo(&wminfo);
	hwnd = wminfo.window;
	SetClassLong(hwnd, GCL_HICON, (LONG)icon);

	SDL_putenv("SDL_VIDEO_WINDOW_POS=center");
	SDL_putenv("SDL_VIDEO_CENTERED=center");
}
开发者ID:madrazo,项目名称:openfl-native-p8,代码行数:17,代码来源:SDLStage.cpp

示例10: main

int main(int argc, char **argv)
{
    if (!SDL_getenv("SDL_AUDIODRIVER")) {
        SDL_putenv("SDL_AUDIODRIVER=waveout");
    }

    return game_main(argc, argv);
}
开发者ID:BlastarIndia,项目名称:raceintospace,代码行数:8,代码来源:main.c

示例11: SDL_putenv

int Display_SDL::CreateScreen(int x0, int y0, int w, int h, Uint32 nFlags) {
  char pc[256] = "SDL_VIDEO_CENTERED=1";
  //sprintf(pc, "SDL_VIDEO_CENTERED", x0, y0);
  //g_pErr->Report("NO!");
  SDL_putenv(pc);
  m_pScreen = SDL_SetVideoMode(w, h, 0, nFlags);
  StimulusBmp::SetScreen(m_pScreen);
  m_bSelfAlloc = true;
}
开发者ID:dalejbarr,项目名称:exp-eyelink,代码行数:9,代码来源:Display_SDL.cpp

示例12: env

Manager::Manager() :
  env( SDL_putenv(const_cast<char*>("SDL_VIDEO_CENTERED=center")) ),
  io( IOManager::getInstance() ),
  clock( Clock::getInstance() ),
  screen( io.getScreen() ),
  world("back"),
  viewport( Viewport::getInstance() ),


  sprites(),
  currentSprite(),

  makeVideo( false ),
  frameCount( 0 ),
  username(  Gamedata::getInstance().getXmlStr("username") ),
  title( Gamedata::getInstance().getXmlStr("screenTitle") ),
  frameMax( Gamedata::getInstance().getXmlInt("frameMax") ),
    eachSpritsNumbe()

{
     if (SDL_Init(SDL_INIT_VIDEO) != 0) {
    throw string("Unable to initialize SDL: ");
  }
  SDL_WM_SetCaption(title.c_str(), NULL);
  atexit(SDL_Quit);

 
  
  	
  sprites.push_back( new TwoWaySprite("Gundam"));

    eachSpritsNumbe.push_back(Gamedata::getInstance().getXmlInt("Gundam/number"));
    eachSpritsNumbe.push_back(Gamedata::getInstance().getXmlInt("Enemy/number"));
    eachSpritsNumbe.push_back(Gamedata::getInstance().getXmlInt("Vessel1/number"));
    eachSpritsNumbe.push_back(Gamedata::getInstance().getXmlInt("Explotion/number"));
    
for (int i = 0; i< eachSpritsNumbe[1]; i++) {
        sprites.push_back( new Enemy("Enemy"));
}
  
for (int i=0; i< eachSpritsNumbe[2]; i++) {
    sprites.push_back( new Vessel("Vessel1") );
}
    

for (int i=0; i< eachSpritsNumbe[3]; i++) {
        sprites.push_back( new Explotion("Explotion") );
}
  
    

  

  currentSprite = sprites.begin();
  viewport.setObjectToTrack(*currentSprite);
}
开发者ID:yuyaolong,项目名称:OOAS3,代码行数:56,代码来源:manager.cpp

示例13: env

Manager::Manager() :
  env( SDL_putenv(const_cast<char*>("SDL_VIDEO_CENTERED=center")) ),
  gdata( Gamedata::getInstance() ),
  io( IOManager::getInstance() ),
  frameFactory( FrameFactory::getInstance() ),
  clock( Clock::getInstance() ),
  smanager(),
  screen( io.getScreen() ),
  
  backgroundWorld(const_cast<Frame*>(frameFactory->getFrame("background","background")[0]),6),
  
  parallaxWorld1(const_cast<Frame*>(frameFactory->getFrame("parallax1","parallax")[0]),5),
  
  parallaxWorld2(const_cast<Frame*>(frameFactory->getFrame("parallax2","parallax")[0]),4),
  
  parallaxWorld3(const_cast<Frame*>(frameFactory->getFrame("parallax3","parallax")[0]),3),

  parallaxWorld4(const_cast<Frame*>(frameFactory->getFrame("parallax4","parallax")[0]),2),

  parallaxWorld5(const_cast<Frame*>(frameFactory->getFrame("parallax5","parallax")[0]),1),
 
  viewport( Viewport::getInstance() ),

  orbs(),
  characters(),
  asteroids(),
  opponents(),
  ai(),
  explosions(),
  collisionStrategy( new MidPointCollisionStrategy ),
  currentOrb(0),
  helpFlag(false),
  done(false),
  rightFlag(false),
  aishootflag(false),
  gameoverflag(false),
  gamewon(false),
  score(0)
{
  if (SDL_Init(SDL_INIT_VIDEO) != 0) {
    throw string("Unable to initialize SDL: ");
  }
  characters.push_back(MultiframeSprite("player1","player",smanager));
  for (int i = 0; i < 15; i++){
  asteroids.push_back(new MultiframeSprite("asteroid","asteroid",smanager));
  }
  for (int i = 0; i < 10; i++){
  opponents.push_back(new MultiframeSprite("opponent","asteroid",smanager));
  }
  for (int i = 0; i < 1; i++){
  ai.push_back(new MultiframeSprite("ai","player",smanager));
  }
  viewport.setObjectToTrack(&characters[currentOrb]);
  atexit(SDL_Quit);
}
开发者ID:aravindhsampath,项目名称:Grad_school_course_Projects,代码行数:55,代码来源:manager.cpp

示例14: bar

Manager::Manager() :
	bar(),
	gameOver(false),
	level(2),
	explosionInterval(Gamedata::getInstance().getXmlInt("NoKillInterval")),
	timeSinceLastExplosion(0),
  env( SDL_putenv(const_cast<char*>("SDL_VIDEO_CENTERED=center")) ),
  io( IOManager::getInstance() ),
  clock( Clock::getInstance() ),
  screen( io.getScreen() ),
  world1("back", Gamedata::getInstance().getXmlInt("backFactor") ),
  world2("back1", Gamedata::getInstance().getXmlInt("back1Factor") ),
  viewport( Viewport::getInstance() ),
  sprites(),
  Rainsprites(),
  parachutes(),
  cachePlayer(new Player("Jet")),
  blast(new MultiSprite("blast")),
  myPlayer(cachePlayer),
  explosion(false),
  cacheEnemies(),
  enemyBlasts(),
  enemies(),
  enemyExploded(),
  bullets("bullet"),
  currentSprite(0),
  showHelp(false),
  showHUD(true)
{
  if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0) {
    throw string("Unable to initialize SDL: ");
  }
  atexit(SDL_Quit);
  //sprites.push_back( new TwoWayMultiSprite("Jet") );
  
  //Player myPlayer = new Player("Jet");
  
  for(unsigned int i =0; i<5000 ; i++)
  Rainsprites.push_back( new Rain("smallrain") );
  
  for(unsigned int i =0; i<1000 ; i++)
  Rainsprites.push_back( new Rain("bigrain") );
  
  //sprites.push_back( myPlayer );
  
  sprites.push_back( new TwoWayMultiSprite("tanks") );
  
  sprites.push_back( new Sprite("logo") );
  //viewport.setObjectToTrack(sprites[currentSprite]);
  //viewport.setObjectToTrack(sprites[1]);
  viewport.setObjectToTrack(myPlayer);
  
  clock.pause();
  
}
开发者ID:himanshu-repo,项目名称:Swat-Kats,代码行数:55,代码来源:manager.cpp

示例15: _bpp

/**
 * Initializes a new display screen for the game to render contents to.
 * @param width Width in pixels.
 * @param height Height in pixels.
 * @param bpp Bits-per-pixel.
 * @param fullscreen Fullscreen mode.
 * @warning Currently the game is designed for 8bpp, so there's no telling what'll
 * happen if you use a different value.
 */
Screen::Screen(int width, int height, int bpp, bool fullscreen, int windowedModePositionX, int windowedModePositionY) : _bpp(bpp), _scaleX(1.0), _scaleY(1.0), _fullscreen(fullscreen), _numColors(0), _firstColor(0), _surface(0)
{
	char *prev;
	if (!_fullscreen && (windowedModePositionX != -1 || windowedModePositionY != -1))
	{
		prev = SDL_getenv("SDL_VIDEO_WINDOW_POS");
		if (0 == prev) prev = (char*)"";
		std::stringstream ss;
		ss << "SDL_VIDEO_WINDOW_POS=" << std::dec << windowedModePositionX << "," << windowedModePositionY;
		SDL_putenv(const_cast<char*>(ss.str().c_str()));
	}
	setResolution(width, height);
	if (!_fullscreen  && (windowedModePositionX != -1 || windowedModePositionY != -1))
	{ // We don't want to put the window back to the starting position later when the window is resized.
		std::stringstream ss;
		ss << "SDL_VIDEO_WINDOW_POS=" << prev;
		SDL_putenv(const_cast<char*>(ss.str().c_str()));
	}
	memset(deferredPalette, 0, 256*sizeof(SDL_Color));
}
开发者ID:JacobGade,项目名称:OpenXcom,代码行数:29,代码来源:Screen.cpp


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