Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Edit 2: Okay, I see the problem you're running into -- it's a limitation I'd forgotten about (so the code I'd posted previously was dead wrong and wouldn't work at all). The problem is that you're not allowed to call <code>glRotate</code> between a <code>glBegin</code>/<code>glEnd</code> pair -- if you do, it'll set an error flag, and no more drawing will be done.</p> <p>That does mean you pretty much have to handle the rotation yourself. Fortunately, that's a bit simpler than you've tried to make it:</p> <pre><code>static const double pi = 3.1416; for (int point=0; point&lt;NUM_POINTS; point++) { glBegin(GL_LINE_STRIP); for (double theta = 0.0; theta &lt; 2.0 * pi; theta += pi/6.0) { double x = cos(theta); double z = sin(theta); glVertex3d(points[point][0]*x, points[point][1], -1.0-points[point][0]*z); } glEnd(); } </code></pre> <p>As-is, this code uses -1.0 along the Z axis as the center of rotation. You can obviously move that where you wish, though anything outside your clipping frustum obviously won't display.</p> <p>Also note that to get a wireframe, you'll have to draw both your "vertical", and your "horizontal" lines separately, so the code will look something like this:</p> <pre><code>for (int point=0; point&lt;NUM_POINTS; point++) { glBegin(GL_LINE_STRIP); for (double theta = 0.0; theta &lt; 2.0 * pi; theta += pi/6.0) { double x = cos(theta); double z = sin(theta); glVertex3d(points[point][0]*x, points[point][1], -1.0 - points[point][0]*z); } glEnd(); } for (double theta = 0.0; theta &lt; 2.0 * pi; theta += pi/6.0) { glBegin(GL_LINE_STRIP); for (int point=0; point&lt;NUM_POINTS; point++) { double x = cos(theta); double z = sin(theta); glVertex3d(points[point][0]*x, points[point][1], -1.0 - points[point][0]*z); } glEnd(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload