예제 #1
0
func createMainWindow() {
	var err error
	var mainWindow *sdl.Window

	gc := gamecontext.GContext
	gc.WindowWidth = 800
	gc.WindowHeight = 600

	mainWindow, err = sdl.CreateWindow("Eggdrop!", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, int(gc.WindowWidth), int(gc.WindowHeight), sdl.WINDOW_SHOWN)
	if err != nil {
		panic(err)
	}

	gc.MainSurface, err = mainWindow.GetSurface()
	if err != nil {
		panic(err)
	}

	gc.PixelFormatEnum, err = mainWindow.GetPixelFormat()
	if err != nil {
		panic(err)
	}

	gc.PixelFormat, err = sdl.AllocFormat(uint(gc.PixelFormatEnum)) // TODO why the cast? Seems to work?
	if err != nil {
		panic(err)
	}

	gc.MainWindow = mainWindow
}