From ee66ee4d8e332387b8176e28a0d709eb3059bf5f Mon Sep 17 00:00:00 2001 From: Milan Nikolic Date: Thu, 26 Oct 2017 19:03:17 +0200 Subject: [PATCH] Update examples --- examples/core/vr_simulator/main.go | 2 +- examples/games/floppy/README.md | 2 -- examples/models/cubicmap/main.go | 26 ++++++++++--------- examples/models/heightmap/main.go | 20 +++++++------- examples/models/obj_loading/main.go | 2 +- .../shaders/custom_uniform/glsl330/base.vs | 6 ++--- examples/shaders/custom_uniform/main.go | 2 +- examples/shaders/model_shader/glsl330/base.vs | 6 ++--- examples/shaders/model_shader/main.go | 4 +-- .../shaders/postprocessing/glsl330/base.vs | 6 ++--- examples/shaders/postprocessing/main.go | 3 ++- .../shaders/shapes_textures/glsl330/base.vs | 6 ++--- examples/shaders/shapes_textures/main.go | 2 +- examples/shapes/basic_shapes/main.go | 2 +- 14 files changed, 46 insertions(+), 43 deletions(-) diff --git a/examples/core/vr_simulator/main.go b/examples/core/vr_simulator/main.go index bec3bb4..725d17f 100644 --- a/examples/core/vr_simulator/main.go +++ b/examples/core/vr_simulator/main.go @@ -13,7 +13,7 @@ func main() { raylib.InitWindow(screenWidth, screenHeight, "raylib [core] example - vr simulator") // NOTE: default device (simulator) - raylib.InitVrSimulator(raylib.HmdOculusRiftCv1) // Init VR device (Oculus Rift CV1) + raylib.InitVrSimulator(raylib.GetVrDeviceInfo(raylib.HmdOculusRiftCv1)) // Init VR device (Oculus Rift CV1) camera := raylib.Camera{} camera.Position = raylib.NewVector3(5.0, 2.0, 5.0) // Camera position diff --git a/examples/games/floppy/README.md b/examples/games/floppy/README.md index 51aaee2..e7e4e00 100644 --- a/examples/games/floppy/README.md +++ b/examples/games/floppy/README.md @@ -1,5 +1,3 @@ ## Floppy Gopher ![screenshot](https://goo.gl/K2NAJ1) - -[Android apk](https://gist.github.com/gen2brain/ae96bc92d2c2e307af35f5583f30ea25/raw/cd771b86ef6c4b03a2c5957fa2a097ee8a3bcbb4/floppy-gopher.apk) diff --git a/examples/models/cubicmap/main.go b/examples/models/cubicmap/main.go index a97e4fc..ab349aa 100644 --- a/examples/models/cubicmap/main.go +++ b/examples/models/cubicmap/main.go @@ -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() } diff --git a/examples/models/heightmap/main.go b/examples/models/heightmap/main.go index 0d85f72..a8bf6e5 100644 --- a/examples/models/heightmap/main.go +++ b/examples/models/heightmap/main.go @@ -16,13 +16,16 @@ func main() { camera.Up = raylib.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) - hmap := raylib.LoadHeightmap(image, raylib.NewVector3(16, 8, 16)) // Load heightmap model with defined size - hmap.Material.TexDiffuse = texture // Set map diffuse texture - mapPosition := raylib.NewVector3(-8.0, 0.0, -8.0) // Set model position + image := raylib.LoadImage("heightmap.png") // Load heightmap image (RAM) + texture := raylib.LoadTextureFromImage(image) // Convert image to texture (VRAM) - raylib.UnloadImage(image) // Unload cubesmap image from RAM, already uploaded to 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 + + model.Material.Maps[raylib.MapDiffuse].Texture = texture // Set map diffuse texture + mapPosition := raylib.NewVector3(-8.0, 0.0, -8.0) // Set model position + + raylib.UnloadImage(image) // Unload heightmap image from RAM, already uploaded to VRAM raylib.SetCameraMode(camera, raylib.CameraOrbital) // Set an orbital camera mode @@ -41,8 +44,7 @@ func main() { raylib.Begin3dMode(camera) - // NOTE: Model is scaled to 1/4 of its original size (128x128 units) - raylib.DrawModel(hmap, mapPosition, 1.0, raylib.Red) + raylib.DrawModel(model, mapPosition, 1.0, raylib.Red) raylib.DrawGrid(20, 1.0) @@ -57,7 +59,7 @@ func main() { } raylib.UnloadTexture(texture) // Unload map texture - raylib.UnloadModel(hmap) // Unload map model + raylib.UnloadModel(model) // Unload map model raylib.CloseWindow() } diff --git a/examples/models/obj_loading/main.go b/examples/models/obj_loading/main.go index 917741b..6f4e089 100644 --- a/examples/models/obj_loading/main.go +++ b/examples/models/obj_loading/main.go @@ -19,7 +19,7 @@ func main() { dwarf := raylib.LoadModel("dwarf.obj") // Load OBJ model texture := raylib.LoadTexture("dwarf_diffuse.png") // Load model texture - dwarf.Material.TexDiffuse = texture // Set dwarf model diffuse texture + dwarf.Material.Maps[raylib.MapDiffuse].Texture = texture // Set dwarf model diffuse texture position := raylib.NewVector3(0.0, 0.0, 0.0) // Set model position diff --git a/examples/shaders/custom_uniform/glsl330/base.vs b/examples/shaders/custom_uniform/glsl330/base.vs index 638cb8a..1cb3729 100644 --- a/examples/shaders/custom_uniform/glsl330/base.vs +++ b/examples/shaders/custom_uniform/glsl330/base.vs @@ -7,7 +7,7 @@ in vec3 vertexNormal; in vec4 vertexColor; // Input uniform values -uniform mat4 mvpMatrix; +uniform mat4 mvp; // Output vertex attributes (to fragment shader) out vec2 fragTexCoord; @@ -22,5 +22,5 @@ void main() fragColor = vertexColor; // Calculate final vertex position - gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); -} \ No newline at end of file + gl_Position = mvp*vec4(vertexPosition, 1.0); +} diff --git a/examples/shaders/custom_uniform/main.go b/examples/shaders/custom_uniform/main.go index eadf4bc..c8b44ad 100644 --- a/examples/shaders/custom_uniform/main.go +++ b/examples/shaders/custom_uniform/main.go @@ -21,7 +21,7 @@ func main() { dwarf := raylib.LoadModel("dwarf.obj") // Load OBJ model texture := raylib.LoadTexture("dwarf_diffuse.png") // Load model texture - dwarf.Material.TexDiffuse = texture // Bind texture to model + dwarf.Material.Maps[raylib.MapDiffuse].Texture = texture // Set dwarf model diffuse texture position := raylib.NewVector3(0.0, 0.0, 0.0) // Set model position diff --git a/examples/shaders/model_shader/glsl330/base.vs b/examples/shaders/model_shader/glsl330/base.vs index 638cb8a..1cb3729 100644 --- a/examples/shaders/model_shader/glsl330/base.vs +++ b/examples/shaders/model_shader/glsl330/base.vs @@ -7,7 +7,7 @@ in vec3 vertexNormal; in vec4 vertexColor; // Input uniform values -uniform mat4 mvpMatrix; +uniform mat4 mvp; // Output vertex attributes (to fragment shader) out vec2 fragTexCoord; @@ -22,5 +22,5 @@ void main() fragColor = vertexColor; // Calculate final vertex position - gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); -} \ No newline at end of file + gl_Position = mvp*vec4(vertexPosition, 1.0); +} diff --git a/examples/shaders/model_shader/main.go b/examples/shaders/model_shader/main.go index 30f422e..96dda16 100644 --- a/examples/shaders/model_shader/main.go +++ b/examples/shaders/model_shader/main.go @@ -24,8 +24,8 @@ func main() { texture := raylib.LoadTexture("dwarf_diffuse.png") // Load model texture shader := raylib.LoadShader("glsl330/base.vs", "glsl330/grayscale.fs") // Load model shader - dwarf.Material.Shader = shader // Set shader effect to 3d model - dwarf.Material.TexDiffuse = texture // Bind texture to model + dwarf.Material.Shader = shader // Set shader effect to 3d model + dwarf.Material.Maps[raylib.MapDiffuse].Texture = texture // Set dwarf model diffuse texture position := raylib.NewVector3(0.0, 0.0, 0.0) // Set model position diff --git a/examples/shaders/postprocessing/glsl330/base.vs b/examples/shaders/postprocessing/glsl330/base.vs index 638cb8a..1cb3729 100644 --- a/examples/shaders/postprocessing/glsl330/base.vs +++ b/examples/shaders/postprocessing/glsl330/base.vs @@ -7,7 +7,7 @@ in vec3 vertexNormal; in vec4 vertexColor; // Input uniform values -uniform mat4 mvpMatrix; +uniform mat4 mvp; // Output vertex attributes (to fragment shader) out vec2 fragTexCoord; @@ -22,5 +22,5 @@ void main() fragColor = vertexColor; // Calculate final vertex position - gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); -} \ No newline at end of file + gl_Position = mvp*vec4(vertexPosition, 1.0); +} diff --git a/examples/shaders/postprocessing/main.go b/examples/shaders/postprocessing/main.go index 6e2292e..6b6d962 100644 --- a/examples/shaders/postprocessing/main.go +++ b/examples/shaders/postprocessing/main.go @@ -20,7 +20,8 @@ func main() { dwarf := raylib.LoadModel("dwarf.obj") // Load OBJ model texture := raylib.LoadTexture("dwarf_diffuse.png") // Load model texture - dwarf.Material.TexDiffuse = texture // Set dwarf model diffuse texture + + dwarf.Material.Maps[raylib.MapDiffuse].Texture = texture // Set dwarf model diffuse texture position := raylib.NewVector3(0.0, 0.0, 0.0) // Set model position diff --git a/examples/shaders/shapes_textures/glsl330/base.vs b/examples/shaders/shapes_textures/glsl330/base.vs index 638cb8a..1cb3729 100644 --- a/examples/shaders/shapes_textures/glsl330/base.vs +++ b/examples/shaders/shapes_textures/glsl330/base.vs @@ -7,7 +7,7 @@ in vec3 vertexNormal; in vec4 vertexColor; // Input uniform values -uniform mat4 mvpMatrix; +uniform mat4 mvp; // Output vertex attributes (to fragment shader) out vec2 fragTexCoord; @@ -22,5 +22,5 @@ void main() fragColor = vertexColor; // Calculate final vertex position - gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); -} \ No newline at end of file + gl_Position = mvp*vec4(vertexPosition, 1.0); +} diff --git a/examples/shaders/shapes_textures/main.go b/examples/shaders/shapes_textures/main.go index 51afc06..7cc319f 100644 --- a/examples/shaders/shapes_textures/main.go +++ b/examples/shaders/shapes_textures/main.go @@ -36,7 +36,7 @@ func main() { raylib.DrawText("USING CUSTOM SHADER", 190, 40, 10, raylib.Red) raylib.DrawRectangle(250-60, 90, 120, 60, raylib.Red) - raylib.DrawRectangleGradient(250-90, 170, 180, 130, raylib.Maroon, raylib.Gold) + raylib.DrawRectangleGradientH(250-90, 170, 180, 130, raylib.Maroon, raylib.Gold) raylib.DrawRectangleLines(250-40, 320, 80, 60, raylib.Orange) // Activate our default shader for next drawings diff --git a/examples/shapes/basic_shapes/main.go b/examples/shapes/basic_shapes/main.go index 6c73f4e..18517a4 100644 --- a/examples/shapes/basic_shapes/main.go +++ b/examples/shapes/basic_shapes/main.go @@ -25,7 +25,7 @@ func main() { raylib.DrawCircleLines(screenWidth/4, 340, 80, raylib.DarkBlue) raylib.DrawRectangle(screenWidth/4*2-60, 100, 120, 60, raylib.Red) - raylib.DrawRectangleGradient(screenWidth/4*2-90, 170, 180, 130, raylib.Maroon, raylib.Gold) + raylib.DrawRectangleGradientH(screenWidth/4*2-90, 170, 180, 130, raylib.Maroon, raylib.Gold) raylib.DrawRectangleLines(screenWidth/4*2-40, 320, 80, 60, raylib.Orange) raylib.DrawTriangle(raylib.NewVector2(float32(screenWidth)/4*3, 80),