This commit is contained in:
Milan Nikolic 2017-02-21 15:06:11 +01:00
parent 5d5a0e708f
commit 29546140b9
19 changed files with 432 additions and 432 deletions

View file

@ -70,17 +70,17 @@ func (s *Shader) cptr() *C.Shader {
return (*C.Shader)(unsafe.Pointer(s))
}
// Returns new Shader
// NewShader - Returns new Shader
func NewShader(id uint32, vertexLoc, texcoordLoc, texcoord2Loc, normalLoc, tangentLoc, colorLoc, mvpLoc, colDiffuseLoc, colAmbientLoc, colSpecularLoc, mapTexture0Loc, mapTexture1Loc, mapTexture2Loc int32) Shader {
return Shader{id, vertexLoc, texcoordLoc, texcoord2Loc, normalLoc, tangentLoc, colorLoc, mvpLoc, colDiffuseLoc, colAmbientLoc, colSpecularLoc, mapTexture0Loc, mapTexture1Loc, mapTexture2Loc}
}
// Returns new Shader from pointer
// NewShaderFromPointer - Returns new Shader from pointer
func NewShaderFromPointer(ptr unsafe.Pointer) Shader {
return *(*Shader)(ptr)
}
// Load a custom shader and bind default locations
// LoadShader - Load a custom shader and bind default locations
func LoadShader(vsFileName string, fsFileName string) Shader {
cvsFileName := C.CString(vsFileName)
cfsFileName := C.CString(fsFileName)
@ -92,27 +92,27 @@ func LoadShader(vsFileName string, fsFileName string) Shader {
return v
}
// Unload a custom shader from memory
// UnloadShader - Unload a custom shader from memory
func UnloadShader(shader Shader) {
cshader := shader.cptr()
C.UnloadShader(*cshader)
}
// Get default shader
// GetDefaultShader - Get default shader
func GetDefaultShader() Shader {
ret := C.GetDefaultShader()
v := NewShaderFromPointer(unsafe.Pointer(&ret))
return v
}
// Get default texture
// GetDefaultTexture - Get default texture
func GetDefaultTexture() *Texture2D {
ret := C.GetDefaultTexture()
v := NewTexture2DFromPointer(unsafe.Pointer(&ret))
return &v
}
// Get shader uniform location
// GetShaderLocation - Get shader uniform location
func GetShaderLocation(shader Shader, uniformName string) int32 {
cshader := shader.cptr()
cuniformName := C.CString(uniformName)
@ -122,7 +122,7 @@ func GetShaderLocation(shader Shader, uniformName string) int32 {
return v
}
// Set shader uniform value (float)
// SetShaderValue - Set shader uniform value (float)
func SetShaderValue(shader Shader, uniformLoc int32, value []float32, size int32) {
cshader := shader.cptr()
cuniformLoc := (C.int)(uniformLoc)
@ -131,7 +131,7 @@ func SetShaderValue(shader Shader, uniformLoc int32, value []float32, size int32
C.SetShaderValue(*cshader, cuniformLoc, cvalue, csize)
}
// Set shader uniform value (int)
// SetShaderValuei - Set shader uniform value (int)
func SetShaderValuei(shader Shader, uniformLoc int32, value []int32, size int32) {
cshader := shader.cptr()
cuniformLoc := (C.int)(uniformLoc)
@ -140,7 +140,7 @@ func SetShaderValuei(shader Shader, uniformLoc int32, value []int32, size int32)
C.SetShaderValuei(*cshader, cuniformLoc, cvalue, csize)
}
// Set shader uniform value (matrix 4x4)
// SetShaderValueMatrix - Set shader uniform value (matrix 4x4)
func SetShaderValueMatrix(shader Shader, uniformLoc int32, mat Matrix) {
cshader := shader.cptr()
cuniformLoc := (C.int)(uniformLoc)
@ -148,72 +148,72 @@ func SetShaderValueMatrix(shader Shader, uniformLoc int32, mat Matrix) {
C.SetShaderValueMatrix(*cshader, cuniformLoc, *cmat)
}
// Set a custom projection matrix (replaces internal projection matrix)
// SetMatrixProjection - Set a custom projection matrix (replaces internal projection matrix)
func SetMatrixProjection(proj Matrix) {
cproj := proj.cptr()
C.SetMatrixProjection(*cproj)
}
// Set a custom modelview matrix (replaces internal modelview matrix)
// SetMatrixModelview - Set a custom modelview matrix (replaces internal modelview matrix)
func SetMatrixModelview(view Matrix) {
cview := view.cptr()
C.SetMatrixModelview(*cview)
}
// Begin custom shader drawing
// BeginShaderMode - Begin custom shader drawing
func BeginShaderMode(shader Shader) {
cshader := shader.cptr()
C.BeginShaderMode(*cshader)
}
// End custom shader drawing (use default shader)
// EndShaderMode - End custom shader drawing (use default shader)
func EndShaderMode() {
C.EndShaderMode()
}
// Begin blending mode (alpha, additive, multiplied)
// BeginBlendMode - Begin blending mode (alpha, additive, multiplied)
func BeginBlendMode(mode BlendMode) {
cmode := (C.int)(mode)
C.BeginBlendMode(cmode)
}
// End blending mode (reset to default: alpha blending)
// EndBlendMode - End blending mode (reset to default: alpha blending)
func EndBlendMode() {
C.EndBlendMode()
}
// Init VR device
// InitVrDevice - Init VR device
func InitVrDevice(vdDevice VrDevice) {
cvdDevice := (C.int)(vdDevice)
C.InitVrDevice(cvdDevice)
}
// Close VR device
// CloseVrDevice - Close VR device
func CloseVrDevice() {
C.CloseVrDevice()
}
// Detect if VR device is ready
// IsVrDeviceReady - Detect if VR device is ready
func IsVrDeviceReady() bool {
ret := C.IsVrDeviceReady()
v := bool(int(ret) == 1)
return v
}
// Detect if VR simulator is running
// IsVrSimulator - Detect if VR simulator is running
func IsVrSimulator() bool {
ret := C.IsVrSimulator()
v := bool(int(ret) == 1)
return v
}
// Update VR tracking (position and orientation) and camera
// UpdateVrTracking - Update VR tracking (position and orientation) and camera
func UpdateVrTracking(camera *Camera) {
ccamera := camera.cptr()
C.UpdateVrTracking(ccamera)
}
// Enable/Disable VR experience (device or simulator)
// ToggleVrMode - Enable/Disable VR experience (device or simulator)
func ToggleVrMode() {
C.ToggleVrMode()
}