Effiziente Weise zu Ellipse zeichnen mit OpenGL oder D3D

Gibt es einen schnellen Weg, um einen Kreis zeichnen, wie dies

void DrawCircle(float cx, float cy, float r, int num_segments) 
{ 
    float theta = 2 * 3.1415926 /float(num_segments); 
    float c = cosf(theta);//precalculate the sine and cosine
    float s = sinf(theta);
    float t;

    float x = r;//we start at angle = 0 
    float y = 0; 

    glBegin(GL_LINE_LOOP); 
    for(int ii = 0; ii < num_segments; ii++) 
    { 
        glVertex2f(x + cx, y + cy);//output vertex 

        //apply the rotation matrix
        t = x;
        x = c * x - s * y;
        y = s * t + c * y;
    } 
    glEnd(); 
}

Frage ich mich, ob es eine ähnliche Weise zu zeichnen, ellipse, wo seine major/minor-Achsen-Vektor und die Größe bekannt sind.

Dieser code wird niemals "effizient" solange Sie den immediate-mode (glBegin, glVertex, glEnd, etc.)

InformationsquelleAutor giggle | 2011-05-04

Schreibe einen Kommentar