Example #1
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;
}
Example #2
0
CGO *CrystalGetUnitCellCGO(CCrystal * I)
{
  PyMOLGlobals *G = I->G;
  float v[3];
  CGO *cgo = NULL;
  if(I) {
    cgo = CGONew(G);
#ifndef PURE_OPENGL_ES_2
    CGODisable(cgo, GL_LIGHTING);
#endif

#ifdef _PYMOL_CGO_DRAWARRAYS
    {
      int nverts = 10, pl = 0;
      float *vertexVals;
      vertexVals = CGODrawArrays(cgo, GL_LINE_STRIP, CGO_VERTEX_ARRAY, nverts);	      
      set3f(v, 0, 0, 0);
      transform33f3f(I->FracToReal, v, v);
      vertexVals[pl++] = v[0]; vertexVals[pl++] = v[1]; vertexVals[pl++] = v[2];
      set3f(v, 1, 0, 0);
      transform33f3f(I->FracToReal, v, v);
      vertexVals[pl++] = v[0]; vertexVals[pl++] = v[1]; vertexVals[pl++] = v[2];
      set3f(v, 1, 1, 0);
      transform33f3f(I->FracToReal, v, v);
      vertexVals[pl++] = v[0]; vertexVals[pl++] = v[1]; vertexVals[pl++] = v[2];
      set3f(v, 0, 1, 0);
      transform33f3f(I->FracToReal, v, v);
      vertexVals[pl++] = v[0]; vertexVals[pl++] = v[1]; vertexVals[pl++] = v[2];
      set3f(v, 0, 0, 0);
      transform33f3f(I->FracToReal, v, v);
      vertexVals[pl++] = v[0]; vertexVals[pl++] = v[1]; vertexVals[pl++] = v[2];
      set3f(v, 0, 0, 1);
      transform33f3f(I->FracToReal, v, v);
      vertexVals[pl++] = v[0]; vertexVals[pl++] = v[1]; vertexVals[pl++] = v[2];
      set3f(v, 1, 0, 1);
      transform33f3f(I->FracToReal, v, v);
      vertexVals[pl++] = v[0]; vertexVals[pl++] = v[1]; vertexVals[pl++] = v[2];
      set3f(v, 1, 1, 1);
      transform33f3f(I->FracToReal, v, v);
      vertexVals[pl++] = v[0]; vertexVals[pl++] = v[1]; vertexVals[pl++] = v[2];
      set3f(v, 0, 1, 1);
      transform33f3f(I->FracToReal, v, v);
      vertexVals[pl++] = v[0]; vertexVals[pl++] = v[1]; vertexVals[pl++] = v[2];
      set3f(v, 0, 0, 1);
      transform33f3f(I->FracToReal, v, v);
      vertexVals[pl++] = v[0]; vertexVals[pl++] = v[1]; vertexVals[pl++] = v[2];
    }
    {
      int nverts = 6, pl = 0;
      float *vertexVals;
      vertexVals = CGODrawArrays(cgo, GL_LINES, CGO_VERTEX_ARRAY, nverts);	      
      set3f(v, 0, 1, 0);
      transform33f3f(I->FracToReal, v, v);
      vertexVals[pl++] = v[0]; vertexVals[pl++] = v[1]; vertexVals[pl++] = v[2];
      set3f(v, 0, 1, 1);
      transform33f3f(I->FracToReal, v, v);
      vertexVals[pl++] = v[0]; vertexVals[pl++] = v[1]; vertexVals[pl++] = v[2];
      set3f(v, 1, 1, 0);
      transform33f3f(I->FracToReal, v, v);
      vertexVals[pl++] = v[0]; vertexVals[pl++] = v[1]; vertexVals[pl++] = v[2];
      set3f(v, 1, 1, 1);
      transform33f3f(I->FracToReal, v, v);
      vertexVals[pl++] = v[0]; vertexVals[pl++] = v[1]; vertexVals[pl++] = v[2];
      set3f(v, 1, 0, 0);
      transform33f3f(I->FracToReal, v, v);
      vertexVals[pl++] = v[0]; vertexVals[pl++] = v[1]; vertexVals[pl++] = v[2];
      set3f(v, 1, 0, 1);
      transform33f3f(I->FracToReal, v, v);
      vertexVals[pl++] = v[0]; vertexVals[pl++] = v[1]; vertexVals[pl++] = v[2];
    }
#else
    CGOBegin(cgo, GL_LINE_STRIP);
    set3f(v, 0, 0, 0);
    transform33f3f(I->FracToReal, v, v);
    CGOVertexv(cgo, v);

    set3f(v, 1, 0, 0);
    transform33f3f(I->FracToReal, v, v);
    CGOVertexv(cgo, v);

    set3f(v, 1, 1, 0);
    transform33f3f(I->FracToReal, v, v);
    CGOVertexv(cgo, v);

    set3f(v, 0, 1, 0);
    transform33f3f(I->FracToReal, v, v);
    CGOVertexv(cgo, v);

    set3f(v, 0, 0, 0);
    transform33f3f(I->FracToReal, v, v);
    CGOVertexv(cgo, v);

    set3f(v, 0, 0, 1);
    transform33f3f(I->FracToReal, v, v);
    CGOVertexv(cgo, v);

    set3f(v, 1, 0, 1);
    transform33f3f(I->FracToReal, v, v);
    CGOVertexv(cgo, v);

    set3f(v, 1, 1, 1);
    transform33f3f(I->FracToReal, v, v);
    CGOVertexv(cgo, v);

    set3f(v, 0, 1, 1);
    transform33f3f(I->FracToReal, v, v);
    CGOVertexv(cgo, v);

    set3f(v, 0, 0, 1);
    transform33f3f(I->FracToReal, v, v);
    CGOVertexv(cgo, v);
    CGOEnd(cgo);

    CGOBegin(cgo, GL_LINES);

    set3f(v, 0, 1, 0);
    transform33f3f(I->FracToReal, v, v);
    CGOVertexv(cgo, v);

    set3f(v, 0, 1, 1);
    transform33f3f(I->FracToReal, v, v);
    CGOVertexv(cgo, v);

    set3f(v, 1, 1, 0);
    transform33f3f(I->FracToReal, v, v);
    CGOVertexv(cgo, v);

    set3f(v, 1, 1, 1);
    transform33f3f(I->FracToReal, v, v);
    CGOVertexv(cgo, v);

    set3f(v, 1, 0, 0);
    transform33f3f(I->FracToReal, v, v);
    CGOVertexv(cgo, v);

    set3f(v, 1, 0, 1);
    transform33f3f(I->FracToReal, v, v);
    CGOVertexv(cgo, v);
    CGOEnd(cgo);
#endif

#ifndef PURE_OPENGL_ES_2
    CGOEnable(cgo, GL_LIGHTING);
#endif
    CGOStop(cgo);
  }
  return (cgo);
}