示例#1
0
func CreateContext(win window.Window) {
	dpy := win.GetHDC()

	xData := (*XWinData)(dpy)

	if xData == nil {
		//TODO: Handle error somehow ???
		return
	}

	//attr := make([]C.int,)

	/*
		attr := []C.int{
			C.GLX_RGBA,
			C.GLX_DEPTH_SIZE,
			24,
			C.GLX_DOUBLEBUFFER,
			C.None,
		}
	*/

	//vi := C.glXChooseVisual(xData.dpy, 0, (*C.int)(unsafe.Pointer(&attr)));
	vi := C.Test(xData.dpy)
	tmpContext := C.glXCreateContext(xData.dpy, vi, nil, C.GL_TRUE)

	err := C.glGetError()

	if err != C.GL_NO_ERROR {
		fmt.Println("Error")
	}

	C.glXMakeCurrent(xData.dpy, (C.GLXDrawable)(xData.win), tmpContext)
	C.glewInit()
	/*
		C.glXMakeCurrent(xData.dpy)
		C.glewInit()

		var context C.HGLRC
		if C.wglewIsSupported(C.CString("WGL_ARB_create_context")) == 1 {
			//TODO: Figure out how to send attr to c func so it works!!!
			context = C.openglCreateContextAttribsARB(*(*C.HDC)(hdc), nil)

			C.wglMakeCurrent(nil, nil)
			C.wglDeleteContext(tmpContext)
			C.wglMakeCurrent(*(*C.HDC)(hdc), context)
		}
	*/
	return
}
示例#2
0
文件: gl.go 项目: shibukawa/nanovg
func InitGlew() error {
	C.glewExperimental = C.GL_TRUE
	err := C.glewInit()

	if err != C.GLEW_OK {
		// fmt.Println(C.GoString(C.glewGetErrorString(glew_err)))
		return errors.New("glew error")
	}

	// Why did I need to do this?
	C.glGetError()

	return nil
}
示例#3
0
文件: blendish.go 项目: james4k/exp
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))
}
示例#4
0
func CreateContext(win window.Window) C.HGLRC {
	hdc := win.GetHDC()

	if hdc == nil {
		//TODO: Handle error somehow ???
		return nil
	}

	tmpContext := C.wglCreateContext(*(*C.HDC)(hdc))
	C.wglMakeCurrent(*(*C.HDC)(hdc), tmpContext)
	C.glewInit()

	var context C.HGLRC
	if C.wglewIsSupported(C.CString("WGL_ARB_create_context")) == 1 {
		//TODO: Figure out how to send attr to c func so it works!!!
		context = C.openglCreateContextAttribsARB(*(*C.HDC)(hdc), nil)

		C.wglMakeCurrent(nil, nil)
		C.wglDeleteContext(tmpContext)
		C.wglMakeCurrent(*(*C.HDC)(hdc), context)
	}
	return tmpContext
}
示例#5
0
文件: gl.go 项目: extrame/gl
func Init() {
	C.glewInit()
}
示例#6
0
文件: gl.go 项目: james4k/gl
func Init() GLenum {
	C.SetGlewExperimental(C.GLboolean(1))
	return GLenum(C.glewInit())
}
示例#7
0
文件: gl.go 项目: aiju/gl
func Init() {
	runtime.LockOSThread()
	C.glewInit()
}
示例#8
0
文件: gl.go 项目: pwaller/gl
func Init() GLenum {
	return GLenum(C.glewInit())
}