示例#1
0
/*
===============
IN_Init
===============
*/
void IN_Init( void )
{
	int appState;

	if( !SDL_WasInit( SDL_INIT_VIDEO ) )
	{
		Com_Error( ERR_FATAL, "IN_Init called before SDL_Init( SDL_INIT_VIDEO )\n" );
		return;
	}

	Com_DPrintf( "\n------- Input Initialization -------\n" );

	in_keyboardDebug = Cvar_Get( "in_keyboardDebug", "0", CVAR_ARCHIVE );

	// mouse variables
	in_mouse = Cvar_Get( "in_mouse", "1", CVAR_ARCHIVE );
	in_nograb = Cvar_Get( "in_nograb", "0", CVAR_ARCHIVE );

	in_joystick = Cvar_Get( "in_joystick", "0", CVAR_ARCHIVE|CVAR_LATCH );
	in_joystickDebug = Cvar_Get( "in_joystickDebug", "0", CVAR_TEMP );
	in_joystickThreshold = Cvar_Get( "in_joystickThreshold", "0.15", CVAR_ARCHIVE );

#ifdef MACOS_X_ACCELERATION_HACK
	in_disablemacosxmouseaccel = Cvar_Get( "in_disablemacosxmouseaccel", "1", CVAR_ARCHIVE );
#endif

	SDL_EnableUNICODE( 1 );
	SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL );
	keyRepeatEnabled = qtrue;

	if( in_mouse->value )
	{
		mouseAvailable = qtrue;
		IN_ActivateMouse( );
	}
	else
	{
		IN_DeactivateMouse( );
		mouseAvailable = qfalse;
	}

	appState = SDL_GetAppState( );
	Cvar_SetValue( "com_unfocused",	!( appState & SDL_APPINPUTFOCUS ) );
	Cvar_SetValue( "com_minimized", !( appState & SDL_APPACTIVE ) );

	IN_InitJoystick( );
	Com_DPrintf( "------------------------------------\n" );
}
示例#2
0
void SDLManager::exec()
{
    d->loadSettings();

    // Initialize defaults, Video and Audio subsystems
    zinfo() << "Initializing SDL.";
    int ret = SDL_Init( SDL_INIT_VIDEO|
                        SDL_INIT_AUDIO|
                        SDL_INIT_TIMER|
                        SDL_INIT_JOYSTICK );
    if(ret==-1) {
        zerror() << "Could not initialize SDL:" << SDL_GetError();
        return;
    }

    zinfo() << "Creating display surface.";
    d->createPainter();
    d->setScreen( 640, 400, false );
    if (!d->display) return;

    SDL_WM_SetCaption("FreeZZT", "FreeZZT");
    SDL_EnableUNICODE(1);
    d->setKeyboardRepeatRate();
    d->openJoystick();

    // Create music stream
    AbstractMusicStream *musicStream = d->createMusicStream();
    d->pFreezztManager->setMusicStream( musicStream );

    // Create factory
    NormalFileModelFactory fileModelFactory;
    d->pFreezztManager->setFileModelFactory( &fileModelFactory );

    // Load speed from settings
    d->pFreezztManager->setSpeed( d->dotFile.getInt( "speed", 1, 4 ) );

    zinfo() << "Entering event loop";
    SDLEventLoop eventLoop;
    eventLoop.setFrameLatency( d->frameTime );
    eventLoop.setPainter( d->painter );
    eventLoop.setSDLManager( this );
    eventLoop.setZZTManager( d->pFreezztManager );
    eventLoop.exec();

    delete musicStream;
    d->closeJoystick();
    delete d->painter;
}
示例#3
0
static void	init_main(SDL_Surface	*screen,
			  s_sound	**sounds,
			  s_perso	**persos,
			  s_game	*game)
{
  s_sound	*sounds_tmp = NULL;
  int		i = 0;

  SDL_Init(SDL_INIT_VIDEO);
  SDL_WM_SetCaption("Bomberman -- Rush Jeu", NULL);
  SDL_WM_SetIcon(IMG_Load("/u/all/peccau_s/public/data/perso.png"), NULL);

  sounds_tmp = malloc(sizeof (s_sound));
  if (Mix_OpenAudio(24000, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 1024) < 0)
    perror(Mix_GetError());

  sounds_tmp->vol_music = MIX_MAX_VOLUME / 2;
  sounds_tmp->vol_fx = MIX_MAX_VOLUME / 4;
  if (game->custom_mus)
    sounds_tmp->music = Mix_LoadMUS(game->custom_mus);
  else
    sounds_tmp->music =
      Mix_LoadMUS("/u/all/peccau_s/public/data/blue_star.wav");

  if (!sounds_tmp->music)
    perror(Mix_GetError());

  Mix_VolumeMusic(sounds_tmp->vol_music);
  Mix_PlayMusic(sounds_tmp->music, -1);

  Mix_AllocateChannels(142);

  sounds_tmp->bomb = Mix_LoadWAV("/u/all/peccau_s/public/data/bomb.wav");
  sounds_tmp->step = Mix_LoadWAV("/u/all/peccau_s/public/data/step.wav");
  Mix_Volume(-1, sounds_tmp->vol_fx);
  sounds_tmp->planted = Mix_LoadWAV("/u/all/peccau_s/public/data/planted.wav");
  *sounds = sounds_tmp;

  SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 38, 51, 56));
  for (i = 0; i < game->max_players; i++)
    {
      persos[i] = malloc(sizeof (s_perso));
      create_perso(persos[i], i + 1);
    }

  SDL_Flip(screen);
  SDL_EnableUNICODE(SDL_ENABLE);
}
示例#4
0
SDL::SDL()
{
  Uint32 flags = SDL_INIT_VIDEO | SDL_INIT_JOYSTICK;

  if (SDL_Init(flags) < 0)
  {
    std::ostringstream msg;
    msg << "Couldn't initialize SDL: " << SDL_GetError();
    throw std::runtime_error(msg.str());
  }
  else
  {
    atexit(SDL_Quit);
    SDL_EnableUNICODE(1);
  }
}
示例#5
0
static void initSDL()
{
		SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
		SDL_EnableUNICODE(1);

		screenWidth = SDL_GetVideoInfo()->current_w;
		screenHeight = SDL_GetVideoInfo()->current_h;

		if ( ! SDL_SetVideoMode(screenWidth, screenHeight, 24, SDL_OPENGL|SDL_DOUBLEBUF|SDL_FULLSCREEN) )
		{
		 fprintf(stderr, "Couldn't set GL video mode: %s\n", SDL_GetError());
		 SDL_Quit();
		 exit(2);
		}
		SDL_WM_SetCaption("test", "test");
}
示例#6
0
Application::~Application(){
	Object::deleteAll();

	if(this->displaySurface != NULL) {
		SDL_FreeSurface(displaySurface);
	}
	if(this->displayText != NULL){
		//SDL_FreeSurface(displayText);
	}
	SDL_EnableUNICODE(SDL_DISABLE); 
    TTF_CloseFont(font);

    TTF_Quit();

	SDL_Quit();
}
示例#7
0
/**
 * @brief Initializes the input event manager.
 */
