Browse Source

Example updates;

bjorn 3 years ago
parent
commit
e8a72c8f37

+ 0 - 1
examples/Animation/2_Bone_IK/main.lua

@@ -72,6 +72,5 @@ function lovr.draw(pass)
   end
   end
 
 
   -- Draw a line from the root to the result from the IK solver, then to the target
   -- Draw a line from the root to the result from the IK solver, then to the target
-  print(solve(root, target, control, boneLengths))
   pass:line(root, solve(root, target, control, boneLengths), target)
   pass:line(root, solve(root, target, control, boneLengths), target)
 end
 end

+ 1 - 1
examples/Environment/Grid/main.lua

@@ -1,5 +1,5 @@
 function lovr.load()
 function lovr.load()
-  lovr.graphics.setBackground(.05, .05, .05)
+  lovr.graphics.setBackgroundColor(.05, .05, .05)
 end
 end
 
 
 function lovr.draw(pass)
 function lovr.draw(pass)

+ 1 - 1
examples/Environment/Grid_(Smooth)/main.lua

@@ -24,7 +24,7 @@ function lovr.load()
     }
     }
   ]], { flags = { highp = true } })
   ]], { flags = { highp = true } })
 
 
-  lovr.graphics.setBackground(.05, .05, .05)
+  lovr.graphics.setBackgroundColor(.05, .05, .05)
 end
 end
 
 
 function lovr.draw(pass)
 function lovr.draw(pass)

+ 1 - 1
examples/Environment/Terrain_-_Heightmap/main.lua

