Setting up to work on thinkpad
This commit is contained in:
parent
47b0428ed2
commit
4474f3e1bc
1
renderer2/.gitignore
vendored
1
renderer2/.gitignore
vendored
@ -1 +1,2 @@
|
||||
renderer2
|
||||
renderer
|
||||
|
@ -24,8 +24,6 @@ const (
|
||||
Movement = 1.0
|
||||
Rotation = 0.25
|
||||
LookLock = math.Pi / 32
|
||||
//ObjectFile = "../head.obj"
|
||||
//TextureFile = "../head.jpg"
|
||||
)
|
||||
|
||||
func must(err error) {
|
||||
@ -41,7 +39,6 @@ type ObjectDef struct {
|
||||
LookVec hrend.Vec3f
|
||||
Scale float32
|
||||
Lighting bool
|
||||
//Transform hrend.Mat44f
|
||||
}
|
||||
|
||||
func NewObjectDef(model *hrend.ObjModel, texture hrend.Framebuffer) *ObjectDef {
|
||||
@ -52,7 +49,6 @@ func NewObjectDef(model *hrend.ObjModel, texture hrend.Framebuffer) *ObjectDef {
|
||||
Scale: 1,
|
||||
Lighting: true,
|
||||
}
|
||||
//result.Transform.SetIdentity()
|
||||
return &result
|
||||
}
|
||||
|
||||
@ -77,25 +73,6 @@ func loadObject(name string) (*hrend.ObjModel, hrend.Framebuffer) {
|
||||
return o, texture
|
||||
}
|
||||
|
||||
// func loadDefault() (*hrend.ObjModel, hrend.Framebuffer) {
|
||||
// log.Printf("Loading obj %s, texture %s", ObjectFile, TextureFile)
|
||||
//
|
||||
// of, err := os.Open(ObjectFile)
|
||||
// must(err)
|
||||
// defer of.Close()
|
||||
// o, err := hrend.ParseObj(of)
|
||||
// must(err)
|
||||
//
|
||||
// jf, err := os.Open(TextureFile)
|
||||
// must(err)
|
||||
// defer jf.Close()
|
||||
// timg, _, err := image.Decode(jf)
|
||||
// must(err)
|
||||
// texture := hrend.NewTexture(timg, 4)
|
||||
//
|
||||
// return o, texture
|
||||
// }
|
||||
|
||||
// However flag works... idk
|
||||
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
|
||||
var width = flag.Int("width", 640, "width of window or frame")
|
||||
@ -154,6 +131,11 @@ func CameraInput(yaw, pitch float32) (float32, float32, hrend.Vec3f) {
|
||||
return yaw, pitch, newcamtrans
|
||||
}
|
||||
|
||||
// --------------------------------------------
|
||||
//
|
||||
// MAIN
|
||||
//
|
||||
// --------------------------------------------
|
||||
func main() {
|
||||
log.Printf("Program start")
|
||||
|
||||
@ -204,9 +186,9 @@ func main() {
|
||||
world := FlatTerrain(1)
|
||||
|
||||
// Generate skybox
|
||||
// skyraw := Gradient1px(color.RGBA{R: 100, G: 100, B: 255, A: 255}, color.RGBA{R: 255, G: 255, B: 255, A: 255}, 32)
|
||||
// skytex := hrend.NewTexture(skyraw, 1)
|
||||
// sky := Skybox()
|
||||
skyraw := Gradient1px(color.RGBA{R: 100, G: 100, B: 255, A: 255}, color.RGBA{R: 255, G: 255, B: 255, A: 255}, 32)
|
||||
skytex := hrend.NewTexture(skyraw, 1)
|
||||
sky := Skybox()
|
||||
|
||||
// Some static models we could put in the scene
|
||||
modnames := []string{"head", "diablo"}
|
||||
@ -219,13 +201,13 @@ func main() {
|
||||
// And the actual objects for the scene. We also put the world in there
|
||||
objects := make([]*ObjectDef, 0)
|
||||
objects = append(objects, NewObjectDef(world, wtex))
|
||||
// objects = append(objects, NewObjectDef(sky, skytex)) // the actual skybox
|
||||
// skyobj := objects[len(objects)-1]
|
||||
// skyobj.Scale = 50
|
||||
// skyobj.Lighting = false
|
||||
// objects = append(objects, NewObjectDef(models[1], textures[1]))
|
||||
// objects[len(objects)-1].Pos.Y += 1
|
||||
// objects[len(objects)-1].Pos.Z -= 2
|
||||
objects = append(objects, NewObjectDef(sky, skytex)) // the actual skybox
|
||||
skyobj := objects[len(objects)-1]
|
||||
skyobj.Scale = 50
|
||||
skyobj.Lighting = false
|
||||
objects = append(objects, NewObjectDef(models[1], textures[1]))
|
||||
objects[len(objects)-1].Pos.Y += 1
|
||||
objects[len(objects)-1].Pos.Z -= 2
|
||||
|
||||
// These don't really change
|
||||
var projection, viewport hrend.Mat44f
|
||||
@ -261,8 +243,6 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
//var osc [3]hrend.Vec3f
|
||||
//var om3d hrend.Mat44f
|
||||
var sc [3]hrend.Vertex
|
||||
var modelmat hrend.Mat44f
|
||||
var intensity float32
|
||||
@ -281,21 +261,9 @@ func main() {
|
||||
minz = min(minz, sc[i].Pos.Z)
|
||||
maxz = max(maxz, sc[i].Pos.Z)
|
||||
}
|
||||
// for i := range 3 {
|
||||
// if math.Signbit(float64(sc[i].Pos.X)) != math.Signbit(float64(osc[i].X)) ||
|
||||
// math.Signbit(float64(sc[i].Pos.Y)) != math.Signbit(float64(osc[i].Y)) {
|
||||
// log.Print(sc[0].Pos, sc[1].Pos, sc[2].Pos)
|
||||
// log.Print(matrix3d)
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
log.Print(o.Model.Faces[0][0].Pos, o.Model.Faces[0][1].Pos, o.Model.Faces[0][2].Pos)
|
||||
log.Print(sc[0].Pos, sc[1].Pos, sc[2].Pos)
|
||||
log.Print(matrix3d)
|
||||
// osc[0] = sc[0].Pos
|
||||
// osc[1] = sc[1].Pos
|
||||
// osc[2] = sc[2].Pos
|
||||
//om3d = *matrix3d
|
||||
//log.Print(sc[0].Pos, sc[1].Pos, sc[2].Pos, matrix3d)
|
||||
if o.Lighting {
|
||||
l1 := f[2].Pos.Sub(&f[0].Pos)
|
||||
@ -311,9 +279,10 @@ func main() {
|
||||
intensity = 1.0
|
||||
}
|
||||
hrend.TriangleTextured(&rb, o.Texture, intensity, sc[0], sc[1], sc[2])
|
||||
break
|
||||
break // only render one face
|
||||
//hrend.TriangleFlat(&rb, hrend.Col2Uint(byte(255*intensity), byte(255*intensity), byte(255*intensity)), sc[0].Pos, sc[1].Pos, sc[2].Pos)
|
||||
}
|
||||
break // only render one object
|
||||
}
|
||||
//log.Print(minz, maxz)
|
||||
|
||||
|
3
renderer2/runopengl21.sh
Executable file
3
renderer2/runopengl21.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
go build -tags opengl21 -o renderer
|
||||
./renderer
|
Loading…
Reference in New Issue
Block a user