コード例 #1
0
ファイル: channel.cpp プロジェクト: whimlex/Equalizer
co::CommandQueue* Channel::getCommandThreadQueue()
{
    Window* window = getWindow();
    LBASSERT( window );
    return window->getCommandThreadQueue();
}
コード例 #2
0
EAPI_MAIN int elm_main(int argc, char **argv)
{
	Window window;
	WindowListener windowListener;

	window.create();

	window.setListener( &windowListener );

	MainContent mainContent( window.getEvasObject() );

	window.setContentLayout( mainContent.getLayout() );

	DrawingContent drawingContent( window.getEvasObject(), mainContent.getLayout() );

	GraphicObjectsContrucor::getInstance().setCanvas( drawingContent.getDrawingCanvas() );

	ToolbarContent toolbar( mainContent.getLayout() );
	{
		string title( "Save objects" );
		ToolbarContentButtonParams * params = new ToolbarContentButtonParams( title, on_save_objects, NULL );
		ToolbarContentItem * item = new ToolbarContentButton( *params );

		toolbar.addToolbarContentItem( *item );
	}

	{
		string title( "Sceleton Mode" );
		ToolbarContentRadioParams * params2 = new ToolbarContentRadioParams( title, on_sceleton_mode, &drawingContent, NULL, true );
		ToolbarContentItem * item2 = new ToolbarContentRadio( *params2 );

		toolbar.addToolbarContentItem( *item2 );

		title = "Run simulation";
		ToolbarContentRadioParams * params3 = new ToolbarContentRadioParams( title, on_run_simulation, &drawingContent, item2->getEvas(), false );
		ToolbarContentItem * item3 = new ToolbarContentRadio( *params3 );

		toolbar.addToolbarContentItem( *item3 );
	}
	{
		string title( "Test objects" );
		ToolbarContentButtonParams * params = new ToolbarContentButtonParams( title, on_construct_test_objects, &drawingContent );
		ToolbarContentItem * item = new ToolbarContentButton( *params );

		toolbar.addToolbarContentItem( *item );
	}
	{
		string title( "Clear" );
		ToolbarContentButtonParams * params = new ToolbarContentButtonParams( title, on_clear_objects, &drawingContent );
		ToolbarContentItem * item = new ToolbarContentButton( *params );

		toolbar.addToolbarContentItem( *item );
	}

	GeometrySceletonOperationTracking geoSceletonObjectTracking( drawingContent );
	SimulationOperationTracking   geoEditingObjectTracking( drawingContent );

	MouseListener mouseListener( NULL, drawingContent.getDrawingCanvas() );

	MouseTrackerManager::getInstance().setMouseListener( &mouseListener );
	MouseTrackerManager::getInstance().addTracker( &geoSceletonObjectTracking );
	MouseTrackerManager::getInstance().addTracker( &geoEditingObjectTracking );

	MouseTrackerManager::getInstance().setMouseListenerTrackerMode( SCELETON_MODE_E );

	window.setMaxSize( 800, 600 );

	srand( time ( 0 ) );

	elm_run();
	return 0;
}
コード例 #3
0
void LoadSaveWindow::onCancel() {
	Window* pParentWindow = dynamic_cast<Window*>(getParent());
	if(pParentWindow != NULL) {
		pParentWindow->closeChildWindow();
	}
}
コード例 #4
0
void WindowDrawTask::execute(HardwareContext *pContext, DrawEnv *pEnv)
{
    Window *pWindow = pEnv->getWindow();

    OSG_ASSERT(pWindow != NULL);

    switch(_uiTypeTask)
    {
        case Init:
        {
#ifdef OSG_DUMP_WINTASK
            fprintf(stderr, "Init\n");
            fflush(stderr);
#endif
            if(_bCreatePrivateContext == true)
                pWindow->init();

            pWindow->doActivate   ();
            pWindow->doFrameInit  (_bReinitExtFunctions);
            pWindow->setupGL      ();
            pWindow->setOpenGLInit();

            if(_oInitFunc)
            {
                _oInitFunc();
            }
        }
        break;

        case Activate:
        {
#ifdef OSG_DUMP_WINTASK
            fprintf(stderr, "Activate\n");
            fflush(stderr);
#endif
            pWindow->doActivate();
        }
        break;

        case FrameInit:
        {
#ifdef OSG_DUMP_WINTASK
            fprintf(stderr, "FrameInit\n");
            fflush(stderr);
#endif

            pWindow->doFrameInit();
        }
        break;

        case FrameExit:
        {
#ifdef OSG_DUMP_WINTASK
            fprintf(stderr, "FrameExit\n");
            fflush(stderr);
#endif
            pWindow->doFrameExit();

            commitChangesAndClear();
        }
        break;

        case WaitAtBarrier:
        {
#ifdef OSG_DUMP_WINTASK
            fprintf(stderr, "WaitAtBarrier\n");
            fflush(stderr);
#endif
            OSG_ASSERT(_pBarrier != NULL);
            _pBarrier->enter();
        }
        break;

        case DeactivateAndWait:
        {
#ifdef OSG_DUMP_WINTASK
            fprintf(stderr, "DeactivateAndWait\n");
            fflush(stderr);
#endif
            pWindow->doDeactivate();

            OSG_ASSERT(_pBarrier != NULL);
            _pBarrier->enter();
        }
        break;

        case Swap:
        {           
#ifdef OSG_DUMP_WINTASK
            fprintf(stderr, "Swap\n");
            fflush(stderr);
#endif
            pWindow->doSwap();

#ifdef OSG_SWAP_BARRIER
            OSG_ASSERT(_pBarrier != NULL);

            _pBarrier->enter();
#endif
        }
        break;

        case EndThread:
        {
#ifdef OSG_DUMP_WINTASK
            fprintf(stderr, "EndThread\n");
            fflush(stderr);
#endif
            pWindow->doFrameExit();
            
#if defined(OSG_WITH_CUDA) && !defined(OSG_OGL_ES2)
            if(0x0000 != (pWindow->getInitState() & 
                          HardwareContext::CudaInitialized))
            {
                cudaThreadExit();
            }
#endif
            pWindow->doDeactivate();
            pWindow->_pContextThread->endRunning();
        }
        break;

        default:
            break;
    }
}
コード例 #5
0
 uint64_t match(Window aWin) { return aWin->WindowID(); }
