Beispiel #1
0
func SetVideoMode(width int, height int, bpp int, flags int) {
	screen := C.SDL_SetVideoMode(C.int(width), C.int(height), C.int(bpp), C.Uint32(flags))

	if screen == nil {
		panic("unable to set video mode")
	}
}
Beispiel #2
0
// Sets up a video mode with the specified width, height, bits-per-pixel and
// returns a corresponding surface.  You don't need to call the Free method
// of the returned surface, as it will be done automatically by sdl.Quit.
func SetVideoMode(w int, h int, bpp int, flags uint32) *Surface {
	GlobalMutex.Lock()
	var screen = C.SDL_SetVideoMode(C.int(w), C.int(h), C.int(bpp), C.Uint32(flags))
	currentVideoSurface = wrap(screen)
	GlobalMutex.Unlock()
	return currentVideoSurface
}
Beispiel #3
0
func mainLoop(width, height int) {
	// SDL window must be created in the same thread where the events are
	// polled. Hence this stuff must be in a separate goroutine along with the
	// event loop.

	initFlags := int64(C.SDL_INIT_VIDEO) | int64(C.SDL_INIT_AUDIO)
	screenFlags := 0

	if C.SDL_Init(C.Uint32(initFlags)) == C.int(-1) {
		panic(getError())
	}

	screen := C.SDL_SetVideoMode(
		C.int(width), C.int(height), 32, C.Uint32(screenFlags))
	if screen == nil {
		panic(getError())
	}
	C.SDL_EnableUNICODE(1)
	C.SDL_EnableKeyRepeat(C.SDL_DEFAULT_REPEAT_DELAY, C.SDL_DEFAULT_REPEAT_INTERVAL)

	initAudio()

	// Synchronize with Run function.
	coord <- true

	eventLoop()
	C.SDL_Quit()

	// Synchronize with Stop function.
	coord <- true
	runLevel = off
}
Beispiel #4
0
func SetVideoMode(width, height, bitsPerPixel int, flags SurfaceFlags) (Surface, error) {
	c_width := C.int(width)
	c_height := C.int(height)
	c_bpp := C.int(bitsPerPixel)
	c_flags := C.Uint32(flags)
	ret := C.SDL_SetVideoMode(c_width, c_height, c_bpp, c_flags)
	if ret == nil {
		return Surface{}, GetError()
	}
	return Surface{unsafe.Pointer(ret)}, nil
}
Beispiel #5
0
func NewDisplay(title string, width, height int) (*Display, error) {
	d := Display{frame: make(chan *C.AVFrame)}
	d.width = C.int(width)
	d.height = C.int(height)
	d.screen = C.SDL_SetVideoMode(d.width, d.height, 0, 0)
	d.overlay = C.SDL_CreateYUVOverlay(d.width, d.height, C.SDL_IYUV_OVERLAY, d.screen)
	t := C.CString(title)
	C.SDL_WM_SetCaption(t, (*C.char)(null))
	C.free(unsafe.Pointer(t))
	return &d, nil
}
Beispiel #6
0
// Sets up a video mode with the specified width, height, bits-per-pixel and
// returns a corresponding surface.  You don't need to call the Free method
// of the returned surface, as it will be done automatically by sdl.Quit.
func SetVideoMode(w int, h int, bpp int, flags uint32) *Surface {
	var screen = C.SDL_SetVideoMode(C.int(w), C.int(h), C.int(bpp), C.Uint32(flags))
	return (*Surface)(cast(screen))
}
Beispiel #7
0
// Set up a video mode with the specified width, height and bits-per-pixel.
//
// If 'bpp' is 0, it is treated as the current display bits per pixel.
//
// If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the
// requested bits-per-pixel, but will return whatever video pixel format is
// available.  The default is to emulate the requested pixel format if it
// is not natively available.
//
// If SDL_HWSURFACE is set in 'flags', the video surface will be placed in
// video memory, if possible, and you may have to call SDL_LockSurface()
// in order to access the raw framebuffer.  Otherwise, the video surface
// will be created in system memory.
//
// If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle
// updates asynchronously, but you must always lock before accessing pixels.
// SDL will wait for updates to complete before returning from the lock.
//
// If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee
// that the colors set by SDL_SetColors() will be the colors you get.
// Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all
// of the colors exactly the way they are requested, and you should look
// at the video surface structure to determine the actual palette.
// If SDL cannot guarantee that the colors you request can be set,
// i.e. if the colormap is shared, then the video surface may be created
// under emulation in system memory, overriding the SDL_HWSURFACE flag.
//
// If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set
// a fullscreen video mode.  The default is to create a windowed mode
// if the current graphics system has a window manager.
// If the SDL library is able to set a fullscreen video mode, this flag
// will be set in the surface that is returned.
//
// If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up
// two surfaces in video memory and swap between them when you call
// SDL_Flip().  This is usually slower than the normal single-buffering
// scheme, but prevents "tearing" artifacts caused by modifying video
// memory while the monitor is refreshing.  It should only be used by
// applications that redraw the entire screen on every update.
//
// If SDL_RESIZABLE is set in 'flags', the SDL library will allow the
// window manager, if any, to resize the window at runtime.  When this
// occurs, SDL will send a SDL_VIDEORESIZE event to you application,
// and you must respond to the event by re-calling SDL_SetVideoMode()
// with the requested size (or another size that suits the application).
//
// If SDL_NOFRAME is set in 'flags', the SDL library will create a window
// without any title bar or frame decoration.  Fullscreen video modes have
// this flag set automatically.
//
// This function returns the video framebuffer surface, or NULL if it fails.
//
// If you rely on functionality provided by certain video flags, check the
// flags of the returned surface to make sure that functionality is available.
// SDL will fall back to reduced functionality if the exact flags you wanted
// are not available.
func setVideoMode(width, height, bpp int, flags uint32) *C.SDL_Surface {
	return C.SDL_SetVideoMode(C.int(width), C.int(height),
		C.int(bpp), C.Uint32(flags))
}