-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample02.lua
49 lines (43 loc) · 1.28 KB
/
example02.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
local lpugl = require"lpugl_opengl"
local gl = require"luagl"
local glu = require"luaglu"
local world = lpugl.newWorld("OpenGL Example App")
local scale = world:getScreenScale()
local view = world:newView
{
title = "OpenGL Example Window",
size = {300*scale, 100*scale},
resizable = true,
eventFunc = function(view, event, ...)
print(event, ...)
if event == "EXPOSE" then
local w, h = view:getSize()
gl.Viewport(0, 0, w, h)
gl.MatrixMode('PROJECTION')
gl.LoadIdentity()
glu.Perspective(80, w / h, 1, 5000)
gl.MatrixMode('MODELVIEW')
gl.Clear('COLOR_BUFFER_BIT,DEPTH_BUFFER_BIT')
gl.LoadIdentity()
gl.Translate(-1.5, 0, -6)
gl.Begin('TRIANGLES')
gl.Vertex( 0, 1, 0)
gl.Vertex(-1, -1, 0)
gl.Vertex( 1, -1, 0)
gl.End()
gl.Translate(3, 0, 0)
gl.Begin('QUADS')
gl.Vertex(-1, 1, 0)
gl.Vertex( 1, 1, 0)
gl.Vertex( 1, -1, 0)
gl.Vertex(-1, -1, 0)
gl.End()
elseif event == "CLOSE" then
view:close()
end
end
}
view:show()
while world:hasViews() do
world:update()
end