本文整理汇总了Golang中github.com/0xe2-0x9a-0x9b/Go-SDL/sdl.GetError函数的典型用法代码示例。如果您正苦于以下问题:Golang GetError函数的具体用法?Golang GetError怎么用?Golang GetError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: initSDL
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)
}
开发者ID:robert-dale-schell,项目名称:clingon,代码行数:32,代码来源:sdlrenderer_benchmark_test.go
示例2: main
func main() {
if sdl.Init(sdl.INIT_VIDEO) != 0 {
panic(sdl.GetError())
}
defer sdl.Quit()
screen := sdl.SetVideoMode(400, 300, 32, 0)
if screen == nil {
panic(sdl.GetError())
}
sdl.WM_SetCaption("Template", "")
ticker := time.NewTicker(1e9 / 2 /*2 Hz*/)
loop:
for {
select {
case <-ticker.C:
// Note: For better efficiency, use UpdateRects instead of Flip
screen.FillRect(nil /*color*/, rand.Uint32())
//screen.Blit(&sdl.Rect{x,y, 0, 0}, image, nil)
screen.Flip()
case event := <-sdl.Events:
fmt.Printf("%#v\n", event)
switch event.(type) {
case sdl.QuitEvent:
break loop
}
}
}
}
开发者ID:Chownie,项目名称:-LPC--Farm-Sim,代码行数:35,代码来源:main.go
示例3: main
func main() {
if sdl.Init(sdl.INIT_VIDEO) < 0 {
fmt.Printf(
"Video initialization failed: %s\n",
sdl.GetError())
quit_tutorial(1)
}
info := sdl.GetVideoInfo()
if info == nil {
fmt.Printf(
"Video query failed: %s\n",
sdl.GetError())
quit_tutorial(1)
}
width := 640
height := 480
bpp := int(info.Vfmt.BitsPerPixel)
sdl.GL_SetAttribute(sdl.GL_RED_SIZE, 5)
sdl.GL_SetAttribute(sdl.GL_GREEN_SIZE, 5)
sdl.GL_SetAttribute(sdl.GL_BLUE_SIZE, 5)
sdl.GL_SetAttribute(sdl.GL_DEPTH_SIZE, 16)
sdl.GL_SetAttribute(sdl.GL_DOUBLEBUFFER, 1)
flags := uint32(sdl.OPENGL | sdl.FULLSCREEN)
if sdl.SetVideoMode(width, height, bpp, flags) == nil {
fmt.Printf("Video mode set failed: %s\n", sdl.GetError())
quit_tutorial(1)
}
setup_opengl(width, height)
for {
process_events()
draw_screen()
}
os.Exit(0)
}
开发者ID:glenn-brown,项目名称:aima,代码行数:34,代码来源:sdldoc.go
示例4: main
func main() {
if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
panic(sdl.GetError())
}
defer sdl.Quit()
screen := sdl.SetVideoMode(640, 480, 32, sdl.SWSURFACE)
if screen == nil {
panic(sdl.GetError())
}
sdl.WM_SetCaption("Hello World", "test.png")
message := load_image("hello.bmp")
background := load_image("background.bmp")
apply_surface(0, 0, background, screen)
apply_surface(320, 0, background, screen)
apply_surface(0, 240, background, screen)
apply_surface(320, 240, background, screen)
apply_surface(180, 140, message, screen)
message.Free()
background.Free()
screen.Flip()
sdl.Delay(2000)
}
开发者ID:pakohan,项目名称:sdl-tutorial,代码行数:31,代码来源:main.go
示例5: newSDL2xScreen
func newSDL2xScreen(fullScreen bool) *sdl2xScreen {
sdlMode := uint32(sdl.SWSURFACE)
if fullScreen {
application.Logf("%s", "Activate fullscreen mode")
sdlMode = sdl.FULLSCREEN
sdl.ShowCursor(sdl.DISABLE)
}
screenSurface := &sdlSurface{sdl.SetVideoMode(SCREEN_WIDTH*2, SCREEN_HEIGHT*2, 32, sdlMode)}
if screenSurface.surface == nil {
log.Printf("%s", sdl.GetError())
application.Exit()
return nil
}
borderSurface := &sdlSurface{sdl.CreateRGBSurface(sdl.SWSURFACE, SCREEN_WIDTH*2, SCREEN_HEIGHT*2, 32, 0, 0, 0, 0)}
if borderSurface.surface == nil {
log.Printf("%s", sdl.GetError())
application.Exit()
return nil
}
displaySurface := &sdlSurface{sdl.CreateRGBSurface(sdl.SWSURFACE, DISPLAY_WIDTH*2, DISPLAY_HEIGHT*2, 32, 0, 0, 0, 0)}
if displaySurface.surface == nil {
log.Printf("%s", sdl.GetError())
application.Exit()
return nil
}
return &sdl2xScreen{screenSurface, borderSurface, displaySurface}
}
开发者ID:cocoa-alex,项目名称:sms,代码行数:27,代码来源:sdl.go
示例6: initTest
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")
}
开发者ID:remogatto,项目名称:clingon,代码行数:27,代码来源:specs.go
示例7: LoadImage
func LoadImage(name string) *sdl.Surface {
image := sdl.Load(name)
if image == nil {
panic(sdl.GetError())
}
return image
}
开发者ID:Chownie,项目名称:-LPC--Farm-Sim,代码行数:7,代码来源:atlas.go
示例8: Init
func (v *Video) Init(t <-chan []int, d <-chan []int, n string) {
if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
log.Fatal(sdl.GetError())
}
v.screen = sdl.SetVideoMode(512, 480, 32, 0)
if v.screen == nil {
log.Fatal(sdl.GetError())
}
sdl.WM_SetCaption(fmt.Sprintf("Fergulator - %s", n), "")
v.tick = t
v.debug = d
}
开发者ID:samnardoni,项目名称:Fergulator,代码行数:16,代码来源:video.go
示例9: NewSDLRenderer
func NewSDLRenderer(surface *sdl.Surface, font *ttf.Font) *SDLRenderer {
renderer := &SDLRenderer{
Color: sdl.Color{255, 255, 255, 0},
visibleSurface: surface,
Font: font,
eventCh: make(chan interface{}),
updatedRectsCh: make(chan []sdl.Rect),
updatedRects: make([]sdl.Rect, 0),
width: uint(surface.W),
height: uint(surface.H),
}
fontWidth, fontHeight, err := font.SizeText("A")
if err != 0 {
panic("failed to determine font dimensions: " + sdl.GetError())
}
renderer.fontWidth = uint(fontWidth)
renderer.fontHeight = uint(fontHeight)
renderer.lastVisibleLine = (renderer.height / renderer.fontHeight) * MAX_INTERNAL_SIZE_FACTOR
renderer.internalSurfaceHeight = uint(renderer.fontHeight)
renderer.internalSurfaceMaxHeight = renderer.height * MAX_INTERNAL_SIZE_FACTOR
renderer.internalSurface = sdl.CreateRGBSurface(sdl.SWSURFACE,
int(renderer.width), int(renderer.internalSurfaceHeight), 32, 0, 0, 0, 0)
renderer.calcCommandLineRect()
renderer.updatedRects = append(renderer.updatedRects, sdl.Rect{0, 0, uint16(renderer.width), uint16(renderer.height)})
go renderer.loop()
return renderer
}
开发者ID:robert-dale-schell,项目名称:clingon,代码行数:35,代码来源:sdlrenderer.go
示例10: Draw_Init
func Draw_Init() {
if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
fmt.Println(sdl.GetError())
}
//screen = sdl.SetVideoMode(sw, sh, 32, sdl.OPENGL)
screen = sdl.SetVideoMode(sw, sh, 32, sdl.RESIZABLE)
if screen == nil {
return
}
var video_info = sdl.GetVideoInfo()
fmt.Println("HW_available = ", video_info.HW_available)
fmt.Println("WM_available = ", video_info.WM_available)
fmt.Println("Video_mem = ", video_info.Video_mem, "kiB")
surface = sdl.CreateRGBSurface(sdl.HWSURFACE, 500, 500, 32, rmask,
gmask, bmask, amask)
surface.FillRect(nil, 0xff00ff00)
surfaceb = sdl.CreateRGBSurface(sdl.HWSURFACE, 500, 500, 32, rmask,
gmask, bmask, amask)
surfaceb.FillRect(nil, 0xffff0000)
}
开发者ID:MerlijnWajer,项目名称:Gollision,代码行数:26,代码来源:draw.go
示例11: StartGraphics
func StartGraphics(id uint32, update chan *State, move chan MoveMsg, quit chan bool) error {
var err error
rc := sdl.Init(sdl.INIT_VIDEO)
if rc == -1 {
return errors.New(sdl.GetError())
}
disp := sdl.SetVideoMode(800, 600, 32, sdl.OPENGL)
if disp == nil {
return errors.New(sdl.GetError())
}
winscale = gl.Mul4(gl.Translate(-1, 1, 0), gl.Scale(1./400, -1./300, 1))
gl.Init()
gl.ClearColor(1, 1, 1, 1)
s := new(State)
ls := time.Now()
quadBuf = gl.NewBuffer(gl.ARRAY_BUFFER, quadData, gl.STATIC_DRAW)
prog, err = gl.MakeProgram([]string{vertexShader}, []string{fragmentShader})
if err != nil {
log.Fatal(err)
}
AddTex("glenda", "glenda.png")
AddTex("tux", "tux.png")
i := image.NewRGBA(image.Rect(0, 0, 800, 600))
texs["black"] = gl.NewTexture2D(i, 0)
tick := time.Tick(time.Second / 50)
squit := make(chan bool)
go ProcessInput(move, quit, squit)
for {
select {
case s = <-update:
ls = time.Now()
case <-tick:
s.Advance(time.Now().Sub(ls))
ls = time.Now()
gl.Clear(gl.COLOR_BUFFER_BIT)
RenderScene(s)
sdl.GL_SwapBuffers()
case <-squit:
return nil
}
}
return nil
}
开发者ID:aiju,项目名称:killer-rabbit,代码行数:45,代码来源:graphics.go
示例12: newSDLSurface
func newSDLSurface(w, h int) *sdlSurface {
surface := sdl.CreateRGBSurface(sdl.SWSURFACE, w, h, 32, 0, 0, 0, 0)
if surface == nil {
log.Printf("%s", sdl.GetError())
application.Exit()
return nil
}
return &sdlSurface{surface}
}
开发者ID:cocoa-alex,项目名称:sms,代码行数:9,代码来源:sdl.go
示例13: sdlInit
func sdlInit(width, height int32) *sdl.Surface {
var surface = sdl.SetVideoMode(int(width), int(height), 32, sdl.RESIZABLE)
if surface == nil {
panic(sdl.GetError())
}
return surface
}
开发者ID:radekp,项目名称:alfi,代码行数:9,代码来源:main.go
示例14: load_image
func load_image(filename string) *sdl.Surface {
loadedImage := sdl.Load(filename)
if loadedImage == nil {
panic(sdl.GetError())
}
optimizedImage := loadedImage.DisplayFormat()
loadedImage.Free()
return optimizedImage
}
开发者ID:pakohan,项目名称:sdl-tutorial,代码行数:11,代码来源:main.go
示例15: NewRacer
func NewRacer(levelDir string) (*Racer, error) {
r := &Racer{cars: make([]*Car, 0)}
var err error
if r.obstaclemap, err = LoadImageGray(filepath.Join(levelDir, "velocity.png")); err != nil {
return nil, err
}
if r.heightmap, err = LoadImageGray(filepath.Join(levelDir, "z.png")); err != nil {
return nil, err
}
carSize := 0.02 * float32(screenWidth)
if r.spriteCarFG, err = NewSprite("data/cars/car1/fg.png", carSize, carSize); err != nil {
return nil, err
}
if r.spriteCarBG, err = NewSprite("data/cars/car1/bg.png", carSize, carSize); err != nil {
return nil, err
}
r.carSize = carSize
if r.spriteForeground, err = NewSprite(filepath.Join(levelDir, "foreground.png"), screenWidth, screenHeight); err != nil {
return nil, err
}
if r.spriteBackground, err = NewSprite(filepath.Join(levelDir, "background.png"), screenWidth, screenHeight); err != nil {
return nil, err
}
if r.music = mixer.LoadMUS("data/music.ogg"); r.music == nil {
return nil, errors.New(sdl.GetError())
}
if r.font = ttf.OpenFont("data/font.otf", 32); r.font == nil {
return nil, errors.New(sdl.GetError())
}
textWaiting := ttf.RenderUTF8_Blended(r.font, "Waiting for other players. Press space to start....", sdl.Color{0, 0, 255, 0})
r.spriteWaiting = NewSpriteFromSurface(textWaiting)
return r, nil
}
开发者ID:mfpi,项目名称:lecture-hall-games,代码行数:41,代码来源:racer.go
示例16: newSDLUnscaledScreen
func newSDLUnscaledScreen() *sdlUnscaledScreen {
screenSurface := &sdlSurface{sdl.SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, sdl.SWSURFACE)}
if screenSurface.surface == nil {
log.Printf("%s", sdl.GetError())
application.Exit()
return nil
}
borderSurface := &sdlSurface{sdl.CreateRGBSurface(sdl.SWSURFACE, SCREEN_WIDTH, SCREEN_HEIGHT, 32, 0, 0, 0, 0)}
if borderSurface.surface == nil {
log.Printf("%s", sdl.GetError())
application.Exit()
return nil
}
displaySurface := &sdlSurface{sdl.CreateRGBSurface(sdl.SWSURFACE, DISPLAY_WIDTH, DISPLAY_HEIGHT, 32, 0, 0, 0, 0)}
if displaySurface.surface == nil {
log.Printf("%s", sdl.GetError())
application.Exit()
return nil
}
return &sdlUnscaledScreen{screenSurface, borderSurface, displaySurface}
}
开发者ID:cocoa-alex,项目名称:sms,代码行数:21,代码来源:sdl.go
示例17: initialize
// 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,
}
}
开发者ID:remogatto,项目名称:clingon,代码行数:41,代码来源:shell.go
示例18: main
func main() {
iWidth := int32(WIDTH)
iHeight := int32(HEIGHT)
var screen = sdl.SetVideoMode(int(iWidth), int(iHeight), 32, sdl.RESIZABLE)
if screen == nil {
log.Fatal(sdl.GetError())
}
iIterationNr := 0
iIterations := int(math.Min(float64(333333), float64((WIDTH)*(HEIGHT))))
iStartNS := time.Now().UnixNano()
//mainloop:
for {
var iX int32
var iY int32
var iColor uint32
for i := 0; i < iIterations; i++ {
iX = rand.Int31() % (iWidth)
iY = rand.Int31() % (iHeight)
iColor = rand.Uint32()
iColor &= 0x00ffffff
iColor += 0x88000000
draw_point(iX, iY, iColor, screen)
//break mainloop;
}
screen.Flip()
iIterationNr++
if iIterationNr%99 == 0 {
iIterationNS := time.Now().UnixNano()
iDeltaNS := iIterationNS - iStartNS
nDeltaS := float64(iDeltaNS) / float64(1000000000)
nFPS := float64(iIterationNr) / nDeltaS
fmt.Printf("fps: %v\n", nFPS)
fmt.Printf("%v x %v\n", screen.W, screen.H)
}
}
base.Dump("")
}
开发者ID:ramanamaharshi,项目名称:my_go_stuff,代码行数:47,代码来源:main.go
示例19: main
func main() {
verbose := flag.Bool("verbose", false, "verbose mode")
debug := flag.Bool("debug", false, "debug mode")
fullScreen := flag.Bool("fullscreen", false, "go fullscreen")
help := flag.Bool("help", false, "Show usage")
flag.Usage = usage
flag.Parse()
if *help {
usage()
return
}
application.Verbose = *verbose
application.Debug = *debug
if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
log.Fatal(sdl.GetError())
}
screen := newSDL2xScreen(*fullScreen)
sdlLoop := newSDLLoop(screen)
emulatorLoop := newEmulatorLoop(sdlLoop)
if emulatorLoop == nil {
usage()
return
}
commandLoop := newCommandLoop(emulatorLoop, sdlLoop)
inputLoop := newInputLoop(emulatorLoop.sms)
application.Register("Emulator loop", emulatorLoop)
application.Register("Command loop", commandLoop)
application.Register("SDL render loop", sdlLoop)
application.Register("SDL input loop", inputLoop)
exitCh := make(chan bool)
application.Run(exitCh)
<-exitCh
sdl.Quit()
}
开发者ID:Sas0ri,项目名称:sms,代码行数:40,代码来源:main.go
示例20: main
func main() {
// Use all processors
runtime.GOMAXPROCS(runtime.NumCPU())
// SDL voodoo
if sdl.Init(sdl.INIT_VIDEO) != 0 {
panic(sdl.GetError())
}
defer sdl.Quit()
if ttf.Init() != 0 {
panic(sdl.GetError())
}
defer ttf.Quit()
screen := sdl.SetVideoMode(640, 480, 32, sdl.ANYFORMAT)
if screen == nil {
panic(sdl.GetError())
}
screen.SetAlpha(sdl.SRCALPHA, 255)
sdl.WM_SetCaption("Connect Four", "")
ticker := time.NewTicker(time.Second / 60 /*60 Hz*/)
// Make some pipes for communicating with the game logic
moveReady := make(chan int)
newState := make(chan c4.State)
nextMove := make(chan int)
gameResults := make(chan c4.Piece)
var winner c4.Piece
var game c4.State
waitingForMove := false
gameOver := false
// Get ready to write text
font := ttf.OpenFont("DroidSans.ttf", 36)
var line1, line2 *sdl.Surface
showMessage := false
// Start a game
startGame := func() {
c4.RunGame(
SDLHuman{moveReady, nextMove},
c4.AlphaBetaAI{
c4.Black,
8,
func(game c4.State, p c4.Piece) float64 {
// Evolved solution:
// return c4.EvalFactors{
// 0.2502943943301069,
// -0.4952316649483701,
// 0.3932539700819625,
// -0.2742452616759889,
// 0.4746881137884282,
// 0.2091091127191147}.Eval(game, p)
// Least mean squares solution after 2 iterations against evolved solution:
return c4.EvalFactors{
0.32386133725050104, 0.5490470895311659, 0.3932539698522742, -0.27424526114286796, 0.4746881136468789, 0.2091091126568151}.Eval(game, p)
},
func(game c4.State) bool {
return game.GetWinner() != c4.None
},
},
NewUpdater(newState),
func(err error) {
fmt.Println(err)
},
func(winner c4.Piece) {
if winner == c4.Red {
gameResults <- c4.Red
} else if winner == c4.Black {
gameResults <- c4.Black
} else {
gameResults <- c4.None
}
})
}
go startGame()
loop:
for {
select {
case <-ticker.C:
screen.FillRect(
&sdl.Rect{0, 0, SCREEN_WIDTH, SCREEN_HEIGHT},
BOARD_COLOR)
for col := 0; col < c4.MaxColumns; col++ {
for row := 0; row < c4.MaxRows; row++ {
drawPiece(screen, col, row, game.GetPiece(col, row))
}
}
if showMessage {
screen.Blit(
&sdl.Rect{
int16(SCREEN_WIDTH/2 - line1.W/2),
int16(SCREEN_HEIGHT/2 - line1.H),
0,
0},
line1,
//.........这里部分代码省略.........
开发者ID:TJSomething,项目名称:cs773c-connect4-minimax,代码行数:101,代码来源:main.go
注:本文中的github.com/0xe2-0x9a-0x9b/Go-SDL/sdl.GetError函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论