// CreateWindowAndRenderer (https://wiki.libsdl.org/SDL_CreateWindowAndRenderer) func CreateWindowAndRenderer(w, h int, flags uint32) (*Window, *Renderer, error) { var window *C.SDL_Window var renderer *C.SDL_Renderer ret := C.SDL_CreateWindowAndRenderer(C.int(w), C.int(h), C.Uint32(flags), &window, &renderer) if ret == -1 { return nil, nil, GetError() } return (*Window)(unsafe.Pointer(window)), (*Renderer)(unsafe.Pointer(renderer)), nil }
func CreateWindowAndRenderer(h, w int, flags uint32) (*Window, *Renderer) { var win Window var rend Renderer C.SDL_CreateWindowAndRenderer(C.int(h), C.int(w), C.Uint32(flags), &win.cWindow, &rend.cRenderer) return &win, &rend }
func CreateWindowAndRenderer(w, h int, flags WindowFlags) (*Window, *Renderer, error) { var win *C.SDL_Window var r *C.SDL_Renderer if C.SDL_CreateWindowAndRenderer(C.int(w), C.int(h), C.Uint32(flags), &win, &r) != 0 { return nil, nil, getError() } return &Window{win}, &Renderer{r}, nil }
func CreateWindowAndRenderer(h, w int, flags uint32) (*Window, *Renderer) { var win Window var rend Renderer GlobalMutex.Lock() defer GlobalMutex.Unlock() C.SDL_CreateWindowAndRenderer(C.int(h), C.int(w), C.Uint32(flags), &win.cWindow, &rend.cRenderer) return &win, &rend }
// 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 }
func CreateWindowAndRenderer(w, h int, flags uint32) (*Window, *Renderer) { var window *C.SDL_Window var renderer *C.SDL_Renderer C.SDL_CreateWindowAndRenderer(C.int(w), C.int(h), C.Uint32(flags), &window, &renderer) return (*Window)(unsafe.Pointer(window)), (*Renderer)(unsafe.Pointer(renderer)) }