func initSDL() {
	if sdl.Init(sdl.INIT_VIDEO) != 0 {
		panic(sdl.GetError())
	}

	if ttf.Init() != 0 {
		panic(sdl.GetError())
	}

	font := ttf.OpenFont("testdata/VeraMono.ttf", 20)

	if font == nil {
		panic(sdl.GetError())
	}

	appSurface = sdl.SetVideoMode(640, 480, 32, 0)
	sdlrenderer = NewSDLRenderer(sdl.CreateRGBSurface(sdl.SRCALPHA, 640, 480, 32, 0, 0, 0, 0), font)
	sdlrenderer.GetSurface().SetAlpha(sdl.SRCALPHA, 0xaa)
	console = NewConsole(nil)

	go func() {
		for {
			select {
			case rects := <-sdlrenderer.UpdatedRectsCh():
				render(rects)
			}

		}
	}()

	render(nil)
}
Exemplo n.º 2
0
func newFont(scale2x, fullscreen bool) *ttf.Font {
	if fullscreen {
		scale2x = true
	}

	var font *ttf.Font
	{
		path, err := spectrum.FontPath("VeraMono.ttf")
		if err != nil {
			panic(err.Error())
		}
		if scale2x {
			font = ttf.OpenFont(path, 12)
		} else {
			font = ttf.OpenFont(path, 10)
		}
		if font == nil {
			panic(sdl.GetError())
		}
	}

	return font
}