コード例 #6
0
QUrl WindowsManager::getUrl() const
{
	Window *window = m_mainWindow->getWorkspace()->getActiveWindow();

	return (window ? window->getUrl() : QUrl());
}
コード例 #7
0
ファイル: main.cpp プロジェクト: kirkbackus/meal-track
//Entry point of the program
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow)
{
    //Create a window
    cWindow = Window(WindowProcedure, hThisInstance, "MealTrackApp", nCmdShow);
    cWindow.Create("MealTrack - Untitled", 462, 375);

    //Actually create the button with the window as its parent
    RECT rEditBox = {16, 280, 272, 24};
    cEditBox = EditBox(cWindow, rEditBox, "Disconnected");
    cEditBox.SetReadOnly(1);

    //Create the Button
    RECT rButton = {304, 280, 128, 24};
    cButton = Button(cWindow, rButton, "Start Meal", IDR_START_BUTTON);
    cButton.SetEnabled(0);

    //Create the listbox
    RECT rListBox = {16, 16, 272, 272};
    cListBox = ListBox(cWindow, rListBox, "MealListBox");

    //Meal wait box
    RECT rLabelDelay = {304, 16, 128, 16};
    RECT rEditDelay = {304, 32, 128, 24};
    cLabelDelay = Label(cWindow, rLabelDelay, "Meal wait (seconds)");
    cEditDelay = EditBox(cWindow, rEditDelay, "10");

    //Create Date format box
    RECT rLabelDate = {304, 64, 128, 16};
    RECT rComboDate = {304, 80, 128, 24};
    cLabelDate = Label(cWindow, rLabelDate, "Date format");
    cComboDate = ComboBox(cWindow, rComboDate, "ComboBoxDate");
    cComboDate.AddItem("12 Hour AM/PM");
    cComboDate.AddItem("24 Hour");
    cComboDate.SetDefaultItem(1);

    //Record format box
    RECT rLabelRecord = {304, 112, 128, 16};
    RECT rComboRecord = {304, 128, 128, 24};
    cLabelRecord = Label(cWindow, rLabelRecord, "Record change type");
    cComboRecord = ComboBox(cWindow, rComboRecord, "ComboBoxRecord");
    cComboRecord.AddItem("Increases");
    cComboRecord.AddItem("Decreases");
    cComboRecord.AddItem("Both");
    cComboRecord.SetDefaultItem(1);

    //Record format box
    RECT rLabelSensitivity = {304, 160, 128, 16};
    RECT rComboSensitivity = {304, 176, 128, 24};
    cLabelSensitivity = Label(cWindow, rLabelSensitivity, "Sensitivity");
    cComboSensitivity = ComboBox(cWindow, rComboSensitivity, "ComboBoxSensitivity");
    cComboSensitivity.AddItem("0.01 g");
    cComboSensitivity.AddItem("0.02 g");
    cComboSensitivity.AddItem("0.03 g");
    cComboSensitivity.AddItem("0.04 g");
    cComboSensitivity.AddItem("0.05 g");
    cComboSensitivity.AddItem("0.06 g");
    cComboSensitivity.AddItem("0.07 g");
    cComboSensitivity.AddItem("0.08 g");
    cComboSensitivity.AddItem("0.09 g");
    cComboSensitivity.SetDefaultItem(2);

    //Custom function to creeate window
    CreateWindowMenu(cWindow);

    //Message loop
    MSG msg;
    while (cWindow.GetMessage(&msg))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    // The program return-value is 0 - The value that PostQuitMessage() gave
    return msg.wParam;
}
コード例 #8
0
ファイル: Main.cpp プロジェクト: henry4k/void
bool ClientEngine::initialize()
{
	// Setup Window
	m_Window.setName("void");
	
	// Connect to server
	ENetAddress address;
	if(enet_address_set_host(&address, "localhost") != 0)
		return false;
	address.port = 1234;
	if(!m_Client.connect(&address))
		return false;
	
	// Setup Resource Manager
	m_ResourceManager.registerResourceType<Texture2dFile>(RES_TEXTURE2D);
	
	// Setup OpenGL
	glClearDepth(1);
	glDepthFunc(GL_LEQUAL);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);
	
	// Setup camera
	m_Camera.setNear(0.1);
	m_Camera.setFar(100);
	m_Camera.setRotation(Quaternion(vec3f(1,0,0), -tools4k::Pi*0.5));
	m_Camera.setScreen(m_Window.size());
	m_Camera.setFov(90);
	
	// Setup shader
	if(!m_Shader.load("Shader.vert", "Shader.frag"))
		return false;
	m_Shader.setUniform("DiffuseMap", 0);
	
	// Setup map
	{
		int myTileMap = m_ClientMap.createTileMap();
		TileMap* tm = m_ClientMap.getTileMap(myTileMap);
		tm->diffuse = (Texture2dFile*)m_ResourceManager.loadResource(RES_TEXTURE2D, "tileset.png");
		tm->tileSize = 32;
		tm->width = 128;
		
		int id = m_ClientMap.createVoxelType("Rock");
		VoxelType* vt = m_ClientMap.getVoxelType(id);
		vt->collisionShape = VCSHAPE_CUBE;
		
		ClientVoxelType* cvt = m_ClientMap.getClientVoxelType(id);
		cvt->mesh = VCSHAPE_CUBE;
		cvt->renderMode = VRENDER_SOLID;
		cvt->tileMap = myTileMap;
		memset(cvt->faces, 0, sizeof(cvt->faces));
		cvt->faces[VFACE_BACK] = 1;
		cvt->faces[VFACE_TOP] = 4;
		
		Voxel voxel;
		voxel.typeId = id;
		m_ClientMap.setVoxel(vec3i(0,0,0), voxel);
		m_ClientMap.setVoxel(vec3i(1,1,1), voxel);
		
		m_ClientMap.updateModel(aabb3i(vec3i(0,0,0), vec3i(10,10,10)));
	}
	
	if(!loadPackage("Base"))
		return false;
	
	return true;
}
コード例 #9
0
ファイル: main.cpp プロジェクト: Matidy/1-col
int main(int argc, char* args[]) {
	Window window;

	if(!window.init()) {
		printf("Failed to initialise SDL and/or game window.\n");
		}

	else {
		Board board;

		if(!board.init()) {
			printf("Failed to intitialise board instance.\n");
		}

		else {
			GameController game_controller;

			if(!game_controller.init(board)) {
				printf("Failed to initialise game controller.\n");
			}

			else {
				// Draw initial board state to screen
				window.draw(board.board_tiles, 0);

				///////////////////////////
				///		 Main Loop      ///
				///////////////////////////
				bool quit = false;
				SDL_Event e;
				int pos_x, pos_y; //UNUSED: Maybe move SDL out to a higher level?
				std::set<Tile*> tiles_to_draw;
				Uint32 start_time = SDL_GetTicks();
				Uint32 current_time = start_time;
				Uint32 time_last_frame;
				Uint32 time_between_frames;
				
				int counted_frames = 0;
		
				while (!quit) {
					/// Frame Rate Cap ///
					time_last_frame = current_time;
					current_time = SDL_GetTicks();
					time_between_frames = current_time - time_last_frame;
					if (time_between_frames <= MINIMUM_FRAME_DURATION)
						SDL_Delay(MINIMUM_FRAME_DURATION - time_between_frames);
					
					/*
					if (current_time - start_time >= 1000) {
						printf("Frame Rate: %d\n", counted_frames);
						start_time = SDL_GetTicks();
						counted_frames = 0;
					}
					++counted_frames;
					*/

					switch(game_controller.phase) {

/*-->*/				case GameController::TILE_CLAIM:

						/// Highlight Hovered Over Tile ///
						board.tileInFocus = board.findTileInFocus();
						if (board.getUID(*board.tileInFocus) != board.getUID(*board.prevTileInFocus)) {
							if (board.getUID(*board.prevTileInFocus) != 0) { // 0->Invalid(NULL)
								window.drawUnhighlight(*board.prevTileInFocus);
							}
							if(board.getUID(*board.tileInFocus) != 0) {
								window.drawHighlight(*board.tileInFocus);
							}
							board.prevTileInFocus = board.tileInFocus;
						}
					
						/// User Event Handling ///
						while (SDL_PollEvent(&e) != 0) {       
							if (e.type == SDL_QUIT) {
								quit = true;
							}
							else if (e.button.type == SDL_MOUSEBUTTONUP) {
								game_controller.eventClick(board.tileInFocus, e.button);
								window.drawHighlight(*board.tileInFocus);
							}
							else if (e.type == SDL_KEYUP) { 
								if (e.key.keysym.sym == SDLK_SPACE) {
									window.drawUnhighlight(*board.tileInFocus);
									// END TURN
									game_controller.claimMarkedTiles();
									window.draw(*game_controller.current_player_prev_claimed, 0);
									// CHANGE STATE
									game_controller.phase = GameController::TERRITORY_EXPAND;
									game_controller.generateTilesToCheck(&board, *game_controller.current_player_prev_claimed);
									game_controller.current_player_prev_claimed->clear();
								}
								else if (e.key.keysym.sym == SDLK_r) { // Reset game
									for(auto it=board.board_tiles.begin(); it!=board.board_tiles.end(); ++it) {
										if (it->owner != Tile::UNOWNABLE) 
											it->owner = Tile::NEUTRAL;
									}
									game_controller.reset();
									window.draw(board.board_tiles, 0);
									window.drawHighlight(*board.tileInFocus);
								}
							}
						}
						break;

/*-->*/				case GameController::TERRITORY_EXPAND:	
						tiles_to_draw = game_controller.expandTerritory(&board);
						SDL_Delay(500);
						window.draw(tiles_to_draw, 0);
						if(game_controller.tiles_to_check.empty()) {
							if (game_controller.unclaimed_tiles <=0) {
								game_controller.phase = GameController::GAME_END;
							}
							else {
								game_controller.switchPlayer();
								game_controller.phase = GameController::TILE_CLAIM;
								window.drawHighlight(*board.tileInFocus);
							}
						}
						break;
					
/*-->*/				case GameController::GAME_END:

						/// Highlight Winner's Tiles ///
						GameController::Player winner;
						if (game_controller.claimed_by_orange - game_controller.claimed_by_blue > 0) 
							winner = GameController::ORANGE;
						else if (game_controller.claimed_by_orange - game_controller.claimed_by_blue < 0)
							winner = GameController::BLUE;
						else
							winner = GameController::NONE;
						
						for (auto it = board.board_tiles.begin(); it != board.board_tiles.end(); ++it) {
							if (int(it->owner) == int(winner)) {
								window.draw(*it, 15);
							}
							else {
								window.draw(*it, -15);
							}
						}

						/// User Event Handling ///
						while (SDL_PollEvent(&e) != 0) {       
							if (e.type == SDL_QUIT) {
								quit = true;
							}
							else if (e.type == SDL_KEYUP) { 
								if (e.key.keysym.sym == SDLK_r) { // Reset game
									for(auto it=board.board_tiles.begin(); it!=board.board_tiles.end(); ++it) {
										if (it->owner != Tile::UNOWNABLE) 
										it->owner = Tile::NEUTRAL;
									}
									game_controller.reset();
									window.draw(board.board_tiles, 0);
									window.drawHighlight(*board.tileInFocus);
									game_controller.phase = GameController::TILE_CLAIM;
								}
							}
						}
						break;
					}
					SDL_RenderPresent(window.gRenderer);
				}
			}
		}
	}
	
	window.close();
	SDL_Delay(100);
	return 0;
}
コード例 #10
0
ファイル: test_hover.cpp プロジェクト: Limsik/e17
void test_hover2 (void *data, Evas_Object *obj, void *event_info)
{
  Box *bx = NULL;
  Button *bt = NULL;

  Window *win = Window::factory ("hover2", ELM_WIN_BASIC);
  win->setTitle ("Hover 2");
  win->setAutoDel (true);

  Background *bg = Background::factory (*win);
  win->addObjectResize (*bg);
  bg->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  bg->show ();

  bx = Box::factory (*win);
  bx->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  win->addObjectResize (*bx);
  bx->show ();

  Hover *hv = Hover::factory (*win);
  hv->setStyle ("popout");

  bt = Button::factory (*win);
  bt->setText ("Button");
  bt->getEventSignal ("clicked")->connect (sigc::bind (sigc::ptr_fun (&my_hover_bt), hv));
  bx->packEnd (*bt);
  bt->show ();
  hv->setParent (*win);
  hv->setTarget (*bt);

  bt = Button::factory (*win);
  bt->setText ("Popup");
  hv->setContent ("middle", *bt);
  bt->show ();

  bx = Box::factory (*win);

  Icon *ic = Icon::factory (*win);
  ic->setFile (searchPixmapFile ("elementaryxx/logo_small.png"));
  ic->setNoScale (true);
  bx->packEnd (*ic);
  ic->show ();

  bt = Button::factory (*win);
  bt->setText ("Top 1");
  bx->packEnd (*bt);
  bt->show ();

  bt = Button::factory (*win);
  bt->setText ("Top 2");
  bx->packEnd (*bt);
  bt->show ();

  bt = Button::factory (*win);
  bt->setText ("Top 3");
  bx->packEnd (*bt);
  bt->show ();

  bx->show ();

  hv->setContent ("top", *bx);

  bt = Button::factory (*win);
  bt->setText ("Bot");
  hv->setContent ("bottom", *bt);
  bt->show ();

  bt = Button::factory (*win);
  bt->setText ("Left");
  hv->setContent ("left", *bt);
  bt->show ();

  bt = Button::factory (*win);
  bt->setText ("Right");
  hv->setContent ("right", *bt);
  bt->show ();

  bg->setMinHintSize (size160x160);
  bg->setMaxHintSize (size640x640);
  win->resize (size320x320);
  win->show ();
}
コード例 #11
0
ファイル: Main.cpp プロジェクト: henry4k/void
void ClientEngine::onResizeWindow( Window* wnd )
{
	glViewport(0, 0, m_Window.size().x, m_Window.size().y);
	m_Camera.setScreen(m_Window.size());
}
コード例 #12
0
ファイル: main.cpp プロジェクト: nito76130/EmulationStation
int main(int argc, char* argv[])
{
	unsigned int width = 0;
	unsigned int height = 0;
	if(argc > 1)
	{
		for(int i = 1; i < argc; i++)
		{
			if(strcmp(argv[i], "-w") == 0)
			{
				width = atoi(argv[i + 1]);
				i++; //skip the argument value
			}else if(strcmp(argv[i], "-h") == 0)
			{
				height = atoi(argv[i + 1]);
				i++; //skip the argument value
			}else if(strcmp(argv[i], "--gamelist-only") == 0)
			{
				PARSEGAMELISTONLY = true;
			}else if(strcmp(argv[i], "--ignore-gamelist") == 0)
			{
				IGNOREGAMELIST = true;
			}else if(strcmp(argv[i], "--draw-framerate") == 0)
			{
				DRAWFRAMERATE = true;
			}else if(strcmp(argv[i], "--no-exit") == 0)
			{
				DONTSHOWEXIT = true;
			}else if(strcmp(argv[i], "--debug") == 0)
			{
				DEBUG = true;
				Log::setReportingLevel(LogDebug);
			}else if(strcmp(argv[i], "--dimtime") == 0)
			{
				DIMTIME = atoi(argv[i + 1]) * 1000;
				i++; //skip the argument value
			}else if(strcmp(argv[i], "--windowed") == 0)
			{
				WINDOWED = true;
			}else if(strcmp(argv[i], "--help") == 0)
			{
				std::cout << "EmulationStation, a graphical front-end for ROM browsing.\n";
				std::cout << "Command line arguments:\n";
				std::cout << "-w [width in pixels]		set screen width\n";
				std::cout << "-h [height in pixels]		set screen height\n";
				std::cout << "--gamelist-only			skip automatic game detection, only read from gamelist.xml\n";
				std::cout << "--ignore-gamelist		ignore the gamelist (useful for troubleshooting)\n";
				std::cout << "--draw-framerate		display the framerate\n";
				std::cout << "--no-exit			don't show the exit option in the menu\n";
				std::cout << "--debug				even more logging\n";
				std::cout << "--dimtime [seconds]		time to wait before dimming the screen (default 30, use 0 for never)\n";

				#ifdef _DESKTOP_
					std::cout << "--windowed			not fullscreen\n";
				#endif

				std::cout << "--help				summon a sentient, angry tuba\n\n";
				std::cout << "More information available in README.md.\n";
				return 0;
			}
		}
	}

	#ifdef _RPI_
		bcm_host_init();
	#endif

	bool running = true;

	//make sure the config directory exists
	std::string home = getHomePath();
	std::string configDir = home + "/.emulationstation";
	if(!fs::exists(configDir))
	{
		std::cout << "Creating config directory \"" << configDir << "\"\n";
		fs::create_directory(configDir);
	}

	//start the logger
	Log::open();

	//the renderer also takes care of setting up SDL for input and sound
	bool renderInit = Renderer::init(width, height);
	if(!renderInit)
	{
		std::cerr << "Error initializing renderer!\n";
		Log::close();
		return 1;
	}


	//initialize audio
	AudioManager::init();

	Window window; //don't call Window.init() because we manually pass the resolution to Renderer::init
	window.getInputManager()->init();

	//try loading the system config file
	if(!fs::exists(SystemData::getConfigPath())) //if it doesn't exist, create the example and quit
	{
		std::cerr << "A system config file in " << SystemData::getConfigPath() << " was not found. An example will be created.\n";
		SystemData::writeExampleConfig();
		std::cerr << "Set it up, then re-run EmulationStation.\n";
		running = false;
	}else{
		SystemData::loadConfig();

		if(SystemData::sSystemVector.size() == 0) //if it exists but was empty, notify the user and quit
		{
			std::cerr << "A system config file in " << SystemData::getConfigPath() << " was found, but contained no systems.\n";
			std::cerr << "Does at least one system have a game presesnt?\n";
			running = false;
		}else{
			//choose which GUI to open depending on Input configuration
			if(fs::exists(InputManager::getConfigPath()))
			{
				//an input config already exists - we have input, proceed to the gamelist as usual.
				GuiGameList::create(&window);
			}else{
				window.pushGui(new GuiDetectDevice(&window));
			}
		}
	}

	bool sleeping = false;
	unsigned int timeSinceLastEvent = 0;

	int lastTime = 0;
	while(running)
	{
		SDL_Event event;
		while(SDL_PollEvent(&event))
		{
			switch(event.type)
			{
				case SDL_JOYHATMOTION:
				case SDL_JOYBUTTONDOWN:
				case SDL_JOYBUTTONUP:
				case SDL_KEYDOWN:
				case SDL_KEYUP:
				case SDL_JOYAXISMOTION:
					if(window.getInputManager()->parseEvent(event))
					{
						sleeping = false;
						timeSinceLastEvent = 0;
					}
					break;

				case SDL_QUIT:
					running = false;
					break;
			}
		}

		if(sleeping)
		{
			lastTime = SDL_GetTicks();
			sleep(1); //this doesn't need to accurate
			continue;
		}

		int curTime = SDL_GetTicks();
		int deltaTime = curTime - lastTime;
		lastTime = curTime;

		window.update(deltaTime);
		window.render();

		if(DRAWFRAMERATE)
		{
			float framerate = 1/((float)deltaTime)*1000;
			std::stringstream ss;
			ss << framerate;
			std::string fps;
			ss >> fps;
			Renderer::drawText(fps, 50, 50, 0x00FF00FF, Renderer::getDefaultFont(Renderer::MEDIUM));
		}

		//sleep if we're past our threshold
		//sleeping entails setting a flag to start skipping frames
		//and initially drawing a black semi-transparent rect to dim the screen
		timeSinceLastEvent += deltaTime;
		if(timeSinceLastEvent >= DIMTIME && DIMTIME != 0)
		{
			sleeping = true;
			timeSinceLastEvent = 0;
			Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000A0);
		}

		Renderer::swapBuffers();
		Log::flush();
	}

	AudioManager::deinit();
	Renderer::deinit();
	SystemData::deleteSystems();

	std::cout << "EmulationStation cleanly shutting down...\n";

	Log::close();

	#ifdef _RPI_
		bcm_host_deinit();
	#endif

	return 0;
}
コード例 #13
0
    void ImageryComponent::render_impl(Window& srcWindow, Rect& destRect, const CEGUI::ColourRect* modColours, const Rect* clipper, bool /*clipToDisplay*/) const
    {
        // get final image to use.
        const Image* img = isImageFetchedFromProperty() ?
            PropertyHelper::stringToImage(srcWindow.getProperty(d_imagePropertyName)) :
            d_image;

        // do not draw anything if image is not set.
        if (!img)
            return;

        HorizontalFormatting horzFormatting = d_horzFormatPropertyName.empty() ? d_horzFormatting :
            FalagardXMLHelper::stringToHorzFormat(srcWindow.getProperty(d_horzFormatPropertyName));

        VerticalFormatting vertFormatting = d_vertFormatPropertyName.empty() ? d_vertFormatting :
            FalagardXMLHelper::stringToVertFormat(srcWindow.getProperty(d_vertFormatPropertyName));

        uint horzTiles, vertTiles;
        float xpos, ypos;

        Size imgSz(img->getSize());

        // calculate final colours to be used
        ColourRect finalColours;
        initColoursRect(srcWindow, modColours, finalColours);

        // calculate initial x co-ordinate and horizontal tile count according to formatting options
        switch (horzFormatting)
        {
            case HF_STRETCHED:
                imgSz.d_width = destRect.getWidth();
                xpos = destRect.d_left;
                horzTiles = 1;
                break;

            case HF_TILED:
                xpos = destRect.d_left;
                horzTiles = (uint)((destRect.getWidth() + (imgSz.d_width - 1)) / imgSz.d_width);
                break;

            case HF_LEFT_ALIGNED:
                xpos = destRect.d_left;
                horzTiles = 1;
                break;

            case HF_CENTRE_ALIGNED:
                xpos = destRect.d_left + PixelAligned((destRect.getWidth() - imgSz.d_width) * 0.5f);
                horzTiles = 1;
                break;

            case HF_RIGHT_ALIGNED:
                xpos = destRect.d_right - imgSz.d_width;
                horzTiles = 1;
                break;

            default:
                throw InvalidRequestException("ImageryComponent::render - An unknown HorizontalFormatting value was specified.");
        }

        // calculate initial y co-ordinate and vertical tile count according to formatting options
        switch (vertFormatting)
        {
            case VF_STRETCHED:
                imgSz.d_height = destRect.getHeight();
                ypos = destRect.d_top;
                vertTiles = 1;
                break;

            case VF_TILED:
                ypos = destRect.d_top;
                vertTiles = (uint)((destRect.getHeight() + (imgSz.d_height - 1)) / imgSz.d_height);
                break;

            case VF_TOP_ALIGNED:
                ypos = destRect.d_top;
                vertTiles = 1;
                break;

            case VF_CENTRE_ALIGNED:
                ypos = destRect.d_top + PixelAligned((destRect.getHeight() - imgSz.d_height) * 0.5f);
                vertTiles = 1;
                break;

            case VF_BOTTOM_ALIGNED:
                ypos = destRect.d_bottom - imgSz.d_height;
                vertTiles = 1;
                break;

            default:
                throw InvalidRequestException("ImageryComponent::render - An unknown VerticalFormatting value was specified.");
        }

        // perform final rendering (actually is now a caching of the images which will be drawn)
        Rect finalRect;
        Rect finalClipper;
        const Rect* clippingRect;
        finalRect.d_top = ypos;
        finalRect.d_bottom = ypos + imgSz.d_height;

        for (uint row = 0; row < vertTiles; ++row)
        {
            finalRect.d_left = xpos;
            finalRect.d_right = xpos + imgSz.d_width;

            for (uint col = 0; col < horzTiles; ++col)
            {
                // use custom clipping for right and bottom edges when tiling the imagery
                if (((vertFormatting == VF_TILED) && row == vertTiles - 1) ||
                    ((horzFormatting == HF_TILED) && col == horzTiles - 1))
                {
                    finalClipper = clipper ? clipper->getIntersection(destRect) : destRect;
                    clippingRect = &finalClipper;
                }
                // not tiliing, or not on far edges, just used passed in clipper (if any).
                else
                {
                    clippingRect = clipper;
                }

                // add geometry for image to the target window.
                img->draw(srcWindow.getGeometryBuffer(), finalRect, clippingRect, finalColours);

                finalRect.d_left += imgSz.d_width;
                finalRect.d_right += imgSz.d_width;
            }

            finalRect.d_top += imgSz.d_height;
            finalRect.d_bottom += imgSz.d_height;
        }
    }
コード例 #14
0
ファイル: TopWindow.cpp プロジェクト: damianob/xcsoar_mess
bool
TopWindow::OnEvent(const SDL_Event &event)
{
  switch (event.type) {
    Window *w;

  case SDL_VIDEOEXPOSE:
    Invalidated_lock.Lock();
    Invalidated = false;
    Invalidated_lock.Unlock();

    Expose();
    return true;

  case SDL_KEYDOWN:
    w = GetFocusedWindow();
    if (w == NULL)
      w = this;

    if (!w->IsEnabled())
      return false;

    return w->OnKeyDown(event.key.keysym.sym);

  case SDL_KEYUP:
    w = GetFocusedWindow();
    if (w == NULL)
      w = this;

    if (!w->IsEnabled())
      return false;

    return w->OnKeyUp(event.key.keysym.sym);

  case SDL_MOUSEMOTION:
    // XXX keys
    return OnMouseMove(event.motion.x, event.motion.y, 0);

  case SDL_MOUSEBUTTONDOWN:
    if (event.button.button == SDL_BUTTON_WHEELUP)
      return OnMouseWheel(event.button.x, event.button.y, 1);
    else if (event.button.button == SDL_BUTTON_WHEELDOWN)
      return OnMouseWheel(event.button.x, event.button.y, -1);

    return double_click.Check(RasterPoint{PixelScalar(event.button.x),
                                          PixelScalar(event.button.y)})
      ? OnMouseDouble(event.button.x, event.button.y)
      : OnMouseDown(event.button.x, event.button.y);

  case SDL_MOUSEBUTTONUP:
    if (event.button.button == SDL_BUTTON_WHEELUP ||
        event.button.button == SDL_BUTTON_WHEELDOWN)
      /* the wheel has already been handled in SDL_MOUSEBUTTONDOWN */
      return false;

    double_click.Moved(RasterPoint{PixelScalar(event.button.x),
                                   PixelScalar(event.button.y)});

    return OnMouseUp(event.button.x, event.button.y);

  case SDL_QUIT:
    return OnClose();

  case SDL_VIDEORESIZE:
    Resize(event.resize.w, event.resize.h);
    return true;
  }

  return false;
}
コード例 #15
0
QVariant WindowsManager::getOption(const QString &key) const
{
	Window *window = m_mainWindow->getWorkspace()->getActiveWindow();

	return (window ? window->getOption(key) : QVariant());
}
コード例 #16
0
ファイル: channel.cpp プロジェクト: aoighost/Equalizer
void Channel::frameDraw( const eq::uint128_t& frameID )
{
    if( stopRendering( ))
        return;

    _initJitter();
    if( _isDone( ))
        return;

    Window* window = static_cast< Window* >( getWindow( ));
    VertexBufferState& state = window->getState();
    const Model* oldModel = _model;
    const Model* model = _getModel();

    if( oldModel != model )
        state.setFrustumCulling( false ); // create all display lists/VBOs

    if( model )
        _updateNearFar( model->getBoundingSphere( ));

    // Setup OpenGL state
    eq::Channel::frameDraw( frameID );

    glLightfv( GL_LIGHT0, GL_POSITION, lightPosition );
    glLightfv( GL_LIGHT0, GL_AMBIENT,  lightAmbient  );
    glLightfv( GL_LIGHT0, GL_DIFFUSE,  lightDiffuse  );
    glLightfv( GL_LIGHT0, GL_SPECULAR, lightSpecular );

    glMaterialfv( GL_FRONT, GL_AMBIENT,   materialAmbient );
    glMaterialfv( GL_FRONT, GL_DIFFUSE,   materialDiffuse );
    glMaterialfv( GL_FRONT, GL_SPECULAR,  materialSpecular );
    glMateriali(  GL_FRONT, GL_SHININESS, materialShininess );

    const FrameData& frameData = _getFrameData();
    glPolygonMode( GL_FRONT_AND_BACK, 
                   frameData.useWireframe() ? GL_LINE : GL_FILL );

    const eq::Vector3f& position = frameData.getCameraPosition();

    glMultMatrixf( frameData.getCameraRotation().array );
    glTranslatef( position.x(), position.y(), position.z() );
    glMultMatrixf( frameData.getModelRotation().array );

    if( frameData.getColorMode() == COLOR_DEMO )
    {
        const eq::Vector3ub color = getUniqueColor();
        glColor3ub( color.r(), color.g(), color.b() );
    }
    else
        glColor3f( .75f, .75f, .75f );

    if( model )
        _drawModel( model );
    else
    {
        glNormal3f( 0.f, -1.f, 0.f );
        glBegin( GL_TRIANGLE_STRIP );
            glVertex3f(  .25f, 0.f,  .25f );
            glVertex3f( -.25f, 0.f,  .25f );
            glVertex3f(  .25f, 0.f, -.25f );
            glVertex3f( -.25f, 0.f, -.25f );
        glEnd();
    }

    state.setFrustumCulling( true );
    Accum& accum = _accum[ lunchbox::getIndexOfLastBit( getEye()) ];
    accum.stepsDone = LB_MAX( accum.stepsDone, 
                              getSubPixel().size * getPeriod( ));
    accum.transfer = true;
}
コード例 #17
0
QString WindowsManager::getTitle() const
{
	Window *window = m_mainWindow->getWorkspace()->getActiveWindow();

	return (window ? window->getTitle() : tr("Empty"));
}
コード例 #18
0
ファイル: channel.cpp プロジェクト: aoighost/Equalizer
void Channel::_drawModel( const Model* scene )
{
    Window* window = static_cast< Window* >( getWindow( ));
    VertexBufferState& state = window->getState();
    const FrameData& frameData = _getFrameData();

    if( frameData.getColorMode() == COLOR_MODEL && scene->hasColors( ))
        state.setColors( true );
    else
        state.setColors( false );
    state.setChannel( this );

    // Compute cull matrix
    const eq::Matrix4f& rotation = frameData.getCameraRotation();
    const eq::Matrix4f& modelRotation = frameData.getModelRotation();
    eq::Matrix4f position = eq::Matrix4f::IDENTITY;
    position.set_translation( frameData.getCameraPosition());

    const eq::Frustumf& frustum = getFrustum();
    const eq::Matrix4f projection = useOrtho() ? frustum.compute_ortho_matrix():
                                                 frustum.compute_matrix();
    const eq::Matrix4f& view = getHeadTransform();
    const eq::Matrix4f model = rotation * position * modelRotation;

    state.setProjectionModelViewMatrix( projection * view * model );
    state.setRange( &getRange().start);

    const eq::Pipe* pipe = getPipe();
    const GLuint program = state.getProgram( pipe );
    if( program != VertexBufferState::INVALID )
        glUseProgram( program );
    
    scene->cullDraw( state );

    state.setChannel( 0 );
    if( program != VertexBufferState::INVALID )
        glUseProgram( 0 );

    const InitData& initData =
        static_cast<Config*>( getConfig( ))->getInitData();
    if( !initData.useROI( ))
    {
        declareRegion( getPixelViewport( ));
        return;
    }

#ifndef NDEBUG // region border
    const eq::PixelViewport& pvp = getPixelViewport();
    const eq::PixelViewport& region = getRegion();

    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    glOrtho( 0.f, pvp.w, 0.f, pvp.h, -1.f, 1.f );
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();

    const eq::View* currentView = getView();
    if( currentView && frameData.getCurrentViewID() == currentView->getID( ))
        glColor3f( 0.f, 0.f, 0.f );
    else
        glColor3f( 1.f, 1.f, 1.f );
    glNormal3f( 0.f, 0.f, 1.f );

    const eq::Vector4f rect( float( region.x ) + .5f, float( region.y ) + .5f,
                             float( region.getXEnd( )) - .5f,
                             float( region.getYEnd( )) - .5f );
    glBegin( GL_LINE_LOOP ); {
        glVertex3f( rect[0], rect[1], -.99f );
        glVertex3f( rect[2], rect[1], -.99f );
        glVertex3f( rect[2], rect[3], -.99f );
        glVertex3f( rect[0], rect[3], -.99f );
    } glEnd();
#endif
}
コード例 #19
0
ファイル: main.cpp プロジェクト: kirkbackus/meal-track
//  This function is called by the Windows function DispatchMessage()
LRESULT CALLBACK WindowProcedure (HWND hWnd, UINT mMsg, WPARAM wParam, LPARAM lParam)
{
    switch (mMsg)
    {
        case WM_CREATE:
            break;

        case WM_SIZE:
            break;

        case WM_COMMAND:
            //If handle is the window, handle the menu
            if (hWnd == cWindow.GetHandle())
                HandleMenu(hWnd, LOWORD(wParam));

            if (LOWORD(wParam) == IDR_START_BUTTON) {
                //Check if we have a connection to the scale
                if (scale != NULL && scale->IsConnected()) {
                    //Check if we just finished a meal as well, if we didn't, start one
                    if (!bMealActive) { //If the meal is not active, start it or reset it
                        if (vMealItems.size() == 0) {
                            _beginthread(Meal, 0, (void*)hWnd);
                        } else {
                            vMealItems.clear();
                            HandleMenu(hWnd, ID_FILE_NEW);
                        }
                    } else { //Otherwise, stop it
                        if (strlen(cSaveName)<=1) GetSaveFile(hWnd);
                        bMealActive = 0;
                    }
                }
            }
            break;

        case WM_CLOSE:
            if (strlen(cSaveName) > 1 && !SaveMeal()) {
                if (CheckAndSave() == -1) break;
            } else if (!bSaved && vMealItems.size() > 0) {
                switch(MessageBox(hWnd, "You haven't saved the current meal, would you like to?","Hold Up!", MB_YESNOCANCEL | MB_ICONINFORMATION)) {
                    case IDYES:
                        if (CheckAndSave() == -1) break;
                    case IDNO:
                        if (scale) delete scale;
                        DestroyWindow(hWnd);
                        hWnd = NULL;
                    break;

                    case IDCANCEL:
                    break;

                    default:
                    break;
                }
            } else {
                if (hWnd != NULL) {
                    if (scale) delete scale;
                    DestroyWindow(hWnd);
                }
            }
            break;

        case WM_DESTROY:
            PostQuitMessage(0);
            break;

        case WM_UPDATE_READING:
            //Destroy any spare messages if scale is null
            if (scale == NULL) break;

            //Retreive the information and print it on the button
            char tBuf[32];
            sprintf(tBuf, "Connected on %s - %.2f %s %s", scale->GetName(), scale->GetWeight(), scale->GetUnit(), (scale->IsStable()?"":"(unstable)"));
            cEditBox.SetText(tBuf);

            hScaleThread = (HANDLE)_beginthread(GetScaleReading, 0, (void*) hWnd);
            break;

        case WM_SCALE_CONNECTED:
            ToggleScaleMenu(1);
            break;

        case WM_SCALE_DISCONNECTED:
            ToggleScaleMenu(0);
            cEditBox.SetText("Disconnected");
            break;

        default:
            return DefWindowProc (hWnd, mMsg, wParam, lParam);
    }

    return 0;
}
コード例 #20
0
int WindowsManager::getZoom() const
{
	Window *window = m_mainWindow->getWorkspace()->getActiveWindow();

	return (window ? window->getContentsWidget()->getZoom() : 100);
}
コード例 #21
0
ファイル: scene02.cpp プロジェクト: drewet/origamibirds
void Scene02::init(const Window& window)
{
    Camera camera(50.0f, window.getAspectRatio(), 0.1f, 100.0f);
    CameraComponent* cameraComponent = new CameraComponent(camera);

    PhysicsEngine physicsEngine;
    PhysicsObject physicsObject1(new BoundingSphere(glm::vec3(-1.0, 0.5, -5.0), 0.2f), glm::vec3(0.1f, 0.1f, 0.0f), true);
    PhysicsObject physicsObject2(new BoundingSphere(glm::vec3(-2.0, 0.5, -5.0), 0.2f), glm::vec3(0.1f, 0.1f, 0.0f), true);
    PhysicsObject physicsObject3(new BoundingSphere(glm::vec3(-3.0, 0.5, -5.0), 0.2f), glm::vec3(0.1f, 0.1f, 0.0f), true);
    PhysicsObject physicsObject4(new BoundingSphere(glm::vec3(-4.0, 0.5, -5.0), 0.2f), glm::vec3(0.1f, 0.1f, 0.0f), true);
    PhysicsObject physicsObject5(new BoundingSphere(glm::vec3(-5.0, 0.5, -5.0), 0.2f), glm::vec3(0.1f, 0.1f, 0.0f), true);
    //PhysicsObject physicsObject6(new BoundingSphere(glm::vec3(-6.0, 0.5, -5.0), 0.2f), glm::vec3(0.1f, 0.1f, 0.0f), true);

    //PhysicsObject physicsObject6(new BoundingSphere(glm::vec3(3.0, 0.0, -5.0), 0.1f), glm::vec3(0.0f, 0.0f, 0.0f), false);

    physicsEngine.addObject(physicsObject1);
    physicsEngine.addObject(physicsObject2);
    physicsEngine.addObject(physicsObject3);
    physicsEngine.addObject(physicsObject4);
    physicsEngine.addObject(physicsObject5);
    //physicsEngine.addObject(physicsObject6);

    PhysicsEngineComponent* physicsEngineComponent = new PhysicsEngineComponent(physicsEngine);
    Node* physicsEngineNode = new Node;
    physicsEngineNode->addComponent(physicsEngineComponent);
    addToScene(physicsEngineNode);

    IndexedMesh floorIndexedMesh("models/plane.obj");
    floorIndexedMesh.m_texCoords.push_back( glm::vec2(1.0, 1.0) );
    floorIndexedMesh.m_texCoords.push_back( glm::vec2(1.0, 0.0) );
    floorIndexedMesh.m_texCoords.push_back( glm::vec2(0.0, 0.0) );
    floorIndexedMesh.m_texCoords.push_back( glm::vec2(0.0, 1.0) );
    Mesh floorMesh;
    floorMesh.init(floorIndexedMesh);
    Material* floor = new Material( new Texture("textures/snow.jpg") , glm::vec3(1.0, 1.0, 1.0));

    // adding interior
    Material* back = new Material( new Texture("textures/Fireplace.jpg") , glm::vec3(1.0, 1.0, 1.0));
    Node* backNode = new Node(glm::vec3(-10.0, 8.0, -10.0), glm::vec3(-90.0f, 0.0f, 0.0f), glm::vec3(20.0f, 1.0f, 10.0f));
    backNode->addComponent(new MeshRenderer(floorMesh, *back));
    addToScene(backNode);

    Material* win = new Material( new Texture("textures/s.jpg") , glm::vec3(1.0, 1.0, 1.0));
    Node* winNode = new Node(glm::vec3(9.99, 10.0, -10.0), glm::vec3(0.0f, -90.0f, -90.0f), glm::vec3(5.0f, 1.0f, 5.0f));
    winNode->addComponent(new MeshRenderer(floorMesh, *win));
    addToScene(winNode);

    Node* winNode2 = new Node(glm::vec3(10.01, 10.0, -10.0), glm::vec3(0.0f, -90.0f, -90.0f), glm::vec3(5.0f, 1.0f, 5.0f));
    winNode2->addComponent(new MeshRenderer(floorMesh, *win));
    addToScene(winNode2);

    Material* walls = new Material( new Texture("textures/carpet5.jpg") , glm::vec3(1.0, 1.0, 1.0));
    Node* roofNode = new Node(glm::vec3(-10.0, 18.0, -10.0), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(20.0f, 1.0f, 20.0f));
    roofNode->addComponent(new MeshRenderer(floorMesh, *walls));
    addToScene(roofNode);

    Node* rwallNode = new Node(glm::vec3(10.0, 8.0, -10.0), glm::vec3(0.0f, 0.0f, -90.0f), glm::vec3(13.0f, 1.0f, 20.0f));
    rwallNode->addComponent(new MeshRenderer(floorMesh, *walls));
    addToScene(rwallNode);

    Material* fwall = new Material( new Texture("textures/Door.jpg") , glm::vec3(1.0, 1.0, 1.0));
     Node* fwallNode = new Node(glm::vec3(-30.0, 8.0, -10.0), glm::vec3(0.0f, 90.0f, -90.0f), glm::vec3(13.0f, 1.0f, 20.0f));
    fwallNode->addComponent(new MeshRenderer(floorMesh, *fwall));
    addToScene(fwallNode);

    Material* flor = new Material( new Texture("textures/carpet4.jpg") , glm::vec3(1.0, 1.0, 1.0));
    Node* florNode = new Node(glm::vec3(-10.0, -0.99, -10.0), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(20.0f, 1.0f, 20.0f));
    florNode->addComponent(new MeshRenderer(floorMesh, *flor));
    addToScene(florNode);

    Material* bg1 = new Material( new Texture("textures/n.jpg") , glm::vec3(1.0, 1.0, 1.0));
    Node* bgNode = new Node(glm::vec3(0.0, 8.0, -10.0), glm::vec3(-90.0f, 0.0f, 0.0f), glm::vec3(30.0f, 1.0f, 10.0f));
    bgNode->addComponent(new MeshRenderer(floorMesh, *bg1));
    addToScene(bgNode);

    Node* bgNode2 = new Node(glm::vec3(30.0, 8.0, -10.0), glm::vec3(-90.0f, 0.0f, 0.0f), glm::vec3(30.0f, 1.0f, 10.0f));
    bgNode2->addComponent(new MeshRenderer(floorMesh, *bg1));
    addToScene(bgNode2);

       Node* bgNode3 = new Node(glm::vec3(90.0, 8.0, -10.0), glm::vec3(-90.0f, 0.0f, 0.0f), glm::vec3(30.0f, 1.0f, 10.0f));
    bgNode3->addComponent(new MeshRenderer(floorMesh, *bg1));
    addToScene(bgNode3);

    // finishing interior

    Node* floorNode = new Node(glm::vec3(0.0, -1.0, 0.0), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(50.0f, 1.0f, 10.0f));
    floorNode->addComponent(new MeshRenderer(floorMesh, *floor));
    addToScene(floorNode);

    Material* bg = new Material( new Texture("textures/bg2.jpg") , glm::vec3(1.0, 1.0, 1.0));
    Node* bgNode1 = new Node(glm::vec3(0.0, 2.5, -10.0), glm::vec3(90.0f, 0.0f, 0.0f), glm::vec3(50.0f, 1.0f, 5.0f));
    bgNode1->addComponent(new MeshRenderer(floorMesh, *bg));
    addToScene(bgNode1);

    Mesh* cubeMesh = new Mesh;
    cubeMesh->initCube();
    //Material* building = new Material( new Texture("textures/igloo.jpg") , glm::vec3(1.0, 1.0, 1.0));
    Material* gift = new Material( new Texture("textures/xmas.jpg") , glm::vec3(1.0, 1.0, 1.0));

//    Node* cubeNode1 = new Node(glm::vec3(3.0, 0.0, -5.0), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 1.0f, 1.0f));
//    cubeNode1->addComponent(new MeshRenderer(*cubeMesh, *building));
//    //cubeNode1->addComponent(new PhysicsObjectComponent(&physicsEngineComponent->getPhysicsEngine().getObject(5)));
//    addToScene(cubeNode1);
//
//    Node* cubeNode2 = new Node(glm::vec3(13.0, 0.0, -6.0), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 1.0f, 1.0f));
//    cubeNode2->addComponent(new MeshRenderer(*cubeMesh, *building));
//    addToScene(cubeNode2);

    Material* building = new Material( new Texture("textures/e.jpg") , glm::vec3(1.0, 1.0, 1.0));
    Material* outer = new Material( new Texture("textures/igloo.jpg") , glm::vec3(1.0, 1.0, 1.0));

    Node* cubeNode1 = new Node(glm::vec3(3.0, 0.0, -6.0), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 1.0f, 1.0f));
    cubeNode1->addComponent(new MeshRenderer(*cubeMesh, *building));
    addToScene(cubeNode1);

    Node* cubeNode2 = new Node(glm::vec3(13.0, 0.0, -6.0), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 1.0f, 1.0f));
    cubeNode2->addComponent(new MeshRenderer(*cubeMesh, *outer));
    addToScene(cubeNode2);

    Node* cubeNode3 = new Node(glm::vec3(23.0, 0.0, -5.0), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 1.0f, 1.0f));
    cubeNode3->addComponent(new MeshRenderer(*cubeMesh, *outer));
    addToScene(cubeNode3);

     Node* cubeNode4 = new Node(glm::vec3(-3.0, 0.0, -5.0), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 1.0f, 1.0f));
    cubeNode4->addComponent(new MeshRenderer(*cubeMesh, *building));
    addToScene(cubeNode4);

//    Node* cubeNode3 = new Node(glm::vec3(23.0, 0.0, -6.0), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 1.0f, 1.0f));
//    cubeNode3->addComponent(new MeshRenderer(*cubeMesh, *building));
//    addToScene(cubeNode3);

    Node* xmasNode = new Node(glm::vec3(33.0, 0.0, -6.0), glm::vec3(90.0f, 0.0f, 0.0f), glm::vec3(3.0f, 1.0f, 1.0f));
    xmasNode->addComponent(new MeshRenderer(floorMesh, *gift));
    addToScene(xmasNode);

    IndexedMesh paperPlaneIndexedMesh("models/paperbird.obj");
    Mesh paperPlaneMesh;
    paperPlaneMesh.init(paperPlaneIndexedMesh);

    Material* yellowPaper = new Material( new Texture("textures/paper.jpg") , glm::vec3(0.95, 0.95, 0.25));
    Node* birdNode1 = new Node(glm::vec3(-1.0, 0.5, -5.0), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.5f, 0.5f, 0.5f));
    birdNode1->addComponent(new MeshRenderer(paperPlaneMesh, *yellowPaper));
    birdNode1->addComponent(new PhysicsObjectComponent(&physicsEngineComponent->getPhysicsEngine().getObject(0)));
    birdNode1->addComponent(cameraComponent);
    addToScene(birdNode1);

    Material* orangePaper = new Material( new Texture("textures/paper.jpg") , glm::vec3(0.93, 0.67, 0.09));
    Node* birdNode2 = new Node(glm::vec3(-2.0, 0.5, -5.0), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.5f, 0.5f, 0.5f));
    birdNode2->addComponent(new MeshRenderer(paperPlaneMesh, *orangePaper));
    birdNode2->addComponent(new PhysicsObjectComponent(&physicsEngineComponent->getPhysicsEngine().getObject(1)));
    addToScene(birdNode2);

    Material* redPaper = new Material( new Texture("textures/paper.jpg") , glm::vec3(0.9, 0.28, 0.28));
    Node* birdNode3 = new Node(glm::vec3(-3.0, 0.5, -5.0), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.5f, 0.5f, 0.5f));
    birdNode3->addComponent(new MeshRenderer(paperPlaneMesh, *redPaper));
    birdNode3->addComponent(new PhysicsObjectComponent(&physicsEngineComponent->getPhysicsEngine().getObject(2)));
    addToScene(birdNode3);

    Material* greenPaper = new Material( new Texture("textures/paper.jpg") , glm::vec3(0.43, 0.79, 0.43));
    Node* birdNode4 = new Node(glm::vec3(-4.0, 0.5, -5.0), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.5f, 0.5f, 0.5f));
    birdNode4->addComponent(new MeshRenderer(paperPlaneMesh, *greenPaper));
    birdNode4->addComponent(new PhysicsObjectComponent(&physicsEngineComponent->getPhysicsEngine().getObject(3)));
    addToScene(birdNode4);

    Material* bluePaper = new Material( new Texture("textures/paper.jpg") , glm::vec3(0.27, 0.51, 0.78));
    Node* birdNode5 = new Node(glm::vec3(-5.0, 0.5, -5.0), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.5f, 0.5f, 0.5f));
    birdNode5->addComponent(new MeshRenderer(paperPlaneMesh, *bluePaper));
    birdNode5->addComponent(new PhysicsObjectComponent(&physicsEngineComponent->getPhysicsEngine().getObject(4)));
    addToScene(birdNode5);

