Пример #1
0
void		MyText::draw() {
  int i = 0;
  int a = 0;
  switchToOrtho();
  glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  texture_.bind();
  while (text_.c_str()[a] != '\0')
    {
      while(list_.c_str()[i] != text_.c_str()[a] && list_.c_str()[i] != '\0')
      i++;
      glBegin(GL_QUADS);
      glTexCoord2f(0, .02565 * i); glVertex2d((20 * height_ * a) + position_.x, 0 + position_.z);
      glTexCoord2f(0, .02565 * (i+1)); glVertex2d((20 * height_ * a) + position_.x, (20 * height_) + position_.z);
      glTexCoord2f(1, .02565 * (i+1)); glVertex2d((20 * height_ *(a+1)) + position_.x, (20 * height_) + position_.z);
      glTexCoord2f(1, .02565 * i); glVertex2d((20 * height_ * (a+1)) + position_.x, 0 + position_.z);
      glEnd();
      i = 0;
      a++;
}
  glDisable(GL_BLEND);
  switchBackToPerspective();
}
void visualize()
{

  glPushMatrix();
  {
    glPushAttrib(GL_ALL_ATTRIB_BITS);
    {
      switchToOrtho();

      // clear the framebuffer
      glClearColor(0.7, 0.6, 0.3, 1.0);
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


      glDisable(GL_COLOR_MATERIAL);
      glDisable(GL_DEPTH_TEST);
      glDisable(GL_LIGHTING);
      glEnable(GL_LINE_SMOOTH);

      // color
      glColor3d(1,1,1);


      g_viewUniforms->set_sampler2D("color_map", g_backgroundTexture);
      g_viewUniforms->set_sampler2D("data_map", g_doubleBufferIds[(int)(!g_currentBuffer)]);
      g_viewUniforms->set_float("f_bufferWidth", g_bufferWidth);
      g_viewUniforms->set_float("f_bufferHeight", g_bufferHeight);

      g_viewShader->set();
      g_viewUniforms->applyToShader(g_viewShader->getShaderHandle());
      {
        glPushMatrix();
          glScalef(g_screenWidth, g_screenHeight, 1.0);
          gloost::drawQuad();
        glPopMatrix();
      }
      g_viewShader->disable();


      if (g_toggle_infoText)
      {
        g_brush->getTransferTexture()->bind();
          glPushMatrix();
            glScalef(g_screenWidth/5.0, g_screenHeight/5.0, 1.0);
            gloost::drawQuad();
          glPopMatrix();
        g_brush->getTransferTexture()->unbind();


        g_texMaster->getTextureWithoutRefcount(g_doubleBufferIds[(int)(!g_currentBuffer)])->bind();
          glPushMatrix();
            glTranslatef(g_screenWidth/5.0, 0.0, 0.0);
            glScalef(g_screenWidth/5.0, g_screenHeight/5.0, 1.0);
            gloost::drawQuad();
          glPopMatrix();
        g_texMaster->getTextureWithoutRefcount(g_doubleBufferIds[(int)(!g_currentBuffer)])->unbind();
      }


    }
    glPopAttrib();
  }
  glPopMatrix();

}