Exemple #1
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)
	*/
}
Exemple #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()
}
Exemple #3
0
//void glColor3ub (uint8 red, uint8 green, uint8 blue)
func Color3ub(red uint8, green uint8, blue uint8) {
	C.glColor3ub(C.GLubyte(red), C.GLubyte(green), C.GLubyte(blue))
}