Exemplo n.º 1
0
static
void RepWireBondFree(RepWireBond * I)
{
    CGOFree(I->shaderCGO);
  CGOFree(I->primitiveCGO);
  RepPurge(&I->R);
  OOFreeP(I);
}
Exemplo n.º 2
0
void RepLabelFree(RepLabel * I)
{
  FreeP(I->R.P);
  FreeP(I->V);
  FreeP(I->L);
  if (I->shaderCGO){
    CGOFree(I->shaderCGO);
  }
  OOFreeP(I);
}
Exemplo n.º 3
0
static void RepWireBondRender(RepWireBond * I, RenderInfo * info)
{
  PyMOLGlobals *G = I->R.G;
  CRay *ray = info->ray;
  auto pick = info->pick;
  int ok = true;

  if(ray) {
#ifndef _PYMOL_NO_RAY
    CGORenderRay(I->primitiveCGO, ray, info, NULL, NULL, I->R.cs->Setting, I->R.cs->Obj->Obj.Setting);
    ray->transparentf(0.0);
#endif
  } else if(G->HaveGUI && G->ValidContext) {
    bool use_shader = SettingGetGlobal_b(G, cSetting_line_use_shader) &&
                      SettingGetGlobal_b(G, cSetting_use_shaders);
    if(pick) {
      CGORenderGLPicking(use_shader ? I->shaderCGO : I->primitiveCGO, info, &I->R.context, NULL, NULL, &I->R);
    } else { /* else not pick i.e., when rendering */
      short line_as_cylinders ;
      line_as_cylinders = SettingGetGlobal_b(G, cSetting_render_as_cylinders) && SettingGetGlobal_b(G, cSetting_line_as_cylinders);
      if (I->shaderCGO && (!use_shader || (line_as_cylinders ^ I->shaderCGO_has_cylinders))){
      CGOFree(I->shaderCGO);
        I->shaderCGO_has_cylinders = 0;
	}
	if (ok){
        if (use_shader) {
          if (!I->shaderCGO)
            ok &= RepWireBondCGOGenerate(I, info);
          CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R);
	    } else {
          CGORenderGL(I->primitiveCGO, NULL, NULL, NULL, info, &I->R);
	}
      }
    }
  }
  if (!ok){
    CGOFree(I->shaderCGO);
    I->R.fInvalidate(&I->R, I->R.cs, cRepInvPurge);
    I->R.cs->Active[cRepLine] = false;
  }
}
Exemplo n.º 4
0
static int RepWireBondCGOGenerate(RepWireBond * I, RenderInfo * info)
{
  PyMOLGlobals *G = I->R.G;
  CGO *convertcgo = NULL;
  int ok = true;
  short line_as_cylinders = 0;
  line_as_cylinders = SettingGetGlobal_b(G, cSetting_use_shaders) && SettingGetGlobal_b(G, cSetting_render_as_cylinders) && SettingGetGlobal_b(G, cSetting_line_as_cylinders);

  {
    if (ok && I->primitiveCGO){
      if (line_as_cylinders){
        CGO *tmpCGO = CGONew(G);

        if (ok) ok &= CGOEnable(tmpCGO, GL_CYLINDER_SHADER);
        if (ok) ok &= CGOSpecial(tmpCGO, CYLINDER_WIDTH_FOR_REPWIRE);
        convertcgo = CGOConvertLinesToCylinderShader(I->primitiveCGO, tmpCGO);
        I->shaderCGO_has_cylinders = true;

        if (ok) ok &= CGOAppendNoStop(tmpCGO, convertcgo);

        if (ok) ok &= CGODisable(tmpCGO, GL_CYLINDER_SHADER);
        if (ok) ok &= CGOStop(tmpCGO);
        CGOFreeWithoutVBOs(convertcgo);
        convertcgo = tmpCGO;
      } else {
        bool trilines = SettingGetGlobal_b(G, cSetting_trilines);
        CGO *tmpCGO = CGONew(G), *tmp2CGO;
        int shader = trilines ? GL_TRILINES_SHADER : GL_LINE_SHADER;

        if (ok) ok &= CGOEnable(tmpCGO, shader);
        if (ok) ok &= CGODisable(tmpCGO, CGO_GL_LIGHTING);
        if (trilines) {
          if (ok) ok &= CGOSpecial(tmpCGO, LINEWIDTH_DYNAMIC_WITH_SCALE);
          tmp2CGO = CGOConvertToTrilinesShader(I->primitiveCGO, tmpCGO);
        } else {
          tmp2CGO = CGOConvertToLinesShader(I->primitiveCGO, tmpCGO);
        }
        if (ok) ok &= CGOAppendNoStop(tmpCGO, tmp2CGO);
        if (ok) ok &= CGODisable(tmpCGO, shader);
        if (ok) ok &= CGOStop(tmpCGO);
        CGOFreeWithoutVBOs(tmp2CGO);
        convertcgo = tmpCGO;
      }
      convertcgo->use_shader = true;
    }
    CGOFree(I->shaderCGO);
    I->shaderCGO = convertcgo;
    CHECKOK(ok, I->shaderCGO);
  }
  return ok;
}
Exemplo n.º 5
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);
      }
    }
  }
}