当前位置: 首页>>代码示例>>Golang>>正文


Golang sdl.GetError函数代码示例

本文整理汇总了Golang中sdl.GetError函数的典型用法代码示例。如果您正苦于以下问题:Golang GetError函数的具体用法?Golang GetError怎么用?Golang GetError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

//=================================
//Initialize Lortet
//=================================
func main() {
	//INIT SDL
	if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
		panic(sdl.GetError())
	}

	screen = sdl.SetVideoMode(SCREENWIDTH, SCREENHEIGHT, BPP, sdl.SWSURFACE)
	if screen == nil {
		panic(sdl.GetError())
	}

	sdl.WM_SetCaption("MapMaker", "")

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

	font = ttf.OpenFont("../Fontin Sans.otf", 15)

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

	objects = ScreenObjects{}

	//Load Media
	IM = LoadImages()

	MainLoop()

	ExitProgram()
}
开发者ID:zozor,项目名称:Cecils-Adventure,代码行数:35,代码来源:main.go

示例2: main

func main() {
	if sdl.Init(sdl.INIT_VIDEO) < 0 {
		panic("Video initialization failed: " + sdl.GetError())
	}

	if sdl.EnableKeyRepeat(100, 25) != 0 {
		panic("Setting keyboard repeat failed: " + sdl.GetError())
	}

	videoFlags := sdl.OPENGL    // Enable OpenGL in SDL
	videoFlags |= sdl.DOUBLEBUF // Enable double buffering
	videoFlags |= sdl.HWPALETTE // Store the palette in hardware
	// FIXME: this causes segfault.
	// videoFlags |= sdl.RESIZABLE // Enable window resizing

	surface = sdl.SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, uint32(videoFlags))

	if surface == nil {
		panic("Video mode set failed: " + sdl.GetError())
	}

	sdl.GL_SetAttribute(sdl.GL_DOUBLEBUFFER, 1)
	initGL()
	resizeWindow(SCREEN_WIDTH, SCREEN_HEIGHT)

	SetupWorld("data/world.txt")

	// wait for events
	running := true
	isActive := true
	for running {
		for ev := sdl.PollEvent(); ev != nil; ev = sdl.PollEvent() {
			switch e := ev.(type) {
			case *sdl.ActiveEvent:
				isActive = e.Gain != 0
			case *sdl.ResizeEvent:
				width, height := int(e.W), int(e.H)
				surface = sdl.SetVideoMode(width, height, SCREEN_BPP, uint32(videoFlags))
				if surface == nil {
					fmt.Println("Could not get a surface after resize:", sdl.GetError())
					Quit(1)
				}
				resizeWindow(width, height)
			case *sdl.KeyboardEvent:
				if e.Type == sdl.KEYDOWN {
					handleKeyPress(e.Keysym)
				}
			case *sdl.QuitEvent:
				running = false
			}
		}

		// draw the scene
		if isActive {
			drawGLScene(sector1)
		}
	}
}
开发者ID:PragmaticCypher,项目名称:opengl-go-tutorials,代码行数:58,代码来源:lesson10.go

示例3: main

func main() {
	if sdl.Init(sdl.INIT_VIDEO) != 0 {
		fmt.Println(sdl.GetError())
		return
	}
	defer sdl.Quit()

	if sdl.SetVideoMode(200, 200, 32, 0) == nil {
		fmt.Println(sdl.GetError())
		return
	}

	for e := new(sdl.Event); e.Wait() && e.Type != sdl.QUIT; {
	}
}
开发者ID:travis1230,项目名称:RosettaCodeData,代码行数:15,代码来源:window-creation-2.go

示例4: loadMusic

func loadMusic(path string) *mixer.Music {
	load := mixer.LoadMUS(path)
	if load == nil {
		panic(sdl.GetError())
	}
	return load
}
开发者ID:zozor,项目名称:Cecils-Adventure,代码行数:7,代码来源:main.go

