Home Overview FAQ Documentation Download Mailing List Geomview For Windows? Support Users Development Bug Reporting Contributing Contact Us Sponsors
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: your mail
> > > Hi! I'm working with Mary Vickerman here at NASA Lewis and I was > perusing the geomview source code and noticed a something that I > was wondering about. In the file .../src/lib/mg/mggldraw.c the > routine "mggl_polyline" has a "unique" method of defining a gl polyline: > > > ============================================================================ > > if (nv == 1) { > if(nc > 0) c4f((float *)c); > mghps_point(v); > } > else if(nv > 0) { > bgnline(); > if(wrapped & 1) { > if(nc > 0) c4f((float *)(c + nc - 1)); > v4f((float *)(v + nv - 1)); > } > > for(;;) { > remain = nv > 254 ? 254 : nv; > nv -= remain; > do { > if(--nc >= 0) c4f((float *)c++); > v4f((float *)v++); > } while(--remain > 0); > if(nv == 0) > break; > if(nc > 0) c4f((float *)c); > v4f((float *)v); > endline(); > bgnline(); > } > endline(); > } > if(!(wrapped & 4) && _mghpsc->znudge) mghps_farther(); > > ============================================================================ > > Should the bgnline within the "for (;;)" loop be placed BEFORE the v4f call? > Ah... well, in general yes. *But*, in this particular context it is actually quite fine and correct. First of all, to even get to the for(;;) loop you mentioned, it has to first decide that nv is > 0: > else if(nv > 0) { > bgnline(); > if(wrapped & 1) { > if(nc > 0) c4f((float *)(c + nc - 1)); > v4f((float *)(v + nv - 1)); > } > Notice that right after we decide (nv > 0) is true we do a bgnline(). Then, we may do a vertex (if wrapped & 1 is true). Now we get to the for(;;) loop; remember we have not called endline() yet. > for(;;) { > remain = nv > 254 ? 254 : nv; > nv -= remain; > do { > if(--nc >= 0) c4f((float *)c++); > v4f((float *)v++); > } while(--remain > 0); So now *what*, you may ask, are we doing here? Why the contorted code? Well, I guess on some SGI machines we are not allowed to draw lines with more than 255 vertices so here we say, if the line indeed has more vertices than 255, we chop it up into sections and draw one at a time. The do loop draws the first and each following section if necessary. > if(nv == 0) > break; If the line was less than 255 vertices or we are finished with drawing all sections of a >255 vertex line then we exit the for(;;) loop. > if(nc > 0) c4f((float *)c); > v4f((float *)v); > endline(); > bgnline(); > } If we get to this code, it means the line indeed has more than 255 vertices. Okay, we add the final vertex and terminate this section with an endline() call. Then we bgnline() to start the next section. Moving back to the start of the for(;;) loop, we begin adding vertices once again. > endline(); > } Once we exit the for(;;) loop we call this endline(); to terminate the last or only (if there was just 1) section of the line. Now do you understand how it works? :-) Enjoy, Daeron daeron at geom.umn.edu
|
||
Home | Overview | FAQ | Documentation | Support | Download | Mailing List Windows? | Development | Bug Reporting | Contributing | Contact Us | Sponsors |
|||
site hosted by |