示例#1
0
文件: video.go 项目: DeedleFake/sdl
func (win *Window) GL_MakeCurrent(ctx GLContext) error {
	if C.SDL_GL_MakeCurrent(win.c, ctx.c()) != 0 {
		return getError()
	}

	return nil
}
示例#2
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")

}
示例#3
0
func GL_MakeCurrent(window *Window, glcontext GLContext) int {
	_window := (*C.SDL_Window)(unsafe.Pointer(window))
	_glcontext := (C.SDL_GLContext)(glcontext)
	return (int)(C.SDL_GL_MakeCurrent(_window, _glcontext))
}
示例#4
0
文件: video.go 项目: flazz/go-sdl2
// GL_MakeCurrent (https://wiki.libsdl.org/SDL_GL_MakeCurrent)
func GL_MakeCurrent(window *Window, glcontext GLContext) error {
	if C.SDL_GL_MakeCurrent(window.cptr(), C.SDL_GLContext(glcontext)) != 0 {
		return GetError()
	}
	return nil
}
示例#5
0
文件: video.go 项目: JalfResi/go-sdl2
func GL_MakeCurrent(window *Window, glcontext GLContext) int {
	return int(C.SDL_GL_MakeCurrent(window.cptr(), C.SDL_GLContext(glcontext)))
}