Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <windows.h>
- #include <string>
- #include "glut.h"
- GLfloat TexP1[] = { 0,1,0,0 };
- GLfloat TexP2[] = { 0,0,1,0 };
- GLubyte TexI[] =
- { 255,0,0,
- 255,0,0,
- 255,255,0,
- 255,255,0,
- 0,255,0,
- 0,255,0,
- 0,0,255,
- 0,0,255
- };
- GLfloat texpts[2][2][2] = { 0,0,0,2,2,0,2,2 };
- GLUnurbsObj* theNurb;
- GLUquadricObj* theqw;
- // массив точек определяющего многоугольника
- GLfloat pts1[12][4] = {
- { 0.5, 0.0, -0.3, 1 },
- { 0.5,0.0,0.3,1 },
- { 0.5,0.0,0.6,1 },
- { 0.0,0.866,-0.3,1 },
- { 0.0, 0.866, 0.3, 1 },
- { 0.0, 0.866, 0.6, 1 },
- { -0.5,0.0,-0.3,1 },
- { -0.5,0.0,0.3,1 },
- { -0.5,0.0,0.6,1 },
- {-1, 0.866, -0.3, 1},
- {-1, 0.866, 0.3, 1},
- {-1, 0.866, 0.6, 1}
- };
- void init(void)
- {
- glClearColor(0.5, 0.75, 0.75, 1);
- theNurb = gluNewNurbsRenderer();
- theqw = gluNewQuadric();
- glEnable(GL_DEPTH_TEST);
- gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25);
- 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);
- //glTexImage1D(GL_TEXTURE_1D, 0, 3, 8, 0, GL_RGB, GL_UNSIGNED_BYTE, TexI);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
- //gluQuadricTexture(theqw, true);
- glEnable(GL_TEXTURE_1D);
- }
- void Display()
- {
- GLfloat knot[7] = { 0.0,0.0,1.0,2.0, 3.0,4.0, 4.0};
- GLfloat knot1[6] = { 0,0,0,1,1,1 };
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glRotatef(0.003, 1, 1, 1);
- glColor3f(1, 0, 0);
- glEnable(GL_TEXTURE_GEN_S);
- glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
- glTexGenfv(GL_S, GL_OBJECT_PLANE, TexP1);
- GLfloat temp[12][4];
- for (int j = 0; j < 12; ++j) {
- for (int z = 0; z < 4; ++z) {
- temp[j][z] = pts1[j][z];
- if (j == 2 || j == 3) {
- temp[j][z] = pts1[j][z] * 1;
- }
- }
- };
- gluBeginSurface(theNurb);
- gluNurbsSurface(theNurb, 7, knot, 6, knot1, 3 * 4, 4, &pts1[0][0], 2, 3, GL_MAP2_VERTEX_4);
- //glFlush();
- glutPostRedisplay();
- glutSwapBuffers();
- }
- void main()
- {
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
- glutInitWindowSize(480, 480);
- glutInitWindowPosition(100, 100);
- glutCreateWindow(" ");
- init();
- glutDisplayFunc(Display);
- glutMainLoop();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement