本文整理汇总了Golang中github.com/veandco/go-sdl2/sdl.GetError函数的典型用法代码示例。如果您正苦于以下问题:Golang GetError函数的具体用法?Golang GetError怎么用?Golang GetError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Init
func Init(width, height int32) *Engine {
window, err := sdl.CreateWindow("test", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
int(width), int(height), sdl.WINDOW_SHOWN)
if err != nil {
fmt.Fprint(os.Stderr, "Failed to create window", sdl.GetError())
os.Exit(1)
}
renderer, err := sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED|sdl.RENDERER_PRESENTVSYNC)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create renderer: %s\n", sdl.GetError())
os.Exit(2)
}
img.Init(0)
ttf.Init()
return &Engine{
Window: window,
Renderer: renderer,
Running: true,
width: width,
height: height,
entities: make([]Drawable, 0),
}
}
开发者ID:stephenbinns,项目名称:ein,代码行数:27,代码来源:engine.go
示例2: start
func start() {
if sdl.Init(sdl.INIT_AUDIO) < 0 {
fmt.Fprintf(os.Stderr, "Failed to init:", sdl.GetError())
os.Exit(1)
}
window = sdl.CreateWindow("test", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
int(W), int(H), sdl.WINDOW_SHOWN)
if window == nil {
fmt.Fprintf(os.Stderr, "Failed to create window: %s\n", sdl.GetError())
os.Exit(1)
}
renderer = sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED|sdl.RENDERER_PRESENTVSYNC)
if renderer == nil {
fmt.Fprintf(os.Stderr, "Failed to create renderer: %s\n", sdl.GetError())
os.Exit(1)
}
mix.SetSoundFonts("resources/")
if !mix.OpenAudio(44100, mix.DEFAULT_FORMAT, 2, 2048) {
fmt.Fprintf(os.Stderr, "Failed to open audio:%s\n", sdl.GetError())
os.Exit(1)
}
}
开发者ID:EvanTheB,项目名称:SDLGame,代码行数:26,代码来源:21sound.go
示例3: main
func main() {
var window *sdl.Window
var renderer *sdl.Renderer
var event sdl.Event
var running bool
window = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
winWidth, winHeight, sdl.WINDOW_SHOWN)
if window == nil {
fmt.Fprintf(os.Stderr, "Failed to create window: %s\n", sdl.GetError())
os.Exit(1)
}
renderer = sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
if renderer == nil {
fmt.Fprintf(os.Stderr, "Failed to create renderer: %s\n", sdl.GetError())
os.Exit(2)
}
var peepArray []sdl.Event = make([]sdl.Event, 5)
running = true
for running {
sdl.PumpEvents()
numEventsRetrieved := sdl.PeepEvents(peepArray, sdl.PEEKEVENT, sdl.FIRSTEVENT, sdl.LASTEVENT)
if numEventsRetrieved < 0 {
fmt.Printf("PeepEvents error: %s\n", sdl.GetError())
} else {
for i := 0; i < numEventsRetrieved; i++ {
fmt.Printf("Event Peeked Value: %v\n", peepArray[i]) // primitive printing of event
}
}
for event = sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
switch t := event.(type) {
case *sdl.QuitEvent:
running = false
case *sdl.MouseMotionEvent:
fmt.Printf("[%d ms] MouseMotion\ttype:%d\tid:%d\tx:%d\ty:%d\txrel:%d\tyrel:%d\n",
t.Timestamp, t.Type, t.Which, t.X, t.Y, t.XRel, t.YRel)
case *sdl.MouseButtonEvent:
fmt.Printf("[%d ms] MouseButton\ttype:%d\tid:%d\tx:%d\ty:%d\tbutton:%d\tstate:%d\n",
t.Timestamp, t.Type, t.Which, t.X, t.Y, t.Button, t.State)
case *sdl.MouseWheelEvent:
fmt.Printf("[%d ms] MouseWheel\ttype:%d\tid:%d\tx:%d\ty:%d\n",
t.Timestamp, t.Type, t.Which, t.X, t.Y)
case *sdl.KeyUpEvent:
fmt.Printf("[%d ms] Keyboard\ttype:%d\tsym:%c\tmodifiers:%d\tstate:%d\trepeat:%d\n",
t.Timestamp, t.Type, t.Keysym.Sym, t.Keysym.Mod, t.State, t.Repeat)
}
}
sdl.Delay(1000 / 30)
}
renderer.Destroy()
window.Destroy()
}
开发者ID:emlai,项目名称:go-sdl2,代码行数:57,代码来源:PeepEvents_peek.go
示例4: main
func main() {
var window *sdl.Window
var renderer *sdl.Renderer
var points []sdl.Point
var rect sdl.Rect
var rects []sdl.Rect
window = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
winWidth, winHeight, sdl.WINDOW_SHOWN)
if window == nil {
fmt.Fprintf(os.Stderr, "Failed to create window: %s\n", sdl.GetError())
os.Exit(1)
}
renderer = sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
if renderer == nil {
fmt.Fprintf(os.Stderr, "Failed to create renderer: %s\n", sdl.GetError())
os.Exit(2)
}
renderer.SetDrawColor(255, 255, 255, 255)
renderer.DrawPoint(150, 300)
renderer.SetDrawColor(0, 0, 255, 255)
renderer.DrawLine(0, 0, 200, 200)
points = []sdl.Point{{0, 0}, {100, 300}, {100, 300}, {200, 0}}
renderer.SetDrawColor(255, 255, 0, 255)
renderer.DrawLines(points)
rect = sdl.Rect{300, 0, 200, 200}
renderer.SetDrawColor(255, 0, 0, 255)
renderer.DrawRect(&rect)
rects = []sdl.Rect{{400, 400, 100, 100}, {550, 350, 200, 200}}
renderer.SetDrawColor(0, 255, 255, 255)
renderer.DrawRects(rects)
rect = sdl.Rect{250, 250, 200, 200}
renderer.SetDrawColor(0, 255, 0, 255)
renderer.FillRect(&rect)
rects = []sdl.Rect{{500, 300, 100, 100}, {200, 300, 200, 200}}
renderer.SetDrawColor(255, 0, 255, 255)
renderer.FillRects(rects)
renderer.Present()
sdl.Delay(2000)
renderer.Destroy()
window.Destroy()
}
开发者ID:JalfResi,项目名称:go-sdl2,代码行数:53,代码来源:render.go
示例5: Start
func Start(windowText string, W, H int) (*sdl.Window, *sdl.Renderer) {
window, err := sdl.CreateWindow(windowText, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
W, H, sdl.WINDOW_SHOWN)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create window: %s\n", sdl.GetError())
os.Exit(1)
}
renderer, err := sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED|sdl.RENDERER_PRESENTVSYNC)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create renderer: %s\n", sdl.GetError())
os.Exit(1)
}
return window, renderer
}
开发者ID:EvanTheB,项目名称:SDLGame,代码行数:14,代码来源:graphics.go
示例6: main
func main() {
var window *sdl.Window
var renderer *sdl.Renderer
var event sdl.Event
var running bool
window = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
winWidth, winHeight, sdl.WINDOW_SHOWN)
if window == nil {
fmt.Fprintf(os.Stderr, "Failed to create window: %s\n", sdl.GetError())
os.Exit(1)
}
renderer = sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
if renderer == nil {
fmt.Fprintf(os.Stderr, "Failed to create renderer: %s\n", sdl.GetError())
os.Exit(2)
}
running = true
for running {
event = sdl.WaitEventTimeout(1000) // wait here until an event is in the event queue
if event == nil {
fmt.Println("WaitEventTimeout timed out")
continue
}
switch t := event.(type) {
case *sdl.QuitEvent:
running = false
case *sdl.MouseMotionEvent:
fmt.Printf("[%d ms] MouseMotion\ttype:%d\tid:%d\tx:%d\ty:%d\txrel:%d\tyrel:%d\n",
t.Timestamp, t.Type, t.Which, t.X, t.Y, t.XRel, t.YRel)
case *sdl.MouseButtonEvent:
fmt.Printf("[%d ms] MouseButton\ttype:%d\tid:%d\tx:%d\ty:%d\tbutton:%d\tstate:%d\n",
t.Timestamp, t.Type, t.Which, t.X, t.Y, t.Button, t.State)
case *sdl.MouseWheelEvent:
fmt.Printf("[%d ms] MouseWheel\ttype:%d\tid:%d\tx:%d\ty:%d\n",
t.Timestamp, t.Type, t.Which, t.X, t.Y)
case *sdl.KeyUpEvent:
fmt.Printf("[%d ms] Keyboard\ttype:%d\tsym:%c\tmodifiers:%d\tstate:%d\trepeat:%d\n",
t.Timestamp, t.Type, t.Keysym.Sym, t.Keysym.Mod, t.State, t.Repeat)
}
}
renderer.Destroy()
window.Destroy()
}
开发者ID:emlai,项目名称:go-sdl2,代码行数:48,代码来源:WaitEventTimeout.go
示例7: SetMusicPosition
// SetMusicPosition
// (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_65.html)
func SetMusicPosition(position int64) error {
_position := (C.double)(position)
if C.Mix_SetMusicPosition(_position) == -1 {
return sdl.GetError()
}
return nil
}
开发者ID:4gophers,项目名称:go-sdl2,代码行数:9,代码来源:sdl_mixer.go
示例8: NewWindowedWindow
func NewWindowedWindow(title string, width, height int) Window {
// FOR GLFW event handling
runtime.LockOSThread()
windowSDL, err := sdl.CreateWindow(title, sdl.WINDOWPOS_UNDEFINED,
sdl.WINDOWPOS_UNDEFINED,
width, height, sdl.WINDOW_OPENGL)
if err != nil {
panic(err)
}
if windowSDL == nil {
panic(sdl.GetError())
}
context, err := sdl.GL_CreateContext(windowSDL)
sdl.GL_MakeCurrent(windowSDL, context)
if err != nil {
panic("Error loading window: " + err.Error())
}
w := Window{title: title, Width: width, Height: height, full: false, windowSDL: windowSDL, contextSDL: context, running: false}
w.init()
var current sdl.DisplayMode
if err := sdl.GetCurrentDisplayMode(0, ¤t); err != nil {
fmt.Println("COuld not get display mode: " + err.Error())
}
fmt.Printf("Display #%d: current display mode is %dx%dpx @ %dhz. \n", 0, current.W, current.H, current.RefreshRate)
return w
}
开发者ID:xladykiller,项目名称:GT,代码行数:33,代码来源:window.go
示例9: Init
func Init(flags int) error {
initted := int(C.Mix_Init(C.int(flags)))
if initted&flags != flags {
return sdl.GetError()
}
return nil
}
开发者ID:4gophers,项目名称:go-sdl2,代码行数:7,代码来源:sdl_mixer.go
示例10: main
func main() {
var window *sdl.Window
var renderer *sdl.Renderer
var texture *sdl.Texture
var src, dst sdl.Rect
window = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
winWidth, winHeight, sdl.WINDOW_SHOWN)
if window == nil {
fmt.Fprintf(os.Stderr, "Failed to create window: %s\n", sdl.GetError())
os.Exit(1)
}
renderer = sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
if renderer == nil {
fmt.Fprintf(os.Stderr, "Failed to create renderer: %s\n", sdl.GetError())
os.Exit(2)
}
image := img.Load(imageName)
if image == nil {
fmt.Fprintf(os.Stderr, "Failed to load PNG: %s\n", sdl.GetError())
os.Exit(3)
}
texture = renderer.CreateTextureFromSurface(image)
if texture == nil {
fmt.Fprintf(os.Stderr, "Failed to create texture: %s\n", sdl.GetError())
os.Exit(4)
}
src = sdl.Rect{0, 0, 512, 512}
dst = sdl.Rect{100, 50, 512, 512}
renderer.Clear()
renderer.SetDrawColor(255, 0, 0, 255)
renderer.FillRect(&sdl.Rect{0, 0, int32(winWidth), int32(winHeight)})
renderer.Copy(texture, &src, &dst)
renderer.Present()
sdl.Delay(2000)
image.Free()
texture.Destroy()
renderer.Destroy()
window.Destroy()
}
开发者ID:JalfResi,项目名称:go-sdl2,代码行数:47,代码来源:texture_png.go
示例11: loadTexture
func loadTexture(path string) *sdl.Texture {
bmp := img.Load(path)
if bmp == nil {
fmt.Fprintf(os.Stderr, "Unable to load image %s! SDL Error: %s\n", path, img.GetError())
} else {
if bmp.SetColorKey(1, sdl.Color{0xFF, 0xFF, 0x00, 0xFF}.Uint32()) != 0 {
fmt.Fprintf(os.Stderr, "Unable to set Color Key %s! SDL Error: %s\n", path, sdl.GetError())
}
texture := renderer.CreateTextureFromSurface(bmp)
if texture == nil {
fmt.Fprintf(os.Stderr, "Unable to create texture %s! SDL Error: %s\n", path, sdl.GetError())
}
bmp.Free()
return texture
}
return nil
}
开发者ID:EvanTheB,项目名称:SDLGame,代码行数:17,代码来源:21sound.go
示例12: Play
// Play (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_57.html)
func (music *Music) Play(loops int) error {
_music := (*C.Mix_Music)(unsafe.Pointer(music))
_loops := (C.int)(loops)
if C.Mix_PlayMusic(_music, _loops) == -1 {
return sdl.GetError()
}
return nil
}
开发者ID:4gophers,项目名称:go-sdl2,代码行数:9,代码来源:sdl_mixer.go
示例13: LoadTextureTransparent
func LoadTextureTransparent(renderer *sdl.Renderer, path string, r, g, b uint8) *sdl.Texture {
bmp, err := img.Load(path)
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to load image %s! SDL Error: %s\n", path, img.GetError())
} else {
if bmp.SetColorKey(1, sdl.MapRGB(bmp.Format, r, g, b)) != 0 {
fmt.Fprintf(os.Stderr, "Unable to set Color Key %s! SDL Error: %s\n", path, sdl.GetError())
}
texture, err := renderer.CreateTextureFromSurface(bmp)
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to create texture %s! SDL Error: %s\n", path, sdl.GetError())
}
bmp.Free()
return texture
}
return nil
}
开发者ID:EvanTheB,项目名称:SDLGame,代码行数:17,代码来源:graphics.go
示例14: SetMusicCMD
// SetMusicCMD
// (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_66.html)
func SetMusicCMD(command string) error {
_command := C.CString(command)
defer C.free(unsafe.Pointer(_command))
if C.Mix_SetMusicCMD(_command) == -1 {
return sdl.GetError()
}
return nil
}
开发者ID:4gophers,项目名称:go-sdl2,代码行数:10,代码来源:sdl_mixer.go
示例15: SetDistance
// SetDistance
// (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_81.html)
func SetDistance(channel int, distance uint8) error {
_channel := (C.int)(channel)
_distance := (C.Uint8)(distance)
if (C.Mix_SetDistance(_channel, _distance)) == 0 {
return sdl.GetError()
}
return nil
}
开发者ID:4gophers,项目名称:go-sdl2,代码行数:10,代码来源:sdl_mixer.go
示例16: SdlError
func SdlError() {
fmt.Println("errtest", counter)
counter = counter + 1
err := sdl.GetError()
if err != nil {
panic(err)
}
}
开发者ID:krux02,项目名称:turnt-octo-wallhack,代码行数:8,代码来源:main.go
示例17: SetReverseStereo
// SetReverseStereo
// (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_83.html)
func SetReverseStereo(channel, flip int) error {
_channel := (C.int)(channel)
_flip := (C.int)(flip)
if (C.Mix_SetReverseStereo(_channel, _flip)) == 0 {
return sdl.GetError()
}
return nil
}
开发者ID:4gophers,项目名称:go-sdl2,代码行数:10,代码来源:sdl_mixer.go
示例18: QuickLoad_WAV
func QuickLoad_WAV(mem unsafe.Pointer) (chunk *Chunk, err error) {
_mem := (*C.Uint8)(mem)
chunk = (*Chunk)(unsafe.Pointer(C.Mix_QuickLoad_WAV(_mem)))
if chunk == nil {
err = sdl.GetError()
}
return
}
开发者ID:flazz,项目名称:go-sdl2,代码行数:8,代码来源:sdl_mixer.go
示例19: main
func main() {
var winTitle string = "Go-SDL2 + Go-GL"
var winWidth, winHeight int = 800, 600
var window *sdl.Window
var context sdl.GLContext
var event sdl.Event
var running bool
if 0 != sdl.Init(sdl.INIT_EVERYTHING) {
panic(sdl.GetError())
}
window = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
winWidth, winHeight, sdl.WINDOW_OPENGL)
if window == nil {
panic(sdl.GetError())
}
context = sdl.GL_CreateContext(window)
if context == nil {
panic(sdl.GetError())
}
gl.Enable(gl.DEPTH_TEST)
gl.ClearColor(0.2, 0.2, 0.3, 1.0)
gl.ClearDepth(1)
gl.DepthFunc(gl.LEQUAL)
gl.Viewport(0, 0, int32(winWidth), int32(winHeight))
running = true
for running {
for event = sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
switch t := event.(type) {
case *sdl.QuitEvent:
running = false
case *sdl.MouseMotionEvent:
fmt.Printf("[%d ms] MouseMotion\tid:%d\tx:%d\ty:%d\txrel:%d\tyrel:%d\n", t.Timestamp, t.Which, t.X, t.Y, t.XRel, t.YRel)
}
}
drawgl()
sdl.GL_SwapWindow(window)
}
sdl.GL_DeleteContext(context)
window.Destroy()
sdl.Quit()
}
开发者ID:JalfResi,项目名称:go-sdl2,代码行数:45,代码来源:opengl.go
示例20: LoadMUS_RW
func LoadMUS_RW(src *sdl.RWops, freesrc int) (mus *Music, err error) {
_src := (*C.SDL_RWops)(unsafe.Pointer(src))
_freesrc := (C.int)(freesrc)
mus = (*Music)(unsafe.Pointer(C.Mix_LoadMUS_RW(_src, _freesrc)))
if mus == nil {
err = sdl.GetError()
}
return
}
开发者ID:flazz,项目名称:go-sdl2,代码行数:9,代码来源:sdl_mixer.go
注:本文中的github.com/veandco/go-sdl2/sdl.GetError函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论