void InputEvent::initialize() {

  // initialize the keyboard
  SDL_EnableUNICODE(SDL_ENABLE);
  SDL_EnableKeyRepeat(0, 0);

  // initialize the joypad
  if (SDL_NumJoysticks() > 0 && Configuration::get_value("enable_joystick", 1) == 1) {
    joystick = SDL_JoystickOpen(0);
  }
  else {
    joystick = NULL;
    SDL_JoystickEventState(SDL_IGNORE);
    SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
  }
}
示例#8
0
// *** Constructor
InputManagerSDL::InputManagerSDL()
:	InputManager(),
	m_rawRmb(false),
	m_emulatedRmb(false)
#ifdef TARGET_OS_LINUX
	,m_xineramaOffsetHack( g_preferences->GetInt("XineramaHack", 1) )
#endif // TARGET_OS_LINUX
{
	// Don't let SDL do mouse button emulation for us; we'll do it ourselves if
	// we want it.
	putenv("SDL_HAS3BUTTONMOUSE=1");
	m_shouldEmulateRmb = g_preferences->GetInt("UseOneButtonMouseModifiers", 0);

	SDL_EnableUNICODE(true);
	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, 90);
}
示例#9
0
	sdl_handler::sdl_handler(const bool auto_join) :
#if !SDL_VERSION_ATLEAST(2, 0, 0)
	unicode_(SDL_EnableUNICODE(1)),
#endif
	has_joined_(false)
{

#if !SDL_VERSION_ATLEAST(2, 0, 0)
	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
#endif
	if(auto_join) {
		assert(!event_contexts.empty());
		event_contexts.back().add_handler(this);
		has_joined_ = true;
	}
}
示例#10
0
/*
===============
IN_Init
===============
*/
void IN_Init( void *windowData )
{
	int appState;

	if ( !SDL_WasInit( SDL_INIT_VIDEO ) )
	{
		Com_Error( ERR_FATAL, "IN_Init called before SDL_Init( SDL_INIT_VIDEO )" );
	}

	window = (SDL_Window*) windowData;

	Com_DPrintf( "\n------- Input Initialization -------\n" );

	in_keyboardDebug = Cvar_Get( "in_keyboardDebug", "0", CVAR_TEMP );

	// mouse variables
	in_mouse = Cvar_Get( "in_mouse", "1", 0 );
	in_nograb = Cvar_Get( "in_nograb", "0", 0 );
	in_uigrab = Cvar_Get( "in_uigrab", "0", 0 );

	in_joystick = Cvar_Get( "in_joystick", "0",  CVAR_LATCH );
	in_joystickDebug = Cvar_Get( "in_joystickDebug", "0", CVAR_TEMP );
	in_joystickThreshold = Cvar_Get( "in_joystickThreshold", "0.15", 0 );

	in_xbox360Controller = Cvar_Get( "in_xbox360Controller", "1", CVAR_TEMP );
	in_xbox360ControllerAvailable = Cvar_Get( "in_xbox360ControllerAvailable", "0", CVAR_ROM );
	in_xbox360ControllerDebug = Cvar_Get( "in_xbox360ControllerDebug", "0", CVAR_TEMP );
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
	SDL_StartTextInput();
#else
	SDL_EnableUNICODE( 1 );
	SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL );
	keyRepeatEnabled = qtrue;
#endif
	mouseAvailable = ( in_mouse->value != 0 );
	IN_DeactivateMouse( qtrue );

	appState = SDL_GetWindowFlags( window );
	Cvar_SetValue( "com_unfocused", !( appState & SDL_WINDOW_INPUT_FOCUS ) );
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
	Cvar_SetValue( "com_minimized", ( appState & SDL_WINDOW_MINIMIZED ) );
#else
	Cvar_SetValue( "com_minimized", !( appState & SDL_APPACTIVE ) );
