Update C sources
This commit is contained in:
parent
02424e2e10
commit
bd6bf15356
53 changed files with 62247 additions and 9914 deletions
|
@ -39,7 +39,7 @@ func main() {
|
|||
|
||||
for !rl.WindowShouldClose() {
|
||||
// Refill audio stream if required
|
||||
if rl.IsAudioBufferProcessed(stream) {
|
||||
if rl.IsAudioStreamProcessed(stream) {
|
||||
numSamples := int32(0)
|
||||
if samplesLeft >= maxSamplesPerUpdate {
|
||||
numSamples = maxSamplesPerUpdate
|
||||
|
|
|
@ -38,19 +38,17 @@ func main() {
|
|||
|
||||
camera := rl.Camera2D{}
|
||||
camera.Target = rl.NewVector2(float32(player.X+20), float32(player.Y+20))
|
||||
camera.Offset = rl.NewVector2(0, 0)
|
||||
camera.Offset = rl.NewVector2(float32(screenWidth/2), float32(screenHeight/2))
|
||||
camera.Rotation = 0.0
|
||||
camera.Zoom = 1.0
|
||||
|
||||
rl.SetTargetFPS(30)
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
if rl.IsKeyDown(rl.KeyRight) {
|
||||
player.X += 2 // Player movement
|
||||
camera.Offset.X -= 2 // Camera displacement with player movement
|
||||
player.X += 2 // Player movement
|
||||
} else if rl.IsKeyDown(rl.KeyLeft) {
|
||||
player.X -= 2 // Player movement
|
||||
camera.Offset.X += 2 // Camera displacement with player movement
|
||||
player.X -= 2 // Player movement
|
||||
}
|
||||
|
||||
// Camera target follows player
|
||||
|
|
|
@ -5,17 +5,19 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
hmd := rl.GetVrDeviceInfo(rl.HmdOculusRiftCv1) // Oculus Rift CV1
|
||||
rl.InitWindow(int32(hmd.HScreenSize), int32(hmd.VScreenSize), "raylib [core] example - vr simulator")
|
||||
//hmd := rl.GetVrDeviceInfo(rl.HmdOculusRiftCv1) // Oculus Rift CV1
|
||||
//rl.InitWindow(int32(hmd.HScreenSize), int32(hmd.VScreenSize), "raylib [core] example - vr simulator")
|
||||
rl.InitWindow(800, 450, "raylib [core] example - vr simulator")
|
||||
|
||||
// NOTE: default device (simulator)
|
||||
rl.InitVrSimulator(hmd) // Init VR device
|
||||
//rl.InitVrSimulator(hmd) // Init VR device
|
||||
rl.InitVrSimulator() // Init VR device
|
||||
|
||||
camera := rl.Camera{}
|
||||
camera.Position = rl.NewVector3(5.0, 2.0, 5.0) // Camera position
|
||||
camera.Target = rl.NewVector3(0.0, 2.0, 0.0) // Camera looking at point
|
||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0) // Camera up vector (rotation towards target)
|
||||
camera.Fovy = 60.0 // Camera field-of-view Y
|
||||
camera.Fovy = 60.0 // Camera field-of-view Y
|
||||
|
||||
cubePosition := rl.NewVector3(0.0, 0.0, 0.0)
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
|
@ -21,11 +23,14 @@ func main() {
|
|||
cubicmap := rl.LoadTextureFromImage(image) // Convert image to texture to display (VRAM)
|
||||
|
||||
mesh := rl.GenMeshCubicmap(*image, rl.NewVector3(1.0, 1.0, 1.0))
|
||||
fmt.Printf("%+v\n", mesh)
|
||||
|
||||
model := rl.LoadModelFromMesh(mesh)
|
||||
|
||||
// NOTE: By default each cube is mapped to one part of texture atlas
|
||||
texture := rl.LoadTexture("cubicmap_atlas.png") // Load map texture
|
||||
model.Material.Maps[rl.MapDiffuse].Texture = texture // Set map diffuse texture
|
||||
texture := rl.LoadTexture("cubicmap_atlas.png") // Load map texture
|
||||
model.Materials = make([]rl.Material, 1)
|
||||
model.Materials[0].Maps[rl.MapDiffuse].Texture = texture // Set map diffuse texture
|
||||
|
||||
mapPosition := rl.NewVector3(-16.0, 0.0, -8.0) // Set model position
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
//"fmt"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
|
@ -20,10 +22,12 @@ func main() {
|
|||
texture := rl.LoadTextureFromImage(image) // Convert image to texture (VRAM)
|
||||
|
||||
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[rl.MapDiffuse].Texture = texture // Set map diffuse texture
|
||||
mapPosition := rl.NewVector3(-8.0, 0.0, -8.0) // Set model position
|
||||
//fmt.Printf("%+v\n", mesh)
|
||||
model := rl.LoadModelFromMesh(mesh) // Load model from generated mesh
|
||||
//fmt.Printf("%+v\n", model)
|
||||
model.Materials = make([]rl.Material, 1)
|
||||
model.Materials[0].Maps[rl.MapDiffuse].Texture = texture // Set map diffuse texture
|
||||
mapPosition := rl.NewVector3(-8.0, 0.0, -8.0) // Set model position
|
||||
|
||||
rl.UnloadImage(image) // Unload heightmap image from RAM, already uploaded to VRAM
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ func main() {
|
|||
dwarf := rl.LoadModel("dwarf.obj") // Load OBJ model
|
||||
texture := rl.LoadTexture("dwarf_diffuse.png") // Load model texture
|
||||
|
||||
dwarf.Material.Maps[rl.MapDiffuse].Texture = texture // Set dwarf model diffuse texture
|
||||
dwarf.Materials = make([]rl.Material, 1)
|
||||
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
|
||||
|
||||
|
|
|
@ -29,10 +29,10 @@ func main() {
|
|||
//b := MustAsset("data.rres")
|
||||
//reader := bytes.NewReader(b)
|
||||
|
||||
res := rres.LoadResource(reader, 0, []byte("passwordpassword"))
|
||||
wav := rl.LoadWaveEx(res.Data, int32(res.Param1), int32(res.Param2), int32(res.Param3), int32(res.Param4))
|
||||
snd := rl.LoadSoundFromWave(wav)
|
||||
rl.UnloadWave(wav)
|
||||
//res := rres.LoadResource(reader, 0, []byte("passwordpassword"))
|
||||
//wav := rl.LoadWaveEx(res.Data, int32(res.Param1), int32(res.Param2), int32(res.Param3), int32(res.Param4))
|
||||
//snd := rl.LoadSoundFromWave(wav)
|
||||
//rl.UnloadWave(wav)
|
||||
|
||||
textures := make([]rl.Texture2D, numTextures)
|
||||
for i := 0; i < numTextures; i++ {
|
||||
|
@ -48,7 +48,7 @@ func main() {
|
|||
|
||||
for !rl.WindowShouldClose() {
|
||||
if rl.IsKeyPressed(rl.KeySpace) {
|
||||
rl.PlaySound(snd)
|
||||
//rl.PlaySound(snd)
|
||||
}
|
||||
|
||||
if rl.IsMouseButtonPressed(rl.MouseLeftButton) {
|
||||
|
@ -84,7 +84,7 @@ func main() {
|
|||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.UnloadSound(snd)
|
||||
//rl.UnloadSound(snd)
|
||||
|
||||
for _, t := range textures {
|
||||
rl.UnloadTexture(t)
|
||||
|
|
|
@ -21,7 +21,8 @@ func main() {
|
|||
dwarf := rl.LoadModel("dwarf.obj") // Load OBJ model
|
||||
texture := rl.LoadTexture("dwarf_diffuse.png") // Load model texture
|
||||
|
||||
dwarf.Material.Maps[rl.MapDiffuse].Texture = texture // Set dwarf model diffuse texture
|
||||
dwarf.Materials = make([]rl.Material, 1)
|
||||
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
|
||||
|
||||
|
|
|
@ -24,8 +24,9 @@ func main() {
|
|||
texture := rl.LoadTexture("dwarf_diffuse.png") // Load model texture
|
||||
shader := rl.LoadShader("glsl330/base.vs", "glsl330/grayscale.fs") // Load model shader
|
||||
|
||||
dwarf.Material.Shader = shader // Set shader effect to 3d model
|
||||
dwarf.Material.Maps[rl.MapDiffuse].Texture = texture // Set dwarf model diffuse texture
|
||||
dwarf.Materials = make([]rl.Material, 1)
|
||||
dwarf.Materials[0].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
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ func main() {
|
|||
fontChars := int32(0)
|
||||
|
||||
// TTF Font loading with custom generation parameters
|
||||
font := rl.LoadFontEx("fonts/KAISG.ttf", 96, 0, &fontChars)
|
||||
font := rl.LoadFontEx("fonts/KAISG.ttf", 96, &fontChars, 0)
|
||||
|
||||
// Generate mipmap levels to use trilinear filtering
|
||||
// NOTE: On 2D drawing it won't be noticeable, it looks like FILTER_BILINEAR
|
||||
|
@ -69,7 +69,7 @@ func main() {
|
|||
|
||||
if count == 1 { // Only support one ttf file dropped
|
||||
rl.UnloadFont(font)
|
||||
font = rl.LoadFontEx(droppedFiles[0], fontSize, 0, &fontChars)
|
||||
font = rl.LoadFontEx(droppedFiles[0], fontSize, &fontChars, 0)
|
||||
rl.ClearDroppedFiles()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,15 +11,15 @@ func main() {
|
|||
rl.InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture loading and drawing")
|
||||
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
cat := rl.LoadImage("cat.png") // Load image in CPU memory (RAM)
|
||||
cat := rl.LoadImage("cat.png") // Load image in CPU memory (RAM)
|
||||
rl.ImageCrop(cat, rl.NewRectangle(100, 10, 280, 380)) // Crop an image piece
|
||||
rl.ImageFlipHorizontal(cat) // Flip cropped image horizontally
|
||||
rl.ImageResize(cat, 150, 200) // Resize flipped-cropped image
|
||||
rl.ImageFlipHorizontal(cat) // Flip cropped image horizontally
|
||||
rl.ImageResize(cat, 150, 200) // Resize flipped-cropped image
|
||||
|
||||
parrots := rl.LoadImage("parrots.png") // Load image in CPU memory (RAM)
|
||||
|
||||
// Draw one image over the other with a scaling of 1.5f
|
||||
rl.ImageDraw(parrots, cat, rl.NewRectangle(0, 0, float32(cat.Width), float32(cat.Height)), rl.NewRectangle(30, 40, float32(cat.Width)*1.5, float32(cat.Height)*1.5))
|
||||
rl.ImageDraw(parrots, cat, rl.NewRectangle(0, 0, float32(cat.Width), float32(cat.Height)), rl.NewRectangle(30, 40, float32(cat.Width)*1.5, float32(cat.Height)*1.5), rl.White)
|
||||
rl.ImageCrop(parrots, rl.NewRectangle(0, 50, float32(parrots.Width), float32(parrots.Height-100))) // Crop resulting image
|
||||
|
||||
rl.UnloadImage(cat) // Unload image from RAM
|
||||
|
|
|
@ -12,7 +12,7 @@ func main() {
|
|||
|
||||
// TTF Font loading with custom generation parameters
|
||||
var fontChars int32
|
||||
font := rl.LoadFontEx("fonts/KAISG.ttf", 64, 0, &fontChars)
|
||||
font := rl.LoadFontEx("fonts/KAISG.ttf", 64, &fontChars, 0)
|
||||
|
||||
parrots := rl.LoadImage("parrots.png") // Load image in CPU memory (RAM)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue