I am wondering about performance in Raylib, especially using the DrawTexture and NewImageFromImage functions. I have the code below, it's written in Go so I am using the go-bindings found here : https://github.com/gen2brain/raylib-go
When I run the code below (full code : https://github.com/Hultan/fractal), I get approx. the following result for each frame:
Calculating done in 30.925822 ms! Drawing done in 135.477039 ms! So it calculates (and generates an image.Image) in 30 ms, and it takes four times as long to draw that image.
Am I using Raylib correct here? I have not tried to generate Mandelbrot fractals in decades, so those numbers might very well be reasonable today. I was expecting the computational part to be much slower than the drawing though, not the reverse...
And I do have a 5 year old graphics card, so maybe that's why...
const ( width, height = 800, 600 ) func main() { rl.InitWindow(width, height, "fractal") defer rl.CloseWindow() img := image.NewRGBA(image.Rect(0, 0, width, height)) for !rl.WindowShouldClose() { ... rl.BeginDrawing() t := time.Now() ... // Generating Mandelbrot fractal image into img ... fmt.Printf("Calculating done in %v!\n", time.Since(t)) t = time.Now() tex := rl.LoadTextureFromImage(rl.NewImageFromImage(img)) rl.DrawTexture(tex, 0, 0, rl.White) fmt.Printf("Drawing done in %v!\n", time.Since(t)) rl.EndDrawing() rl.UnloadTexture(tex) } } Edit : Added information about the fractal size, see comment.