Update C sources, add new functions and rename package to

This commit is contained in:
Milan Nikolic 2018-10-08 18:56:34 +02:00
parent 391c25482d
commit 08aa518a46
156 changed files with 34542 additions and 19573 deletions

View file

@ -8,42 +8,42 @@ func main() {
screenWidth := int32(800)
screenHeight := int32(450)
raylib.InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture loading and drawing")
rl.InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture loading and drawing")
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
cat := raylib.LoadImage("cat.png") // Load image in CPU memory (RAM)
raylib.ImageCrop(cat, raylib.NewRectangle(100, 10, 280, 380)) // Crop an image piece
raylib.ImageFlipHorizontal(cat) // Flip cropped image horizontally
raylib.ImageResize(cat, 150, 200) // Resize flipped-cropped image
cat := rl.LoadImage("cat.png") // Load image in CPU memory (RAM)
rl.ImageCrop(cat, rl.NewRectangle(100, 10, 280, 380)) // Crop an image piece
rl.ImageFlipHorizontal(cat) // Flip cropped image horizontally
rl.ImageResize(cat, 150, 200) // Resize flipped-cropped image
parrots := raylib.LoadImage("parrots.png") // Load image in CPU memory (RAM)
parrots := rl.LoadImage("parrots.png") // Load image in CPU memory (RAM)
// Draw one image over the other with a scaling of 1.5f
raylib.ImageDraw(parrots, cat, raylib.NewRectangle(0, 0, float32(cat.Width), float32(cat.Height)), raylib.NewRectangle(30, 40, float32(cat.Width)*1.5, float32(cat.Height)*1.5))
raylib.ImageCrop(parrots, raylib.NewRectangle(0, 50, float32(parrots.Width), float32(parrots.Height-100))) // Crop resulting image
rl.ImageDraw(parrots, cat, rl.NewRectangle(0, 0, float32(cat.Width), float32(cat.Height)), rl.NewRectangle(30, 40, float32(cat.Width)*1.5, float32(cat.Height)*1.5))
rl.ImageCrop(parrots, rl.NewRectangle(0, 50, float32(parrots.Width), float32(parrots.Height-100))) // Crop resulting image
raylib.UnloadImage(cat) // Unload image from RAM
rl.UnloadImage(cat) // Unload image from RAM
texture := raylib.LoadTextureFromImage(parrots) // Image converted to texture, uploaded to GPU memory (VRAM)
raylib.UnloadImage(parrots) // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
texture := rl.LoadTextureFromImage(parrots) // Image converted to texture, uploaded to GPU memory (VRAM)
rl.UnloadImage(parrots) // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
raylib.SetTargetFPS(60)
rl.SetTargetFPS(60)
for !raylib.WindowShouldClose() {
raylib.BeginDrawing()
for !rl.WindowShouldClose() {
rl.BeginDrawing()
raylib.ClearBackground(raylib.RayWhite)
rl.ClearBackground(rl.RayWhite)
raylib.DrawTexture(texture, screenWidth/2-texture.Width/2, screenHeight/2-texture.Height/2-40, raylib.White)
raylib.DrawRectangleLines(screenWidth/2-texture.Width/2, screenHeight/2-texture.Height/2-40, texture.Width, texture.Height, raylib.DarkGray)
rl.DrawTexture(texture, screenWidth/2-texture.Width/2, screenHeight/2-texture.Height/2-40, rl.White)
rl.DrawRectangleLines(screenWidth/2-texture.Width/2, screenHeight/2-texture.Height/2-40, texture.Width, texture.Height, rl.DarkGray)
raylib.DrawText("We are drawing only one texture from various images composed!", 240, 350, 10, raylib.DarkGray)
raylib.DrawText("Source images have been cropped, scaled, flipped and copied one over the other.", 190, 370, 10, raylib.DarkGray)
rl.DrawText("We are drawing only one texture from various images composed!", 240, 350, 10, rl.DarkGray)
rl.DrawText("Source images have been cropped, scaled, flipped and copied one over the other.", 190, 370, 10, rl.DarkGray)
raylib.EndDrawing()
rl.EndDrawing()
}
raylib.UnloadTexture(texture)
rl.UnloadTexture(texture)
raylib.CloseWindow()
rl.CloseWindow()
}