Fix examples
This commit is contained in:
parent
c42d027833
commit
ad07f2586d
14 changed files with 5164 additions and 55024 deletions
Binary file not shown.
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
@ -1,8 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/gen2brain/raylib-go/raylib"
|
"github.com/gen2brain/raylib-go/raylib"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,20 +15,16 @@ func main() {
|
||||||
camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
|
camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
|
||||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||||
camera.Fovy = 45.0
|
camera.Fovy = 45.0
|
||||||
camera.Type = rl.CameraPerspective
|
|
||||||
|
|
||||||
image := rl.LoadImage("cubicmap.png") // Load cubicmap image (RAM)
|
image := rl.LoadImage("cubicmap.png") // Load cubicmap image (RAM)
|
||||||
cubicmap := rl.LoadTextureFromImage(image) // Convert image to texture to display (VRAM)
|
cubicmap := rl.LoadTextureFromImage(image) // Convert image to texture to display (VRAM)
|
||||||
|
|
||||||
mesh := rl.GenMeshCubicmap(*image, rl.NewVector3(1.0, 1.0, 1.0))
|
mesh := rl.GenMeshCubicmap(*image, rl.NewVector3(1.0, 1.0, 1.0))
|
||||||
fmt.Printf("%+v\n", mesh)
|
|
||||||
|
|
||||||
model := rl.LoadModelFromMesh(mesh)
|
model := rl.LoadModelFromMesh(mesh)
|
||||||
|
|
||||||
// NOTE: By default each cube is mapped to one part of texture atlas
|
// NOTE: By default each cube is mapped to one part of texture atlas
|
||||||
texture := rl.LoadTexture("cubicmap_atlas.png") // Load map texture
|
texture := rl.LoadTexture("cubicmap_atlas.png") // Load map texture
|
||||||
model.Materials = make([]rl.Material, 1)
|
rl.SetMaterialTexture(model.Materials, rl.MapDiffuse, texture) // Set map diffuse texture
|
||||||
model.Materials[0].Maps[rl.MapDiffuse].Texture = texture // Set map diffuse texture
|
|
||||||
|
|
||||||
mapPosition := rl.NewVector3(-16.0, 0.0, -8.0) // Set model position
|
mapPosition := rl.NewVector3(-16.0, 0.0, -8.0) // Set model position
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,10 @@ func main() {
|
||||||
texture := rl.LoadTextureFromImage(image) // Convert image to texture (VRAM)
|
texture := rl.LoadTextureFromImage(image) // Convert image to texture (VRAM)
|
||||||
|
|
||||||
mesh := rl.GenMeshHeightmap(*image, rl.NewVector3(16, 8, 16)) // Generate heightmap mesh (RAM and VRAM)
|
mesh := rl.GenMeshHeightmap(*image, rl.NewVector3(16, 8, 16)) // Generate heightmap mesh (RAM and VRAM)
|
||||||
//fmt.Printf("%+v\n", mesh)
|
|
||||||
model := rl.LoadModelFromMesh(mesh) // Load model from generated mesh
|
model := rl.LoadModelFromMesh(mesh) // Load model from generated mesh
|
||||||
//fmt.Printf("%+v\n", model)
|
|
||||||
model.Materials = make([]rl.Material, 1)
|
rl.SetMaterialTexture(model.Materials, rl.MapDiffuse, texture) // Set map diffuse texture
|
||||||
model.Materials[0].Maps[rl.MapDiffuse].Texture = texture // Set map diffuse texture
|
|
||||||
mapPosition := rl.NewVector3(-8.0, 0.0, -8.0) // Set model position
|
mapPosition := rl.NewVector3(-8.0, 0.0, -8.0) // Set model position
|
||||||
|
|
||||||
rl.UnloadImage(image) // Unload heightmap image from RAM, already uploaded to VRAM
|
rl.UnloadImage(image) // Unload heightmap image from RAM, already uploaded to VRAM
|
||||||
|
|
|
@ -11,16 +11,16 @@ func main() {
|
||||||
rl.InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading")
|
rl.InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading")
|
||||||
|
|
||||||
camera := rl.Camera{}
|
camera := rl.Camera{}
|
||||||
camera.Position = rl.NewVector3(3.0, 3.0, 3.0)
|
camera.Position = rl.NewVector3(50.0, 50.0, 50.0)
|
||||||
camera.Target = rl.NewVector3(0.0, 1.5, 0.0)
|
camera.Target = rl.NewVector3(0.0, 10.0, 0.0)
|
||||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||||
camera.Fovy = 45.0
|
camera.Fovy = 45.0
|
||||||
|
camera.Type = rl.CameraPerspective
|
||||||
|
|
||||||
obj := rl.LoadModel("castle.obj") // Load OBJ model
|
obj := rl.LoadModel("castle.obj") // Load OBJ model
|
||||||
texture := rl.LoadTexture("castle_diffuse.png") // Load model texture
|
texture := rl.LoadTexture("castle_diffuse.png") // Load model texture
|
||||||
|
|
||||||
obj.Materials = make([]rl.Material, 1)
|
rl.SetMaterialTexture(obj.Materials, rl.MapDiffuse, texture) // Set map diffuse texture
|
||||||
obj.Materials[0].Maps[rl.MapDiffuse].Texture = texture // Set castle model diffuse texture
|
|
||||||
|
|
||||||
position := rl.NewVector3(0.0, 0.0, 0.0) // Set model position
|
position := rl.NewVector3(0.0, 0.0, 0.0) // Set model position
|
||||||
|
|
||||||
|
@ -33,9 +33,9 @@ func main() {
|
||||||
|
|
||||||
rl.BeginMode3D(camera)
|
rl.BeginMode3D(camera)
|
||||||
|
|
||||||
rl.DrawModel(obj, position, 2.0, rl.White) // Draw 3d model with texture
|
rl.DrawModel(obj, position, 1.0, rl.White) // Draw 3d model with texture
|
||||||
|
|
||||||
rl.DrawGrid(10, 1.0) // Draw a grid
|
rl.DrawGrid(20, 10.0) // Draw a grid
|
||||||
|
|
||||||
rl.EndMode3D()
|
rl.EndMode3D()
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,11 @@ func main() {
|
||||||
dwarf := rl.LoadModel("dwarf.obj") // Load OBJ model
|
dwarf := rl.LoadModel("dwarf.obj") // Load OBJ model
|
||||||
texture := rl.LoadTexture("dwarf_diffuse.png") // Load model texture
|
texture := rl.LoadTexture("dwarf_diffuse.png") // Load model texture
|
||||||
|
|
||||||
dwarf.Materials = make([]rl.Material, 1)
|
rl.SetMaterialTexture(dwarf.Materials, rl.MapDiffuse, texture) // Set dwarf model diffuse texture
|
||||||
dwarf.Materials[0].Maps[rl.MapDiffuse].Texture = texture // Set dwarf model diffuse texture
|
|
||||||
|
|
||||||
position := rl.NewVector3(0.0, 0.0, 0.0) // Set model position
|
position := rl.NewVector3(0.0, 0.0, 0.0) // Set model position
|
||||||
|
|
||||||
shader := rl.LoadShader("glsl330/base.vs", "glsl330/swirl.fs") // Load postpro shader
|
shader := rl.LoadShader("", "glsl330/swirl.fs")
|
||||||
|
|
||||||
// Get variable (uniform) location on the shader to connect with the program
|
// Get variable (uniform) location on the shader to connect with the program
|
||||||
// NOTE: If uniform variable could not be found in the shader, function returns -1
|
// NOTE: If uniform variable could not be found in the shader, function returns -1
|
||||||
|
@ -53,7 +52,7 @@ func main() {
|
||||||
swirlCenter[1] = float32(screenHeight) - mousePosition.Y
|
swirlCenter[1] = float32(screenHeight) - mousePosition.Y
|
||||||
|
|
||||||
// Send new value to the shader to be used on drawing
|
// Send new value to the shader to be used on drawing
|
||||||
rl.SetShaderValue(shader, swirlCenterLoc, swirlCenter, 2)
|
rl.SetShaderValue(shader, swirlCenterLoc, swirlCenter, 1)
|
||||||
|
|
||||||
rl.UpdateCamera(&camera) // Update camera
|
rl.UpdateCamera(&camera) // Update camera
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,8 @@ func main() {
|
||||||
texture := rl.LoadTexture("dwarf_diffuse.png") // Load model texture
|
texture := rl.LoadTexture("dwarf_diffuse.png") // Load model texture
|
||||||
shader := rl.LoadShader("glsl330/base.vs", "glsl330/grayscale.fs") // Load model shader
|
shader := rl.LoadShader("glsl330/base.vs", "glsl330/grayscale.fs") // Load model shader
|
||||||
|
|
||||||
dwarf.Materials = make([]rl.Material, 1)
|
rl.SetMaterialTexture(dwarf.Materials, rl.MapDiffuse, texture)
|
||||||
dwarf.Materials[0].Shader = shader // Set shader effect to 3d model
|
dwarf.Materials.Shader = shader // Set shader effect to 3d model
|
||||||
dwarf.Materials[0].Maps[rl.MapDiffuse].Texture = texture // Set dwarf model diffuse texture
|
|
||||||
|
|
||||||
position := rl.NewVector3(0.0, 0.0, 0.0) // Set model position
|
position := rl.NewVector3(0.0, 0.0, 0.0) // Set model position
|
||||||
|
|
||||||
|
|
5116
examples/shaders/postprocessing/church.obj
Normal file
5116
examples/shaders/postprocessing/church.obj
Normal file
File diff suppressed because it is too large
Load diff
BIN
examples/shaders/postprocessing/church_diffuse.png
Normal file
BIN
examples/shaders/postprocessing/church_diffuse.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 350 KiB |
File diff suppressed because it is too large
Load diff
Binary file not shown.
Before Width: | Height: | Size: 1.2 MiB |
|
@ -40,20 +40,19 @@ func main() {
|
||||||
screenWidth := int32(800)
|
screenWidth := int32(800)
|
||||||
screenHeight := int32(450)
|
screenHeight := int32(450)
|
||||||
|
|
||||||
rl.SetConfigFlags(rl.FlagMsaa4xHint | rl.FlagVsyncHint) // Enable Multi Sampling Anti Aliasing 4x (if available)
|
rl.SetConfigFlags(rl.FlagMsaa4xHint) // Enable Multi Sampling Anti Aliasing 4x (if available)
|
||||||
|
|
||||||
rl.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader")
|
rl.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader")
|
||||||
|
|
||||||
camera := rl.Camera{}
|
camera := rl.Camera{}
|
||||||
camera.Position = rl.NewVector3(3.0, 3.0, 3.0)
|
camera.Position = rl.NewVector3(2.0, 3.0, 2.0)
|
||||||
camera.Target = rl.NewVector3(0.0, 1.5, 0.0)
|
camera.Target = rl.NewVector3(0.0, 1.0, 0.0)
|
||||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||||
camera.Fovy = 45.0
|
camera.Fovy = 45.0
|
||||||
|
|
||||||
dwarf := rl.LoadModel("dwarf.obj") // Load OBJ model
|
obj := rl.LoadModel("church.obj") // Load OBJ model
|
||||||
texture := rl.LoadTexture("dwarf_diffuse.png") // Load model texture
|
texture := rl.LoadTexture("church_diffuse.png") // Load model texture
|
||||||
dwarf.Materials = make([]rl.Material, 1)
|
rl.SetMaterialTexture(obj.Materials, rl.MapDiffuse, texture) // Set obj model diffuse texture
|
||||||
dwarf.Materials[0].Maps[rl.MapDiffuse].Texture = texture // Set dwarf model diffuse texture
|
|
||||||
|
|
||||||
position := rl.NewVector3(0.0, 0.0, 0.0) // Set model position
|
position := rl.NewVector3(0.0, 0.0, 0.0) // Set model position
|
||||||
|
|
||||||
|
@ -105,7 +104,7 @@ func main() {
|
||||||
|
|
||||||
rl.BeginMode3D(camera)
|
rl.BeginMode3D(camera)
|
||||||
|
|
||||||
rl.DrawModel(dwarf, position, 2.0, rl.White) // Draw 3d model with texture
|
rl.DrawModel(obj, position, 0.1, rl.White) // Draw 3d model with texture
|
||||||
|
|
||||||
rl.DrawGrid(10, 1.0) // Draw a grid
|
rl.DrawGrid(10, 1.0) // Draw a grid
|
||||||
|
|
||||||
|
@ -123,7 +122,7 @@ func main() {
|
||||||
|
|
||||||
rl.DrawRectangle(0, 9, 580, 30, rl.Fade(rl.LightGray, 0.7))
|
rl.DrawRectangle(0, 9, 580, 30, rl.Fade(rl.LightGray, 0.7))
|
||||||
|
|
||||||
rl.DrawText("(c) Dwarf 3D model by David Moreno", screenWidth-200, screenHeight-20, 10, rl.DarkGray)
|
rl.DrawText("(c) Church 3D model by Alberto Cano", screenWidth-200, screenHeight-20, 10, rl.DarkGray)
|
||||||
|
|
||||||
rl.DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, rl.Black)
|
rl.DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, rl.Black)
|
||||||
rl.DrawText(postproShaderText[currentShader], 330, 15, 20, rl.Red)
|
rl.DrawText(postproShaderText[currentShader], 330, 15, 20, rl.Red)
|
||||||
|
@ -140,7 +139,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.UnloadTexture(texture) // Unload texture
|
rl.UnloadTexture(texture) // Unload texture
|
||||||
rl.UnloadModel(dwarf) // Unload model
|
rl.UnloadModel(obj) // Unload model
|
||||||
rl.UnloadRenderTexture(target) // Unload render texture
|
rl.UnloadRenderTexture(target) // Unload render texture
|
||||||
|
|
||||||
rl.CloseWindow()
|
rl.CloseWindow()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue