Exemple #1
0
func initGL() {
	// Using attribute arrays in OpenGL 3.3 requires the use of a VBA.
	// But VBAs don't exist in ES 2. So we bind a default one.
	var id C.GLuint
	C.glGenVertexArrays(1, &id)
	C.glBindVertexArray(id)
}
// createContext creates an OpenGL context, binds it as the current context
// stored in thread-local storage, and locks the current goroutine to an os
// thread.
func createContext() *contextGL {
	// The OpenGL active context is stored in TLS.
	runtime.LockOSThread()

	c := new(contextGL)
	C.CGCreate(&c.ctx)

	// Using attribute arrays in OpenGL 3.3 requires the use of a VBA.
	// But VBAs don't exist in ES 2. So we bind a default one.
	var id C.GLuint
	C.glGenVertexArrays(1, &id)
	C.glBindVertexArray(id)

	return c
}
Exemple #3
0
// createContext creates an OpenGL context, binds it as the current context
// stored in thread-local storage, and locks the current goroutine to an os
// thread.
func createContext() (*contextGL, error) {
	// The OpenGL active context is stored in TLS.
	runtime.LockOSThread()

	c := new(contextGL)
	if cglErr := C.CGCreate(&c.ctx); cglErr != C.kCGLNoError {
		return nil, fmt.Errorf("CGL: %v", C.GoString(C.CGLErrorString(cglErr)))
	}

	// Using attribute arrays in OpenGL 3.3 requires the use of a VBA.
	// But VBAs don't exist in ES 2. So we bind a default one.
	var id C.GLuint
	C.glGenVertexArrays(1, &id)
	C.glBindVertexArray(id)

	return c, nil
}
Exemple #4
0
func CreateVertexArray() VertexArray {
	a := VertexArray(0)
	C.glGenVertexArrays(1, (*C.GLuint)(&a))
	return a
}
Exemple #5
0
func GenVertexArrays(arrays []VertexArray) {
	C.glGenVertexArrays(C.GLsizei(len(arrays)), (*C.GLuint)(&arrays[0]))
}
Exemple #6
0
func GenVertexArray() VertexArray {
	var a C.GLuint
	C.glGenVertexArrays(1, &a)
	return VertexArray(a)
}