Пример #1
0
static void RepLabelRender(RepLabel * I, RenderInfo * info)
{
  CRay *ray = info->ray;
  Picking **pick = info->pick;
  PyMOLGlobals *G = I->R.G;
  float *v = I->V;
  int c = I->N;
  int *l = I->L;
  int font_id = SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting,
                             cSetting_label_font_id);
  float font_size = SettingGet_f(G, I->R.cs->Setting, I->R.obj->Setting,
                                 cSetting_label_size);

  if(ray) {
    if(c) {
      char *st;
      TextSetOutlineColor(G, I->OutlineColor);
      while(c--) {
        if(*l) {
          st = OVLexicon_FetchCString(G->Lexicon, *l);
          TextSetPosNColor(G, v + 3, v);
          TextRenderRay(G, ray, font_id, st, font_size, v + 6);
        }
        v += 9;
        l++;
      }
    }
  } else if(G->HaveGUI && G->ValidContext) {
    if(pick) {
      Pickable *p = I->R.P;
      int i;
      if(c) {
        char *st;
        int float_text = (int) SettingGet(G, cSetting_float_labels);
        if(float_text)
          glDisable(GL_DEPTH_TEST);

        i = (*pick)->src.index;
        while(c--) {
          if(*l) {
            int first_pass = (!(*pick)[0].src.bond);
            i++;
            TextSetPosNColor(G, v + 3, v);
            TextSetPickColor(G, first_pass, i);
            if(first_pass) {
              VLACheck((*pick), Picking, i);
              p++;
              (*pick)[i].src = *p;      /* copy object and atom info */
              (*pick)[i].context = I->R.context;
            }
            st = OVLexicon_FetchCString(G->Lexicon, *l);
            TextRenderOpenGL(G, info, font_id, st, font_size, v + 6);
          }
          l++;
          v += 9;
        }
        if(float_text)
          glEnable(GL_DEPTH_TEST);
        (*pick)[0].src.index = i;       /* pass the count */
      }
    } else {
      if(c) {
        char *st;
        int float_text = (int) SettingGet(G, cSetting_float_labels);
        if(float_text)
          glDisable(GL_DEPTH_TEST);
#ifdef PURE_OPENGL_ES_2
    /* TODO */
#else
        if(!info->line_lighting)
          glDisable(GL_LIGHTING);
#endif
        TextSetOutlineColor(G, I->OutlineColor);
        while(c--) {
          if(*l) {
            TextSetPosNColor(G, v + 3, v);
            st = OVLexicon_FetchCString(G->Lexicon, *l);
            TextRenderOpenGL(G, info, font_id, st, font_size, v + 6);
          }
          l++;
          v += 9;
        }
#ifdef PURE_OPENGL_ES_2
    /* TODO */
#else
        glEnable(GL_LIGHTING);
#endif
        glEnable(GL_BLEND);
        if(float_text)
          glEnable(GL_DEPTH_TEST);
      }
    }
  }
}
Пример #2
0
static void RepLabelRender(RepLabel * I, RenderInfo * info)
{
  CRay *ray = info->ray;
  Picking **pick = info->pick;
  PyMOLGlobals *G = I->R.G;
  float *v = I->V;
  int c = I->N;
  int *l = I->L;
  int font_id = SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting,
                             cSetting_label_font_id);
  float font_size = SettingGet_f(G, I->R.cs->Setting, I->R.obj->Setting,
                                 cSetting_label_size);

  if(ray) {
    if(c) {
      char *st;
      TextSetOutlineColor(G, I->OutlineColor);
      while(c--) {
        if(*l) {
          st = OVLexicon_FetchCString(G->Lexicon, *l);
          TextSetPosNColor(G, v + 3, v);
          TextRenderRay(G, ray, font_id, st, font_size, v + 6);
        }
        v += 9;
        l++;
      }
    }
  } else if(G->HaveGUI && G->ValidContext) {
    if(pick) {
      Pickable *p = I->R.P;
      int i;
      if (I->shaderCGO){
	CGORenderGLPicking(I->shaderCGO, pick, &I->R.context, I->R.cs->Setting, I->R.obj->Setting);
	return;
      }
      SceneSetupGLPicking(G);
      if(c) {
        char *st;
        int float_text = SettingGetGlobal_i(G, cSetting_float_labels);
        if(float_text)
          glDisable(GL_DEPTH_TEST);

        i = (*pick)->src.index;
        while(c--) {
          if(*l) {
            int first_pass = (!(*pick)[0].src.bond);
            i++;
            TextSetPosNColor(G, v + 3, v);
            TextSetPickColor(G, first_pass, i);
            if(first_pass) {
              VLACheck((*pick), Picking, i);
              p++;
              (*pick)[i].src = *p;      /* copy object and atom info */
              (*pick)[i].context = I->R.context;
            }
            st = OVLexicon_FetchCString(G->Lexicon, *l);
            TextRenderOpenGL(G, info, font_id, st, font_size, v + 6, SHADERCGO);
          }
          l++;
          v += 9;
        }
        if(float_text)
          glEnable(GL_DEPTH_TEST);
        (*pick)[0].src.index = i;       /* pass the count */
      }
    } else {
      if(c) {
        char *st;
        int float_text = SettingGetGlobal_i(G, cSetting_float_labels);
	short use_shader;
	Pickable *p = I->R.P;
	use_shader = SettingGetGlobal_b(G, cSetting_use_shaders);
        if(float_text)
          glDisable(GL_DEPTH_TEST);
	if (use_shader){
	  if (!I->shaderCGO){
	    I->shaderCGO = CGONew(G);
	    if (use_shader){
	      I->shaderCGO->use_shader = true;
	      I->shaderCGO->enable_shaders = true;
	    }
	  } else {
	    CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R);
	    if(float_text)
	      glEnable(GL_DEPTH_TEST);
	    return;
	  }
	} else if (I->shaderCGO) {
	  CGOFree(I->shaderCGO);
	  I->shaderCGO = NULL;
	}
        TextSetOutlineColor(G, I->OutlineColor);

        while(c--) {
          if(*l) {
	    p++;
	    if (I->shaderCGO)
	      CGOPickColor(I->shaderCGO, p->index, p->bond);
            TextSetPosNColor(G, v + 3, v);
            st = OVLexicon_FetchCString(G->Lexicon, *l);
            TextRenderOpenGL(G, info, font_id, st, font_size, v + 6, SHADERCGO);
          }
          l++;
          v += 9;
        }
        if (I->shaderCGO){
          CGO *convertcgo;
	  CGOStop(I->shaderCGO);
	  convertcgo = CGOOptimizeLabels(I->shaderCGO, 0);
	  CGOFree(I->shaderCGO);
	  I->shaderCGO = convertcgo;
	  convertcgo = NULL;
	  if (I->shaderCGO){
	    I->shaderCGO->use_shader = true;
	    I->shaderCGO->enable_shaders = true;
	    CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R);
	  }
        }
        if(float_text)
          glEnable(GL_DEPTH_TEST);
      }
    }
  }
}