Example #1
0
func BufferInit(target Enum, size int, usage Enum) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.BufferInit(%v, %v, %v) %v", target, size, usage, errstr)
	}()
	C.glBufferData(target.c(), C.GLsizeiptr(size), nil, usage.c())
}
Example #2
0
func BufferData(target Enum, usage Enum, src []byte) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.BufferData(%v, %v, len(%d)) %v", target, usage, len(src), errstr)
	}()
	C.glBufferData(target.c(), C.GLsizeiptr(len(src)), unsafe.Pointer(&src[0]), usage.c())
}
Example #3
0
func BufferSubData(target Enum, offset int, data []byte) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.BufferSubData(%v, %v, len(%d)) %v", target, offset, len(data), errstr)
	}()
	C.glBufferSubData(target.c(), C.GLintptr(offset), C.GLsizeiptr(len(data)), unsafe.Pointer(&data[0]))
}
Example #4
0
File: gla.go Project: spate/gla
// BufferData uses glBufferData to allocate memory for the bound GL buffer,
// and fills it with the data in slice. slice can be either a slice or pointer.
// Behaviour is undefined if the underlying data type is or contains anything
// other than sized numeric types. (Structs and arrays are okay as long as they're
// of sized numeric types. Pointers and slices are only allowed at the topmost level.)
func BufferData(target GLenum, slice interface{}, usage GLenum) error {
	data, e := sliceToUintptr(slice)
	if e != nil {
		return e
	}
	C.glBufferData(C.GLenum(target), C.GLsizeiptr(data.Size*data.Length), unsafe.Pointer(data.Ptr), C.GLenum(usage))
	return nil
}
Example #5
0
File: gla.go Project: spate/gla
// BufferSubData uses glBufferSubData to update a section of the buffer
// currently bound to target. The buffer's type is treated as being an array
// of the same type as slice. Trying to set data off the end of the buffer
// is not checked, and will likely result in a GL error.
//
// This function sets:
//   buffer_bound_to_target[start:start+len(slice)] = slice[:]
func BufferSubData(target GLenum, start_index int, slice interface{}) error {
	data, e := sliceToUintptr(slice)
	if e != nil {
		return e
	}
	C.glBufferSubData(C.GLenum(target), C.GLintptr(uintptr(start_index)*data.Size), C.GLsizeiptr(data.Size*data.Length), unsafe.Pointer(data.Ptr))
	return nil
}
Example #6
0
File: gl.go Project: extrame/gl
// Set calls glBufferData with appropriate arguments to load the data pointed to by data into the buffer. usage is passed along verbatim. targ is used for binding and it should most likely be ARRAY_BUFFER.
func (buf *Buffer) Set(targ int, data interface{}, usage int) {
	buf.Bind(targ)
	p, t, ts, s := toCtype(data)
	C.glBufferData(C.GLenum(targ), C.GLsizeiptr(s), p, C.GLenum(usage))
	buf.t = t
	buf.ts = ts
	buf.Unbind(targ)
}
Example #7
0
func BufferData(
	target Enum, size SizeiPtr,
	data Void, usage Enum) {
	C.glBufferData(
		C.GLenum(target),
		C.GLsizeiptr(size),
		unsafe.Pointer(data),
		C.GLenum(usage))

}
Example #8
0
func BufferSubData(
	target Enum, offset IntPtr,
	size SizeiPtr, data Void) {
	C.glBufferSubData(
		C.GLenum(target),
		C.GLintptr(offset),
		C.GLsizeiptr(size),
		unsafe.Pointer(data))

}
Example #9
0
func (game *game) initGL() {
	log.Printf("GL_VERSION: %v GL_RENDERER: %v GL_VENDOR %v\n",
		GetString(C.GL_VERSION), GetString(C.GL_RENDERER), GetString(C.GL_VENDOR))
	log.Printf("GL_EXTENSIONS: %v\n", GetString(C.GL_EXTENSIONS))
	C.glClearColor(0.0, 0.0, 0.0, 1.0)
	C.glEnable(C.GL_CULL_FACE)
	C.glEnable(C.GL_DEPTH_TEST)

	game.prog = createProgram(vertShaderSrcDef, fragShaderSrcDef)
	posAttrib := attribLocation(game.prog, "vPosition")
	game.offsetUni = uniformLocation(game.prog, "offset")
	game.colorUni = uniformLocation(game.prog, "color")
	C.glUseProgram(game.prog)
	C.glEnableVertexAttribArray(C.GLuint(posAttrib))

	vertVBO := GenBuffer()
	checkGLError()
	C.glBindBuffer(C.GL_ARRAY_BUFFER, vertVBO)
	verts := []float32{.0, 0.5, -0.5, -0.5, 0.5, -0.5}
	C.glBufferData(C.GL_ARRAY_BUFFER, C.GLsizeiptr(len(verts)*int(unsafe.Sizeof(verts[0]))), unsafe.Pointer(&verts[0]), C.GL_STATIC_DRAW)
	C.glVertexAttribPointer(C.GLuint(posAttrib), 2, C.GL_FLOAT, C.GL_FALSE, 0, unsafe.Pointer(uintptr(0)))
}
Example #10
0
func BufferDataf(target BufferTarget, data []float32, usage BufferUsage) {
	C.glBufferData(C.GLenum(target), C.GLsizeiptr(unsafe.Sizeof(data[0])*uintptr(len(data))), unsafe.Pointer(&data[0]), C.GLenum(usage))
}
Example #11
0
func BufferSubData(target Enum, offset int, data []byte) {
	C.glBufferSubData(target.c(), C.GLintptr(offset), C.GLsizeiptr(len(data)), unsafe.Pointer(&data[0]))
}
Example #12
0
func BufferData(target Enum, src []byte, usage Enum) {
	C.glBufferData(target.c(), C.GLsizeiptr(len(src)), unsafe.Pointer(&src[0]), usage.c())
}
Example #13
0
// Creates and initializes a buffer object's data store
func BufferData(target GLenum, size int, data interface{}, usage GLenum) {
	C.glBufferData(C.GLenum(target), C.GLsizeiptr(size), ptr(data), C.GLenum(usage))
}
Example #14
0
// Bind this buffer range as index of target
func (buffer Buffer) BindBufferRange(target GLenum, index uint, offset int, size uint) {
	C.glBindBufferRange(C.GLenum(target), C.GLuint(index), C.GLuint(buffer), C.GLintptr(offset), C.GLsizeiptr(size))
}
Example #15
0
// Returns a subset of a buffer object's data store
func GetBufferSubData(target GLenum, offset int, size int, data interface{}) {
	C.glGetBufferSubData(C.GLenum(target), C.GLintptr(offset),
		C.GLsizeiptr(size), ptr(data))
}
Example #16
0
// BufferSubData updates a subset of a buffer object's data store.
func BufferSubData(targ BufferTarget, offs int, data interface{}) {
	_, sz, ptr := rawData(data)
	C.glBufferSubData(C.GLenum(targ), C.GLintptr(offs), C.GLsizeiptr(sz), ptr)
}
Example #17
0
func BufferInit(target Enum, size int, usage Enum) {
	C.glBufferData(target.c(), C.GLsizeiptr(size), nil, usage.c())
}
Example #18
0
func BufferData(target uint, size int, data Void, usage uint) {
	C.glBufferData(
		C.GLenum(target), C.GLsizeiptr(size),
		unsafe.Pointer(data), C.GLenum(usage))
}
Example #19
0
func BufferSubData(target uint, offset int, size int, data Void) {
	C.glBufferSubData(
		C.GLenum(target), C.GLintptr(offset),
		C.GLsizeiptr(size), unsafe.Pointer(data))
}
Example #20
0
func BufferData(target BufferTarget, size int, usage BufferUsage) {
	C.glBufferData(C.GLenum(target), C.GLsizeiptr(size), nil, C.GLenum(usage))
}
Example #21
0
func BufferSubDataf(target BufferTarget, offset int, data []float32) {
	C.glBufferSubData(C.GLenum(target), C.GLintptr(offset), C.GLsizeiptr(unsafe.Sizeof(data[0])*uintptr(len(data))), unsafe.Pointer(&data[0]))
}
Example #22
0
func BufferData(target Enum, size int, src unsafe.Pointer, usage Enum) {
	C.glBufferData(target.c(), C.GLsizeiptr(size), src, usage.c())
}
Example #23
0
func CopyBufferSubData(readTarget, writeTarget BufferTarget, readOffset, writeOffset, size int) {
	C.glCopyBufferSubData(C.GLenum(readTarget), C.GLenum(writeTarget), C.GLintptr(readOffset), C.GLintptr(writeOffset), C.GLsizeiptr(size))
}
Example #24
0
func BufferSubData(target Enum, offset, size int, data unsafe.Pointer) {
	C.glBufferSubData(target.c(), C.GLintptr(offset), C.GLsizeiptr(size), data)
}
Example #25
0
// BufferData creates and initializes a buffer object's data store.
func BufferData(targ BufferTarget, data interface{}, usage BufferDataUsage) {
	_, sz, ptr := rawData(data)
	C.glBufferData(C.GLenum(targ), C.GLsizeiptr(sz), ptr, C.GLenum(usage))
}