本文整理汇总了Golang中github.com/0xe2-0x9a-0x9b/Go-SDL/sdl.GetError函数的典型用法代码示例。如果您正苦于以下问题:Golang GetError函数的具体用法?Golang GetError怎么用?Golang GetError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
}
示例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
}
}
}
}
示例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)
}
示例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)
}
示例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}
}
示例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")
}
示例7: LoadImage
func LoadImage(name string) *sdl.Surface {
image := sdl.Load(name)
if image == nil {
panic(sdl.GetError())
}
return image
}
示例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
}
示例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
}
示例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)
}
示例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
}
示例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}
}
示例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
}
示例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
}
示例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
}