Golang GLsizei示例

说明

golang glsizei示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。

编程语言: Golang

命名空间/包名称: C

示例#1
文件: gldebug.go 项目: Miaque/mojo

func RenderbufferStorage(target, internalFormat Enum, width, height int) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.RenderbufferStorage(%v, %v, %v, %v) %v", target, internalFormat, width, height, errstr)
	}()
	C.glRenderbufferStorage(target.c(), internalFormat.c(), C.GLsizei(width), C.GLsizei(height))
}

示例#2
文件: gldebug.go 项目: Miaque/mojo

func Viewport(x, y, width, height int) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.Viewport(%v, %v, %v, %v) %v", x, y, width, height, errstr)
	}()
	C.glViewport(C.GLint(x), C.GLint(y), C.GLsizei(width), C.GLsizei(height))
}

示例#3
文件: shader.go 项目: jackscan/go-gles3

func (program *Program) GetAttrib(name string) VertexAttrib {

	cname := (*C.GLchar)(C.CString(name))
	defer C.free(unsafe.Pointer(cname))

	iloc := C.glGetAttribLocation(program.id, cname)
	if iloc < 0 {
		panic(fmt.Errorf("not an active attribute: %s", name))
	}

	loc := C.GLuint(iloc)

	datatype := C.GLenum(0)
	length := C.GLsizei(0)
	size := C.GLint(0)

	aname := [32]byte{}

	C.glGetActiveAttrib(program.id, C.GLuint(loc), C.GLsizei(len(aname)), &length, &size, &datatype, (*C.GLchar)(unsafe.Pointer(&aname[0])))

	switch datatype {
	case C.GL_FLOAT:
		return FloatAttrib{vattrib{loc}}
	case C.GL_FLOAT_VEC2:
		return Vec2Attrib{FloatAttrib{vattrib{loc}}}
	case C.GL_FLOAT_VEC3:
		return Vec3Attrib{FloatAttrib{vattrib{loc}}}
	case C.GL_FLOAT_VEC4:
		return Vec4Attrib{FloatAttrib{vattrib{loc}}}
	default:
		panic(fmt.Errorf("unsupported attribute type: %#x", datatype))
	}
}

示例#4
文件: gldebug.go 项目: Miaque/mojo

func Scissor(x, y, width, height int32) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.Scissor(%v, %v, %v, %v) %v", x, y, width, height, errstr)
	}()
	C.glScissor(C.GLint(x), C.GLint(y), C.GLsizei(width), C.GLsizei(height))
}

示例#5
文件: gl.go 项目: jackscan/go-gles2

func ReadAlpha(image *image.Alpha) {

	alignment := C.GLint(0)
	C.glGetIntegerv(C.GL_PACK_ALIGNMENT, &alignment)

	align := C.GLint(1)

	for align < alignment && image.Stride%(int(align)*2) == 0 {
		align *= 2
	}

	// need smaller alignment
	if align < alignment {
		C.glPixelStorei(C.GL_PACK_ALIGNMENT, align)
	}

	C.glReadPixels(C.GLint(image.Rect.Min.X), C.GLint(image.Rect.Min.Y),
		C.GLsizei(image.Rect.Dx()), C.GLsizei(image.Rect.Dy()),
		C.GL_ALPHA, C.GL_UNSIGNED_BYTE, unsafe.Pointer(&image.Pix[0]))

	// restore alignment
	if align < alignment {
		C.glPixelStorei(C.GL_PACK_ALIGNMENT, alignment)
	}
}

示例#6
文件: es2.go 项目: nick-fedesna/egles

func CopyTexImage2D(target uint, level int, internalformat uint,
	x, y, width, height, border int) {
	C.glCopyTexImage2D(
		C.GLenum(target), C.GLint(level), C.GLenum(internalformat),
		C.GLint(x), C.GLint(y), C.GLsizei(width), C.GLsizei(height),
		C.GLint(border))
}

