Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new functions (4.5.0 Update) #258

Merged
merged 1 commit into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion raylib/rcore.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,19 @@ func RestoreWindow() {
C.RestoreWindow()
}

// SetWindowIcon - Set icon for window (only PLATFORM_DESKTOP)
// SetWindowIcon - Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP)
func SetWindowIcon(image Image) {
cimage := image.cptr()
C.SetWindowIcon(*cimage)
}

// SetWindowIcons - Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
func SetWindowIcons(images []Image, count int32) {
cimages := (&images[0]).cptr()
cimagesCount := C.int(count)
C.SetWindowIcons(cimages, cimagesCount)
}

// SetWindowTitle - Set title for window (only PLATFORM_DESKTOP)
func SetWindowTitle(title string) {
ctitle := C.CString(title)
Expand Down
8 changes: 8 additions & 0 deletions raylib/rlgl.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ func LoadShaderFromMemory(vsCode string, fsCode string) Shader {
return v
}

// IsShaderReady - Check if a shader is ready
func IsShaderReady(shader Shader) bool {
cshader := shader.cptr()
ret := C.IsShaderReady(*cshader)
v := bool(ret)
return v
}

// UnloadShader - Unload a custom shader from memory
func UnloadShader(shader Shader) {
cshader := shader.cptr()
Expand Down
12 changes: 12 additions & 0 deletions raylib/rshapes.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,18 @@ func CheckCollisionPointTriangle(point, p1, p2, p3 Vector2) bool {
return v
}

// CheckCollisionPointPoly - Check if point is within a polygon described by array of vertices
//
// NOTE: Based on http://jeffreythompson.org/collision-detection/poly-point.php
func CheckCollisionPointPoly(point Vector2, points []Vector2, pointCount int32) bool {
cpoint := point.cptr()
cpoints := (&points[0]).cptr()
cpointCount := C.int(pointCount)
ret := C.CheckCollisionPointPoly(*cpoint, cpoints, cpointCount)
v := bool(ret)
return v
}

// CheckCollisionLines - Check the collision between two lines defined by two points each, returns collision point by reference
func CheckCollisionLines(startPos1, endPos1, startPos2, endPos2 Vector2, point *Vector2) bool {
cstartPos1 := startPos1.cptr()
Expand Down
38 changes: 38 additions & 0 deletions raylib/rtextures.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,21 @@ func LoadImageFromMemory(fileType string, fileData []byte, dataSize int32) *Imag
return v
}

// LoadImageFromScreen - Load image from screen buffer (screenshot)
func LoadImageFromScreen() *Image {
ret := C.LoadImageFromScreen()
v := newImageFromPointer(unsafe.Pointer(&ret))
return v
}

// IsImageReady - Check if an image is ready
func IsImageReady(image *Image) bool {
cimage := image.cptr()
ret := C.IsImageReady(*cimage)
v := bool(ret)
return v
}

// LoadTexture - Load an image as texture into GPU memory
func LoadTexture(fileName string) Texture2D {
cfileName := C.CString(fileName)
Expand Down Expand Up @@ -116,12 +131,28 @@ func UnloadImage(image *Image) {
C.UnloadImage(*cimage)
}

// IsTextureReady - Check if a texture is ready
func IsTextureReady(texture Texture2D) bool {
ctexture := texture.cptr()
ret := C.IsTextureReady(*ctexture)
v := bool(ret)
return v
}

// UnloadTexture - Unload texture from GPU memory
func UnloadTexture(texture Texture2D) {
ctexture := texture.cptr()
C.UnloadTexture(*ctexture)
}

// IsRenderTextureReady - Check if a render texture is ready
func IsRenderTextureReady(target RenderTexture2D) bool {
ctarget := target.cptr()
ret := C.IsRenderTextureReady(*ctarget)
v := bool(ret)
return v
}

// UnloadRenderTexture - Unload render texture from GPU memory
func UnloadRenderTexture(target RenderTexture2D) {
ctarget := target.cptr()
Expand Down Expand Up @@ -248,6 +279,13 @@ func ImageAlphaPremultiply(image *Image) {
C.ImageAlphaPremultiply(cimage)
}

// ImageBlurGaussian - Apply box blur
func ImageBlurGaussian(image *Image, blurSize int32) {
cimage := image.cptr()
cblurSize := C.int(blurSize)
C.ImageBlurGaussian(cimage, cblurSize)
}

// ImageResize - Resize an image (bilinear filtering)
func ImageResize(image *Image, newWidth, newHeight int32) {
cimage := image.cptr()
Expand Down