作者:krux0
项目:libov
func c_fovPort(that FovPort) (this C.ovrFovPort) {
this.DownTan = C.float(that.DownTan)
this.LeftTan = C.float(that.LeftTan)
this.RightTan = C.float(that.RightTan)
this.UpTan = C.float(that.UpTan)
return
}
作者:lambda
项目:go-fit
// Image returns image for given page number
func (f *Document) Image(page int) (image.Image, error) {
var ctm C.fz_matrix
C.fz_scale(&ctm, C.float(4.0), C.float(4.0))
cs := C.fz_device_rgb(f.ctx)
defer C.fz_drop_colorspace(f.ctx, cs)
pixmap := C.fz_new_pixmap_from_page_number(f.ctx, f.doc, C.int(page), &ctm, cs)
if pixmap == nil {
return nil, errors.New("fitz: cannot create pixmap")
}
defer C.fz_drop_pixmap(f.ctx, pixmap)
var bbox C.fz_irect
C.fz_pixmap_bbox(f.ctx, pixmap, &bbox)
pixels := C.fz_pixmap_samples(f.ctx, pixmap)
if pixels == nil {
return nil, errors.New("fitz: cannot get pixmap samples")
}
rect := image.Rect(int(bbox.x0), int(bbox.y0), int(bbox.x1), int(bbox.y1))
bytes := C.GoBytes(unsafe.Pointer(pixels), 4*bbox.x1*bbox.y1)
img := &image.RGBA{bytes, 4 * rect.Max.X, rect}
return img, nil
}
作者:james4
项目:ex
func TextField(x, y, w, h int, corners CornerFlags, state WidgetState, label string, cstart, cend int) {
clabel := C.CString(label)
defer C.free(unsafe.Pointer(clabel))
C.bndTextField(vg, C.float(x), C.float(y), C.float(w), C.float(h),
C.int(corners), C.BNDwidgetState(state), -1, clabel,
C.int(cstart), C.int(cend))
}
作者:theaide
项目:fmo
func (v *Vector) toC() C.FMOD_VECTOR {
var cv C.FMOD_VECTOR
cv.x = C.float(v.X)
cv.y = C.float(v.Y)
cv.z = C.float(v.Z)
return cv
}
作者:jle
项目:step
func (f *Filter) madgwick(timestamp int64, values []float32) {
C.madgwick_update_array(
f.orientation, C.float(sampleFreq), C.float(beta),
(*_Ctype_float)(&values[0]))
// quaternion slice
o := f.orientation
q := []float32{
float32(o.q0),
float32(o.q1),
float32(o.q2),
float32(o.q3),
}
q1 := float64(o.q0)
q2 := float64(o.q1)
q3 := float64(o.q2)
q4 := float64(o.q3)
// euler angles in radians (madgwick 2010)
z := math.Atan2(2*q2*q3-2*q1*q4, 2*q1*q1+2*q2*q2-1) * rad2deg
y := -math.Asin(2*q2*q4+2*q1*q3) * rad2deg
x := math.Atan2(2*q3*q4-2*q1*q2, 2*q1*q1+2*q4*q4-1) * rad2deg
e := []float64{z, y, x}
if false {
log.Println("qtn", timestamp, q)
log.Println("eul", timestamp, e)
}
broadcast(timestamp, "qtn", q)
}
作者:PragmaticCyphe
项目:gogo
// DrawRectAt draws a portion of the image specified w
// at the specified position.
func (img *Image) DrawRectAt(rx, ry, rw, rh, x, y int) {
C.textureDraw(img.id,
C.int(img.W), C.int(img.H),
C.int(rx), C.int(ry),
C.int(rw), C.int(rh),
C.float(x), C.float(y))
}
作者:num
项目:steve
func SetListenerDirection(x, y, z float32) {
C.sfListener_setDirection(C.sfVector3f{
C.float(x),
C.float(y),
C.float(z),
})
}
作者:num
项目:steve
func (s Sound) SetPosition(x, y, z float32) {
C.sfSound_setPosition(s.internal, C.sfVector3f{
C.float(x),
C.float(y),
C.float(z),
})
}
作者:floffel0
项目:gohord
func PickRay(cameraNode H3DNode, nwx float32, nwy float32, ox *float32, oy *float32, oz *float32,
dx *float32, dy *float32, dz *float32) {
C.h3dutPickRay(C.H3DNode(cameraNode), C.float(nwx), C.float(nwy), (*C.float)(unsafe.Pointer(ox)),
(*C.float)(unsafe.Pointer(oy)), (*C.float)(unsafe.Pointer(oz)),
(*C.float)(unsafe.Pointer(dx)), (*C.float)(unsafe.Pointer(dy)),
(*C.float)(unsafe.Pointer(dz)))
}
作者:drhode
项目:go-sfm
// \brief Change a 3-components vector parameter of a shader
// \a name is the name of the variable to change in the shader.
// The corresponding parameter in the shader must be a 3x1 vector
// (vec3 GLSL type).
// Example:
// \code
// uniform vec3 myparam; // this is the variable in the shader
// \endcode
// \code
// sfShader_setFloat3Parameter(shader, "myparam", 5.2f, 6.0f, -8.1f);
// \endcode
// \param shader Shader object
// \param name Name of the parameter in the shader
// \param x First component of the value to assign
// \param y Second component of the value to assign
// \param z Third component of the value to assign
// void sfShader_setFloat3Parameter(sfShader* shader, const char* name, float x, float y, float z);
func (self Shader) SetFloat3Parameter(name string, x, y, z float32) {
n := C.CString(name)
x1 := C.float(x)
y1 := C.float(y)
z1 := C.float(z)
C.sfShader_setFloat3Parameter(self.Cref, n, x1, y1, z1)
}
作者:bluepepper
项目:allegr
func (b *Bitmap) DrawTintedRotated(cx, cy, dx, dy, angle float32, flags int, color Color) {
C.al_draw_tinted_rotated_bitmap((*C.ALLEGRO_BITMAP)(b), (C.ALLEGRO_COLOR)(color),
C.float(cx), C.float(cy),
C.float(dx), C.float(dy), C.float(angle), C.int(flags))
}
作者:bluepepper
项目:allegr
func (b *Bitmap) DrawRotated(cx, cy, dx, dy, angle float32, flags int) {
C.al_draw_rotated_bitmap((*C.ALLEGRO_BITMAP)(b),
C.float(cx), C.float(cy), C.float(dx), C.float(dy),
C.float(angle), C.int(flags))
}
作者:krux0
项目:libov
// Used to generate projection from ovrEyeDesc::Fov.
func MatrixProjection(fov FovPort, znear, zfar float32, rightHanded bool) Matrix4f {
if rightHanded {
return matrix4f(C.ovrMatrix4f_Projection(c_fovPort(fov), C.float(znear), C.float(zfar), 1))
} else {
return matrix4f(C.ovrMatrix4f_Projection(c_fovPort(fov), C.float(znear), C.float(zfar), 0))
}
}
作者:krux0
项目:libov
func c_quatf(that Quatf) (this C.ovrQuatf) {
this.x = C.float(that.X)
this.y = C.float(that.Y)
this.z = C.float(that.Z)
this.w = C.float(that.W)
return
}
作者:bluepepper
项目:allegr
func (f *Font) DrawJustified(color Color, x1, x2, y, diff float32, flags int, text string) {
ctext := C.CString(text)
defer C.free(unsafe.Pointer(ctext))
C.al_draw_justified_text((*C.ALLEGRO_FONT)(f), C.ALLEGRO_COLOR(color),
C.float(x1), C.float(x2), C.float(y), C.float(diff), C.int(flags), ctext)
}
作者:drhode
项目:go-sfm
// \brief Change a 4-components vector parameter of a shader
// \a name is the name of the variable to change in the shader.
// The corresponding parameter in the shader must be a 4x1 vector
// (vec4 GLSL type).
// Example:
// \code
// uniform vec4 myparam; // this is the variable in the shader
// \endcode
// \code
// sfShader_setFloat4Parameter(shader, "myparam", 5.2f, 6.0f, -8.1f, 0.4f);
// \endcode
// \param shader Shader object
// \param name Name of the parameter in the shader
// \param x First component of the value to assign
// \param y Second component of the value to assign
// \param z Third component of the value to assign
// \param w Fourth component of the value to assign
// void sfShader_setFloat4Parameter(sfShader* shader, const char* name, float x, float y, float z, float w);
func (self Shader) Setfloat4parameter(name string, x, y, z, w float32) {
n := C.CString(name)
x1 := C.float(x)
y1 := C.float(y)
z1 := C.float(z)
w1 := C.float(w)
C.sfShader_setFloat4Parameter(self.Cref, n, x1, y1, z1, w1)
}
作者:floffel0
项目:gohord
func SetMaterialUniform(materialRes H3DRes, name string, a float32, b float32,
c float32, d float32) bool {
cName := C.CString(name)
defer C.free(unsafe.Pointer(cName))
return Bool[int(C.h3dSetMaterialUniform(C.H3DRes(materialRes), cName,
C.float(a), C.float(b), C.float(c), C.float(d)))]
}
作者:theaide
项目:fmo
func (v *Vector) toCp() **C.FMOD_VECTOR {
var cv C.FMOD_VECTOR
cv.x = C.float(v.X)
cv.y = C.float(v.Y)
cv.z = C.float(v.Z)
data := *(**C.FMOD_VECTOR)(unsafe.Pointer(&cv))
return &data
}
作者:krux0
项目:libov
// Calculates texture size recommended for rendering one eye within HMD, given FOV cone.
// Higher FOV will generally require larger textures to maintain quality.
// - pixelsPerDisplayPixel specifies that number of render target pixels per display
// pixel at center of distortion; 1.0 is the default value. Lower values
// can improve performance.
func (hmd *Hmd) GetFovTextureSize(eye EyeType, fov FovPort, pixelsPerDisplayPixel float32) Sizei {
var cFov C.ovrFovPort
cFov.DownTan = C.float(fov.DownTan)
cFov.LeftTan = C.float(fov.LeftTan)
cFov.RightTan = C.float(fov.RightTan)
cFov.UpTan = C.float(fov.UpTan)
return sizei(C.ovrHmd_GetFovTextureSize(hmd.cptr(), C.ovrEyeType(eye), cFov, C.float(pixelsPerDisplayPixel)))
}
作者:bluepepper
项目:allegr
func (f *Font) Draw(color Color, x, y float32, flags int, text string) {
ctext := C.CString(text)
defer C.free(unsafe.Pointer(ctext))
C.al_draw_text((*C.ALLEGRO_FONT)(f), (C.ALLEGRO_COLOR)(color),
C.float(x), C.float(y), C.int(flags), ctext)
}