示例5: loadSound

func loadSound(path string) *mixer.Chunk {
	load := mixer.LoadWAV(path)
	if load == nil {
		panic(sdl.GetError())
	}
	return load
}
开发者ID:zozor,项目名称:Cecils-Adventure,代码行数:7,代码来源:main.go

示例6: loadImage

func loadImage(path string) *sdl.Surface {
	loaded := sdl.Load(path)

	if loaded == nil {
		panic(sdl.GetError())
	}
	defer loaded.Free()
	return sdl.DisplayFormat(loaded)
}
开发者ID:zozor,项目名称:Cecils-Adventure,代码行数:9,代码来源:main.go

示例7: loadImage

func loadImage(name string) *sdl.Surface {
	image := sdl.Load(name)

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

	return image

}
开发者ID:jgastal,项目名称:Go-SDL,代码行数:10,代码来源:template.go

示例8: main

func main() {

	flag.Parse()

	var done bool
	var keys []uint8

	sdl.Init(sdl.INIT_VIDEO)

	var screen = sdl.SetVideoMode(640, 480, 16, sdl.OPENGL|sdl.RESIZABLE)

	if screen == nil {
		sdl.Quit()
		panic("Couldn't set 300x300 GL video mode: " + sdl.GetError() + "\n")
	}

	sdl.WM_SetCaption("Gears", "gears")

	init_()
	reshape(int(screen.W), int(screen.H))
	done = false
	for !done {
		var event sdl.Event

		idle()
		for event.Poll() {
			switch event.Type {
			case sdl.VIDEORESIZE:
				screen = sdl.SetVideoMode(int(event.Resize().W), int(event.Resize().H), 16,
					sdl.OPENGL|sdl.RESIZABLE)
				if screen != nil {
					reshape(int(screen.W), int(screen.H))
				} else {
					panic("we couldn't set the new video mode??")
				}
				break

			case sdl.QUIT:
				done = true
				break
			}
		}
		keys = sdl.GetKeyState()

		handleKeyPress(keys)
		if keys[sdl.K_ESCAPE] != 0 {
			done = true
		}

		draw()
	}
	sdl.Quit()
	return

}
开发者ID:yohcop,项目名称:cubopolis.go,代码行数:55,代码来源:main.go

示例9: LoadGLTexture

// Load bitmap from path as GL texture
func LoadGLTexture(path string) {
	image := sdl.Load(path)
	if image == nil {
		panic(sdl.GetError())
	}

	// Check that the image's width is a power of 2
	if image.W&(image.W-1) != 0 {
		fmt.Println("warning:", path, "has a width that is not a power of 2")
	}

	// Also check if the height is a power of 2
	if image.H&(image.H-1) != 0 {
		fmt.Println("warning:", path, "has an height that is not a power of 2")
	}

	// get the number of channels in the SDL surface
	nOfColors := image.Format.BytesPerPixel
	var textureFormat gl.GLenum

	if nOfColors == 4 { // contains alpha channel
		if image.Format.Rmask == 0x000000ff {
			textureFormat = gl.RGBA
		} else {
			textureFormat = gl.BGRA
		}
	} else if nOfColors == 3 { // no alpha channel
		if image.Format.Rmask == 0x000000ff {
			textureFormat = gl.RGB
		} else {
			textureFormat = gl.BGR
		}
	} else {
		fmt.Println("warning:", path, "is not truecolor, this will probably break")
	}

	texture = gl.GenTexture()

	// Typical texture generation using data from the bitmap
	gl.BindTexture(gl.TEXTURE_2D, uint(texture))

	// Generate the texture
	gl.TexImage2D(gl.TEXTURE_2D, 0, int(image.Format.BytesPerPixel),
		int(image.W), int(image.H),
		0, textureFormat, gl.UNSIGNED_BYTE, image.Pixels,
	)

	// linear filtering
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)

	// free up memory we have used.
	image.Free()
}
开发者ID:PragmaticCypher,项目名称:opengl-go-tutorials,代码行数:55,代码来源:lesson09.go

