func lamp(n uint) { // if !lightInitialized[n] { return } xx, yy, zz := lightSource[n].Coord3() x, y, z := C.GLdouble(xx), C.GLdouble(yy), C.GLdouble(zz) r := C.GLdouble(0.1) C.glBegin(TRIANGLE_FAN) C.glColor3ub(C.GLubyte(lightColour[n].R), C.GLubyte(lightColour[n].G), C.GLubyte(lightColour[n].B)) C.glNormal3d(C.GLdouble(0.0), C.GLdouble(0.0), C.GLdouble(-1.0)) C.glVertex3d(C.GLdouble(x), C.GLdouble(y), C.GLdouble(z+r)) r0 := r * sin[1] z0 := z + r*cos[1] for l := 0; l <= nLamp; l++ { C.glNormal3d(-sin[1]*cos[l], -sin[1]*sin[l], -cos[1]) C.glVertex3d(x+r0*cos[l], y+r0*sin[l], z0) } C.glEnd() C.glBegin(QUAD_STRIP) var r1, z1 C.GLdouble for b := 1; b <= nLamp/2-2; b++ { r0, z0 = r*sin[b], z+r*cos[b] r1, z1 = r*sin[b+1], z+r*cos[b+1] for l := 0; l <= nLamp; l++ { C.glNormal3d(-sin[b+1]*cos[l], -sin[b+1]*sin[l], -cos[b+1]) C.glVertex3d(x+r1*cos[l], y+r1*sin[l], z1) C.glNormal3d(-sin[b]*cos[l], -sin[b]*sin[l], -cos[b]) C.glVertex3d(x+r0*cos[l], y+r0*sin[l], z0) } } C.glEnd() C.glBegin(TRIANGLE_FAN) C.glNormal3d(0., 0., 1.) C.glVertex3d(x, y, z-r) r0, z0 = r*sin[1], z-r*cos[1] b := nLamp/2 - 1 for l := 0; l <= nLamp; l++ { C.glNormal3d(-sin[b]*cos[l], -sin[b]*sin[l], -cos[b]) C.glVertex3d(x+r0*cos[l], y+r0*sin[l], z0) } C.glEnd() }
//void glNormal3d (float64 nx, float64 ny, float64 nz) func Normal3d(nx float64, ny float64, nz float64) { C.glNormal3d(C.GLdouble(nx), C.GLdouble(ny), C.GLdouble(nz)) }