#endif
	IN_InitJoystick();
	Com_DPrintf( "------------------------------------\n" );
}
示例#11
0
bool Renderer::Init()
{
	if (SDL_Init(SDL_INIT_VIDEO)<0)
	{
		//fprintf(stderr, "Unable to initialise SDL: %s", SDL_GetError());
		//exit(0);
		std::cout << "Unable to initialise SDL: " << SDL_GetError() << std::endl;
		return false;
	}

	//Here we initialise SDL with video support. We need this for CEGUI. O.K. now SDL is ready to go. So let's fire up OpenGL:

	//SCREEN_WIDTH, SCREEN_HEIGHT
	if (SDL_SetVideoMode(800,600,0,SDL_OPENGL)==NULL)
	{
		std::cout << "Unable to set OpenGL videomode: " << SDL_GetError() << std::endl;
		return false;
		//fprintf(stderr, "Unable to set OpenGL videomode: %s", SDL_GetError());
		SDL_Quit();
		//exit(0);
	}
	SDL_WM_SetCaption("MilesChat v1.0", NULL);

	//Now OpenGL is ready. But we still need to set a decent configuration:

	glEnable(GL_CULL_FACE);
	glDisable(GL_FOG);
	glClearColor(0.0f,0.0f,0.0f,1.0f);
	glViewport(0,0, 800,600);

	//The OpenGL renderer that comes with CEGUI sets the matrices itself, so if you're using CEGUI for all your rendering needs this would be fine. Normally you would want the normal perspective projection setup though:

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(45.0, 800.0/600.0, 0.1,100.0);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	//let sdl unicode symbols be recognised
	SDL_EnableUNICODE(1);

	//create renderer
	CEGUI::OpenGLRenderer* myRenderer = &CEGUI::OpenGLRenderer::bootstrapSystem();

	return true;
}
示例#12
0
void INKFrame::init(int iFps) {
	setFPS(iFps);

	//intialize SDL
	if(-1 == SDL_Init(SDL_INIT_VIDEO)) {
        throw std::runtime_error("Unable to initialize SDL");
    }

	SDL_WM_SetCaption(_strTitle.c_str(), 0);

	//open the window
	if(!SDL_SetVideoMode(_iW, _iH, _iBbp, SDL_OPENGL | SDL_GL_DOUBLEBUFFER )) {
        throw std::runtime_error("Unable to open a window");
    }

	SDL_EnableUNICODE(SDL_ENABLE);
}
示例#13
0
//
// initinput() -- init input system
//
int initinput(void)
{
	int i,j;
	
#ifdef __APPLE__
	// force OS X to operate in >1 button mouse mode so that LMB isn't adulterated
	if (!getenv("SDL_HAS3BUTTONMOUSE")) putenv("SDL_HAS3BUTTONMOUSE=1");
#endif
	
	if (SDL_EnableKeyRepeat(250, 30)) buildputs("Error enabling keyboard repeat.\n");
	inputdevices = 1|2;	// keyboard (1) and mouse (2)
	mouseacquired = 0;

	SDL_EnableUNICODE(1);	// let's hope this doesn't hit us too hard

	memset(keynames,0,sizeof(keynames));
	for (i=0; i<SDLK_LAST; i++) {
		if (!keytranslation[i]) continue;
		strncpy(keynames[ keytranslation[i] ], SDL_GetKeyName(i), sizeof(keynames[i])-1);
	}

	if (!SDL_InitSubSystem(SDL_INIT_JOYSTICK)) {
		i = SDL_NumJoysticks();
		buildprintf("%d joystick(s) found\n",i);
		for (j=0;j<i;j++) buildprintf("  %d. %s\n", j+1, SDL_JoystickName(j));
		joydev = SDL_JoystickOpen(0);
		if (joydev) {
			SDL_JoystickEventState(SDL_ENABLE);
			inputdevices |= 4;

			joynumaxes    = SDL_JoystickNumAxes(joydev);
			joynumbuttons = min(32,SDL_JoystickNumButtons(joydev));
			joynumhats    = SDL_JoystickNumHats(joydev);
			buildprintf("Joystick 1 has %d axes, %d buttons, and %d hat(s).\n",
				joynumaxes,joynumbuttons,joynumhats);

			joyaxis = Bcalloc(joynumaxes, sizeof(int));
            if (joynumhats > 0) {
                joyhat = malloc(joynumhats * sizeof(int));
                memset(joyhat, -1, sizeof(int)*joynumhats);
            }
		}
	}

	return 0;
}
示例#14
0
void OSystem_SDL::initSDL() {
    // Check if SDL has not been initialized
    if (!_initedSDL) {
        uint32 sdlFlags = 0;
        if (ConfMan.hasKey("disable_sdl_parachute"))
            sdlFlags |= SDL_INIT_NOPARACHUTE;

        // Initialize SDL (SDL Subsystems are initiliazed in the corresponding sdl managers)
        if (SDL_Init(sdlFlags) == -1)
            error("Could not initialize SDL: %s", SDL_GetError());

        // Enable unicode support if possible
        SDL_EnableUNICODE(1);

        _initedSDL = true;
    }
}
示例#15
0
static void create_window(int w, int h, bool fullscreen) {
	if ( fullscreen  ) {
		find_resolution();
#ifndef NO_OPENGL	
		if (TCOD_ctx.renderer != TCOD_RENDERER_SDL ) {
			TCOD_opengl_init_attributes();
			screen=SDL_SetVideoMode(TCOD_ctx.actual_fullscreen_width,TCOD_ctx.actual_fullscreen_height,32,SDL_FULLSCREEN|SDL_OPENGL);
			if ( screen && TCOD_opengl_init_state(w, h, charmap) && TCOD_opengl_init_shaders() ) {
				TCOD_LOG(("Using %s renderer...\n",TCOD_ctx.renderer == TCOD_RENDERER_GLSL ? "GLSL" : "OPENGL"));
			} else {
				TCOD_LOG(("Fallback to SDL renderer...\n"));
				TCOD_ctx.renderer = TCOD_RENDERER_SDL;
			}
		} 
#endif		
		if (TCOD_ctx.renderer == TCOD_RENDERER_SDL ) {
			screen=SDL_SetVideoMode(TCOD_ctx.actual_fullscreen_width,TCOD_ctx.actual_fullscreen_height,32,SDL_FULLSCREEN);
			if ( screen == NULL ) TCOD_fatal_nopar("SDL : cannot set fullscreen video mode");
		}
		SDL_ShowCursor(0);
		TCOD_ctx.actual_fullscreen_width=screen->w;
		TCOD_ctx.actual_fullscreen_height=screen->h;
		TCOD_sys_init_screen_offset();
		SDL_FillRect(screen,0,0);
	} else {
#ifndef NO_OPENGL	
		if (TCOD_ctx.renderer != TCOD_RENDERER_SDL ) {
			TCOD_opengl_init_attributes();
			screen=SDL_SetVideoMode(w*TCOD_ctx.font_width,h*TCOD_ctx.font_height,32,SDL_OPENGL);
			if ( screen && TCOD_opengl_init_state(w, h, charmap) && TCOD_opengl_init_shaders() ) {
				TCOD_LOG(("Using %s renderer...\n",TCOD_ctx.renderer == TCOD_RENDERER_GLSL ? "GLSL" : "OPENGL"));
			} else {
				TCOD_LOG(("Fallback to SDL renderer...\n"));
				TCOD_ctx.renderer = TCOD_RENDERER_SDL;
			}
		} 
#endif		
		if (TCOD_ctx.renderer == TCOD_RENDERER_SDL ) {
			screen=SDL_SetVideoMode(w*TCOD_ctx.font_width,h*TCOD_ctx.font_height,32,0);
			TCOD_LOG(("Using SDL renderer...\n"));
		}
		if ( screen == NULL ) TCOD_fatal_nopar("SDL : cannot create window");
	}
	SDL_EnableUNICODE(1);
	TCOD_ctx.fullscreen=fullscreen;
}
示例#16
0
void vultures_enter_graphics_mode()
{
	if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE) == -1)
	{
		vultures_sdl_error(__FILE__, __LINE__, "Could not initialize SDL");
		exit(1);
	}

	/* Initialize the event handlers */
	atexit(SDL_Quit);
	/* Filter key, mouse and quit events */
	/*  SDL_SetEventFilter(FilterEvents); */
	/* Enable key repeat */
	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);  
	SDL_WM_SetCaption(VERSION_ID,NULL);

	if (vultures_opts.fullscreen)
		vultures_screen = SDL_SetVideoMode(vultures_opts.width, vultures_opts.height, 32,
										SDL_SWSURFACE | SDL_FULLSCREEN | SDL_ASYNCBLIT);
	else
		vultures_screen = SDL_SetVideoMode(vultures_opts.width, vultures_opts.height, 32,
										SDL_SWSURFACE | SDL_RESIZABLE | SDL_ASYNCBLIT);

	/* no screen: maybe the configured video mode didn't work */
	if (!vultures_screen) {
		vultures_sdl_error(__FILE__, __LINE__, "Failed to set configured video mode, trying to fall back to 800x600 windowed");
		vultures_screen = SDL_SetVideoMode(800, 600, 32, SDL_SWSURFACE | SDL_RESIZABLE | SDL_ASYNCBLIT);
		vultures_opts.fullscreen = 0;
	}

	/* still no screen: nothing more to be done */
	if (!vultures_screen)
	{
		vultures_sdl_error(__FILE__, __LINE__, "Could not initialize video mode");
		exit(1);
	}

	/* Don't show double cursor */
	SDL_ShowCursor(SDL_DISABLE);

	/* Enable Unicode translation. Necessary to match keypresses to characters */
	SDL_EnableUNICODE(1);

	if (vultures_opts.play_effects || vultures_opts.play_music)
		vultures_init_sound();
}
示例#17
0
文件: sdl.cpp 项目: 1198s/enigma2
void gSDLDC::evSetVideoMode(unsigned long xres, unsigned long yres)
{
	m_screen = SDL_SetVideoMode(xres, yres, 32, SDL_HWSURFACE);
	if (!m_screen) {
		eFatal("Could not create SDL surface: %s", SDL_GetError());
		return;
	}

	m_surface.x = m_screen->w;
	m_surface.y = m_screen->h;
	m_surface.bpp = m_screen->format->BitsPerPixel;
	m_surface.bypp = m_screen->format->BytesPerPixel;
	m_surface.stride = m_screen->pitch;
	m_surface.data = m_screen->pixels;

	SDL_EnableUNICODE(1);
}
示例#18
0
文件: sdl.c 项目: GGGO/baresip
static int sdl_open(void)
{
	if (sdl.open)
		return 0;

	if (SDL_Init(SDL_INIT_VIDEO) < 0) {
		warning("sdl: unable to init SDL: %s\n", SDL_GetError());
		return ENODEV;
	}

	SDL_EnableUNICODE(1);

	tmr_start(&sdl.tmr, 100, event_handler, NULL);
	sdl.open = true;

	return 0;
}
示例#19
0
文件: video.c 项目: insin/sopwith-wii
static void Vid_SetMode()
{
	int n;
	int w, h;
	int flags = 0;

	printf("CGA Screen Emulation\n");
	printf("init screen: ");

	SDL_Init(SDL_INIT_VIDEO);

	srand(time(NULL));
	set_icon(symbol_plane[rand() % 2][rand() % 16]);

	w = SCR_WDTH;
	h = SCR_HGHT;

	if (vid_double_size) {
		w *= 2;
		h *= 2;
	}

	flags = SDL_HWPALETTE;
	if (vid_fullscreen)
		flags |= SDL_FULLSCREEN;

	screen = SDL_SetVideoMode(w, h, 8, flags);

	if (screen) {
		printf("initialised\n");
	} else {
		printf("failed\n");
		fprintf(stderr, "cant init SDL\n");
		exit(-1);
	}

	SDL_EnableUNICODE(1);

	for (n = 0; n < NUM_KEYS; ++n)
		keysdown[n] = 0;

	SDL_WM_SetCaption("SDL Sopwith", NULL);

	SDL_SetColors(screen, cga_pal, 0, sizeof(cga_pal)/sizeof(*cga_pal));
	SDL_SetColors(screenbuf, cga_pal, 0, sizeof(cga_pal)/sizeof(*cga_pal));
}
示例#20
0
//create a window using SDL
int createWindow(const char* caption, int width, int height, bool fullscreen = false)
{
	int bpp = 0;
	int flags;

	if( SDL_Init(SDL_INIT_VIDEO) < 0)
	{
		fprintf(stderr, "Video initialization failed: %s\n", SDL_GetError());
		exit(-1);
	}
	SDL_EnableUNICODE(1);
	atexit(SDL_Quit);

	flags = SDL_OPENGL | ( fullscreen ? SDL_FULLSCREEN : 0);
	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); //or 24
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
	SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);

	//antialiasing (disable this lines if it goes too slow)
	SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
	SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4 ); //increase to have smoother polygons

	const SDL_VideoInfo* info = SDL_GetVideoInfo();

	if(!info)
	{
		fprintf(stderr, "Video query failed: %s\n", SDL_GetError());
		return 0;
	}

	bpp = info->vfmt->BitsPerPixel;
	if(SDL_SetVideoMode(width, height, bpp, flags) == 0)
	{
		fprintf(stderr, "Video mode set failed: %s\n", SDL_GetError());
		return 0;
	}

	SDL_PumpEvents(); //without this line asserts could fail on windows
	SDL_WM_SetCaption(caption,NULL);
	//SDL_GetMouseState(&mouse_last_x,&mouse_last_y);
	return bpp;
}
	virtual void CreateMenu(const std::string& name, boost::shared_ptr<SceneGraph> scenegraph){
		signalbroker.InvokeSignal<OutputStreamView::LogHandler>("/log/output", "Loading Pacman CreditsGUI");

		SDL_EnableUNICODE(1);
		SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);

		try{
		imageLoader = new gcn::OpenGLSDLImageLoader();
		gcn::Image::setImageLoader(imageLoader);
		graphics = new gcn::OpenGLGraphics(640,480);
		input = new gcn::SDLInput();

		font = new gcn::ImageFont(FileSystem::MakeUsrLocalPath("/images/fixedfont.png"), " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
		hoverfont = new gcn::ImageFont(FileSystem::MakeUsrLocalPath("/images/hoverfont.png"), " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
		gcn::Widget::setGlobalFont(font);
		}catch(gcn::Exception e){
			signalbroker.InvokeSignal<OutputStreamView::LogHandler>("/log/output",
				"gcn::Exception:" + e.getMessage());
		}

		signalbroker.InvokeSignal<OutputStreamView::LogHandler>("/log/output", "Parsing Credits XML");

		xmlgui->parse(FileSystem::MakeUsrLocalPath("/menus/creditsgui.xml"));
		gui->setGraphics(graphics);
		gui->setInput(input);
		gui->setTop(xmlgui->getWidget("top"));

		signalbroker.InvokeSignal<OutputStreamView::LogHandler>("/log/output", "Finding GuiChan widgets");

		continuelabel = dynamic_cast<gcn::Label*>(xmlgui->getWidget("continue"));


		signalbroker.InvokeSignal<OutputStreamView::LogHandler>("/log/output", "Connecting Listeners");

		continuemouselistener = new MenuItemMouseListener(menuname, "quit", continuelabel, signalbroker);
		continuelabel->addMouseListener(continuemouselistener);


		boost::shared_ptr<IRenderable> guichangui(new GuiChanGui(gui));
		scenegraph->GetRoot().AddSceneNodeProperty("renderable", boost::shared_ptr<SceneNodeProperty>(new RenderableProperty(guichangui)));

		signalbroker.InvokeSignal<OutputStreamView::LogHandler>("/log/output", "Loaded Pacman HighScoresGUI");

		MenuInitialized();
	}
示例#22
0
static void
init_sdl (void)
{
  static int inited = 0;

  if (!inited)
    {
      inited = 1;

      if (SDL_Init (SDL_INIT_VIDEO) < 0)
        {
          fprintf (stderr, "Unable to init SDL: %s\n", SDL_GetError ());
          return;
        }
      atexit (SDL_Quit);
      SDL_EnableUNICODE (1);
    }
}
示例#23
0
/**
 * @brief Constructor principal
 *
 * @param fuente Ruta del fichero *.ttf a cargar
 * @param color Color del texto a generar
 * @param tam Tamaño con el que se cargará la fuente
 * @param ax,ay Offset sobre #x, #y
 * @param l Longitud máxima de la cadena a ingresar.
 *
 * Asigna los valores pasados como parámetros y llama a la función SDL_EnableUNICODE()
 */
CTeclado::CTeclado(const char* fuente, uint tam, SDL_Color* color, int ax, int ay, uint l)
{
  ttf_fuente = TTF_OpenFont(fuente, tam);

  str = "";
  img_texto = NULL;

  length = l;

  color_texto.r = color->r;
  color_texto.b = color->b;
  color_texto.g = color->g;

  x = ax;
  y = ay;

  SDL_EnableUNICODE( SDL_ENABLE );
}
示例#24
0
文件: sdl.c 项目: kireerik/siva
void initWindow() {
	SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
	#ifdef __WIN32__
		freopen("CON", "w", stdout);
		freopen("CON", "w", stderr);
	#endif
	const SDL_VideoInfo *info = SDL_GetVideoInfo();
	w.width = info->current_w;
	w.height = info->current_h;
	screen = SDL_SetVideoMode(w.width, w.height, 0, SDL_HWSURFACE | SDL_FULLSCREEN);
	if (!screen) {
		fprintf(stderr, "Nem sikerult megnyitni az ablakot!\n");
		exit(1);
	}
	SDL_WM_SetCaption(w.title, w.title);

	SDL_EnableUNICODE(1);
}
示例#25
0
文件: control.cpp 项目: espio/Mypaint
bool		Control::InputKeyboardEvent(SDL_KeyboardEvent* event)
{
	SDL_keysym*	keysym;
	Uint8*		keys;

	SDL_EnableUNICODE(SDL_ENABLE);
	keysym = &event->keysym;
	keys = SDL_GetKeyState(NULL);
	if (keys[SDLK_LCTRL] && keys[SDLK_z])
	{
		std::cout << "ctrl + z" << std::endl;
//		if (this->Undo())
//			return 1;
	}
	if (keysym->unicode > 32)
		std::cout << "touche " << SDL_GetKeyName(keysym->sym) << std::endl;
	return 0;
}
int main(int argc, char* argv[])
{
	initSDL();
	SDL_EnableUNICODE(1);
	SDL_WM_SetCaption("Remote PC Keyboard", "Remote PC Keyboard");

	openInput();

	createGuiMain();

	while( true )
	{
		mainLoop();
	}

	deinitSDL();
	return 0;
}
示例#27
0
文件: cglemon.c 项目: koo5/cheapglk
void glk_make_sdl_window(void)
{


	s=initsdl(w,h,&bpp,SDL_OPENGL);
	SDL_EnableUNICODE(1);
	SDL_InitSubSystem( SDL_INIT_TIMER);
	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY/2, SDL_DEFAULT_REPEAT_INTERVAL/3);
	gle();
	resetviewport();
	resetmatrices();
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
	glClearColor( 0.0, 0.0, 0.0, 0.0 );
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	printf("LEMON\n");
}
示例#28
0
GUI_status GUI_TextInput::MouseUp(int x, int y, int button)
{
 if(button == SDL_BUTTON_WHEELUP || button == SDL_BUTTON_WHEELDOWN)
   return GUI_PASS;
 //release focus if we click outside the text box.
 if(focused && !HitRect(x, y))
   release_focus();
 else
  {
   if(!focused)
     {
      grab_focus();
      SDL_EnableUNICODE(1); //turn on unicode processing.
     }
  }

 return(GUI_PASS);
}
示例#29
0
文件: Input.cpp 项目: mpreisler/ember
void Input::initialize(int width, int height)
{
	SDL_ShowCursor(0);
	SDL_EnableUNICODE(1);
	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);

	//must initialize the clipboard support
#ifndef WITHOUT_SCRAP
	if (init_scrap() < 0) {
		S_LOG_FAILURE("Couldn't init clipboard: \n" << SDL_GetError());
	}
#endif // WITHOUT_SCRAP
	ConsoleBackend::getSingletonPtr()->registerCommand(BINDCOMMAND, this);
	ConsoleBackend::getSingletonPtr()->registerCommand(UNBINDCOMMAND, this);

	setGeometry(width, height);

}
示例#30
0
/**
 * @brief Runs on application start and should perform all
 * initialization for SDL.
 *
 * @return True if successful, false otherwise.
 */
bool MazeSolverApp::OnInit()
{
    if(SDL_Init(SDL_INIT_EVERYTHING) < 0)
    {
        return false;
    }

    if((surf = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32,
                                SDL_HWSURFACE | SDL_DOUBLEBUF)) == NULL)
    {
        return false;
    }

    /* This is necessary to receive Unicode keycodes. */
    SDL_EnableUNICODE(1);

    return true;
}