示例#7
文件: gl.go 项目: extrame/gl

// Link links the attached shader objects
func (p *Program) Link() error {
	var val, val2 C.GLint
	C.glLinkProgram(p.i)
	C.glGetProgramiv(p.i, LINK_STATUS, &val)
	if val != TRUE {
		C.glGetProgramiv(p.i, INFO_LOG_LENGTH, &val)
		buf := make([]C.GLchar, val+1)
		C.glGetProgramInfoLog(p.i, C.GLsizei(val), nil, &buf[0])
		return errors.New(C.GoString((*C.char)(&buf[0])))
	}
	p.attr = make(map[string]C.GLuint)
	C.glGetProgramiv(p.i, ACTIVE_ATTRIBUTES, &val)
	C.glGetProgramiv(p.i, ACTIVE_ATTRIBUTE_MAX_LENGTH, &val2)
	buf := make([]C.char, val2)
	for i := C.GLuint(0); i < C.GLuint(val); i++ {
		C.glGetActiveAttrib(p.i, i, C.GLsizei(val2), nil, nil, nil, (*C.GLchar)(&buf[0]))
		p.attr[C.GoString(&buf[0])] = C.GLuint(C.glGetAttribLocation(p.i, (*C.GLchar)(&buf[0])))
	}
	p.uni = make(map[string]C.GLint)
	C.glGetProgramiv(p.i, ACTIVE_UNIFORMS, &val)
	C.glGetProgramiv(p.i, ACTIVE_UNIFORM_MAX_LENGTH, &val2)
	buf = make([]C.char, val2)
	for i := C.GLuint(0); i < C.GLuint(val); i++ {
		C.glGetActiveUniform(p.i, i, C.GLsizei(val2), nil, nil, nil, (*C.GLchar)(&buf[0]))
		p.uni[C.GoString(&buf[0])] = C.glGetUniformLocation(p.i, (*C.GLchar)(&buf[0]))
	}
	return nil
}

示例#8
文件: es2.go 项目: nick-fedesna/egles

func CopyTexSubImage2D(target uint, level, xoffset, yoffset,
	x, y, width, height int) {
	C.glCopyTexSubImage2D(
		C.GLenum(target), C.GLint(level),
		C.GLint(xoffset), C.GLint(yoffset),
		C.GLint(x), C.GLint(y), C.GLsizei(width), C.GLsizei(height))
}

示例#9
文件: gl_opengles.go 项目: shibukawa/gl

func TexImage2D(target Enum, level int, width, height int, format Enum, ty Enum, data []byte) {
	p := unsafe.Pointer(nil)
	if len(data) > 0 {
		p = unsafe.Pointer(&data[0])
	}
	C.glTexImage2D(target.c(), C.GLint(level), C.GLint(format), C.GLsizei(width), C.GLsizei(height), 0, format.c(), ty.c(), p)
}

示例#10
文件: texture.go 项目: jackscan/go-gles3

func TexImage2D(target TextureTarget, level int, internalformat InternalFormat, width, height int, format TextureFormat, datatype DataType, pixels []uint8) {
	if pixels != nil {
		C.glTexImage2D(C.GLenum(target), C.GLint(level), C.GLint(internalformat), C.GLsizei(width), C.GLsizei(height), 0, C.GLenum(format), C.GLenum(datatype), unsafe.Pointer(&pixels[0]))
	} else {
		C.glTexImage2D(C.GLenum(target), C.GLint(level), C.GLint(internalformat), C.GLsizei(width), C.GLsizei(height), 0, C.GLenum(format), C.GLenum(datatype), unsafe.Pointer(nil))
	}
}

示例#11
文件: gldebug.go 项目: Miaque/mojo

func ReadPixels(dst []byte, x, y, width, height int, format, ty Enum) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.ReadPixels(len(%d), %v, %v, %v, %v, %v, %v) %v", len(dst), x, y, width, height, format, ty, errstr)
	}()
	C.glReadPixels(C.GLint(x), C.GLint(y), C.GLsizei(width), C.GLsizei(height), format.c(), ty.c(), unsafe.Pointer(&dst[0]))
}

示例#12
文件: blendish.go 项目: james4k/exp

func BeginFrame(width, height int, devicePixelRatio float32) {
	w := C.GLsizei(float32(width) * devicePixelRatio)
	h := C.GLsizei(float32(height) * devicePixelRatio)
	C.glViewport(0, 0, w, h)
	C.glClearColor(0, 0, 0, 1)
	C.glClear(C.GL_COLOR_BUFFER_BIT | C.GL_DEPTH_BUFFER_BIT | C.GL_STENCIL_BUFFER_BIT)
	C.nvgBeginFrame(vg, C.int(width), C.int(height), C.float(devicePixelRatio))
}

示例#13
文件: es2.go 项目: nick-fedesna/egles

func CompressedTexImage2D(target uint, level int, internalformat uint,
	width, height, border, imageSize int, data Void) {
	C.glCompressedTexImage2D(
		C.GLenum(target), C.GLint(level), C.GLenum(internalformat),
		C.GLsizei(width), C.GLsizei(height),
		C.GLint(border), C.GLsizei(imageSize),
		unsafe.Pointer(data))
}

示例#14
文件: es2.go 项目: nick-fedesna/egles

func TexSubImage2D(target uint, level, xoffset, yoffset, width, height int,
	format, type_ uint, pixels Void) {

	C.glTexSubImage2D(C.GLenum(target), C.GLint(level),
		C.GLint(xoffset), C.GLint(yoffset), C.GLsizei(width), C.GLsizei(height),
		C.GLenum(format), C.GLenum(type_),
		unsafe.Pointer(pixels))
}

示例#15
文件: gl.go 项目: TriangleGo/golang.org

// TexImage2D writes a 2D texture image.
//
// http://www.khronos.org/opengles/sdk/docs/man3/html/glTexImage2D.xhtml
func TexImage2D(target Enum, level int, width, height int, format Enum, ty Enum, data []byte) {
	// TODO(crawshaw): GLES3 offset for PIXEL_UNPACK_BUFFER and PIXEL_PACK_BUFFER.
	p := unsafe.Pointer(nil)
	if len(data) > 0 {
		p = unsafe.Pointer(&data[0])
	}
	C.glTexImage2D(target.c(), C.GLint(level), C.GLint(format), C.GLsizei(width), C.GLsizei(height), 0, format.c(), ty.c(), p)
}

示例#16
文件: gles2.go 项目: remogatto/egles

func Viewport(
	x int32, y int32, width Sizei, height Sizei) {
	C.glViewport(
		C.GLint(x),
		C.GLint(y),
		C.GLsizei(width),
		C.GLsizei(height))
}

示例#17
文件: imp.go 项目: CaptainSoOmA/Uni

func initialize() {
	//
	if !initialized {
		initialized = true
		scr.Switch(scr.XGA) // (scr.MaxMode())
		C.glViewport(0, 0, C.GLsizei(scr.NX()), C.GLsizei(scr.NY()))
	}
}

示例#18
文件: gles2.go 项目: remogatto/egles

func Scissor(
	x int32, y int32, width Sizei, height Sizei) {
	C.glScissor(
		C.GLint(x),
		C.GLint(y),
		C.GLsizei(width),
		C.GLsizei(height))
}

示例#19
文件: shader.go 项目: jackscan/go-gles3

