summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--honey/init.lua3
-rw-r--r--main.lua18
2 files changed, 16 insertions, 5 deletions
diff --git a/honey/init.lua b/honey/init.lua
index 26d16e1..6cf8801 100644
--- a/honey/init.lua
+++ b/honey/init.lua
@@ -13,6 +13,9 @@ function init(width, height, title)
local title = title or "honey3d"
glfw.Init()
+ glfw.WindowHint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
+ glfw.WindowHint(glfw.CONTEXT_VERSION_MAJOR, 4)
+ glfw.WindowHint(glfw.CONTEXT_VERSION_MINOR, 1)
local window = honey.Window(width, height, title)
glfw.MakeContextCurrent(window.win)
gl.InitGlad()
diff --git a/main.lua b/main.lua
index 2c92223..9f39825 100644
--- a/main.lua
+++ b/main.lua
@@ -59,14 +59,13 @@ level:addSystem{
surface = {
mode = ode.ContactBounce + ode.ContactSoftCFM,
mu = ode.Infinity,
- bounce = 0.99,
+ bounce = 0.90,
bounce_vel = 0.1,
soft_cfm = 0.001,
},
}
local collisions = ode.Collide(o1, o2, 1)
if #collisions > 0 then
- print("collision detected!")
ode.ContactSetGeom(contact, collisions[1])
local joint = ode.JointCreateContact(self.world, self.contactgroup, contact)
ode.JointAttach(joint, b1, b2)
@@ -83,7 +82,7 @@ level:addSystem{
end
local x, y, z = ode.BodyGetPosition(entity.physicsBody)
- local a, b, c, d = ode.BodyGetQuaternion(entity.physicsBody)
+ local d, a, b, c = ode.BodyGetQuaternion(entity.physicsBody)
entity.transform:identity():translate(Vec3{x, y, z}):mul(Quaternion{a, b, c, d}:toMat4())
end,
}
@@ -150,7 +149,7 @@ local ball = {
parent=false,
mesh=icosa,
shader=shader,
- collisionShape=ode.CreateSphere(space, 0.5),
+ collisionShape=ode.CreateSphere(space, 1.0),
physicsBody=ode.BodyCreate(world),
}
level:addEntity(ball)
@@ -195,12 +194,21 @@ local fpsAverage = averager(200)
-- main loop
honey.loop(window, function(dt)
gl.ClearColor(0.2, 0.4, 1.0, 1.0)
- gl.Clear(gl.COLOR_BUFFER_BIT + gl.DEPTH_BUFFER_BIT)
+ gl.Clear(gl.COLOR_BUFFER_BIT + gl.DEPTH_BUFFER_BIT + gl.STENCIL_BUFFER_BIT)
+
+ gl.UseProgram(0)
+ gl.Enable(gl.DEPTH_TEST)
+
level:update(dt)
nvg.BeginFrame(vg, vw, vh, 1.0)
nvg.StrokeColor(vg, nvg.RGBf(1, 1, 1))
nvg.FontFace(vg, "November")
nvg.Text(vg, 50, 50, "fps: "..tostring(math.floor(fpsAverage(1/dt))))
+ nvg.BeginPath(vg)
+ nvg.MoveTo(vg, 50, 50)
+ nvg.LineTo(vg, 50, 100)
+ nvg.LineTo(vg, 100, 50)
+ nvg.Stroke(vg)
nvg.EndFrame(vg)
end)