Example #1
0
File: widget.cpp Project: RSATom/Qt
void Widget::start()
{
    QSurfaceFormat fmt;

    int idx = m_version->currentIndex();
    if (idx < 0)
        return;
    fmt.setVersion(versions[idx].major, versions[idx].minor);

    for (size_t i = 0; i < sizeof(profiles) / sizeof(Profile); ++i)
        if (static_cast<QRadioButton *>(m_profiles->itemAt(int(i))->widget())->isChecked()) {
            fmt.setProfile(profiles[i].profile);
            break;
        }

    bool forceGLSL110 = false;
    for (size_t i = 0; i < sizeof(options) / sizeof(Option); ++i)
        if (static_cast<QCheckBox *>(m_options->itemAt(int(i))->widget())->isChecked()) {
            if (options[i].option)
                fmt.setOption(options[i].option);
            else if (i == 3)
                forceGLSL110 = true;
        }

    for (size_t i = 0; i < sizeof(renderables) / sizeof(Renderable); ++i)
        if (static_cast<QRadioButton *>(m_renderables->itemAt(int(i))->widget())->isChecked()) {
            fmt.setRenderableType(renderables[i].renderable);
            break;
        }

    // The example rendering will need a depth buffer.
    fmt.setDepthBufferSize(16);

    m_output->clear();
    m_extensions->clear();
    qDebug() << "Requesting surface format" << fmt;

    m_renderWindowLayout->removeWidget(m_renderWindowContainer);
    delete m_renderWindowContainer;

    RenderWindow *renderWindow = new RenderWindow(fmt);
    if (!renderWindow->context()) {
        m_output->append(tr("Failed to create context"));
        delete renderWindow;
        m_renderWindowContainer = new QWidget;
        addRenderWindow();
        return;
    }
    m_surface = renderWindow;

    renderWindow->setForceGLSL110(forceGLSL110);
    connect(renderWindow, &RenderWindow::ready, this, &Widget::renderWindowReady);
    connect(renderWindow, &RenderWindow::error, this, &Widget::renderWindowError);

    m_renderWindowContainer = QWidget::createWindowContainer(renderWindow);
    addRenderWindow();
}
Example #2
0
void OtherObjects::drawBonusObjects(RenderWindow &window)
{
	if (starSprite.getPosition().x < VideoMode::getDesktopMode().width + 300){
		window.draw(starSprite);
	}

	window.draw(fuelIconSprite[1]);
	if (!hardcore) window.draw(healthIconSprite[1]);
}
Example #3
0
//a little bit ugly
string fetchNameFromUser()
{	
	string resultString= "You have ended the game with score:" + std::to_string(score);
	
	Text alphabet [26];

	Text resultText;
	setText(resultText, font, Color::White, 35, resultString, { 200,220 });

	Text enterNameText;
	setText(enterNameText, font, Color::White, 30, "Please Enter Your Name", { 340,300 });

	Text gameOverText;
	setText(gameOverText, font, Color::Red, 40, "GAME OVER", { 370,150 });

	pair <unsigned char, unsigned char> myPair = { 0,0 };
	char chosenLetter = 'A';
	string userName = "******";

	Text providedNameText;

	RectangleShape marker;
	while (window.waitEvent(myEvent))
	{
		window.clear(Color::Black);
		setText(providedNameText, font, Color::White, 30, userName, { 460,360 });
		drawTextes(gameOverText, enterNameText, providedNameText, scoreText,resultText);

		int j = 1;
		int k = 0;

		for (unsigned char i = 0; i<26; ++i)
		{	
			if (0 == i % 13) 
			{
					++j; k=0;
			}
			++k;
			char letter[2] = "A";
			letter[0] = letter[0] + i;
	
			setText(alphabet[i], font, Color::White, 20 , letter , {350.0f+20*k,380.0f+20*j});
			window.draw(alphabet[i]);
		}

		setMarker(marker, alphabet[chosenLetter - 65].getPosition());
		window.draw(marker);
	
		static int i = 0;
		gameOverInput(myEvent, userName, chosenLetter, myPair, i);

		window.display();

		if (3 == i)
			return userName;
	}
}
Example #4
0
  void go(void)
  {
    // OGRE의 메인 루트 오브젝트 생성
#if !defined(_DEBUG)
    mRoot = new Root("plugins.cfg", "ogre.cfg", "ogre.log");
#else
    mRoot = new Root("plugins_d.cfg", "ogre.cfg", "ogre.log");
#endif


    // 초기 시작의 컨피규레이션 설정 - ogre.cfg 이용
    if (!mRoot->restoreConfig()) {
      if (!mRoot->showConfigDialog()) return;
    }
    mWindow = mRoot->initialise(true, "Hello Professor : Copyleft Dae-Hyun Lee");

    // ESC key를 눌렀을 경우, 오우거 메인 렌더링 루프의 탈출을 처리
	size_t windowHnd = 0;
	std::ostringstream windowHndStr;
	OIS::ParamList pl;
	mWindow->getCustomAttribute("WINDOW", &windowHnd);
	windowHndStr << windowHnd;
	pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
	mInputManager = OIS::InputManager::createInputSystem(pl);
	mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, false));

	mESCListener = new ESCListener(mKeyboard);
    mRoot->addFrameListener(mESCListener);

	mSceneMgr = mRoot->createSceneManager(ST_GENERIC);

    mCamera = mSceneMgr->createCamera("camera");
    mCamera->setPosition(0.0f, 200.0f, 300.0f);
    mCamera->lookAt(0.0f, 100.0f, 0.00f);
    mCamera->setNearClipDistance(5.0f);

    mViewport = mWindow->addViewport(mCamera);
    mViewport->setBackgroundColour(ColourValue(0.0f,0.0f,0.5f));
    mCamera->setAspectRatio(Real(mViewport->getActualWidth()) / Real(mViewport->getActualHeight()));

    ResourceGroupManager::getSingleton().addResourceLocation("resource.zip", "Zip");
    ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

    mSceneMgr->setAmbientLight(ColourValue(1.0f, 1.0f, 1.0f));

    Entity* daehyunEntity = mSceneMgr->createEntity("Daehyun", "DustinBody.mesh");

    SceneNode* daehyunNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    daehyunNode->attachObject(daehyunEntity);

    mRoot->startRendering();

    mInputManager->destroyInputObject(mKeyboard);
    OIS::InputManager::destroyInputSystem(mInputManager);

    delete mRoot;
  }
