Beispiel #1
0
void RasterNode::blt(const glm::mat4& transform, const glm::vec2& destSize)
{
    GLContext* pContext = GLContext::getCurrent();
    FRect destRect;
    
    StandardShaderPtr pShader = pContext->getStandardShader();
    float opacity = getEffectiveOpacity();
    pContext->setBlendColor(glm::vec4(1.0f, 1.0f, 1.0f, opacity));
    pShader->setAlpha(opacity);
    if (m_pFXNode) {
        pContext->setBlendMode(m_BlendMode, true);
        m_pFXNode->getTex()->activate(GL_TEXTURE0);
        pShader->setColorModel(0);
        pShader->disableColorspaceMatrix();
        pShader->setGamma(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
        pShader->setPremultipliedAlpha(true);
        pShader->setMask(false);

        FRect relDestRect = m_pFXNode->getRelDestRect();
        destRect = FRect(relDestRect.tl.x*destSize.x, relDestRect.tl.y*destSize.y,
                relDestRect.br.x*destSize.x, relDestRect.br.y*destSize.y);
    } else {
        m_pSurface->activate(getMediaSize());
        pContext->setBlendMode(m_BlendMode, m_pSurface->isPremultipliedAlpha());
        destRect = FRect(glm::vec2(0,0), destSize);
    }
    glm::vec3 pos(destRect.tl.x, destRect.tl.y, 0);
    glm::vec3 scaleVec(destRect.size().x, destRect.size().y, 1);
    glm::mat4 localTransform = glm::translate(transform, pos);
    localTransform = glm::scale(localTransform, scaleVec);
    pShader->setTransform(localTransform);
    pShader->activate();
    m_pSubVA->draw();
}
EmissionSource::EmissionSource(FRect rect) : pos(rect.center()), param(rect.size() * 0.5f), type(Type::rect) {}
Beispiel #3
0
	MultiPlayerMenu::MultiPlayerMenu(const FRect &rect, int2 window_size)
		:HudLayer(rect, HudLayer::slide_top), m_please_refresh(true), m_window_size(window_size) {
		enum { spacing = layer_spacing };

		setTitle("Connecting to server:");
		m_visible_time = 0.0f;

		m_waiting_for_refresh = false;
		m_waiting_to_connect = false;

		m_last_refresh_time = -1.0;
		m_last_connect_time = -1.0;

		FRect button_rect(s_button_size);
		button_rect += float2(rect.width() - spacing, rect.height() - spacing) - button_rect.size();

		PHudButton button_close = make_shared<HudClickButton>(button_rect);
		button_close->setIcon(HudIcon::close);

		button_rect -= float2(s_button_size.x + spacing * 2, 0.0f);
		PHudButton button_down = make_shared<HudClickButton>(button_rect);
		button_down->setIcon(HudIcon::down_arrow);
		button_down->setAccelerator(InputKey::pagedown);

		button_rect -= float2(s_button_size.x + spacing * 2, 0.0f);
		PHudButton button_up = make_shared<HudClickButton>(button_rect);
		button_up->setIcon(HudIcon::up_arrow);
		button_up->setAccelerator(InputKey::pageup);

		button_rect -= float2(s_button_size.x + spacing * 2, 0.0f);
		button_rect = button_rect.enlarge({50, 0}, {});
		PHudButton button_refresh = make_shared<HudClickButton>(button_rect);
		button_refresh->setLabel("refresh");
		
		button_rect -= float2(button_rect.width() + spacing * 2, 0.0f);
		button_rect = button_rect.enlarge({20, 0}, {});
		PHudButton button_connect = make_shared<HudClickButton>(button_rect);
		button_connect->setLabel("connect");
		button_connect->setAccelerator(InputKey::enter);

		button_rect = FRect(float2(185, s_button_size.y));
		button_rect += float2(rect.width() - button_rect.width() - spacing, spacing + topOffset());
		m_password = make_shared<HudEditBox>(button_rect, net::limits::max_password_size);
		m_password->setLabel("Pass: "******"Nick: ");
		m_nick_name->setText("random_dude");

		FRect sub_rect(rect.size());
		sub_rect = sub_rect.inset(float2(spacing, spacing * 2 + topOffset() + s_button_size.y),
						 		  float2(spacing, spacing * 2 + s_button_size.y));
		m_grid = make_shared<HudGrid>(sub_rect);
		
		m_grid->addColumn("Server name",	150.0f);
		m_grid->addColumn("Map name",	150.0f);
		m_grid->addColumn("Num players",	80.0f);
		m_grid->addColumn("Game mode",	80.0f);
		m_grid->addColumn("Ping",		50.0f);
		attach(m_grid);

		m_buttons.push_back(button_close);
		m_buttons.push_back(button_up);
		m_buttons.push_back(button_down);
		m_buttons.push_back(button_refresh);
		m_buttons.push_back(button_connect);
		m_buttons.push_back(m_password);
		m_buttons.push_back(m_nick_name);

		for(auto &button : m_buttons) {
			button->setButtonStyle(HudButtonStyle::small);
			attach(button);
		}

		m_client.reset(new net::Client());
	}