Esempio n. 1
0
Rect Button::setupText(const Rect &rect, const TextLabelInfo &ti)
{
    std::ostringstream texId(std::ostringstream::out);
    texId << this;
    m_buttonText = new TextLabel(rect.pos(), ti, texId.str());
    Rect realRect = rect;
    if( rect.size().x() < m_buttonText->size().x() )
    {
	realRect.setSize( Point( m_buttonText->size().x(), realRect.size().y() ) );
    }
    if( rect.size().y() < m_buttonText->size().y() )
    {
	realRect.setSize( Point( realRect.size().x(), m_buttonText->size().y() ) );
    }
    m_buttonText->setPos( rect.pos() + (realRect.size() - m_buttonText->size()) / 2 );
    return realRect;
}
Esempio n. 2
0
void ShaderLibrary::generateFilters()
{
   GLuint texId(s_normalBuffer->texture()); 
   QSize  size(s_normalBuffer->size()); 

   Texture texture;
   texture.id   = texId;
   texture.size = size;
   texture.slot = NormalBuffer;
   texture.data = 0;
 
   setTextureVariable("Filters", "NormalMap", texture);

   s_filterBuffer->bind();
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

   bindShader("Filters");



 
   texture.id   = s_normalBuffer->texture(); 
   texture.size = size;
   texture.slot = (Texture_t)0;
   texture.data = 0;
   setTextureVariable("Filters", "NormalMap", texture);

   texture.id   = s_rotationTextureId;
   texture.size = QSize(s_rotationTextureSize, s_rotationTextureSize);
   texture.slot = (Texture_t)1;
   texture.data = s_rotationTextureData;
   setTextureVariable("Filters", "RotationTexture", texture);














   //bindTextures("Filters");
/*
   glActiveTexture(GL_TEXTURE0);  
   glBindTexture(GL_TEXTURE_2D, texId);

   glActiveTexture(GL_TEXTURE2);  
   glBindTexture(GL_TEXTURE_2D, s_rotationTextureId);
*/


   float w(size.width());  float h(size.height());  float z(0.0);
  
   glMatrixMode(GL_PROJECTION);
   glPushMatrix();
   glLoadIdentity();
   glOrtho(z, w, z, h, -1, 1);
   glMatrixMode(GL_MODELVIEW);
   glPushMatrix();
   glLoadIdentity();

   glBegin(GL_QUADS);
      glTexCoord2f(1.0f,0.0f);  glVertex3f(w, z, z);
      glTexCoord2f(0.0f,0.0f);  glVertex3f(z, z, z);
      glTexCoord2f(0.0f,1.0f);  glVertex3f(z, h, z);
      glTexCoord2f(1.0f,1.0f);  glVertex3f(w, h, z);
   glEnd();

   glMatrixMode(GL_PROJECTION);
   glPopMatrix();
   glMatrixMode(GL_MODELVIEW);
   glPopMatrix();

   s_filterBuffer->release();
   releaseTextures();
}