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,56 +8,56 @@ func main() {
screenWidth := int32(800)
screenHeight := int32(450)
raylib.InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture from raw data")
rl.InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture from raw data")
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
// Load RAW image data (384x512, 32bit RGBA, no file header)
fudesumiRaw := raylib.LoadImageRaw("texture_formats/fudesumi.raw", 384, 512, raylib.UncompressedR8g8b8a8, 0)
fudesumi := raylib.LoadTextureFromImage(fudesumiRaw) // Upload CPU (RAM) image to GPU (VRAM)
raylib.UnloadImage(fudesumiRaw) // Unload CPU (RAM) image data
fudesumiRaw := rl.LoadImageRaw("texture_formats/fudesumi.raw", 384, 512, rl.UncompressedR8g8b8a8, 0)
fudesumi := rl.LoadTextureFromImage(fudesumiRaw) // Upload CPU (RAM) image to GPU (VRAM)
rl.UnloadImage(fudesumiRaw) // Unload CPU (RAM) image data
// Generate a checked texture by code (1024x1024 pixels)
width := 1024
height := 1024
// Dynamic memory allocation to store pixels data (Color type)
pixels := make([]raylib.Color, width*height)
pixels := make([]rl.Color, width*height)
for y := 0; y < height; y++ {
for x := 0; x < width; x++ {
if ((x/32+y/32)/1)%2 == 0 {
pixels[y*height+x] = raylib.Orange
pixels[y*height+x] = rl.Orange
} else {
pixels[y*height+x] = raylib.Gold
pixels[y*height+x] = rl.Gold
}
}
}
// Load pixels data into an image structure and create texture
checkedIm := raylib.LoadImageEx(pixels, int32(width), int32(height))
checked := raylib.LoadTextureFromImage(checkedIm)
raylib.UnloadImage(checkedIm) // Unload CPU (RAM) image data
checkedIm := rl.LoadImageEx(pixels, int32(width), int32(height))
checked := rl.LoadTextureFromImage(checkedIm)
rl.UnloadImage(checkedIm) // Unload CPU (RAM) image data
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(checked, screenWidth/2-checked.Width/2, screenHeight/2-checked.Height/2, raylib.Fade(raylib.White, 0.5))
raylib.DrawTexture(fudesumi, 430, -30, raylib.White)
rl.DrawTexture(checked, screenWidth/2-checked.Width/2, screenHeight/2-checked.Height/2, rl.Fade(rl.White, 0.5))
rl.DrawTexture(fudesumi, 430, -30, rl.White)
raylib.DrawText("CHECKED TEXTURE ", 84, 100, 30, raylib.Brown)
raylib.DrawText("GENERATED by CODE", 72, 164, 30, raylib.Brown)
raylib.DrawText("and RAW IMAGE LOADING", 46, 226, 30, raylib.Brown)
rl.DrawText("CHECKED TEXTURE ", 84, 100, 30, rl.Brown)
rl.DrawText("GENERATED by CODE", 72, 164, 30, rl.Brown)
rl.DrawText("and RAW IMAGE LOADING", 46, 226, 30, rl.Brown)
raylib.EndDrawing()
rl.EndDrawing()
}
raylib.UnloadTexture(fudesumi) // Texture unloading
raylib.UnloadTexture(checked) // Texture unloading
rl.UnloadTexture(fudesumi) // Texture unloading
rl.UnloadTexture(checked) // Texture unloading
raylib.CloseWindow()
rl.CloseWindow()
}