예제 #1
0
파일: window.go 프로젝트: anthonyrego/gosmf
// blitScreen swaps the buffers and clears the screen
func (window *Screen) blitScreen() {
	C.SDL_GL_SwapWindow(window.sdlWindow)
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	window.elapsedTime = time.Since(window.frameTime).Seconds()
	window.frameTime = time.Now()
}
예제 #2
0
파일: window.go 프로젝트: anthonyrego/gosmf
// New returns a newly created Screen
func New(width int, height int, fullscreen bool, FSAA int, name string) *Screen {
	window := &Screen{}

	C.SDL_Init(C.SDL_INIT_VIDEO)
	C.setGlContextAttributes()

	C.SDL_GL_SetAttribute(C.SDL_GL_DOUBLEBUFFER, 1)

	// Force hardware accel
	C.SDL_GL_SetAttribute(C.SDL_GL_ACCELERATED_VISUAL, 1)

	if FSAA > 0 {
		// FSAA (Fullscreen antialiasing)
		C.SDL_GL_SetAttribute(C.SDL_GL_MULTISAMPLEBUFFERS, 1)
		C.SDL_GL_SetAttribute(C.SDL_GL_MULTISAMPLESAMPLES, C.int(FSAA)) // 2, 4, 8
	}

	flags := C.SDL_WINDOW_OPENGL | C.SDL_RENDERER_ACCELERATED
	if fullscreen {
		flags = flags | C.SDL_WINDOW_FULLSCREEN
	}

	C.SDL_CreateWindowAndRenderer(C.int(width), C.int(height), C.Uint32(flags), &window.sdlWindow, &window.renderer)
	C.SDL_SetWindowTitle(window.sdlWindow, C.CString(name))
	C.SDL_GL_CreateContext(window.sdlWindow)

	if err := gl.Init(); err != nil {
		panic(err)
	}
	version := gl.GoStr(gl.GetString(gl.VERSION))
	fmt.Println("OpenGL version", version)

	// Configure global settings
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)

	gl.ClearColor(0.0, 0.0, 0.0, 1.0)
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	window.Width = width
	window.Height = height
	window.name = name
	window.shouldClose = false
	C.SDL_GL_SwapWindow(window.sdlWindow)

	window.startTime = time.Now()
	window.frameTime = time.Now()
	C.SDL_GL_SetSwapInterval(1)
	window.vsync = true

	return window
}
예제 #3
0
파일: video.go 프로젝트: krig/Go-SDL2
// Swaps OpenGL framebuffers/Update Display.
func (w *Window) GL_SwapWindow() {
	C.SDL_GL_SwapWindow(w.cWindow)
}
예제 #4
0
파일: gl.go 프로젝트: henkman/Go2D
func GL_SwapWindow(_win *Window) {
	C.SDL_GL_SwapWindow(_win.window)
}
예제 #5
0
func GL_SwapWindow(window *Window) {
	_window := (*C.SDL_Window)(unsafe.Pointer(window))
	C.SDL_GL_SwapWindow(_window)
}
예제 #6
0
파일: video.go 프로젝트: DeedleFake/sdl
func (win *Window) GL_Swap() {
	C.SDL_GL_SwapWindow(win.c)
}
예제 #7
0
파일: video.go 프로젝트: flazz/go-sdl2
// GL_SwapWindow (https://wiki.libsdl.org/SDL_GL_SwapWindow)
func GL_SwapWindow(window *Window) {
	C.SDL_GL_SwapWindow(window.cptr())
}
예제 #8
0
func Flip() {
	C.SDL_GL_SwapWindow(win)
}
예제 #9
0
파일: sdl.go 프로젝트: kalaspuffar/Go-SDL2
// Swaps OpenGL framebuffers/Update Display.
func (w *Window) GL_SwapWindow() {
	GlobalMutex.Lock()
	C.SDL_GL_SwapWindow(w.cWindow)
	GlobalMutex.Unlock()
}