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,64 +8,64 @@ func main() {
|
|||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing")
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing")
|
||||
|
||||
camera := raylib.Camera{}
|
||||
camera.Position = raylib.NewVector3(16.0, 14.0, 16.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(16.0, 14.0, 16.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
|
||||
camera.Type = raylib.CameraPerspective
|
||||
camera.Type = rl.CameraPerspective
|
||||
|
||||
image := raylib.LoadImage("cubicmap.png") // Load cubicmap image (RAM)
|
||||
cubicmap := raylib.LoadTextureFromImage(image) // Convert image to texture to display (VRAM)
|
||||
image := rl.LoadImage("cubicmap.png") // Load cubicmap image (RAM)
|
||||
cubicmap := rl.LoadTextureFromImage(image) // Convert image to texture to display (VRAM)
|
||||
|
||||
mesh := raylib.GenMeshCubicmap(*image, raylib.NewVector3(1.0, 1.0, 1.0))
|
||||
model := raylib.LoadModelFromMesh(mesh)
|
||||
mesh := rl.GenMeshCubicmap(*image, rl.NewVector3(1.0, 1.0, 1.0))
|
||||
model := rl.LoadModelFromMesh(mesh)
|
||||
|
||||
// NOTE: By default each cube is mapped to one part of texture atlas
|
||||
texture := raylib.LoadTexture("cubicmap_atlas.png") // Load map texture
|
||||
model.Material.Maps[raylib.MapDiffuse].Texture = texture // Set map diffuse texture
|
||||
texture := rl.LoadTexture("cubicmap_atlas.png") // Load map texture
|
||||
model.Material.Maps[rl.MapDiffuse].Texture = texture // Set map diffuse texture
|
||||
|
||||
mapPosition := raylib.NewVector3(-16.0, 0.0, -8.0) // Set model position
|
||||
mapPosition := rl.NewVector3(-16.0, 0.0, -8.0) // Set model position
|
||||
|
||||
raylib.UnloadImage(image) // Unload cubicmap image from RAM, already uploaded to VRAM
|
||||
rl.UnloadImage(image) // Unload cubicmap 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.White)
|
||||
rl.DrawModel(model, mapPosition, 1.0, rl.White)
|
||||
|
||||
raylib.EndMode3D()
|
||||
rl.EndMode3D()
|
||||
|
||||
raylib.DrawTextureEx(cubicmap, raylib.NewVector2(float32(screenWidth-cubicmap.Width*4-20), 20), 0.0, 4.0, raylib.White)
|
||||
raylib.DrawRectangleLines(screenWidth-cubicmap.Width*4-20, 20, cubicmap.Width*4, cubicmap.Height*4, raylib.Green)
|
||||
rl.DrawTextureEx(cubicmap, rl.NewVector2(float32(screenWidth-cubicmap.Width*4-20), 20), 0.0, 4.0, rl.White)
|
||||
rl.DrawRectangleLines(screenWidth-cubicmap.Width*4-20, 20, cubicmap.Width*4, cubicmap.Height*4, rl.Green)
|
||||
|
||||
raylib.DrawText("cubicmap image used to", 658, 90, 10, raylib.Gray)
|
||||
raylib.DrawText("generate map 3d model", 658, 104, 10, raylib.Gray)
|
||||
rl.DrawText("cubicmap image used to", 658, 90, 10, rl.Gray)
|
||||
rl.DrawText("generate map 3d model", 658, 104, 10, rl.Gray)
|
||||
|
||||
raylib.DrawFPS(10, 10)
|
||||
rl.DrawFPS(10, 10)
|
||||
|
||||
raylib.EndDrawing()
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
raylib.UnloadTexture(cubicmap) // Unload cubicmap texture
|
||||
raylib.UnloadTexture(texture) // Unload map texture
|
||||
raylib.UnloadModel(model) // Unload map model
|
||||
rl.UnloadTexture(cubicmap) // Unload cubicmap texture
|
||||
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