コード例 #1
0
ファイル: specs.go プロジェクト: remogatto/clingon
func initTest() {
	if sdl.Init(sdl.INIT_VIDEO) != 0 {
		panic(sdl.GetError())
	}

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

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

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

	appSurface = sdl.SetVideoMode(appSurfaceW, appSurfaceH, 32, 0)
	gopher = sdl.Load("../testdata/gopher.jpg")

	sdlrenderer := clingon.NewSDLRenderer(sdl.CreateRGBSurface(sdl.SRCALPHA, int(consoleW), int(consoleH), 32, 0, 0, 0, 0), font)
	sdlrenderer.GetSurface().SetAlpha(sdl.SRCALPHA, 0xaa)

	newRenderingLoop(sdlrenderer)

	console = clingon.NewConsole(&Echoer{})
	console.SetRenderer(sdlrenderer)
	console.Print("Welcome to the CLIngon shell!\n\n")
}
コード例 #2
0
ファイル: sdl.go プロジェクト: remogatto/gospeccy
func newCLISurface(scale2x, fullscreen bool) *clingon.SDLRenderer {
	cliSurface := clingon.NewSDLRenderer(
		sdl.CreateRGBSurface(
			sdl.SRCALPHA,
			width(scale2x, fullscreen),
			height(scale2x, fullscreen)/2, 32, 0, 0, 0, 0),
		newFont(scale2x, fullscreen),
	)
	cliSurface.GetSurface().SetAlpha(sdl.SRCALPHA, 0xdd)
	return cliSurface
}
コード例 #3
0
ファイル: shell.go プロジェクト: remogatto/clingon
// Initialization boilerplate
func initialize(config *configuration) *renderer {
	var bgImage, appSurface *sdl.Surface

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

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

	font := ttf.OpenFont(flag.Arg(0), 12)

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

	sdl.EnableUNICODE(1)

	if config.fullscreen {
		flags := sdl.FULLSCREEN
		appSurface = sdl.SetVideoMode(640, 480, 32, uint32(flags))
		sdl.ShowCursor(sdl.DISABLE)
	} else {
		appSurface = sdl.SetVideoMode(640, 480, 32, 0)
	}
	if config.bgImage != "" {
		bgImage = sdl.Load(config.bgImage)
	}

	sdlrenderer = clingon.NewSDLRenderer(sdl.CreateRGBSurface(sdl.SRCALPHA, int(config.consoleW), int(config.consoleH), 32, 0, 0, 0, 0), font)
	sdlrenderer.GetSurface().SetAlpha(sdl.SRCALPHA, 0xaa)

	return &renderer{
		config:         config,
		appSurface:     appSurface,
		sdlRenderer:    sdlrenderer,
		bgImageSurface: bgImage,
	}
}