我想在opengl中绘制一个圆,但我似乎无法获得正确的坐标,所以无论使用什么方法,我总是得到一个省略号。当前的代码如下:OpenGL圆形绘图变椭圆
void Ball::Render() {
float center_position_x = _body->GetWorldCenter().x;
float center_position_y = _body->GetWorldCenter().y;
float radius = static_cast<b2CircleShape*>(_body->GetFixtureList()->GetShape())->m_radius;
glBegin(GL_LINE_STRIP);
for(float angle = 0; angle <= 360; ++angle) {
float angleInRadians = glm::radians(angle);
float x = glm::cos(angleInRadians);
float y = glm::sin(angleInRadians);
glVertex3f(x,y,0);
}
glEnd();
}
(我知道的代码应该吸取在原点的圆,但即使如此,它不是一个完美的圆,如果我理解正确的话应该在半径原点画一个圆= 1)我用
另一方法是: http://slabode.exofire.net/circle_draw.shtml http://www.opengl.org/discussion_boards/showthread.php/167955-drawing-a-smooth-circle
这是我的OpenGL窗口设置代码(这是一个存根程序所以我开始硬编码值): gluOrtho2D(-10, 15, -10, 15);
听起来像高宽比问题。你如何处理? – 2013-04-24 17:15:51
@MichaelDorgan哦,耶稣。张贴作为答复,所以我可以接受它。 *在我身上的耻辱* – 2013-04-24 17:21:32