Пример #1
0
func serverMain() {
	cfgFilePath, err := assets.Locate(cfgFileName)
	if err != nil {
		tlog.Fatal("Cannot locate configuration file: ", err)
	}
	cfg, err := readConfigFile(cfgFilePath)
	if err != nil {
		tlog.Fatal("Cannot read configuration file: ", err)
	}

	hdm := hdm.NewHdm(cfg)
	space := hdm.NewSpace()

	textFile := nex.Path(nexsys.GetFileNex("main.go"), nexsys.TextFile)
	space.NewSurf().Add(textFile).Expand(100, nex.TopType)
	space.NewSurf().Add(parse.Parse("main.go")).Expand(100, nex.TopType)

	dir := "."
	ndir := nexsys.GetFileNex(dir)
	space.NewSurf().Add(ndir).Expand(2, nex.TopType)
	recursiveAddFile(space, ndir)

	netServer := netserv.NewServer(hdm.MasterChan())
	netServer.Start()
}
Пример #2
0
func Start(windowName string) error {
	err := llgl.InitDisplay(windowName)
	if err != nil {
		return err
	}
	err = llgl.InitGL()
	if err != nil {
		return err
	}

	glstate.program, err = loadShaders("cube.vert", "cube.frag")
	if err != nil {
		return err
	}
	glstate.program.Use()

	glstate.projectionUL = glstate.program.Uniform("projection")
	glstate.cameraUL = glstate.program.Uniform("camera")
	glstate.modelUL = glstate.program.Uniform("model")
	glstate.texUL = glstate.program.Uniform("tex")

	state.camera = mgl.LookAtV(mgl.Vec3{3, 3, 3}, mgl.Vec3{0, 0, 0}, mgl.Vec3{0, 1, 0})
	state.model = mgl.Ident4()

	glstate.cameraUL.SetMat4(state.camera)
	glstate.modelUL.SetMat4(state.model)
	glstate.texUL.SetTextureSlot(0)

	glstate.program.BindFragDataLocation(0, "outputColor")

	texturePath, err := assets.Locate("code.png")
	if err != nil {
		return err
	}
	texture, err := llgl.MakeTexture(0, texturePath)
	if err != nil {
		return err
	}
	texture.Bind(0)

	// Configure the vertex data
	vao := llgl.NewVertexArray()
	vao.Bind()

	glstate.vbo = llgl.NewVertexBuffer()
	glstate.vbo.Bind()

	val := glstate.program.VertexAttrib("vert")
	val.Enable()
	val.PointerFloat32(3, 5, 0)

	valTC := glstate.program.VertexAttrib("vertTexCoord")
	valTC.Enable()
	valTC.PointerFloat32(2, 5, 3)

	fpsCounter = NewFpsCounter()
	return nil
}