/
driver_test.go
79 lines (52 loc) · 1.67 KB
/
driver_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package rigo
import (
"testing"
"log"
. "github.com/mae-global/rigo2/ri"
. "github.com/mae-global/rigo2/ri/core"
"github.com/mae-global/rigo2/drivers"
"github.com/mae-global/rigo2/drivers/RIB"
. "github.com/smartystreets/goconvey/convey"
)
func Test_Driver(t *testing.T) {
/* construct a custom driver (we cheat by using an existing driver) */
custom := func(logger *log.Logger, options []RtPointer, args ...string) (drivers.Driver,error) {
return ribdriver.BuildStdoutDriver(logger,options,args...)
}
Convey("Custom Driver test",t,func() {
/* add a custom driver as "custom" */
So(AddDriver("custom",custom),ShouldBeNil)
ri := New(nil)
ri.Begin("custom")
ri.Display("simplesphere.tiff", "file", "rgba")
ri.Format(320, 240, 1)
ri.Projection(PERSPECTIVE, RtToken("float fov"), RtFloat(30))
ri.Translate(0, 0, 6)
ri.WorldBegin()
ri.Light("PxrEnvDayLight", "-", RtToken("float intensity"), RtFloat(0.5))
ri.Color(RtColor{1, 0, 0})
ri.Sphere(1, -1, 1, 360)
ri.WorldEnd()
ri.End()
/* remove custom driver */
So(RemoveDriver("custom"),ShouldBeNil)
})
}
func Test_RigoDriver(t *testing.T) {
/* This driver should write to tmp/out.go a formalised version as a program */
Convey("Rigo Driver test",t,func() {
ri := New(nil)
ri.Begin("rigo tmp/out.go")
ri.Display("simplesphere.exr","openexr","rgba")
ri.Format(320,240,1)
ri.Projection(PERSPECTIVE,RtToken("float fov"),RtFloat(30))
ri.Translate(0,0,6)
ri.WorldBegin()
ri.Light("PxrEnvDayLight","-",RtToken("float intensity"),RtFloat(0.5))
ri.Color(RtColor{1,0,0})
ri.Sphere(1,-1,1,360)
ri.WorldEnd()
ri.End()
/* TODO: check for outputted file */
})
}