func (program *Program) GetUniform(name string) Uniform {

	cname := (*C.GLchar)(C.CString(name))
	defer C.free(unsafe.Pointer(cname))

	loc := C.GLint(C.glGetUniformLocation(program.id, cname))
	if loc < 0 {
		panic(fmt.Errorf("not an active uniform: %s", name))
	}

	datatype := C.GLenum(0)
	length := C.GLsizei(0)
	size := C.GLint(0)

	uname := [32]byte{}

	C.glGetActiveUniform(program.id, C.GLuint(loc), C.GLsizei(len(uname)), &length, &size, &datatype, (*C.GLchar)(unsafe.Pointer(&uname[0])))

	switch datatype {
	case C.GL_FLOAT:
		return Uniform1f{uniformBase{loc}}
	case C.GL_FLOAT_VEC2:
		return Uniform2f{uniformBase{loc}}
	case C.GL_FLOAT_VEC3:
		return Uniform3f{uniformBase{loc}}
	case C.GL_FLOAT_VEC4:
		return Uniform4f{uniformBase{loc}}
	case C.GL_INT:
		return Uniform1i{uniformBase{loc}}
	case C.GL_INT_VEC2:
		return Uniform2i{uniformBase{loc}}
	case C.GL_INT_VEC3:
		return Uniform3i{uniformBase{loc}}
	case C.GL_INT_VEC4:
		return Uniform4i{uniformBase{loc}}
	case C.GL_BOOL:
		return Uniform1i{uniformBase{loc}}
	case C.GL_BOOL_VEC2:
		return Uniform2i{uniformBase{loc}}
	case C.GL_BOOL_VEC3:
		return Uniform3i{uniformBase{loc}}
	case C.GL_BOOL_VEC4:
		return Uniform4i{uniformBase{loc}}
	case C.GL_FLOAT_MAT2:
		return UniformMatrix2f{uniformBase{loc}}
	case C.GL_FLOAT_MAT3:
		return UniformMatrix3f{uniformBase{loc}}
	case C.GL_FLOAT_MAT4:
		return UniformMatrix4f{uniformBase{loc}}
	case C.GL_SAMPLER_2D:
		return Uniform1i{uniformBase{loc}}
	case C.GL_SAMPLER_CUBE:
		return Uniform1i{uniformBase{loc}}
	default:
		panic(fmt.Errorf("unsupported uniform type: %#x", datatype))
	}
}

示例#20
文件: gles2.go 项目: remogatto/egles

func RenderbufferStorage(
	target Enum, internalformat Enum,
	width Sizei, height Sizei) {
	C.glRenderbufferStorage(
		C.GLenum(target),
		C.GLenum(internalformat),
		C.GLsizei(width),
		C.GLsizei(height))
}

示例#21
文件: es2.go 项目: nick-fedesna/egles

func CompressedTexSubImage2D(target uint, level, xoffset, yoffset int,
	width, height int, format uint, imageSize int, data Void) {
	C.glCompressedTexSubImage2D(
		C.GLenum(target), C.GLint(level),
		C.GLint(xoffset), C.GLint(yoffset),
		C.GLsizei(width), C.GLsizei(height),
		C.GLenum(format), C.GLsizei(imageSize),
		unsafe.Pointer(data))
}

示例#22
文件: gles2.go 项目: remogatto/egles

func ShaderBinary(
	n Sizei, shaders *uint32,
	binaryformat Enum, binary Void, length Sizei) {
	C.glShaderBinary(
		C.GLsizei(n),
		(*C.GLuint)(shaders),
		C.GLenum(binaryformat),
		unsafe.Pointer(binary),
		C.GLsizei(length))
}

示例#23
文件: glu.go 项目: abieberbach/goplanemp

func Build2DMipmaps(target uint32, internalFormat int, width, height int, format, typ uint32, data unsafe.Pointer) int {
	return int(C.gluBuild2DMipmaps(
		C.GLenum(target),
		C.GLint(internalFormat),
		C.GLsizei(width),
		C.GLsizei(height),
		C.GLenum(format),
		C.GLenum(typ),
		data))
}

示例#24
文件: glu.go 项目: sirctseb/glu