示例10: resize

func resize(width int, height int) {
	screen = sdl.SetVideoMode(width, height, 32, sdl.RESIZABLE)
	if screen == nil {
		panic(sdl.GetError())
	}

	gridSizePixels := min(width, height)
	cellSize = gridSizePixels / gridSize
	offsetX = (width - gridSizePixels) / 2
	offsetY = (height - gridSizePixels) / 2
}
开发者ID:thejoshwolfe,项目名称:blokus,代码行数:11,代码来源:main.go

示例11: main

func main() {

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

	var screen = sdl.SetVideoMode(640, 480, 32, 0)

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

	sdl.WM_SetCaption("Template", "")

	running := true

	for running {

		e := &sdl.Event{}

		for e.Poll() {
			switch e.Type {
			case sdl.QUIT:
				running = false
				break
			default:
			}
		}

		screen.FillRect(nil, 0x000000)

		//screen.Blit(&sdl.Rect{x,y, 0, 0}, image, nil)

		screen.Flip()
		sdl.Delay(25)

	}

	sdl.Quit()

}
开发者ID:Daminvar,项目名称:Go-SDL,代码行数:41,代码来源:template.go

示例12: initinc

func initinc() error {
	if initnum == 0 {
		errn := sdl.Init(sdl.INIT_VIDEO)
		if errn < 0 {
			return errors.New(sdl.GetError())
		}
	}

	initnum++

	return nil
}
开发者ID:GunioRobot,项目名称:Go-SDL,代码行数:12,代码来源:gui.go

示例13: NewFont

func NewFont(_file string, _size int) *PU_Font {
	sdlfont := sdl.LoadFont(_file, _size)
	if sdlfont == nil {
		fmt.Printf("Error loading Font: %v", sdl.GetError())
	}
	f := &PU_Font{font: sdlfont,
		fontmap: make(map[uint32]map[uint16]*PU_Image),
		color:   &sdl.Color{255, 255, 255, 255},
		alpha:   255,
		size:    _size}
	f.Build()
	return f
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:13,代码来源:font.go

示例14: NewFont

//Load font from file and specify font size (each font-size needs a seperate font instance)
func NewFont(_file string, _size int) *Font {
	sdlfont := sdl.LoadFont(_file, _size)
	if sdlfont == nil {
		fmt.Printf("Go2D Error: Loading Font: %v", sdl.GetError())
	}
	f := &Font{font: sdlfont,
		fontmap: make(map[uint32]map[uint16]*Image),
		color:   &sdl.Color{255, 255, 255, 255},
		alpha:   255,
		size:    _size}
	addResource(f)
	f.build()
	return f
}
开发者ID:WaylandGod,项目名称:Go2D,代码行数:15,代码来源:font.go

示例15: main

func main() {
	fmt.Println("loaded", len(blokus.Tiles), "shapes")
	blokus.Board[2][4] = blokus.Red
	if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
		panic(sdl.GetError())
	}
	resize(640, 480)
	sdl.WM_SetCaption("Blokus", "")

	for running {
		e := &sdl.Event{}

		for e.Poll() {
			switch e.Type {
			case sdl.QUIT:
				running = false
			case sdl.KEYDOWN:
				keyDown(e.Keyboard())
			case sdl.KEYUP:
				keyUp(e.Keyboard())
			case sdl.MOUSEBUTTONDOWN:
				mouseDown(e.MouseButton())
			case sdl.VIDEORESIZE:
				r := e.Resize()
				resize(int(r.W), int(r.H))
			default:
			}
			if !running {
				break
			}
		}

		draw()

		sdl.Delay(25)
	}

	sdl.Quit()
}
开发者ID:thejoshwolfe,项目名称:blokus,代码行数:39,代码来源:main.go


注:本文中的sdl.GetError函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。