本文整理匯總了Golang中github.com/0xe2-0x9a-0x9b/Go-SDL/sdl.SetVideoMode函數的典型用法代碼示例。如果您正苦於以下問題:Golang SetVideoMode函數的具體用法?Golang SetVideoMode怎麽用?Golang SetVideoMode使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了SetVideoMode函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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)
}
示例2: 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")
}
示例3: 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
}
}
}
}
示例4: 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}
}
示例5: 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)
}
示例6: 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)
}
示例7: 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)
}
示例8: 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
}
示例9: reinitScreen
func reinitScreen(width, height int) {
winWidth, winHeight = gl.Sizei(width), gl.Sizei(height)
if sdlScreen != nil {
sdlScreen.Free()
}
sdlScreen = sdl.SetVideoMode(width, height, 24, sdl.OPENGL|sdl.RESIZABLE)
if sdlScreen == nil {
panic("SDL video init error")
}
}
示例10: 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,
}
}
示例11: main
func main() {
sdl.Init(sdl.INIT_VIDEO)
sdl.SetVideoMode(800, 600, 32, sdl.OPENGL)
gl.Init()
gl.Enable(gl.DEPTH_TEST)
gl.Viewport(0, 0, 800, 600)
tick := time.Tick(time.Second / 50)
timer := 0.0
posbuf := gl.NewBuffer(gl.ARRAY_BUFFER, Vertices, gl.STATIC_DRAW)
prog, err := gl.MakeProgram([]string{vertexShader}, []string{fragmentShader})
if err != nil {
fmt.Println(err)
return
}
f, err := os.Open("glenda.png")
if err != nil {
fmt.Println(err)
return
}
img, _, err := image.Decode(f)
if err != nil {
fmt.Println(err)
return
}
tex := gl.NewTexture2D(img, 0)
for {
select {
case ev := <-sdl.Events:
if _, ok := ev.(sdl.QuitEvent); ok {
return
}
case <-tick:
gl.ClearColor(0, 0, 0, 1)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
prog.Use()
mat := gl.Mul4(gl.Frustum(45, 800./600, 0.01, 100), gl.Translate(0, 0, -8), gl.RotX(timer), gl.RotY(2*timer), gl.RotZ(3*timer))
prog.EnableAttrib("position", posbuf, 0, 3, 5, false)
prog.EnableAttrib("texcoord", posbuf, 3, 2, 5, false)
prog.SetUniform("tex", 0)
prog.SetUniform("matrix", mat)
tex.Enable(0, gl.TEXTURE_2D)
gl.DrawArrays(gl.TRIANGLE_STRIP, 0, len(Vertices)/5)
prog.DisableAttrib("position")
prog.Unuse()
sdl.GL_SwapBuffers()
timer += 1
}
}
}
示例12: 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
}
示例13: 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("")
}
示例14: 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
}
示例15: 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}
}