Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- //#include <window.h>
- #include <gl/glut.h>
- GLfloat ctlarray[3][2][4] = { 0.5, 0.0, -0.5, 1.0, 0.5, 0.0, 0.5, 1.0,
- 0.0, 0.866*0.55, -0.5 * 0.55, 1.0*0.55, 0.0, 0.866*0.55, 0.5 * 0.55, 1.0 * 0.55, -0.5, 0.0, -0.5, 1.0, -0.5, 0.0, 0.5, 1.0 };
- GLUnurbsObj *theNurb;
- GLfloat texpt[2][2][2] = { 0, 0, 0, 1, 1, 0, 1, 1 };
- GLUquadricObj* theqw;
- GLubyte *Iz_RGB;
- void file_read()
- {
- }
- void init()
- {
- glClearColor(0.1, 0.98, 0.3, 1);
- theNurb = gluNewNurbsRenderer();
- theqw = gluNewQuadric();
- glEnable(GL_DEPTH_TEST);
- gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, Iz_RGB);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
- gluQuadricTexture(theqw, true);
- glEnable(GL_TEXTURE_2D);
- free(Iz_RGB);
- }
- void Display()
- {
- GLfloat knot[] = { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 };
- GLfloat knot1[] = { 0.0, 0.0, 1.0, 1.0 };
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glRotatef(1, 1.0, 1.0, 1.0);
- glColor3f(1, 0, 0);
- glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2, &texpt[0][0][0]);
- glEnable(GL_MAP2_TEXTURE_COORD_2);
- gluSphere(theqw, 0.3, 50, 50);
- gluBeginSurface(theNurb);
- gluNurbsSurface(theNurb, 6, knot, 4, knot1, 2 * 4, 4, &ctlarray[0][0][0], 3, 2, GL_MAP2_VERTEX_4);
- gluEndSurface(theNurb);
- glutPostRedisplay();
- glutSwapBuffers();
- }
- void main()
- {
- file_read();
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
- glutInitWindowSize(500, 500);
- glutCreateWindow("Task4");
- init();
- glutDisplayFunc(Display);
- glutMainLoop();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement