#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <Windows.h>
#include "glut.h"
#include <gl\GL.h>
#include <gl\GLU.h>
#include <iostream>
#include <vector>
#include <array>
#include <fstream>
GLfloat ctlarray[2][4][4] = {
{
{ 0.0, 0.0, 0.0, 1.0 },
{ 0.0, 0.5, 0.2, 1.0 },
{ 0.0, 0.0, 0.4, 1.0 },
{ 0.0, 0.5, 0.6, 1.0 }
},
{
{ 0.2, 0.0, 0.0, 1.0 },
{ 0.2, 0.5, 0.2, 1.0 },
{ 0.2, 0.0, 0.4, 1.0 },
{ 0.2, 0.5, 0.6, 1.0 }
},
};
GLUnurbsObj* theNurb;
void init() {
glClearColor(1.0, 1.0, 1.0, 1);
theNurb = gluNewNurbsRenderer();
glEnable(GL_DEPTH_TEST);
}
void Display()
{
GLfloat knot[] = { 0.0, 0.0, 1.0, 1.0}; // x
GLfloat knot1[] = { 0.0, 0.0, 0.0, 1.0, 2.0, 2.0, 2.0}; // z
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glRotatef(0.1, 1.0, 1.0, 0.5);
glColor3f(0.4, 0.2, 0.7);
glEnable(GL_TEXTURE_GEN_S);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
gluBeginSurface(theNurb);
gluNurbsSurface(theNurb,
4, knot,
7, knot1,
4 * 4,
4,
&ctlarray[0][0][0],
2, 3,
GL_MAP2_VERTEX_4);
gluEndSurface(theNurb);
glutPostRedisplay();
glutSwapBuffers();
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(580, 580);
glutInitWindowPosition(100, 100);
glutCreateWindow("Test");
init();
glutDisplayFunc(Display);
glutMainLoop();
}