Example #5
0
void OtherObjects::drawBorders(RenderWindow &window)
{
	for (int i=0; i<2; i++){
		window.draw(debrisSprite[i]);
	}
	for (int i=2; i<4; i++){
		window.draw(debrisSprite[i]);
	}
}
bool BreakoutAboutState::FrameRender(RenderWindow& window, float frametime)
{
    text.setString("About Breakout");
    text.setCharacterSize(20);
    text.setPosition(window.getSize().x / 2 - text.getGlobalBounds().width / 2, 120);
    window.draw(text);

    return false;
}
Example #7
0
void Draw(RenderWindow& window, RectangleStruct rect[QUANTITY])
{
	for (int i = 0; i < QUANTITY; i++)
	{
		window.draw(rect[i].square);
	}
	window.display();
	window.clear(sf::Color::White);
}
Example #8
0
static VALUE RenderWindow_set_backgroundColor(VALUE vSelf, VALUE vColor) {
	// Get C++ object pointer from vSelf
	RenderWindow *pSelf;
	Data_Get_Struct(vSelf, RenderWindow, pSelf);
	Color *pColor;
	Data_Get_Struct(vColor, Color, pColor);
	pSelf->SetBackgroundColor(*pColor);
	return Qnil;
}
Example #9
0
static VALUE RenderWindow_set_view(VALUE vSelf, VALUE vView) {
	// Get C++ object pointer from vSelf
	RenderWindow *pSelf;
	Data_Get_Struct(vSelf, RenderWindow, pSelf);
	View *pView;
	Data_Get_Struct(vView, View, pView);
	pSelf->SetView(pView);
	return Qnil;
}
Example #10
0
void Player::drawFlames(RenderWindow &window, bool paused)
{
	if(getPlayerFuel() > 0){
		window.draw(flameSpriteTop);

		if (Keyboard::isKeyPressed(Keyboard::Space) || paused || controlScheme == 2 || controlScheme == 3){
			window.draw(flameSpriteBottom);
		}
	}
}
Example #11
0
///Камера///
Kamera::Kamera(Hero &hero, lv::Level &level, RenderWindow &window)
{
	this->hero = &hero;
	this->level = &level;
	this->window = &window;
	view.reset(FloatRect(0.0, 0.0, window.getSize().x, window.getSize().y)); // камера по размеру окна
	MapRect.height = level.GetMapSize().y*level.GetTileSize().y; MapRect.width = level.GetMapSize().x*level.GetTileSize().x; // данные о размере карты 
	L_W_H_Size.x = level.GetMapSize().x*level.GetTileSize().x;
	L_W_H_Size.y = level.GetMapSize().y*level.GetTileSize().y;
}
startMenu::startMenu(RenderWindow &window, Event &event) : 
	_start("Старт", Vector2f(window.getView().getSize().x / 2.5f, window.getView().getSize().y / 2.5f), 50),
	_options("Настройки", Vector2f(_start.getGlobalBounds().left, _start.getGlobalBounds().top + _start.getGlobalBounds().height), 50),
	_autors("Авторы", Vector2f(_start.getGlobalBounds().left, _options.getGlobalBounds().top + _options.getGlobalBounds().height), 50),
	_quit("Выход", Vector2f(_start.getGlobalBounds().left, _autors.getGlobalBounds().top + _autors.getGlobalBounds().height), 50),
	_window(window), _event(event)
{
	
	_ButtFocus = start;
}
Example #13
0
void OtherObjects::drawMeters(RenderWindow &window)
{
	if (!hardcore){
		window.draw(healthMeter);
		window.draw(healthIconSprite[0]);
	}
	
	window.draw(fuelMeter);
	window.draw(fuelIconSprite[0]);
}
Example #14
0
void Player::drawPlayer(RenderWindow &window)
{
	window.draw(playerSprite);

	if (drawCollisionShapes){
		window.draw(collisionCircle[0]);
		window.draw(collisionCircle[1]);
		window.draw(collisionCircle[2]);
	}
}
Example #15
0
static VALUE RenderWindow_getEvent(VALUE vSelf) {
	// Get C++ object pointer from vSelf
	RenderWindow *pSelf;
	Data_Get_Struct(vSelf, RenderWindow, pSelf);
	Event ePoll;
	if(!pSelf->GetEvent(ePoll))
		return Qnil;
	DECLARE_OBJ_VAR(Event, Event, ePoll);
	return vEvent;
}
Example #16
0
void loadingScreen(RenderWindow& window) {
	Text loadingMessage;
	loadingMessage.setFont(infoFont);
	loadingMessage.setColor(Color::Green);
	loadingMessage.setString("Loading...");
	loadingMessage.setPosition(Vector2f(660, 750));
	window.clear(Color::Black);
	window.draw(loadingMessage);
	window.display();
}
Example #17
0
void DrawBackground(RenderWindow & window, Sprite & wallBackgroundSprite, Sprite & floorBackgroundSprite)
{
	//background
	wallBackgroundSprite.setOrigin(wallBackgroundSprite.getGlobalBounds().width / 2, wallBackgroundSprite.getGlobalBounds().height / 2);
	wallBackgroundSprite.setPosition(view.getCenter().x, view.getCenter().y);
	floorBackgroundSprite.setOrigin(floorBackgroundSprite.getGlobalBounds().width / 2, floorBackgroundSprite.getGlobalBounds().height / 2);
	floorBackgroundSprite.setPosition(view.getCenter().x, view.getCenter().y);
	window.draw(wallBackgroundSprite);
	window.draw(floorBackgroundSprite);
}
Example #18
0
void Turt::window::
animate_window(RenderWindow& window, Graphics& graphics){

	window.clear(sf::Color::Black);

	draw_drawables(window, graphics);
	
	window.display();

}
Example #19
0
void ProcessEvents(RenderWindow & window)
{
	Event event;
	while (window.pollEvent(event))
	{
		if (event.type == Event::Closed)
		{
			window.close();
		}
	}
};
Example #20
0
File: main.cpp Project: dlxgit/TP
void CheckWindowClose(RenderWindow & window)
{
	Event event;
	while (window.pollEvent(event))
	{
		if (event.type == Event::Closed)
		{
			window.close();
		}
	}
}
Example #21
0
static VALUE RenderWindow_draw(VALUE vSelf, VALUE vObject) {
	if(!ISKO(vObject, g_cDrawable))
		rb_raise(rb_eTypeError, "wrong argument type(s)");
	// Get C++ object pointer from vSelf
	RenderWindow *pSelf;
	Data_Get_Struct(vSelf, RenderWindow, pSelf);
	Drawable *pObject;
	Data_Get_Struct(vObject, Drawable, pObject);
	pSelf->Draw(*pObject);
	return Qnil;
}
Example #22
0
void DrawBossBar(RenderWindow & window, Boss & boss, const Vector2f & viewPos)
{
	if (boss.health > 0)
	{
		boss.indicator.setTextureRect(IntRect(0, 0, 246 * int(float(boss.health) / float(BOSS_MAX_HEALTH)), 8));
	}
	boss.bar.setPosition(BOSS_BAR_POSITION.x + viewPos.x - WINDOW_SIZE.x / 2.f, BOSS_BAR_POSITION.y + viewPos.y - WINDOW_SIZE.y / 2.f);
	boss.indicator.setPosition(BOSS_INDICATOR_POSITION.x + viewPos.x - WINDOW_SIZE.x / 2.f, BOSS_INDICATOR_POSITION.y + viewPos.y - WINDOW_SIZE.y / 2.f);
	window.draw(boss.bar);
	window.draw(boss.indicator);
}
Example #23
0
void Game::menu()
{
	Text title("Mechanized Techno Explorer",font,80);
	title.setStyle(Text::Bold);

	title.setPosition(1280/2-title.getGlobalBounds().width/2,20);

	const int ile = 2;

	Text tekst[ile];

	string str[] = {"Play","Exit"};
	for(int i=0;i<ile;i++)
	{
		tekst[i].setFont(font);
		tekst[i].setCharacterSize(65);

		tekst[i].setString(str[i]);
		tekst[i].setPosition(1280/2-tekst[i].getGlobalBounds().width/2,250+i*120);
	}

	while(state == MENU)
	{
		Vector2f mouse(Mouse::getPosition());
		Event event;

		while(window.pollEvent(event))
		{
			//Wciœniêcie ESC lub przycisk X
			if(event.type == Event::Closed || event.type == Event::KeyPressed &&
				event.key.code == Keyboard::Escape)
				state = END;
			
			//klikniêcie EXIT
			else if(tekst[1].getGlobalBounds().contains(mouse) &&
				event.type == Event::MouseButtonReleased && event.key.code == Mouse::Left)
			{
				state = END;
			}
		}
		for(int i=0;i<ile;i++)
			if(tekst[i].getGlobalBounds().contains(mouse))
				tekst[i].setColor(Color::Cyan);
			else tekst[i].setColor(Color::White);
		
		window.clear();
		
		window.draw(title);
		for(int i=0;i<ile;i++)
			window.draw(tekst[i]);

		window.display();
	}
}
Example #24
0
 void HUD::Draw(RenderWindow& window){
    
    window.Draw(*menuHUD);
    window.Draw(*nivel);
    barravida->Draw(window, 0.f);
    soundButton->Draw(window);
    musicButton->Draw(window);
    window.Draw(*clock);
    window.Draw(*coins);
    
}
Example #25
0
void Player::drawCrashDebris(RenderWindow &window)
{
	if (showParticles){
		for (int i = 0; i < crashDebris.size(); i++){
			window.draw(crashDebris[i]);
		}
		for (int i = 0; i < crashDebris2.size(); i++){
			window.draw(crashDebris2[i]);
		}
	}
}
Example #26
0
void Player::drawDamageParticles(RenderWindow &window)
{
	if (showParticles){
		for (int i = 0; i < damageParticle.size(); i++){
			window.draw(damageParticle[i]);
		}
		for (int i = 0; i < damageParticle2.size(); i++){
			window.draw(damageParticle2[i]);
		}
	}
}
Example #27
0
void demography  :: draw(RenderWindow&window)
{
    //for(auto&a:bars)a.draw(window);
    update();
//    pts.update(pos_sf);
//    for(auto&a:sensors)window.draw(a);
    //window.draw(vbunk);
    for(auto&a:cells)window.draw(a.second);
    for(auto&a:walls)window.draw(a);
    
}
Example #28
0
	RenderWindow* WindowFactory::CreateGLWindow(const AnyString& title, uint width,
		uint height, uint bits, bool fullScreen)
	{
		RenderWindow* wnd = new GLXWindow(title, width, height, bits, fullScreen);
		if (!wnd->initialize())
		{
			wnd->kill();
			delete wnd;
			return NULL;
		}
		return wnd;
	}
Example #29
0
void processEvents(RenderWindow & window, Racket & racket, Racket & racket2, GameState & gameState)
{
	Event event;
	while (window.pollEvent(event))
	{
		// Проверяем нажатую кнопку
		if (Keyboard::isKeyPressed(Keyboard::W))
		{
			racket.direction = W;
		}
		else if (Keyboard::isKeyPressed(Keyboard::S))
		{
			racket.direction = S;
		}
		else
		{
			racket.direction = NONE;
		}

		if (Keyboard::isKeyPressed(Keyboard::Up))
		{
			racket2.direction = UP;
		}
		else if (Keyboard::isKeyPressed(Keyboard::Down))
		{
			racket2.direction = DOWN;
		}
		else
		{
			racket2.direction = NONE;
		}
		if (event.type == Event::KeyPressed && event.key.code == Keyboard::Return) // Возвращение в главное меню
		{
			gameState.isPlay = false;
		}
		if (event.type == Event::KeyPressed && event.key.code == Keyboard::P) // Поставить на паузу или снять с паузы игру
		{
			if (!gameState.isPayse)
			{
				gameState.isPayse = true;
			}
			else
			{
				gameState.isPayse = false;
			}
		}
		// Окно закрыли
		if ((event.type == Event::Closed) || (event.type == Event::KeyPressed && event.key.code == Keyboard::Escape))
		{
			window.close();
		}
	}
}
Example #30
0
void		RoomPanel::newPlayer(std::string &newUsername)
{
  RenderWindow *window = RenderWindow::getInstance();
  unsigned int i = static_cast<RoomPanel*>(window->getPanels().top())->getNbPlayers();

  static_cast<RoomPanel*>(window->getPanels().top())->getLabels().at(i + 2).setString(newUsername);
  static_cast<RoomPanel*>(window->getPanels().top())->getLabels().at(i + 2).setOrigin(static_cast<RoomPanel*>(window->getPanels().top())->getLabels().at(i + 2).getText().getGlobalBounds().width / 2, static_cast<RoomPanel*>(window->getPanels().top())->getLabels().at(i + 2).getText().getGlobalBounds().height / 2);

  static_cast<RoomPanel*>(window->getPanels().top())->getBackgrounds().at(i + 1).setTexture(*(static_cast<RoomPanel*>(window->getPanels().top())->getTextures()).at(i + 1));

  static_cast<RoomPanel*>(window->getPanels().top())->addNbPlayers();
}