Пример #1
0
func CreateCtx(flags createFlags) (*Context, error) {
	ctx := C.nvgCreateGL3((C.int)(flags))
	if ctx == nil {
		return nil, errors.New("cannot create nanovg context")
	}

	return &Context{ctx}, nil
}
Пример #2
0
func Init() {
	if vg != nil {
		panic("blendish: already initialized")
	}
	C.glewExperimental = C.GL_TRUE
	if C.glewInit() != C.GLEW_OK {
		log.Fatalln("blendish: could not init glew (GL extensions)")
	}
	// GLEW generates GL error because it calls
	// glGetString(GL_EXTENSIONS), we'll consume it here.
	C.glGetError()
	vg = C.nvgCreateGL3(C.NVG_ANTIALIAS | C.NVG_STENCIL_STROKES)

	fontPath := C.CString(filepath.Join(dirs[0], "DejaVuSans.ttf"))
	iconsPath := C.CString(filepath.Join(dirs[0], "blender_icons16.png"))
	sys := C.CString("system")
	defer C.free(unsafe.Pointer(fontPath))
	defer C.free(unsafe.Pointer(iconsPath))
	defer C.free(unsafe.Pointer(sys))
	C.bndSetFont(C.nvgCreateFont(vg, sys, fontPath))
	C.bndSetIconImage(C.nvgCreateImage(vg, iconsPath, 0))
}