@@ -23,7 +23,7 @@ vec4 lovrmain() {
 
 
 function lovr.load()
 function lovr.load()
   skyColor = { 0.208, 0.208, 0.275 }
   skyColor = { 0.208, 0.208, 0.275 }
-  lovr.graphics.setBackground(skyColor)
+  lovr.graphics.setBackgroundColor(skyColor)
   heightmap = lovr.graphics.newTexture('heightmap.png')
   heightmap = lovr.graphics.newTexture('heightmap.png')
   shader = lovr.graphics.newShader(unpack(shaderCode))
   shader = lovr.graphics.newShader(unpack(shaderCode))
 end
 end

+ 1 - 1
examples/Environment/Terrain_-_Procedural/main.lua

@@ -41,7 +41,7 @@ end
 
 
 function lovr.load()
 function lovr.load()
   skyColor = {0.208, 0.208, 0.275}
   skyColor = {0.208, 0.208, 0.275}
-  lovr.graphics.setBackground(skyColor)
+  lovr.graphics.setBackgroundColor(skyColor)
   shader = lovr.graphics.newShader(unpack(shaderCode))
   shader = lovr.graphics.newShader(unpack(shaderCode))
 
 
   local vertices, indices = grid(100)
   local vertices, indices = grid(100)

+ 5 - 5
examples/Interaction/Pointer/main.lua

@@ -1,12 +1,12 @@
-function lovr.draw()
+function lovr.draw(pass)
   for i, hand in ipairs(lovr.headset.getHands()) do
   for i, hand in ipairs(lovr.headset.getHands()) do
     local position = vec3(lovr.headset.getPosition(hand))
     local position = vec3(lovr.headset.getPosition(hand))
     local direction = quat(lovr.headset.getOrientation(hand)):direction()
     local direction = quat(lovr.headset.getOrientation(hand)):direction()
 
 
-    lovr.graphics.setColor(1, 1, 1)
-    lovr.graphics.sphere(position, .01)
+    pass:setColor(1, 1, 1)
+    pass:sphere(position, .01)
 
 
-    lovr.graphics.setColor(1, 0, 0)
-    lovr.graphics.line(position, position + direction * 50)
+    pass:setColor(1, 0, 0)
+    pass:line(position, position + direction * 50)
   end
   end
 end
 end

+ 14 - 14
examples/Interaction/Pointer_UI/main.lua

@@ -65,35 +65,35 @@ function lovr.update()
   end
   end
 end
 end
 
 
-function lovr.draw()
+function lovr.draw(pass)
   -- Button background
   -- Button background
   if button.active then
   if button.active then
-    lovr.graphics.setColor(.4, .4, .4)
+    pass:setColor(.4, .4, .4)
   elseif button.hover then
   elseif button.hover then
-    lovr.graphics.setColor(.2, .2, .2)
+    pass:setColor(.2, .2, .2)
   else
   else
-    lovr.graphics.setColor(.1, .1, .1)
+    pass:setColor(.1, .1, .1)
   end
   end
-  lovr.graphics.plane('fill', button.position, button.width, button.height)
+  pass:plane(button.position, button.width, button.height)
 
 
   -- Button text (add a small amount to the z to put the text slightly in front of button)
   -- Button text (add a small amount to the z to put the text slightly in front of button)
-  lovr.graphics.setColor(1, 1, 1)
-  lovr.graphics.print(button.text, button.position + vec3(0, 0, .001), button.textSize)
-  lovr.graphics.print('Count: ' .. button.count, button.position + vec3(0, .5, 0), .1)
+  pass:setColor(1, 1, 1)
+  pass:text(button.text, button.position + vec3(0, 0, .001), button.textSize)
+  pass:text('Count: ' .. button.count, button.position + vec3(0, .5, 0), .1)
 
 
   -- Pointers
   -- Pointers
   for hand, tip in pairs(tips) do
   for hand, tip in pairs(tips) do
     local position = vec3(lovr.headset.getPosition(hand))
     local position = vec3(lovr.headset.getPosition(hand))
 
 
-    lovr.graphics.setColor(1, 1, 1)
-    lovr.graphics.sphere(position, .01)
+    pass:setColor(1, 1, 1)
+    pass:sphere(position, .01)
 
 
     if button.active then
     if button.active then
-      lovr.graphics.setColor(0, 1, 0)
+      pass:setColor(0, 1, 0)
     else
     else
-      lovr.graphics.setColor(1, 0, 0)
+      pass:setColor(1, 0, 0)
     end
     end
-    lovr.graphics.line(position, tip)
-    lovr.graphics.setColor(1, 1, 1)
+
+    pass:line(position, tip)
   end
   end
 end
 end

+ 1 - 1
examples/Intro/Shapes/main.lua

@@ -1,6 +1,6 @@
 shader = require 'shader'
 shader = require 'shader'
 
 
-lovr.graphics.setBackground(.1, .1, .1)
+lovr.graphics.setBackgroundColor(.1, .1, .1)
 
 
 local function drawLabel(pass, str, x, y, z)
 local function drawLabel(pass, str, x, y, z)
   pass:setColor(1, 1, 1)
   pass:setColor(1, 1, 1)

+ 1 - 1
examples/Physics/Boxes/main.lua

@@ -19,7 +19,7 @@ function lovr.load()
   controllerBoxes = {}
   controllerBoxes = {}
 
 
   lovr.timer.step() -- Reset the timer before the first update
   lovr.timer.step() -- Reset the timer before the first update
-  lovr.graphics.setBackground(.8, .8, .8)
+  lovr.graphics.setBackgroundColor(.8, .8, .8)
 end
 end
 
 
 local isFirstFrame = true
 local isFirstFrame = true

+ 1 - 1
examples/Physics/Newtons_Cradle/main.lua

@@ -30,7 +30,7 @@ function lovr.load()
   -- displace the last ball to set the Newton's cradle in motion
   -- displace the last ball to set the Newton's cradle in motion
   local lastBall = balls[#balls]
   local lastBall = balls[#balls]
   lastBall:setPosition(vec3(lastBall:getPosition()) + vec3(5 * radius, 5 * radius, 0))
   lastBall:setPosition(vec3(lastBall:getPosition()) + vec3(5 * radius, 5 * radius, 0))
-  lovr.graphics.setBackground(0.1, 0.1, 0.1)
+  lovr.graphics.setBackgroundColor(0.1, 0.1, 0.1)
 end
 end
 
 
 
 

+ 1 - 1
examples/Physics/Saloon_Door/main.lua

@@ -19,7 +19,7 @@ function lovr.load()
   local joint = lovr.physics.newDistanceJoint(door1, door2, vec3(door1:getPosition()), vec3(door2:getPosition()))
   local joint = lovr.physics.newDistanceJoint(door1, door2, vec3(door1:getPosition()), vec3(door2:getPosition()))
   joint:setTightness(0.2)
   joint:setTightness(0.2)
   joint:setResponseTime(10)
   joint:setResponseTime(10)
-  lovr.graphics.setBackground(0.1, 0.1, 0.1)
+  lovr.graphics.setBackgroundColor(0.1, 0.1, 0.1)
 end
 end
 
 
 function lovr.draw(pass)
 function lovr.draw(pass)

+ 1 - 1
examples/Physics/Wrecking_Ball/main.lua

@@ -42,7 +42,7 @@ function lovr.load()
     even = not even
     even = not even
   end
   end
 
 
-  lovr.graphics.setBackground(0.1, 0.1, 0.1)
+  lovr.graphics.setBackgroundColor(0.1, 0.1, 0.1)
 end
 end
 
 
 
 

+ 1 - 1
examples/Physics/Zip_Line/main.lua

@@ -24,7 +24,7 @@ function lovr.load()
   local joint = lovr.physics.newDistanceJoint(trolley, weight, vec3(trolley:getPosition()), vec3(weight:getPosition()) + vec3(0, 0.3, 0))
   local joint = lovr.physics.newDistanceJoint(trolley, weight, vec3(trolley:getPosition()), vec3(weight:getPosition()) + vec3(0, 0.3, 0))
   joint:setResponseTime(10) -- make the hanging rope streachable
   joint:setResponseTime(10) -- make the hanging rope streachable
 
 
-  lovr.graphics.setBackground(0.1, 0.1, 0.1)
+  lovr.graphics.setBackgroundColor(0.1, 0.1, 0.1)
 end
 end
 
 
 
 

+ 1 - 1
examples/UI/Spectator_Camera/main.lua

@@ -1,5 +1,5 @@
 function lovr.load()
 function lovr.load()
-  lovr.graphics.setBackground(.7, .7, .7)
+  lovr.graphics.setBackgroundColor(.7, .7, .7)
 
 
   -- Precompute camera transform (could also be attached to a controller)
   -- Precompute camera transform (could also be attached to a controller)
   local x, y, z = -3, 3, 3
   local x, y, z = -3, 3, 3