如何在开放的gl中画一个圆 [英] How to draw a circle in open gl
本文介绍了如何在开放的gl中画一个圆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以帮我如何在图像中绘制与圆相似的圆,以便使用android的open gl v1.5来使M大于N.
[IMG] http://i49.tinypic.com/254y5bs.png [/IMG]
Can anyone help me how to draw a circle similar to one in the image, such that M is greater than N using open gl v1.5 for android
[IMG]http://i49.tinypic.com/254y5bs.png[/IMG]
推荐答案
很多建议易于查找 [ ^ ].
请尝试一下...
Please try this...
int RADIUS = 2;
float DEGREE_TO_RAD = 3.14 / 180;
glBegin( GL_LINE_LOOP );
glVertex2f( 0,0 );
int M_IN_DEGREE = 370;
int N_IN_DEGREE = 100;
for( int nR =N_IN_DEGREE; nR < M_IN_DEGREE; nR++ )
{
float fX = sin((float)nR * DEGREE_TO_RAD ) ;
float fY = cos((float)nR * DEGREE_TO_RAD );
glVertex2f( fX, fY );
}
glEnd();
使用glDrawArrays
With glDrawArrays
int M_IN_DEGREE = 370;
int N_IN_DEGREE = 100;
int nCount = 1;
float stVertexArray[2*360];
stVertexArray[0] = 0.0;
stVertexArray[1] = 0.0;
for( int nR =N_IN_DEGREE; nR < M_IN_DEGREE; nR++ )
{
float fX = sin((float)nR * DEGREE_TO_RAD ) ;
float fY = cos((float)nR * DEGREE_TO_RAD );
stVertexArray[nCount*2] = fX;
stVertexArray[nCount*2 + 1] = fY;
nCount++;
}
glEnableClientState( GL_VERTEX_ARRAY );
glVertexPointer( 2, GL_FLOAT, 0, stVertexArray );
glDrawArrays( GL_LINE_LOOP, 0, nCount );
这篇关于如何在开放的gl中画一个圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文