void estiva_rectmesh(xyc **Zp, nde **Np) { static xyc *Z; static nde *N; static que *q; double x, y, h; long i, j; initq(q); h = 0.125; if ( defop("-n") ) h = 1.0/atof(getop("-n")); if ( defop("-h") ) h = atof(getop("-h")); for ( i = 0, x = 0.0; i < 1.0/h+h/2.0; i++, x += h) for ( j = 0, y = 0.0; j < 1.0/h+h/2.0; j++, y += h) { if ( x == 0.0 || eq(x,1.0) || y == 0.0 || eq(y,1.0) ) { if ( eq(y,1.0) && x != 0.0 && !eq(x,1.0) ) pushxyc(q,x,y,"north"); else if ( y == 0.0 && x != 0.0 && !eq(x,1.0) ) pushxyc(q,x,y,"south"); else if ( x == 0.0 && y != 0.0 && !eq(y,1.0) ) pushxyc(q,x,y,"west"); else if ( eq(x,1.0) && y != 0.0 && !eq(y,1.0) ) pushxyc(q,x,y,"east"); else pushxyc(q,x,y,"zero"); } else pushxyc(q,x,y,NULL); } pushxyc(q,h/2.0,h/2.0,NULL); pushxyc(q,1.0-h/2.0,1.0-h/2.0,NULL); genmesh(q,Z,N); p2(Z,N); *Zp = Z; *Np = N; }
int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(480, 272); glutCreateWindow( __FILE__ ); #if !SYS glutJoystickFunc(joystick, 0); #else glutPassiveMotionFunc(motion); #endif glutKeyboardFunc(keydown); glutKeyboardUpFunc(keyup); glutSpecialFunc(special_down); glutSpecialUpFunc(special_up); glutReshapeFunc(reshape); glutDisplayFunc(display); GLCHK(glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)); GLCHK(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, firefox_start)); GLCHK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); GLCHK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); genmesh(); GLCHK(glEnableClientState(GL_VERTEX_ARRAY)); GLCHK(glVertexPointer(3, GL_FLOAT, sizeof(struct vertex), &mesh[0].x)); GLCHK(glEnableClientState(GL_TEXTURE_COORD_ARRAY)); GLCHK(glTexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), &mesh[0].s)); GLCHK(glEnableClientState(GL_NORMAL_ARRAY)); GLCHK(glNormalPointer(GL_FLOAT, sizeof(struct vertex), &mesh[0].nx)); { GLfloat ambient[] = { .3,.3,.3,1 }; GLCHK(glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient)); GLCHK(glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR)); } { GLfloat diff[] = { 1,1,1,1 }; GLfloat spec[] = { 1,1,1,1 }; GLfloat ambient[] = { .4,.4,.4,1 }; GLCHK(glMaterialfv(GL_FRONT, GL_DIFFUSE, diff)); GLCHK(glMaterialfv(GL_FRONT, GL_AMBIENT, ambient)); GLCHK(glMaterialfv(GL_FRONT, GL_SPECULAR, spec)); GLCHK(glMateriali(GL_FRONT, GL_SHININESS, 40)); } GLCHK(glLockArraysEXT(0, MESHX*MESHY)); GLCHK(glEnable(GL_DEPTH_TEST)); GLCHK(glClearColor(0,0,.5,1)); GLCHK(glEnable(GL_NORMALIZE)); #if GL_PSP_bezier_patch GLCHK(glPatchSubdivisionPSP(8,8)); //GLCHK(glPatchSubdivisionPSP(16,16)); //GLCHK(glPatchSubdivisionPSP(64,64)); #endif // GLCHK(glPolygonOffset(1,0)); // GLCHK(glEnable(GL_POLYGON_OFFSET_FILL)); glutMainLoop(); return 0; }