func Build2DMipmaps(target gl.GLenum, internalFormat int, width, height int, format, typ gl.GLenum, data interface{}) int {
	return int(C.gluBuild2DMipmaps(
		C.GLenum(target),
		C.GLint(internalFormat),
		C.GLsizei(width),
		C.GLsizei(height),
		C.GLenum(format),
		C.GLenum(typ),
		ptr(data),
	))
}

示例#25
文件: glu.go 项目: krakensden/Go-OpenGL

func Build2DMipmaps(target gl.GLenum, internalFormat gl.GLint, width, height gl.GLsizei, format, kind gl.GLenum, data unsafe.Pointer) gl.GLint {
	return gl.GLint(C.gluBuild2DMipmaps(
		C.GLenum(target),
		C.GLint(internalFormat),
		C.GLsizei(width),
		C.GLsizei(height),
		C.GLenum(format),
		C.GLenum(kind),
		data,
	))
}

示例#26
文件: gldebug.go 项目: Miaque/mojo

func TexImage2D(target Enum, level int, width, height int, format Enum, ty Enum, data []byte) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.TexImage2D(%v, %v, %v, %v, %v, %v, len(%d)) %v", target, level, width, height, format, ty, len(data), errstr)
	}()
	p := unsafe.Pointer(nil)
	if len(data) > 0 {
		p = unsafe.Pointer(&data[0])
	}
	C.glTexImage2D(target.c(), C.GLint(level), C.GLint(format), C.GLsizei(width), C.GLsizei(height), 0, format.c(), ty.c(), p)
}

示例#27
文件: gles2.go 项目: remogatto/egles

func ReadPixels(
	x int32, y int32, width Sizei, height Sizei,
	format Enum, type_ Enum, pixels Void) {
	C.glReadPixels(
		C.GLint(x),
		C.GLint(y),
		C.GLsizei(width),
		C.GLsizei(height),
		C.GLenum(format),
		C.GLenum(type_),
		unsafe.Pointer(pixels))
}

示例#28
文件: gl.go 项目: extrame/gl

// Add the interface to export image
func ReadPixels(x int, y int, w int, h int) image.Image {
	data := make([]uint16, 4*w*h)
	p := unsafe.Pointer(&data[0])
	C.glReadPixels(C.GLint(x), C.GLint(y), C.GLsizei(w), C.GLsizei(h), C.GLenum(RGBA), C.GLenum(UNSIGNED_SHORT), p)
	rec := image.Rect(x, y, x+w, y+h)
	rgba := image.NewRGBA64(rec)
	for i := 0; i < w*h; i++ {
		c := color.RGBA64{data[4*i], data[4*i+1], data[4*i+2], data[4*i+3]}
		rgba.Set(i%w, h-i/w-1, c)
	}
	return rgba
}

示例#29
文件: glu.go 项目: paul-lalonde/Go-OpenGL

func Build2DMipmaps(target gl.GLenum, internalFormat int, width, height int, format gl.GLenum, data interface{}) int {
	t, p := gl.GetGLenumType(data)
	return int(C.gluBuild2DMipmaps(
		C.GLenum(target),
		C.GLint(internalFormat),
		C.GLsizei(width),
		C.GLsizei(height),
		C.GLenum(format),
		C.GLenum(t),
		p,
	))
}

示例#30
文件: texture.go 项目: eaburns/gl

// TexImage2D specifies a two-dimensional texture image.
func TexImage2D(targ TextureTarget, lvl int, ifmt TextureFormat, w, h, border int, fmt TextureFormat, data interface{}) {
	tipe, _, ptr := rawData(data)
	C.glTexImage2D(C.GLenum(targ),
		C.GLint(lvl),
		C.GLint(ifmt),
		C.GLsizei(w),
		C.GLsizei(h),
		C.GLint(border),
		C.GLenum(fmt),
		C.GLenum(tipe),
		ptr)
}

展开阅读全文