Update examples
This commit is contained in:
parent
2013bc4628
commit
7b91ce25fb
8 changed files with 32 additions and 36 deletions
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
const numTextures = 7
|
||||
|
@ -17,7 +17,6 @@ func main() {
|
|||
radialGradient := rl.GenImageGradientRadial(screenWidth, screenHeight, 0, rl.White, rl.Black)
|
||||
checked := rl.GenImageChecked(screenWidth, screenHeight, 32, 32, rl.Red, rl.Blue)
|
||||
whiteNoise := rl.GenImageWhiteNoise(screenWidth, screenHeight, 0.5)
|
||||
perlinNoise := rl.GenImagePerlinNoise(screenWidth, screenHeight, 50, 50, 4.0)
|
||||
cellular := rl.GenImageCellular(screenWidth, screenHeight, 32)
|
||||
|
||||
textures := make([]rl.Texture2D, numTextures)
|
||||
|
@ -26,8 +25,7 @@ func main() {
|
|||
textures[2] = rl.LoadTextureFromImage(radialGradient)
|
||||
textures[3] = rl.LoadTextureFromImage(checked)
|
||||
textures[4] = rl.LoadTextureFromImage(whiteNoise)
|
||||
textures[5] = rl.LoadTextureFromImage(perlinNoise)
|
||||
textures[6] = rl.LoadTextureFromImage(cellular)
|
||||
textures[5] = rl.LoadTextureFromImage(cellular)
|
||||
|
||||
// Unload image data (CPU RAM)
|
||||
rl.UnloadImage(verticalGradient)
|
||||
|
@ -35,7 +33,6 @@ func main() {
|
|||
rl.UnloadImage(radialGradient)
|
||||
rl.UnloadImage(checked)
|
||||
rl.UnloadImage(whiteNoise)
|
||||
rl.UnloadImage(perlinNoise)
|
||||
rl.UnloadImage(cellular)
|
||||
|
||||
currentTexture := 0
|
||||
|
@ -74,9 +71,6 @@ func main() {
|
|||
rl.DrawText("WHITE NOISE", 640, 10, 20, rl.Red)
|
||||
break
|
||||
case 5:
|
||||
rl.DrawText("PERLIN NOISE", 630, 10, 20, rl.RayWhite)
|
||||
break
|
||||
case 6:
|
||||
rl.DrawText("CELLULAR", 670, 10, 20, rl.RayWhite)
|
||||
break
|
||||
default:
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"image/png"
|
||||
"os"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -35,7 +35,7 @@ func main() {
|
|||
|
||||
for !rl.WindowShouldClose() {
|
||||
if rl.IsKeyPressed(rl.KeyS) {
|
||||
rimg := rl.GetTextureData(texture)
|
||||
rimg := rl.LoadImageFromTexture(texture)
|
||||
|
||||
f, err := os.Create("image_saved.png")
|
||||
if err != nil {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
const numProcesses = 8
|
||||
|
@ -35,9 +35,9 @@ func main() {
|
|||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [textures] example - image processing")
|
||||
|
||||
image := rl.LoadImage("parrots.png") // Loaded in CPU memory (RAM)
|
||||
image := rl.LoadImage("parrots.png") // Loaded in CPU memory (RAM)
|
||||
rl.ImageFormat(image, rl.UncompressedR8g8b8a8) // Format image to RGBA 32bit (required for texture update)
|
||||
texture := rl.LoadTextureFromImage(image) // Image converted to texture, GPU memory (VRAM)
|
||||
texture := rl.LoadTextureFromImage(image) // Image converted to texture, GPU memory (VRAM)
|
||||
|
||||
currentProcess := None
|
||||
textureReload := false
|
||||
|
@ -98,8 +98,8 @@ func main() {
|
|||
break
|
||||
}
|
||||
|
||||
pixels := rl.GetImageData(image) // Get pixel data from image (RGBA 32bit)
|
||||
rl.UpdateTexture(texture, pixels) // Update texture with new image data
|
||||
pixels := rl.LoadImageColors(image) // Get pixel data from image (RGBA 32bit)
|
||||
rl.UpdateTexture(texture, pixels) // Update texture with new image data
|
||||
|
||||
textureReload = false
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -14,8 +14,8 @@ func main() {
|
|||
texture := rl.LoadTextureFromImage(image) // Image converted to texture, GPU memory (RAM -> VRAM)
|
||||
rl.UnloadImage(image) // Unload image data from CPU memory (RAM)
|
||||
|
||||
image = rl.GetTextureData(texture) // Retrieve image data from GPU memory (VRAM -> RAM)
|
||||
rl.UnloadTexture(texture) // Unload texture from GPU memory (VRAM)
|
||||
image = rl.LoadImageFromTexture(texture) // Retrieve image data from GPU memory (VRAM -> RAM)
|
||||
rl.UnloadTexture(texture) // Unload texture from GPU memory (VRAM)
|
||||
|
||||
texture = rl.LoadTextureFromImage(image) // Recreate texture from retrieved image data (RAM -> VRAM)
|
||||
rl.UnloadImage(image) // Unload retrieved image data from CPU memory (RAM)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue