Пример #1
0
func Write0() {
	//
	if !initialized {
		initialize()
	}
	if !scr.UnderX() {
		ker.Stop(pack, 1)
	}
	C.glMatrixMode(C.GL_MODELVIEW)
	C.glLoadIdentity()
	for i := 0; i < 3; i++ {
		matrix[i][0] = C.GLdouble(right[i])
		matrix[i][1] = C.GLdouble(top[i])
		matrix[i][2] = C.GLdouble(-front[i])
	}
	C.glMultMatrixd(&matrix[0][0])
	C.glTranslated(C.GLdouble(-eye[0]), C.GLdouble(-eye[1]), C.GLdouble(-eye[2]))
	C.glClear(C.GL_COLOR_BUFFER_BIT + C.GL_DEPTH_BUFFER_BIT)
	for n := uint(0); n < MaxL; n++ {
		if lightInitialized[n] {
			ActualizeLight(n)
		}
	}
	C.glBegin(POINTS)
	nn = 0
}
Пример #2
0
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()
}
Пример #3
0
func Write(f Figure, a uint, V, N []*vect.Imp, c col.Colour) {
	//
	switch f {
	case UNDEF:
		nn = 0 // forces glEnd / glBegin
		println("gl.Write UNDEF")
		return
	case LIGHT:
		lightVis = true
		if a >= MaxL {
			ker.Stop(pack, 2)
		}
		InitLight(a, V[0], N[0], c)
		nn = 0
		println("gl.Write LIGHT")
		return
	}
	if f != fig || a != nn || nn == 0 {
		fig = f
		nn = a
		C.glEnd()
		C.glBegin(C.GLenum(f))
	}
	C.glColor3ub(C.GLubyte(c.R), C.GLubyte(c.G), C.GLubyte(c.B))
	for i := uint(0); i < a; i++ {
		println("gl.Write", i)
		vector2yyy(V[i])
		C.glVertex3dv(&yyy[0])
		vector2yyy(N[i])
		C.glNormal3dv(&yyy[0])
	}
	/*
	   tmp:= vect.New ()
	   C.glEnd ()
	   for i:= uint(0); i < a; i++ {
	     C.glBegin (LINES)
	     C.glColor3ub (C.GLubyte(0), C.GLubyte(255), C.GLubyte(0))
	     vector2yyy (V[i]); C.glVertex3dv (&yyy[0])
	     tmp.Copy (V[i])
	     tmp.Inc (N[i])
	     vector2yyy (tmp); C.glVertex3dv (&yyy[0])
	     C.glEnd ()
	   }
	   nn = 0
	   C.glBegin (POINTS)
	*/
}
Пример #4
0
Файл: gl.go Проект: james4k/gl
//void glBegin (GLenum mode)
func Begin(mode GLenum) {
	C.glBegin(C.GLenum(mode))
}