Exemplo n.º 1
0
func (self *AppStateManager) FPSMouseMode(on bool) {
	self.FPSMouseModeEnabled = on
	if on {
		sdl.ShowCursor(0)
	} else {
		sdl.ShowCursor(1)
	}
}
Exemplo n.º 2
0
func (self *MCPlayAppState) Setup(manager *glutils.AppStateManager) {
	self.Manager = manager

	self.Camera = glutils.NewCamera(glutils.GetViewport())
	self.Camera.SetFrustrumProjection(60, 0.01, 200)

	self.Controller = glutils.NewFpsController(self.Camera)
	self.Controller.Pos = v.Vector3f{0, 0, -30}

	self.gameState = state.NewGameState()

	self.gameState.ObjectManager.SetRenderer(state.NewRenderContext(self.Camera))

	var err error
	if self.shader, err = glutils.GetProgram(
		"shaders/blob.vertex",
		"shaders/blob.fragment"); err != nil {
		panic(err.Error())
	}
	self.bindFunc = func(prog *glutils.ShaderProgram) {
		prog.GetUniform("light0_direction").Uniform3f(0, -1, 0)
	}

	self.gameState.CreatePlayer()

	sdl.ShowCursor(1)
}
Exemplo n.º 3
0
func main() {
	if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
		panic(sdl.GetError())
	}

	// The actual resolution (screenspace)
	W := 800
	H := 600

	// The virtual resolution (worldspace)
	MAXX := 400
	MAXY := 300

	screen := sdl.SetVideoMode(W, H, 32, sdl.FULLSCREEN)
	if screen == nil {
		panic(sdl.GetError())
	}
	sdl.EnableUNICODE(1)
	sdl.ShowCursor(0)

	sdl.WM_SetCaption("Random Lines", "")

	red := sdl.Color{255, 0, 0, 255}
	color := red

	rand.Seed(time.Now().UnixNano())

	for {
		color = sdl.Color{uint8(rand.Intn(255)), uint8(rand.Intn(255)), uint8(rand.Intn(255)), 255}
		DoublePixelLine(screen, rand.Intn(MAXX), rand.Intn(MAXY), rand.Intn(MAXX), rand.Intn(MAXY), color)
		if escPressed() {
			break
		}
		screen.Flip()
		sdl.PollEvent()
		//sdl.Delay(10)
	}

	sdl.Quit()
}