//    Material* whitePaper = new Material( new Texture("textures/paper.jpg") , glm::vec3(1.0, 1.0, 1.0));
//    Node* birdNode6 = new Node(glm::vec3(-6.0, 0.5, -5.0), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.5f, 0.5f, 0.5f));
//    birdNode6->addComponent(new MeshRenderer(paperPlaneMesh, *whitePaper));
//    birdNode6->addComponent(new PhysicsObjectComponent(&physicsEngineComponent->getPhysicsEngine().getObject(5)));
//    addToScene(birdNode6);

}
コード例 #22
0
bool WindowsManager::canZoom() const
{
	Window *window = m_mainWindow->getWorkspace()->getActiveWindow();

	return (window ? window->getContentsWidget()->canZoom() : false);
}
コード例 #23
0
 bool match(Window aWin) { return aWin->IsTopLevelWindow(); }
コード例 #24
0
void WindowsManager::open(BookmarksItem *bookmark, OpenHints hints)
{
	if (!bookmark)
	{
		return;
	}

	Window *window = m_mainWindow->getWorkspace()->getActiveWindow();

	if (hints == DefaultOpen && ((window && Utils::isUrlEmpty(window->getUrl())) || SettingsManager::getValue(QLatin1String("Browser/ReuseCurrentTab")).toBool()))
	{
		hints = CurrentTabOpen;
	}

	switch (static_cast<BookmarksModel::BookmarkType>(bookmark->data(BookmarksModel::TypeRole).toInt()))
	{
		case BookmarksModel::UrlBookmark:
			open(QUrl(bookmark->data(BookmarksModel::UrlRole).toUrl()), hints);

			break;
		case BookmarksModel::RootBookmark:
		case BookmarksModel::FolderBookmark:
			{
				const QList<QUrl> urls = bookmark->getUrls();
				bool canOpen = true;

				if (urls.count() > 1 && SettingsManager::getValue(QLatin1String("Choices/WarnOpenBookmarkFolder")).toBool())
				{
					QMessageBox messageBox;
					messageBox.setWindowTitle(tr("Question"));
					messageBox.setText(tr("You are about to open %n bookmark(s).", "", urls.count()));
					messageBox.setInformativeText(tr("Do you want to continue?"));
					messageBox.setIcon(QMessageBox::Question);
					messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
					messageBox.setDefaultButton(QMessageBox::Yes);
					messageBox.setCheckBox(new QCheckBox(tr("Do not show this message again")));

					if (messageBox.exec() == QMessageBox::Cancel)
					{
						canOpen = false;
					}

					SettingsManager::setValue(QLatin1String("Choices/WarnOpenBookmarkFolder"), !messageBox.checkBox()->isChecked());
				}

				if (urls.isEmpty() || !canOpen)
				{
					return;
				}

				open(urls.at(0), hints);

				for (int i = 1; i < urls.count(); ++i)
				{
					open(urls.at(i), ((hints == DefaultOpen || hints.testFlag(CurrentTabOpen)) ? NewTabOpen : hints));
				}
			}

			break;
		default:
			break;
	}
}
コード例 #25
0
ファイル: Desktop.cpp プロジェクト: gattschardo/s25client
/*
 *  Reagiert auf Spielfenstergrößenänderung
 *
 *  @author Divan
 */
