Пример #1
0
// vertex draws vertices.
// Used in classic render mode.
func (a *Attr) vertex(i int) {
	i *= a.size

	switch a.size {
	case 2:
		switch v := a.data.(type) {
		case []int16:
			gl.Vertex2s(v[i], v[i+1])
		case []int32:
			gl.Vertex2i(int(v[i]), int(v[i+1]))
		case []float32:
			gl.Vertex2f(v[i], v[i+1])
		case []float64:
			gl.Vertex2d(v[i], v[i+1])
		}
	case 3:
		switch v := a.data.(type) {
		case []int16:
			gl.Vertex3s(v[i], v[i+1], v[i+2])
		case []int32:
			gl.Vertex3i(int(v[i]), int(v[i+1]), int(v[i+2]))
		case []float32:
			gl.Vertex3f(v[i], v[i+1], v[i+2])
		case []float64:
			gl.Vertex3d(v[i], v[i+1], v[i+2])
		}
	case 4:
		switch v := a.data.(type) {
		case []int16:
			gl.Vertex4s(v[i], v[i+1], v[i+2], v[i+3])
		case []int32:
			gl.Vertex4i(int(v[i]), int(v[i+1]), int(v[i+2]), int(v[i+3]))
		case []float32:
			gl.Vertex4f(v[i], v[i+1], v[i+2], v[i+3])
		case []float64:
			gl.Vertex4d(v[i], v[i+1], v[i+2], v[i+3])
		}
	}
}
Пример #2
0
func LoadFileTypeObj(filename string) {
	rdr := bufio.NewReader(os.Stdin)
	switch line, err := rdr.ReadString('\n'); err {
	case nil:
		switch line {
		case strings.HasPrefix(line, "v "): //vertex
			verticies := strings.Split(line[2:], " ")
			gl.Vertex4f(float64(verticies[0]), float64(verticies[1]), float64(verticies[2]), float64(1.0))
		case strings.HasPrefix(line, "f "): //face
			verticies := strings.Split(line[2:], " ")
			gl.GLushort
			a--
			b--
			c--

		case strings.HasPrefix(line, "#"):
		}
	case io.EOF:
	default:
	}

}