作者:Miaqu
项目:moj
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))
}
作者:Miaqu
项目:moj
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))
}
作者:jacksca
项目:go-gles
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))
}
}
作者:Miaqu
项目:moj
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))
}
作者:jacksca
项目:go-gles
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)
}
}
作者:nick-fedesn
项目:egle
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))
}
作者:extram
项目:g
// 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
}
作者:nick-fedesn
项目:egle
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))
}
作者:shibukaw
项目:g
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)
}
作者:jacksca
项目:go-gles
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))
}
}
作者:Miaqu
项目:moj
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]))
}
作者:james4
项目:ex
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))
}
作者:nick-fedesn
项目:egle
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))
}
作者:nick-fedesn
项目:egle
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))
}
作者:TriangleG
项目:golang.or
// 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)
}
作者:remogatt
项目:egle
func Viewport(
x int32, y int32, width Sizei, height Sizei) {
C.glViewport(
C.GLint(x),
C.GLint(y),
C.GLsizei(width),
C.GLsizei(height))
}
作者:CaptainSoOm
项目:Un
func initialize() {
//
if !initialized {
initialized = true
scr.Switch(scr.XGA) // (scr.MaxMode())
C.glViewport(0, 0, C.GLsizei(scr.NX()), C.GLsizei(scr.NY()))
}
}
作者:remogatt
项目:egle
func Scissor(
x int32, y int32, width Sizei, height Sizei) {
C.glScissor(
C.GLint(x),
C.GLint(y),
C.GLsizei(width),
C.GLsizei(height))
}
作者:jacksca
项目:go-gles
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))
}
}
作者:remogatt
项目:egle
func RenderbufferStorage(
target Enum, internalformat Enum,
width Sizei, height Sizei) {
C.glRenderbufferStorage(
C.GLenum(target),
C.GLenum(internalformat),
C.GLsizei(width),
C.GLsizei(height))
}