Removed test per maintainer instruction, added back in ImageFromImage and LoadTextureCubemap
This commit is contained in:
parent
509ad7da5c
commit
1f80c1e4c2
2 changed files with 18 additions and 49 deletions
|
@ -184,6 +184,15 @@ func LoadRenderTexture(width, height int32) RenderTexture2D {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadTextureCubemap - Loads a texture for a cubemap using given layout
|
||||||
|
func LoadTextureCubemap(image *Image, layout int32) Texture2D {
|
||||||
|
cimage := image.cptr()
|
||||||
|
clayout := (C.int)(layout)
|
||||||
|
ret := C.LoadTextureCubemap(*cimage, clayout)
|
||||||
|
v := newTexture2DFromPointer(unsafe.Pointer(&ret))
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
// UnloadImage - Unload image from CPU memory (RAM)
|
// UnloadImage - Unload image from CPU memory (RAM)
|
||||||
func UnloadImage(image *Image) {
|
func UnloadImage(image *Image) {
|
||||||
cimage := image.cptr()
|
cimage := image.cptr()
|
||||||
|
@ -250,7 +259,6 @@ func ExportImage(image Image, fileName string) bool {
|
||||||
cfileName := C.CString(fileName)
|
cfileName := C.CString(fileName)
|
||||||
defer C.free(unsafe.Pointer(cfileName))
|
defer C.free(unsafe.Pointer(cfileName))
|
||||||
cimage := image.cptr()
|
cimage := image.cptr()
|
||||||
|
|
||||||
return bool(C.ExportImage(*cimage, cfileName))
|
return bool(C.ExportImage(*cimage, cfileName))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,6 +282,15 @@ func ImageCopy(image *Image) *Image {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create an image from another image piece
|
||||||
|
func ImageFromImage(image Image, rec Rectangle) Image {
|
||||||
|
cimage := image.cptr()
|
||||||
|
crec := rec.cptr()
|
||||||
|
ret := C.ImageFromImage(*cimage, *crec)
|
||||||
|
v := newImageFromPointer(unsafe.Pointer(&ret))
|
||||||
|
return *v
|
||||||
|
}
|
||||||
|
|
||||||
// ImageText - Create an image from text (default font)
|
// ImageText - Create an image from text (default font)
|
||||||
func ImageText(text string, fontSize int32, col color.RGBA) *Image {
|
func ImageText(text string, fontSize int32, col color.RGBA) *Image {
|
||||||
ctext := C.CString(text)
|
ctext := C.CString(text)
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
package rl_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"image/color"
|
|
||||||
|
|
||||||
rl "github.com/gen2brain/raylib-go/raylib"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestExportImage(t *testing.T) {
|
|
||||||
var tests = []struct {
|
|
||||||
name string
|
|
||||||
image rl.Image
|
|
||||||
fileName string
|
|
||||||
want bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "ValidImageExport",
|
|
||||||
image: *rl.GenImageColor(100, 100, color.RGBA{255, 0, 0, 255}),
|
|
||||||
fileName: "test_image.png",
|
|
||||||
want: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "InvalidImageExport",
|
|
||||||
image: rl.Image{},
|
|
||||||
fileName: "",
|
|
||||||
want: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
success := rl.ExportImage(tt.image, tt.fileName)
|
|
||||||
defer os.Remove(tt.fileName)
|
|
||||||
|
|
||||||
if success != tt.want {
|
|
||||||
t.Errorf("ExportImage() result = %v, wantResult %v", success, tt.want)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := os.Stat(tt.fileName); os.IsNotExist(err) && tt.want {
|
|
||||||
t.Errorf("ExportImage() failed to create file %s", tt.fileName)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue