السلام عليكم::
اطلعت على أغلب الموضوعات التي تختص برسم دائرة في برنامج ++Visual C وليس Visual Studio
بمكتبة الــOpen Gl والحمد لله استطعت رسمها ولكن يبقى لدي سؤال؟؟؟
عندي شكل مجسم ((لكائن)) وأريد رسم ملامحه ( العينان والفم والأنف) ولم أستطع التحكم لابحجم الدائرة ومكانها داخل الكود؟؟
ياليت أحد يوضحلي ماهو السطر بالضبط في الكود هو اللي يتحكم بما أردت السؤال عنه؟؟؟
هذا الكود
#include <GL/glut.h>
#include <stdlib.h>
#include <cmath>
/* Initialize material property, light source, lighting model,
* and depth buffer.
*/
struct CPOINT {
float x,y;
};
CPOINT cp[360];
//--------------- Draw Circle -----------------
void glCircle(float radian,unsigned int softness,CPOINT cp[])
{
glBegin(GL_POLYGON);
for(int i=0;i<360;i+=softness)
glVertex2f(cp.x * radian,cp.y*radian);
glEnd();
}
//--------------- Init Points---------------
void init(void)
{
for( int degree =0;degree<360;degree++)
{
double d=(degree*(3.14/180));
cp[degree].x=sin(d);
cp[degree].y=cos(d);
}
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
}
//************************************//
void display(void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1,1,1);
glLoadIdentity();
glTranslatef(1,0,0);
glCircle(1,8,cp);
glColor3f(1,0,0);
glLoadIdentity();
glTranslatef(-1,0,0);
glCircle(0.1,10,cp);
glFlush ();
glutSwapBuffers();
}
//********************************************//
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
if (w <= h)
glOrtho (-1.5, 1.5, -1.5*(GLfloat)h/(GLfloat)w,
1.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0);
else
glOrtho (-1.5*(GLfloat)w/(GLfloat)h,
1.5*(GLfloat)w/(GLfloat)h, -1.5, 1.5, -10.0, 10.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
//**********************************************//
void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(0);
break;
}
}
//*************************************************//
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
ولكم جزيـــــــــــــــــل الشكر::
