Update C sources, add new functions and rename package to
This commit is contained in:
parent
391c25482d
commit
08aa518a46
156 changed files with 34542 additions and 19573 deletions
|
@ -10,85 +10,85 @@ func main() {
|
|||
screenWidth := 800
|
||||
screenHeight := 450
|
||||
|
||||
raylib.InitWindow(int32(screenWidth), int32(screenHeight), "raylib [textures] example - procedural images generation")
|
||||
rl.InitWindow(int32(screenWidth), int32(screenHeight), "raylib [textures] example - procedural images generation")
|
||||
|
||||
verticalGradient := raylib.GenImageGradientV(screenWidth, screenHeight, raylib.Red, raylib.Blue)
|
||||
horizontalGradient := raylib.GenImageGradientH(screenWidth, screenHeight, raylib.Red, raylib.Blue)
|
||||
radialGradient := raylib.GenImageGradientRadial(screenWidth, screenHeight, 0, raylib.White, raylib.Black)
|
||||
checked := raylib.GenImageChecked(screenWidth, screenHeight, 32, 32, raylib.Red, raylib.Blue)
|
||||
whiteNoise := raylib.GenImageWhiteNoise(screenWidth, screenHeight, 0.5)
|
||||
perlinNoise := raylib.GenImagePerlinNoise(screenWidth, screenHeight, 50, 50, 4.0)
|
||||
cellular := raylib.GenImageCellular(screenWidth, screenHeight, 32)
|
||||
verticalGradient := rl.GenImageGradientV(screenWidth, screenHeight, rl.Red, rl.Blue)
|
||||
horizontalGradient := rl.GenImageGradientH(screenWidth, screenHeight, rl.Red, rl.Blue)
|
||||
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([]raylib.Texture2D, numTextures)
|
||||
textures[0] = raylib.LoadTextureFromImage(verticalGradient)
|
||||
textures[1] = raylib.LoadTextureFromImage(horizontalGradient)
|
||||
textures[2] = raylib.LoadTextureFromImage(radialGradient)
|
||||
textures[3] = raylib.LoadTextureFromImage(checked)
|
||||
textures[4] = raylib.LoadTextureFromImage(whiteNoise)
|
||||
textures[5] = raylib.LoadTextureFromImage(perlinNoise)
|
||||
textures[6] = raylib.LoadTextureFromImage(cellular)
|
||||
textures := make([]rl.Texture2D, numTextures)
|
||||
textures[0] = rl.LoadTextureFromImage(verticalGradient)
|
||||
textures[1] = rl.LoadTextureFromImage(horizontalGradient)
|
||||
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)
|
||||
|
||||
// Unload image data (CPU RAM)
|
||||
raylib.UnloadImage(verticalGradient)
|
||||
raylib.UnloadImage(horizontalGradient)
|
||||
raylib.UnloadImage(radialGradient)
|
||||
raylib.UnloadImage(checked)
|
||||
raylib.UnloadImage(whiteNoise)
|
||||
raylib.UnloadImage(perlinNoise)
|
||||
raylib.UnloadImage(cellular)
|
||||
rl.UnloadImage(verticalGradient)
|
||||
rl.UnloadImage(horizontalGradient)
|
||||
rl.UnloadImage(radialGradient)
|
||||
rl.UnloadImage(checked)
|
||||
rl.UnloadImage(whiteNoise)
|
||||
rl.UnloadImage(perlinNoise)
|
||||
rl.UnloadImage(cellular)
|
||||
|
||||
currentTexture := 0
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
if raylib.IsMouseButtonPressed(raylib.MouseLeftButton) {
|
||||
for !rl.WindowShouldClose() {
|
||||
if rl.IsMouseButtonPressed(rl.MouseLeftButton) {
|
||||
currentTexture = (currentTexture + 1) % numTextures // Cycle between the textures
|
||||
}
|
||||
|
||||
raylib.BeginDrawing()
|
||||
rl.BeginDrawing()
|
||||
|
||||
raylib.ClearBackground(raylib.RayWhite)
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
raylib.DrawTexture(textures[currentTexture], 0, 0, raylib.White)
|
||||
rl.DrawTexture(textures[currentTexture], 0, 0, rl.White)
|
||||
|
||||
raylib.DrawRectangle(30, 400, 325, 30, raylib.Fade(raylib.SkyBlue, 0.5))
|
||||
raylib.DrawRectangleLines(30, 400, 325, 30, raylib.Fade(raylib.White, 0.5))
|
||||
raylib.DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL TEXTURES", 40, 410, 10, raylib.White)
|
||||
rl.DrawRectangle(30, 400, 325, 30, rl.Fade(rl.SkyBlue, 0.5))
|
||||
rl.DrawRectangleLines(30, 400, 325, 30, rl.Fade(rl.White, 0.5))
|
||||
rl.DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL TEXTURES", 40, 410, 10, rl.White)
|
||||
|
||||
switch currentTexture {
|
||||
case 0:
|
||||
raylib.DrawText("VERTICAL GRADIENT", 560, 10, 20, raylib.RayWhite)
|
||||
rl.DrawText("VERTICAL GRADIENT", 560, 10, 20, rl.RayWhite)
|
||||
break
|
||||
case 1:
|
||||
raylib.DrawText("HORIZONTAL GRADIENT", 540, 10, 20, raylib.RayWhite)
|
||||
rl.DrawText("HORIZONTAL GRADIENT", 540, 10, 20, rl.RayWhite)
|
||||
break
|
||||
case 2:
|
||||
raylib.DrawText("RADIAL GRADIENT", 580, 10, 20, raylib.LightGray)
|
||||
rl.DrawText("RADIAL GRADIENT", 580, 10, 20, rl.LightGray)
|
||||
break
|
||||
case 3:
|
||||
raylib.DrawText("CHECKED", 680, 10, 20, raylib.RayWhite)
|
||||
rl.DrawText("CHECKED", 680, 10, 20, rl.RayWhite)
|
||||
break
|
||||
case 4:
|
||||
raylib.DrawText("WHITE NOISE", 640, 10, 20, raylib.Red)
|
||||
rl.DrawText("WHITE NOISE", 640, 10, 20, rl.Red)
|
||||
break
|
||||
case 5:
|
||||
raylib.DrawText("PERLIN NOISE", 630, 10, 20, raylib.RayWhite)
|
||||
rl.DrawText("PERLIN NOISE", 630, 10, 20, rl.RayWhite)
|
||||
break
|
||||
case 6:
|
||||
raylib.DrawText("CELLULAR", 670, 10, 20, raylib.RayWhite)
|
||||
rl.DrawText("CELLULAR", 670, 10, 20, rl.RayWhite)
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
raylib.EndDrawing()
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
for _, t := range textures {
|
||||
raylib.UnloadTexture(t)
|
||||
rl.UnloadTexture(t)
|
||||
}
|
||||
|
||||
raylib.CloseWindow()
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue