Exemple #1
0
	/* Private Member Functions */
	void Slider::updateValue(const FingerEventArgs &e)
	{
		float fingerX			= e.getPosition().getX();
		float targetRegionX		= getSizef(position.getX() + BORDER);
		float targetRegionWidth	= getSizef(dimensions.getX() - (BORDER * 2));
		float tx				= (fingerX - targetRegionX) / targetRegionWidth;

		// clamp
		if(tx < 0.0f)
		{
			tx = 0.0f;
		}
		else if(tx > 1.0f)
		{
			tx = 1.0f;
		}

		bool changed = (value != tx);
		value = tx;

		if(changed && valueChanged != NULL)
		{
			valueChanged(value);
		}
	}
	void CheckBox::render(void)
	{
		if(isChecked)
		{
            float px    = getSizef(position.getX());
            float py    = getSizef(position.getY());
            float w     = getSizef(dimensions.getX());
            float h     = getSizef(dimensions.getY());
            float b     = getSizef(BORDER);
            
            glMatrixMode(GL_MODELVIEW);
            glPushMatrix();
            glTranslatef(px + b, py + b, 0.0f);
            glScalef(w, h, 1.0f);

            glEnable(GL_BLEND);
            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

            VALUE_COLOUR.use();
            GLPrimitives::getInstance()->renderSquare();

            glDisable(GL_BLEND);
            glPopMatrix();
		}

		Button::render();
	}
Exemple #3
0
    void Texture::crt()
    {
        if (!m_pRenderTargetView) return; // Not a render target
        if (!m_pRenderTargetViewFX)
        {
            createRenderTargetViews(m_pTextureFX, m_pTextureViewFX, m_pRenderTargetViewFX);
        }

        ID3D11RenderTargetView* pPrevRT = nullptr;
        const FLOAT clearColor[] = {0, 0, 0, 0};

        ORenderer->getDeviceContext()->OMGetRenderTargets(1, &pPrevRT, nullptr);
        UINT prevViewportCount = 1;
        D3D11_VIEWPORT pPrevViewports[8];
        ORenderer->getDeviceContext()->RSGetViewports(&prevViewportCount, pPrevViewports);

        D3D11_VIEWPORT viewport = {0, 0, (FLOAT)m_size.x, (FLOAT)m_size.y, 0, 1};
        ORenderer->getDeviceContext()->RSSetViewports(1, &viewport);

        ORenderer->getDeviceContext()->OMSetRenderTargets(1, &m_pRenderTargetViewFX, nullptr);
        ORenderer->getDeviceContext()->ClearRenderTargetView(m_pRenderTargetViewFX, clearColor);
        ORenderer->getDeviceContext()->PSSetShaderResources(0, 1, &m_pTextureView);
        ORenderer->setCRT(getSizef());
        ORenderer->drawCRT();

        std::swap(m_pTexture, m_pTextureFX);
        std::swap(m_pTextureView, m_pTextureViewFX);
        std::swap(m_pRenderTargetView, m_pRenderTargetViewFX);

        ORenderer->getDeviceContext()->OMSetRenderTargets(1, &pPrevRT, nullptr);
        ORenderer->getDeviceContext()->RSSetViewports(prevViewportCount, pPrevViewports);

        ORenderer->resetState();
    }
    void RubBrowserControls::render(void) const
    {
        float x = getSizef(position.getX());
		float y	= getSizef(position.getY());
        
		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();
		glTranslatef(x, y, 0.0f);
		glScalef(bx, by, 1.0f);
        glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
        
        GLPrimitives::getInstance()->renderSquare();
        
        glPopMatrix();
        
        BrowserControls::render();
    }
 /* Public */
 RubBrowserControls::RubBrowserControls(const Point2i &position, const Point2i &dimensions) :
     BrowserControls(position, dimensions)
 {
     int px = position.getX();
     int py = position.getY();
     int dx = dimensions.getX() - CONTROL_BAR_HEIGHT;
     int dy = dimensions.getY();
     
     bx = getSizef(dx);
     by = getSizef(dy);
     
     px += dx;
     dy = CONTROL_BAR_HEIGHT;
     
     exit = new ExitButton(Point2i(px, py), Point2i(dy, dy));
     exit->setClickedCallback(MakeDelegate(this, &RubBrowserControls::exit_Clicked));
     registerEventHandler(exit);
 }
Exemple #6
0
	void Slider::render(void)
	{
		LabelledUIElement::render();

		float px			= getSizef(position.getX());
		float py			= getSizef(position.getY() + getLabelHeight());
		float border		= getSizef(BORDER);
		float labelHeight	= getSizef(getLabelHeight());
		float width			= getSizef(dimensions.getX());

		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();
		glTranslatef(px + border, py + border, 0.0f);
		glScalef(width - border, labelHeight - border, 1.0f);
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

		// selected region
		if(selected)
		{
			LIGHT_COLOUR.use();
		}
		else
		{
			DARK_COLOUR.use();
		}
        
        GLPrimitives::getInstance()->renderSquare();
         
		glPopMatrix();

		border		= getSizef(BORDER);
		labelHeight	= getSizef(getLabelHeight());
		width		= getSizef(dimensions.getX());

		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();
		glTranslatef(px + border, py + border, 0.0f);
		glScalef((width - border) * value, labelHeight - border, 1.0f);

        VALUE_COLOUR.use();
        GLPrimitives::getInstance()->renderSquare();
        
        glDisable(GL_BLEND);
		glPopMatrix();
	}
    void Camera::render(void) const
    {
        float x = getSizef(position.getX());
		float y	= getSizef(position.getY());
        float r = (float)frameDimensions.getX() / (float)frameDimensions.getY();
        float fh = getSizef(dimensions.getY() - UIElement::CONTROL_BAR_HEIGHT);
        float fw = fh / r;

        if(fw < 1.0f)
        {
            fw = 1.0f;
            fh = r;
        }

		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();
		glTranslatef(x, y, 0.0f);
		glScalef(fw, fh, 1.0f);
        
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, cameraTexture);
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
        
        glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
        vbo->render();
        
        glDisable(GL_TEXTURE_2D);
        glPopMatrix();
        
        controls->render();
        mode->render();
    }