با عرض سلام و درود.
قطعه کد زیر مربوط به طراحی میکی موس بوده که بعنوان سوال میانترم برای یکی از گروه ها در مورخه ی 3 آذر 96 طرح شده بود و به کمک دوستان بلافاصله پس از پایان امتحان به ساده ترین شکل ممکن طراحی گردیده است.
#include<glut.h> #pragma comment(lib,"glut32.lib") #pragma comment(lib,"opengl32.lib") void init(void) { glClearColor(0, 1, 1, 1); glMatrixMode(GL_PROJECTION); gluOrtho2D(-600, 600, -600, 600); } void madar(void) { glClear(GL_COLOR_BUFFER_BIT); GLUquadricObj*obj; obj = gluNewQuadric(); // head glPushMatrix(); glTranslated(0, 0, 0); glColor3f(0, 0, 0); gluDisk(obj, 0, 400, 50, 4); glPopMatrix(); // g r glPushMatrix(); glTranslated(200, 450, 0); glColor3f(0, 0, 0); gluDisk(obj, 0, 150, 50, 4); glPopMatrix(); // g l glPushMatrix(); glTranslated(-200, 450, 0); glColor3f(0, 0, 0); gluDisk(obj, 0, 150, 50, 4); glPopMatrix(); // face1 glPushMatrix(); glTranslated(-80, 0, 0); glColor3f(0.9, 0.19, 0.05); gluDisk(obj, 0, 200, 50, 4); glPopMatrix(); // face2 glPushMatrix(); glTranslated(80, 0, 0); glColor3f(0.9, 0.19, 0.05); gluDisk(obj, 0, 200, 50, 4); glPopMatrix(); //chaneh glPushMatrix(); glColor3f(0.9, 0.19, 0.05); glBegin(GL_QUADS); glVertex2d(-300, -450); glVertex2d(-300, -100); glVertex2d(300, -100); glVertex2d(300, -450); glEnd(); glPopMatrix(); // ch l glPushMatrix(); glColor3f(0.9, 0.19, 0.05); glTranslated(-260, -275, 0); gluDisk(obj, 0, 177.5, 50, 4); glPopMatrix(); // ch r glPushMatrix(); glColor3f(0.9, 0.19, 0.05); glTranslated(260, -275, 0); gluDisk(obj, 0, 177.5, 50, 4); glPopMatrix(); //ch botoom glPushMatrix(); glColor3f(0.9, 0.19, 0.05); glTranslated(0, -350, 0); gluDisk(obj, 0, 175, 50, 4); glPopMatrix(); glPushMatrix();//zaban glColor3f(0, 0, 0); glTranslated(0, -300, 0); gluDisk(obj, 0, 100, 50, 4); glPopMatrix(); //dahan glPushMatrix(); glColor3f(0, 0, 0); glTranslated(0, -150, 0); gluDisk(obj, 195, 200, 50, 4); glPopMatrix(); glPushMatrix();//pas dahan glColor3f(0.9, 0.19, 0.05); glTranslated(0, -150, 0); gluDisk(obj, 0, 195, 50, 4); glPopMatrix(); glPushMatrix(); glColor3f(0.9, 0.19, 0.05); glBegin(GL_QUADS); glVertex2d(-250, -250); glVertex2d(-250, -50); glVertex2d(250, -50); glVertex2d(250, -250); glEnd(); glPopMatrix(); // e r glPushMatrix(); glTranslated(100, 0, 0); glColor3f(1, 1, 1); gluDisk(obj, 0, 100, 50, 4); glPopMatrix(); glPushMatrix(); glTranslated(100, 0, 0); glColor3f(0.9, 0.19, 0.05); gluDisk(obj, 80, 125, 50, 4); glPopMatrix(); glPushMatrix(); glTranslated(70, -20, 0); glColor3f(0, 0, 0); gluDisk(obj, 0, 50, 50, 4); glPopMatrix(); // e l glPushMatrix(); glTranslated(-100, 0, 0); glColor3f(1, 1, 1); gluDisk(obj, 0, 100, 50, 4); glPopMatrix(); glPushMatrix(); glTranslated(-125, 0, 0); glColor3f(0.9, 0.19, 0.05); gluDisk(obj, 80, 125, 50, 4); glPopMatrix(); glPushMatrix(); glTranslated(-150, -20, 0); glColor3f(0, 0, 0); gluDisk(obj, 0, 50, 50, 4); glPopMatrix(); //nose glPushMatrix(); glColor3f(0, 0, 0); glTranslated(0, -150, 0); gluDisk(obj, 0, 75, 50, 4); glPopMatrix(); glFlush(); } int main(int argc, char**argv) { glutInit(&argc, argv); glutInitWindowPosition(0, 0); glutInitWindowSize(1000, 700); glutCreateWindow("mickey mouse"); init(); glutDisplayFunc(madar); glutMainLoop(); }
موفق و موید باشید.