# Two Bezier Surface

I have to modeling a dirigible and I want to make that with bezier surface.

How can make 2 Bezier surface in same project ?

I try this but doesn’t work:

``````#include <stdlib.h>
#include <GL/glut.h>

GLfloat ctrlpoints[4][4][3] = {
{ { 1, 5, 0 }, { 2, 6, 0 },{ 4, 6, 0 }, { 5, 5, 0.0 } },
{ { 0, 4, 0 }, { 2, 4, 8 },{ 4, 4, 8 }, { 6, 4, 0 } },
{ { 0, 2, 0 }, { 2, 2, 8 },{ 4, 2, 8 }, { 6, 2, 0 } },
{ { 1, 1, 0 }, { 2, 0, 0 },{ 4, 0, 0 }, { 5, 1, 0 } }
};

GLfloat ctrlpoints1[4][4][3] = {
{ { 1, 5, 0 }, { 2, 6, 0 }, { 4, 6, 0 }, { 5, 5, 0.0 } },
{ { 0, 4, 0 }, { 2, 4, 8 }, { 4, 4, 8 }, { 6, 4, 0 } },
{ { 0, 2, 0 }, { 2, 2, 8 }, { 4, 2, 8 }, { 6, 2, 0 } },
{ { 1, 1, 0 }, { 2, 0, 0 }, { 4, 0, 0 }, { 5, 1, 0 } }
};

void display(void)
{
int i, j;

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glPushMatrix();
//glRotatef(-45.0, 1.0, 0.0, 0.0);

glTranslatef(-5, -3, 0);
glRotatef(-90.0, 0.0, 1.0, 0.0);

for (j = 0; j <= 8; j++) {
glBegin(GL_LINE_STRIP);
for (i = 0; i <= 30; i++)
glEvalCoord2f((GLfloat)i / 30.0, (GLfloat)j / 8.0);
glEnd();
glBegin(GL_LINE_STRIP);
for (i = 0; i <= 30; i++)
glEvalCoord2f((GLfloat)j / 8.0, (GLfloat)i / 30.0);
glEnd();
}
glPopMatrix();

glPushMatrix();
glPolygonMode(GL_FRONT, GL_LINE);
glPolygonMode(GL_BACK, GL_LINE);

glTranslatef(-5,0,0);
glRotatef(90.0f, 0.0f, 1.0f, 0.0f);

glPolygonMode(GL_FRONT, GL_FILL);
glPolygonMode(GL_BACK, GL_FILL);

glPopMatrix();
glFlush();
}

void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4,
0, 1, 12, 4, &ctrlpoints[0][0][0]);

glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4,
0, 1, 12, 4, &ctrlpoints1[0][0][0]);

glEnable(GL_MAP2_VERTEX_3);
glMapGrid2f(20, 0.0, 1.0, 20, 0.0, 1.0);
glEnable(GL_DEPTH_TEST);

/*glClearColor(0.0, 0.0, 0.0, 0.0);
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4,
0, 1, 12, 4, &ctrlpoints1[0][0][0]);
glEnable(GL_MAP2_VERTEX_3);
glMapGrid2f(20, 0.0, 1.0, 20, 0.0, 1.0);
glEnable(GL_DEPTH_TEST);
}

void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei)w, (GLsizei)h);
glMatrixMode(GL_PROJECTION);
if (w <= h)
glOrtho(-6.0, 6.0, -6.0*(GLfloat)h / (GLfloat)w,
6.0*(GLfloat)h / (GLfloat)w, -6.0, 6.0);
else
glOrtho(-6.0*(GLfloat)w / (GLfloat)h,
6.0*(GLfloat)w / (GLfloat)h, -6.0, 6.0, -6.0, 6.0);
glMatrixMode(GL_MODELVIEW);
}

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(1000, 600);
glutInitWindowPosition(100, 100);
glutCreateWindow(argv[0]);
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
``````