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
|
@ -8,58 +8,58 @@ func main() {
|
|||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing")
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing")
|
||||
|
||||
camera := raylib.Camera{}
|
||||
camera.Position = raylib.NewVector3(18.0, 16.0, 18.0)
|
||||
camera.Target = raylib.NewVector3(0.0, 0.0, 0.0)
|
||||
camera.Up = raylib.NewVector3(0.0, 1.0, 0.0)
|
||||
camera := rl.Camera{}
|
||||
camera.Position = rl.NewVector3(18.0, 16.0, 18.0)
|
||||
camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
|
||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||
camera.Fovy = 45.0
|
||||
|
||||
image := raylib.LoadImage("heightmap.png") // Load heightmap image (RAM)
|
||||
texture := raylib.LoadTextureFromImage(image) // Convert image to texture (VRAM)
|
||||
image := rl.LoadImage("heightmap.png") // Load heightmap image (RAM)
|
||||
texture := rl.LoadTextureFromImage(image) // Convert image to texture (VRAM)
|
||||
|
||||
mesh := raylib.GenMeshHeightmap(*image, raylib.NewVector3(16, 8, 16)) // Generate heightmap mesh (RAM and VRAM)
|
||||
model := raylib.LoadModelFromMesh(mesh) // Load model from generated mesh
|
||||
mesh := rl.GenMeshHeightmap(*image, rl.NewVector3(16, 8, 16)) // Generate heightmap mesh (RAM and VRAM)
|
||||
model := rl.LoadModelFromMesh(mesh) // Load model from generated mesh
|
||||
|
||||
model.Material.Maps[raylib.MapDiffuse].Texture = texture // Set map diffuse texture
|
||||
mapPosition := raylib.NewVector3(-8.0, 0.0, -8.0) // Set model position
|
||||
model.Material.Maps[rl.MapDiffuse].Texture = texture // Set map diffuse texture
|
||||
mapPosition := rl.NewVector3(-8.0, 0.0, -8.0) // Set model position
|
||||
|
||||
raylib.UnloadImage(image) // Unload heightmap image from RAM, already uploaded to VRAM
|
||||
rl.UnloadImage(image) // Unload heightmap image from RAM, already uploaded to VRAM
|
||||
|
||||
raylib.SetCameraMode(camera, raylib.CameraOrbital) // Set an orbital camera mode
|
||||
rl.SetCameraMode(camera, rl.CameraOrbital) // Set an orbital camera mode
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
for !rl.WindowShouldClose() {
|
||||
// Update
|
||||
|
||||
raylib.UpdateCamera(&camera) // Update camera
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
|
||||
// Draw
|
||||
|
||||
raylib.BeginDrawing()
|
||||
rl.BeginDrawing()
|
||||
|
||||
raylib.ClearBackground(raylib.RayWhite)
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
raylib.BeginMode3D(camera)
|
||||
rl.BeginMode3D(camera)
|
||||
|
||||
raylib.DrawModel(model, mapPosition, 1.0, raylib.Red)
|
||||
rl.DrawModel(model, mapPosition, 1.0, rl.Red)
|
||||
|
||||
raylib.DrawGrid(20, 1.0)
|
||||
rl.DrawGrid(20, 1.0)
|
||||
|
||||
raylib.EndMode3D()
|
||||
rl.EndMode3D()
|
||||
|
||||
raylib.DrawTexture(texture, screenWidth-texture.Width-20, 20, raylib.White)
|
||||
raylib.DrawRectangleLines(screenWidth-texture.Width-20, 20, texture.Width, texture.Height, raylib.Green)
|
||||
rl.DrawTexture(texture, screenWidth-texture.Width-20, 20, rl.White)
|
||||
rl.DrawRectangleLines(screenWidth-texture.Width-20, 20, texture.Width, texture.Height, rl.Green)
|
||||
|
||||
raylib.DrawFPS(10, 10)
|
||||
rl.DrawFPS(10, 10)
|
||||
|
||||
raylib.EndDrawing()
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
raylib.UnloadTexture(texture) // Unload map texture
|
||||
raylib.UnloadModel(model) // Unload map model
|
||||
rl.UnloadTexture(texture) // Unload map texture
|
||||
rl.UnloadModel(model) // Unload map model
|
||||
|
||||
raylib.CloseWindow()
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue