Exemplo n.º 1
0
func InitGL(width, height, msaa int, fullscreen bool) {
	C.SDL_Init(C.SDL_INIT_VIDEO)
	C.SDL_VideoInit( /*nil*/ C.SDL_GetVideoDriver(0))
	C.SDL_GL_SetAttribute(C.SDL_GL_CONTEXT_MAJOR_VERSION, 3)
	C.SDL_GL_SetAttribute(C.SDL_GL_CONTEXT_MINOR_VERSION, 2)

	if msaa != 0 {
		C.SDL_GL_SetAttribute(C.SDL_GL_MULTISAMPLEBUFFERS, 1)
		C.SDL_GL_SetAttribute(C.SDL_GL_MULTISAMPLESAMPLES, C.int(msaa))
	}

	C.SDL_GL_SetAttribute(C.SDL_GL_DEPTH_SIZE, 16)
	//win = C.SDL_CreateWindow(nil, C.SDL_WINDOWPOS_CENTERED, C.SDL_WINDOWPOS_CENTERED,C.int(width), C.int(height), C.SDL_WINDOW_OPENGL)
	if fullscreen {
		win = C.SDL_CreateWindow(nil, C.SDL_WINDOWPOS_CENTERED, C.SDL_WINDOWPOS_CENTERED, C.int(width), C.int(height), C.SDL_WINDOW_OPENGL|C.SDL_WINDOW_FULLSCREEN_DESKTOP)
	} else {
		win = C.SDL_CreateWindow(nil, C.SDL_WINDOWPOS_CENTERED, C.SDL_WINDOWPOS_CENTERED, C.int(width), C.int(height), C.SDL_WINDOW_OPENGL)
	}

	C.SDL_ShowWindow(win)
	wat := C.SDL_GL_CreateContext(win)
	fmt.Println(C.GoString(C.SDL_GetVideoDriver(0)))

	C.SDL_GL_MakeCurrent(win, wat)
	//C.SDL_GL_SetSwapInterval(1)

	C.glEnable(C.GL_DEPTH_TEST)
	C.glDepthFunc(C.GL_LEQUAL)

	C.glClearColor(0.3, 0.5, 1, 0)
	C.glClear(C.GL_COLOR_BUFFER_BIT | C.GL_DEPTH_BUFFER_BIT)
	printerr("failed to initialize openGL")

}
Exemplo n.º 2
0
Arquivo: video.go Projeto: salihdb/sdl
// VideoDriver returns the name of a built-in video driver.
func VideoDriver(index int) (driver string) {
	cDriver := C.SDL_GetVideoDriver(C.int(index))
	if cDriver == nil {
		return ""
	}
	return C.GoString(cDriver)
}
Exemplo n.º 3
0
func GetVideoDriver(index int) string {
	_index := (C.int)(index)
	return (string)(C.GoString(C.SDL_GetVideoDriver(_index)))
}
Exemplo n.º 4
0
func GetVideoDriver(i int) string {
	return C.GoString(C.SDL_GetVideoDriver(C.int(i)))
}
Exemplo n.º 5
0
// GetVideoDriver (https://wiki.libsdl.org/SDL_GetVideoDriver)
func GetVideoDriver(index int) string {
	return string(C.GoString(C.SDL_GetVideoDriver(C.int(index))))
}