void Desktop::Msg_ScreenResize(const ScreenResizeEvent& sr)
{
// Keep the following block the same as in ctrlGroup class:
    // Für skalierte Desktops ist alles einfach, die brauchen im besten Fall gar nichts selbst implementieren
    if (scale_)
    {
        //Zunächst an die Kinder weiterleiten
        for(std::map<unsigned int, Window*>::iterator it = childIdToWnd_.begin(); it != childIdToWnd_.end(); ++it)
            if(it->second)
            {
                Window* ctrl = it->second;
                // unskalierte Position und Größe bekommen
                unsigned realx = ctrl->GetX() * 800 / sr.oldWidth;
                unsigned realy = ctrl->GetY() * 600 / sr.oldHeight;
                unsigned realwidth  = ctrl->GetWidth()  * 800 / sr.oldWidth;
                unsigned realheight = ctrl->GetHeight() * 600 / sr.oldHeight;
                // Rundungsfehler?
                if (realx * sr.oldWidth  / 800 < ctrl->GetX()) ++realx;
                if (realy * sr.oldHeight / 600 < ctrl->GetY()) ++realy;
                if (realwidth  * sr.oldWidth  / 800 < ctrl->GetWidth())  ++realwidth;
                if (realheight * sr.oldHeight / 600 < ctrl->GetHeight()) ++realheight;
                // Und los
                ctrl->Move(realx * sr.newWidth  / 800, realy * sr.newHeight / 600);
                ctrl->Msg_ScreenResize(sr);
                ctrl->Resize(realwidth * sr.newWidth / 800, realheight * sr.newHeight / 600);
            }
    }

    // Individuelle Reaktion ist auch erlaubt
    Resize(sr.newWidth, sr.newHeight);
}
コード例 #26
0
void WindowsManager::handleWindowClose(Window *window)
{
	const int index = (window ? getWindowIndex(window->getIdentifier()) : -1);

	if (index < 0)
	{
		return;
	}

	if (window && !window->isPrivate())
	{
		const WindowHistoryInformation history = window->getContentsWidget()->getHistory();

		if (!Utils::isUrlEmpty(window->getUrl()) || history.entries.count() > 1)
		{
			Window *nextWindow = getWindowByIndex(index + 1);
			Window *previousWindow = ((index > 0) ? getWindowByIndex(index - 1) : NULL);

			ClosedWindow closedWindow;
			closedWindow.window = window->getSession();
			closedWindow.nextWindow = (nextWindow ? nextWindow->getIdentifier() : 0);
			closedWindow.previousWindow = (previousWindow ? previousWindow->getIdentifier() : 0);

			if (window->getType() != QLatin1String("web"))
			{
				removeStoredUrl(closedWindow.window.getUrl());
			}

			m_closedWindows.prepend(closedWindow);

			emit closedWindowsAvailableChanged(true);
		}
	}

	const QString lastTabClosingAction = SettingsManager::getValue(QLatin1String("Interface/LastTabClosingAction")).toString();

	if (m_mainWindow->getTabBar()->count() == 1)
	{
		if (lastTabClosingAction == QLatin1String("closeWindow") || (lastTabClosingAction == QLatin1String("closeWindowIfNotLast") && SessionsManager::getWindows().count() > 1))
		{
			m_mainWindow->triggerAction(ActionsManager::CloseWindowAction);

			return;
		}

		if (lastTabClosingAction == QLatin1String("openTab"))
		{
			window = getWindowByIndex(0);

			if (window)
			{
				window->clear();

				return;
			}
		}
		else
		{
			m_mainWindow->getAction(ActionsManager::CloseTabAction)->setEnabled(false);
			m_mainWindow->setCurrentWindow(NULL);

			emit windowTitleChanged(QString());
		}
	}

	m_mainWindow->getTabBar()->removeTab(index);

	Action *closePrivateTabsAction = m_mainWindow->getAction(ActionsManager::ClosePrivateTabsAction);

	if (closePrivateTabsAction->isEnabled() && getWindowCount(true) == 0)
	{
		closePrivateTabsAction->setEnabled(false);
	}

	emit windowRemoved(window->getIdentifier());

	m_windows.remove(window->getIdentifier());

	if (m_mainWindow->getTabBar()->count() < 1 && lastTabClosingAction == QLatin1String("openTab"))
	{
		open();
	}
}
コード例 #27
0
bool RenderContextOpenGLWin32::Initialize(Window& window, const RenderParameters_t& renderParameters) {
	Logger::GetInstance()->Debug("Initializing OpenGL context");

    size_t colorBits, redBits, greenBits, blueBits, depthBits;
    size_t alphaBits = 0;
    size_t stencilBits = 0;
    switch (renderParameters.displayFormat) {
        case DISPLAY_FORMAT_A1R5G5B5:
            colorBits = 16;
            alphaBits = 1;
            redBits = blueBits = 5;
            greenBits = 6;
            break;

        case DISPLAY_FORMAT_A2R10G10B10:
            colorBits = 24;
            alphaBits = 2;
            redBits = greenBits = blueBits = 10;
            break;

        case DISPLAY_FORMAT_A8R8G8B8:
            colorBits = 24;
            alphaBits = 8;
            redBits = greenBits = blueBits = 8;
            break;

        case DISPLAY_FORMAT_R5G6B5:
            colorBits = 16;
            redBits = blueBits = 5;
            greenBits = 6;
            break;

        case DISPLAY_FORMAT_X1R5G5B5:
            colorBits = 16;
            redBits = greenBits = blueBits = 5;
            break;

        case DISPLAY_FORMAT_X8R8G8B8:
            colorBits = 24;
            redBits = greenBits = blueBits = 8;
            break;
    }

    switch (renderParameters.depthStencilBits) {
        case DEPTH_STENCIL_BITS_D15S1:
            depthBits = 15;
            stencilBits = 1;
            break;

        case DEPTH_STENCIL_BITS_D16:
            depthBits = 16;
            break;

        case DEPTH_STENCIL_BITS_D24S8:
            depthBits = 24;
            stencilBits = 8;
            break;

        case DEPTH_STENCIL_BITS_D24X4S4:
            depthBits = 24;
            stencilBits = 4;
            break;

        case DEPTH_STENCIL_BITS_D24X8:
            depthBits = 24;
            break;

        case DEPTH_STENCIL_BITS_D32:
            depthBits = 32;
            break;
    }

    if (!window.IsWindowed()) {
        // From http://www.falloutsoftware.com/tutorials/gl/gl2.htm
        DEVMODE dmode;
 
        memset(&dmode, 0, sizeof(DEVMODE));
        dmode.dmSize=sizeof(DEVMODE);
        dmode.dmPelsWidth = renderParameters.width;
        dmode.dmPelsHeight = renderParameters.height;
        dmode.dmBitsPerPel = (colorBits == 24) ? 32 : colorBits;
        dmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
 
        // Change resolution, if possible
        if (ChangeDisplaySettings(&dmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) {
            Logger::GetInstance()->Warning("Couldn't set window to fullscreen mode");
        }

        // Make the window flags compatible with fullscreen mode
        SetWindowLongW(window.GetHandle(), GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
        SetWindowLongW(window.GetHandle(), GWL_EXSTYLE, WS_EX_APPWINDOW);
        SetWindowPos(window.GetHandle(), NULL, 0, 0, renderParameters.width, renderParameters.height, SWP_FRAMECHANGED);
        ShowWindow(window.GetHandle(), SW_SHOW);
    }

    deviceContext_ = GetDC(reinterpret_cast<HWND>(window.GetHandle()));
    if (!deviceContext_) {
        Logger::GetInstance()->Error("Couldn't retrieve device context");
        return false;
    }

	PIXELFORMATDESCRIPTOR pixelFormat;
	ZeroMemory(&pixelFormat, sizeof(pixelFormat));
	pixelFormat.nSize = sizeof(pixelFormat);
	pixelFormat.nVersion = 1;
	pixelFormat.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
						  PFD_DOUBLEBUFFER;
	pixelFormat.iPixelType = PFD_TYPE_RGBA;
    pixelFormat.cColorBits = colorBits;
    pixelFormat.cDepthBits = depthBits;
    pixelFormat.cAlphaBits = alphaBits;
    pixelFormat.cRedBits = redBits;
    pixelFormat.cGreenBits = greenBits;
    pixelFormat.cBlueBits = blueBits;
    pixelFormat.cStencilBits = stencilBits;
	pixelFormat.iLayerType = PFD_MAIN_PLANE;

	int format = ChoosePixelFormat(deviceContext_, &pixelFormat);
	if (format == 0) {
		Logger::GetInstance()->Error("Failed to create a suitable pixel format "
									 "for device context");
        return false;
	}

	if (!SetPixelFormat(deviceContext_, format, &pixelFormat)) {
		Logger::GetInstance()->Error("Couldn't set the pixel format");
		return false;
	}
	
	// Create a dummy context, because we are going to create a context using
	// an extension function
	HGLRC dummyRenderContext = wglCreateContext(deviceContext_);
	wglMakeCurrent(deviceContext_, dummyRenderContext);

	int attributes[] = {
		WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
		WGL_CONTEXT_MINOR_VERSION_ARB, 3,
		WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
		0, 0
	};

	PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = reinterpret_cast<PFNWGLCREATECONTEXTATTRIBSARBPROC>(wglGetProcAddress("wglCreateContextAttribsARB"));
	renderContext_ = wglCreateContextAttribsARB(deviceContext_, NULL, attributes);
	if (!renderContext_) {
        wglDeleteContext(dummyRenderContext);
		Logger::GetInstance()->Error("Couldn't create render context");
		return false;
	}

    if (!wglDeleteContext(dummyRenderContext)) {
        Logger::GetInstance()->Error("Couldn't delete dummy context");
        return false;
    }

	if (!wglMakeCurrent(deviceContext_, renderContext_)) {
		Logger::GetInstance()->Error("Couldn't set the new rendering context");
		return false;
	}
	
	if (GLEW_OK != glewInit()) {
		Logger::GetInstance()->Error("Couldn't initialize GLEW library");
		return false;
	}

	Logger::GetInstance()->Debug("Render context created");
	return true;
}
コード例 #28
0
Action* WindowsManager::getAction(int identifier)
{
	Window *window = m_mainWindow->getWorkspace()->getActiveWindow();

	return (window ? window->getContentsWidget()->getAction(identifier) : NULL);
}
コード例 #29
0
ファイル: point2D.cpp プロジェクト: heinrich-foto/fensterchen
void Point2D::draw(Window & win) const
{
    win.drawPoint(x_, y_, color_.r_, color_.g_, color_.b_);
}
コード例 #30
0
ファイル: channel.cpp プロジェクト: whimlex/Equalizer
ServerPtr Channel::getServer()
{
    Window* window = getWindow();
    LBASSERT( window );
    return ( window ? window->getServer() : 0 );
}