Commit 363243dc6398549137b0f98aff3c20f2bedaff32

Authored by Pavel Govyadinov
1 parent 8303b04d

More comments

Showing 1 changed file with 24 additions and 25 deletions   Show diff stats
stim/gl/gl_spider.h
... ... @@ -1560,31 +1560,30 @@ class gl_spider // : public virtual gl_texture<T>
1560 1560 gpuStartTimer();
1561 1561 #endif
1562 1562  
1563   -// float s = 3.0;
1564   - GLuint selectBuf[2048];
1565   - GLint hits;
1566   - glSelectBuffer(2048, selectBuf);
1567   - glDisable(GL_CULL_FACE);
1568   - (void) glRenderMode(GL_SELECT);
  1563 + GLuint selectBuf[2048]; ///size of the selection buffer in bytes.
  1564 + GLint hits; ///hit fibers
  1565 + glSelectBuffer(2048, selectBuf); ///bind the selection mode to the selection buffer.
  1566 + glDisable(GL_CULL_FACE); ///Disable cullFace
  1567 + (void) glRenderMode(GL_SELECT); ///initialize GL select mode.
1569 1568 //Init Names stack
1570 1569  
1571   - glInitNames();
1572   - glPushName(1);
  1570 + glInitNames(); ///Initialize the naming array.
  1571 + glPushName(1); ///Push a single name to the stack.
1573 1572  
1574 1573 CHECK_OPENGL_ERROR
1575 1574 //What would that vessel see in front of it.
1576   - camSel.setPosition(loc);
1577   - camSel.setFocalDistance(mag/stepsize);
  1575 + camSel.setPosition(loc); ///Set the viewing camera
  1576 + camSel.setFocalDistance(mag/stepsize); ///Set how far the fiber looks forward.
1578 1577 camSel.LookAt((loc[0]+dir[0]*mag/stepsize),
1579 1578 (loc[1]+dir[1]*mag/stepsize),
1580   - (loc[2]+dir[2]*mag/stepsize));
1581   - ps = camSel.getPosition();
  1579 + (loc[2]+dir[2]*mag/stepsize)); ///Set the look direction
  1580 + ps = camSel.getPosition(); ///get all the necessary rotation variable for openGL
1582 1581 ups = camSel.getUp();
1583 1582 ds = camSel.getLookAt();
1584   - glMatrixMode(GL_PROJECTION);
1585   - glPushMatrix();
  1583 + glMatrixMode(GL_PROJECTION); ///Push the projection matrix.
  1584 + glPushMatrix(); ///Reset the current projection matrix
1586 1585 glLoadIdentity();
1587   - glOrtho(-mag/stepsize/2.0, mag/stepsize/2.0, -mag/stepsize/2.0, mag/stepsize/2.0, 0.0, mag/stepsize/2.0);
  1586 + glOrtho(-mag/stepsize/2.0, mag/stepsize/2.0, -mag/stepsize/2.0, mag/stepsize/2.0, 0.0, mag/stepsize/2.0); ///Finalize the look paramenters
1588 1587 glMatrixMode(GL_MODELVIEW);
1589 1588 glPushMatrix();
1590 1589 glLoadIdentity();
... ... @@ -1593,36 +1592,36 @@ class gl_spider // : public virtual gl_texture<T>
1593 1592 gluLookAt(ps[0], ps[1], ps[2],
1594 1593 ds[0], ds[1], ds[2],
1595 1594 ups[0], ups[1], ups[2]);
1596   -
1597   - sk.Render();
  1595 + ///Set the look at distance
  1596 + sk.Render(); ///Render the network
1598 1597 // nt.Render();
1599 1598  
1600 1599 CHECK_OPENGL_ERROR
1601 1600  
1602 1601  
1603   - glLoadName((int) sk.numL());
  1602 + glLoadName((int) sk.numL()); ///Load all the names
1604 1603 // glLoadName(nt.sizeE());
1605 1604  
1606   - sk.RenderLine(cL);
  1605 + sk.RenderLine(cL); ///Render the current line.
1607 1606 // nt.RenderLine(cL);
1608 1607  
1609 1608 // glPopName();
1610   - glFlush();
  1609 + glFlush(); ///Flush the buffer
1611 1610  
1612 1611 glMatrixMode(GL_PROJECTION);
1613 1612 glPopMatrix();
1614 1613 glMatrixMode(GL_MODELVIEW);
1615 1614 CHECK_OPENGL_ERROR
1616   - glPopMatrix();
  1615 + glPopMatrix(); ///clear the vis matrices and pop the matrix
1617 1616  
1618 1617 // glEnable(GL_CULL_FACE);
1619   - hits = glRenderMode(GL_RENDER);
1620   - int found_hits = processHits(hits, selectBuf);
  1618 + hits = glRenderMode(GL_RENDER); ///Check for hits.
  1619 + int found_hits = processHits(hits, selectBuf); ///Process the hits.
1621 1620 #ifdef TIMING
1622 1621 hit_time += gpuStopTimer();
1623 1622 #endif
1624 1623  
1625   - return found_hits;
  1624 + return found_hits; ///return whether we hit something or not.
1626 1625 }
1627 1626  
1628 1627 //Given a size of the array (hits) and the memory holding it (buffer)
... ... @@ -1630,7 +1629,7 @@ class gl_spider // : public virtual gl_texture<T>
1630 1629 int
1631 1630 processHits(GLint hits, GLuint buffer[])
1632 1631 {
1633   - GLuint *ptr;
  1632 + GLuint *ptr; ///pointer to the detection buffer
1634 1633 ptr = (GLuint *) buffer;
1635 1634 ptr++;
1636 1635 ptr++; //Skip the minimum depth value.
... ...