Update examples
This commit is contained in:
parent
2a0340eb70
commit
ee66ee4d8e
14 changed files with 46 additions and 43 deletions
|
@ -16,17 +16,19 @@ func main() {
|
|||
camera.Up = raylib.NewVector3(0.0, 1.0, 0.0)
|
||||
camera.Fovy = 45.0
|
||||
|
||||
image := raylib.LoadImage("cubicmap.png") // Load cubicmap image (RAM)
|
||||
cubic := raylib.LoadTextureFromImage(image) // Convert image to texture to display (VRAM)
|
||||
cubicmap := raylib.LoadCubicmap(image) // Load cubicmap model (generate model from image)
|
||||
image := raylib.LoadImage("cubicmap.png") // Load cubicmap image (RAM)
|
||||
cubicmap := raylib.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)
|
||||
|
||||
// NOTE: By default each cube is mapped to one part of texture atlas
|
||||
texture := raylib.LoadTexture("cubicmap_atlas.png") // Load map texture
|
||||
cubicmap.Material.TexDiffuse = texture // Set map diffuse texture
|
||||
texture := raylib.LoadTexture("cubicmap_atlas.png") // Load map texture
|
||||
model.Material.Maps[raylib.MapDiffuse].Texture = texture // Set map diffuse texture
|
||||
|
||||
mapPosition := raylib.NewVector3(-16.0, 0.0, -8.0) // Set model position
|
||||
|
||||
raylib.UnloadImage(image) // Unload cubesmap image from RAM, already uploaded to VRAM
|
||||
raylib.UnloadImage(image) // Unload cubicmap image from RAM, already uploaded to VRAM
|
||||
|
||||
raylib.SetCameraMode(camera, raylib.CameraOrbital) // Set an orbital camera mode
|
||||
|
||||
|
@ -45,12 +47,12 @@ func main() {
|
|||
|
||||
raylib.Begin3dMode(camera)
|
||||
|
||||
raylib.DrawModel(cubicmap, mapPosition, 1.0, raylib.White)
|
||||
raylib.DrawModel(model, mapPosition, 1.0, raylib.White)
|
||||
|
||||
raylib.End3dMode()
|
||||
|
||||
raylib.DrawTextureEx(cubic, raylib.NewVector2(float32(screenWidth-cubic.Width*4-20), 20), 0.0, 4.0, raylib.White)
|
||||
raylib.DrawRectangleLines(screenWidth-cubic.Width*4-20, 20, cubic.Width*4, cubic.Height*4, raylib.Green)
|
||||
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)
|
||||
|
||||
raylib.DrawText("cubicmap image used to", 658, 90, 10, raylib.Gray)
|
||||
raylib.DrawText("generate map 3d model", 658, 104, 10, raylib.Gray)
|
||||
|
@ -60,9 +62,9 @@ func main() {
|
|||
raylib.EndDrawing()
|
||||
}
|
||||
|
||||
raylib.UnloadTexture(cubic) // Unload cubicmap texture
|
||||
raylib.UnloadTexture(texture) // Unload map texture
|
||||
raylib.UnloadModel(cubicmap) // Unload map model
|
||||
raylib.UnloadTexture(cubicmap) // Unload cubicmap texture
|
||||
raylib.UnloadTexture(texture) // Unload map texture
|
||||
raylib.UnloadModel(model) // Unload map model
|
||||
|
||||
raylib.CloseWindow()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue