Diablo default

This commit is contained in:
Carlos Sanchez 2024-08-02 16:15:10 -04:00
parent e384989cfc
commit 37ec57a83f

View File

@ -7,6 +7,7 @@ import (
"log" "log"
"math" "math"
"os" "os"
"path/filepath"
"renderer1/hrend" "renderer1/hrend"
"runtime/pprof" // For performance profiling (unnecessary) "runtime/pprof" // For performance profiling (unnecessary)
"time" "time"
@ -17,18 +18,18 @@ import (
) )
const ( const (
Width = 640 Width = 640
Height = 480 Height = 480
NearClip = 0.1 NearClip = 0.01
FarClip = 100 FarClip = 100
FOV = 90.0 FOV = 90.0
ZOffset = 1.5 ZOffset = 1.5
Movement = 1.0 Movement = 1.0
Rotation = 0.25 Rotation = 0.25
LookLock = math.Pi / 32 LookLock = math.Pi / 32
Fps = 60 Fps = 60
ObjectFile = "../head.obj" //ObjectFile = "../head.obj"
TextureFile = "../head.jpg" //TextureFile = "../head.jpg"
) )
func must(err error) { func must(err error) {
@ -38,15 +39,17 @@ func must(err error) {
} }
func loadDefault() (*hrend.ObjModel, hrend.Framebuffer) { func loadDefault() (*hrend.ObjModel, hrend.Framebuffer) {
log.Printf("Loading obj %s, texture %s", ObjectFile, TextureFile) ofile := filepath.Join("../", *model+".obj")
tfile := filepath.Join("../", *model+".jpg")
log.Printf("Loading obj %s, texture %s", ofile, tfile)
of, err := os.Open(ObjectFile) of, err := os.Open(ofile)
must(err) must(err)
defer of.Close() defer of.Close()
o, err := hrend.ParseObj(of) o, err := hrend.ParseObj(of)
must(err) must(err)
jf, err := os.Open(TextureFile) jf, err := os.Open(tfile)
must(err) must(err)
defer jf.Close() defer jf.Close()
timg, _, err := image.Decode(jf) timg, _, err := image.Decode(jf)
@ -58,6 +61,7 @@ func loadDefault() (*hrend.ObjModel, hrend.Framebuffer) {
// However flag works... idk // However flag works... idk
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file") var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
var model = flag.String("model", "diablo", "Which model to use (single name)")
// var dozbuf = flag.Bool("zbuffer", false, "Write zbuffer instead of image") // var dozbuf = flag.Bool("zbuffer", false, "Write zbuffer instead of image")
// var p6file = flag.String("p6file", "", "Output binary ppm to given file instead") // var p6file = flag.String("p6file", "", "Output binary ppm to given file instead")