Permalink
Browse files

modified: Keyboard.lua

	modified:   egl.lua
	modified:   egl_utils.lua
	modified:   test_egl.lua
	new file:   test_egl_vg_window.lua
	renamed:    test_egl_basic.lua -> test_egl_window.lua
	new file:   test_tiger.lua
	new file:   tests/test_keyboard.lua
	new file:   tiger.lua
  • Loading branch information...
1 parent 41974c9 commit 05273f2bd9d8228c06a8a245501d23063438e0cd @Wiladams committed Nov 8, 2012
Showing with 2,552 additions and 14 deletions.
  1. +8 −9 Keyboard.lua
  2. +1 −1 egl.lua
  3. +3 −3 egl_utils.lua
  4. +1 −1 test_egl.lua
  5. +113 −0 test_egl_vg_window.lua
  6. 0 test_egl_basic.lua → test_egl_window.lua
  7. +363 −0 test_tiger.lua
  8. +104 −0 tests/test_keyboard.lua
  9. +1,959 −0 tiger.lua
View
@@ -7,7 +7,7 @@ local lshift = bit.lshift
local S = require "syscall"
local UI = require "input"
-test_bit = function(yalv, abs_b)
+local test_bit = function(yalv, abs_b)
return (band(ffi.cast("const uint8_t *",abs_b)[yalv/8], lshift(1, yalv%8)) > 0)
end
@@ -18,20 +18,19 @@ local Keyboard_mt = {
}
-Keyboard.new = function(devicename)
+Keyboard.new = function(handlers, devicename)
devicename = devicename or "/dev/input/event0";
-- Create Actual Device Handle
- local devicefd, err = S.open(devicename, S.c.O.RDONLY);
+ local devicefd, err = S.open(devicename, S.c.O.RDWR);
if not devicefd then
return false, err
end
- local obj = {
- DeviceDescriptor = devicefd,
- AlertHandle = devicefd,
- WhichAlerts = S.c.POLL.RDNORM,
- }
+ local obj = handlers or {}
+ obj.DeviceDescriptor = devicefd;
+ obj.AlertHandle = devicefd;
+ obj.WhichAlerts = S.c.POLL.RDNORM;
setmetatable(obj, Keyboard_mt)
@@ -128,7 +127,7 @@ Keyboard.SetNumLock = function(self, state)
self:SetLED(LED_NUML, state)
end
-Keyboard.SetScrollLock(state)
+Keyboard.SetScrollLock = function(self, state)
self:SetLED(LED_SCROLLL, state)
end
View
@@ -218,7 +218,7 @@ EGL_CORE_NATIVE_ENGINE = 0x305B;
}
--[[ EGL 1.2 tokens renamed for consistency in EGL 1.3 --]]
-EGL.EGL_COLORSPACE = EGL_VG_COLORSPACE;
+EGL.EGL_COLORSPACE = EGL_VG_COLORSPACE;
EGL.EGL_ALPHA_FORMAT = EGL_VG_ALPHA_FORMAT;
EGL.EGL_COLORSPACE_sRGB = EGL_VG_COLORSPACE_sRGB;
EGL.EGL_COLORSPACE_LINEAR = EGL_VG_COLORSPACE_LINEAR;
View
@@ -188,7 +188,7 @@ local function createNativeWindow(dmxdisplay, width, height)
nativewindow.width = width;
nativewindow.height = height;
- return nativewindow;
+ return nativewindow, dmxview;
end
@@ -211,8 +211,8 @@ EGLWindow.new = function(width, height, config, api)
-- create nativewindow
local dmxdisplay = DMX.DMXDisplay();
- obj.NativeWindow = createNativeWindow(dmxdisplay, width, height);
-
+ obj.NativeWindow, obj.NativeElement = createNativeWindow(dmxdisplay, width, height);
+
-- create window surface
obj.Surface = obj.Display:CreateWindowSurface(obj.NativeWindow);
obj.Display:MakeCurrent();
View
@@ -104,7 +104,7 @@ glFrustumf(-ratio, ratio, -1, 1, 1, 10);
-- Now, finally do some drawing
-tick(RealDisplay, 1);
+--tick(RealDisplay, 1);
-- Sleep for a few seconds so we can see the results
View
@@ -0,0 +1,113 @@
+
+local ffi = require "ffi"
+local bit = require "bit"
+local bor = bit.bor
+local lshift = bit.lshift;
+
+
+
+local rpiui = require "rpiui"
+
+local GLES = rpiui.GLES;
+local EGL = rpiui.EGL;
+local OpenVG = rpiui.OpenVG;
+local egl = require "egl"
+
+
+local screenWidth = 640;
+local screenHeight = 480;
+
+
+local mainWindow = EGL.Window.new(screenWidth, screenHeight, nil, EGL.EGL_OPENVG_API);
+--local mainWindow = EGL.Window.new(screenWidth, screenHeight, nil, EGL.EGL_OPENGLES_API);
+--local mainWindow = EGL.Window.new(screenWidth, screenHeight, nil);
+
+local RenderClass = require"Drawing"
+
+
+print("-- EGL --");
+print("Vendor: ", mainWindow.Display:Vendor());
+print("ClientAPIs: ", mainWindow.Display:ClientAPIs());
+print(string.format("Current API: 0x%x", mainWindow.Display:CurrentAPI()));
+print("Extensions: ");
+print(mainWindow.Display:Extensions());
+
+-- Create the renderer so we can do some drawing
+local Renderer = RenderClass.new(mainWindow.Display, screenWidth, screenHeight);
+
+
+
+local drawLines = function()
+ --Renderer:Begin();
+ Renderer:StrokeWidth(1);
+ Renderer:SetStroke(250,250,250,1);
+ Renderer:Line(1,1, screenWidth/2, screenHeight/2);
+ --Renderer:End();
+end
+
+local drawRectangles = function(count)
+ count = count or 100;
+
+
+ --Renderer:Begin();
+ for i=1,count do
+ local width = math.random(10,250);
+ local height = math.random(10,250);
+ local x = math.random(0,screenWidth -1-width);
+ local y = math.random(0,screenHeight - 1-height);
+
+ local red = math.random(0,255);
+ local green = math.random(0,255);
+ local blue = math.random(0,255);
+
+ Renderer:Fill(red, green, blue, 1);
+ --print(x,y,width, height, ": ", red, green, blue);
+ Renderer:Rect(x,y,width,height);
+ end
+ --Renderer:End();
+
+end
+
+local drawEllipses = function()
+ Renderer:PushTransform();
+
+ --Renderer:Begin();
+ Renderer:Translate(screenWidth/2, screenHeight/2);
+ Renderer:Fill(44, 77, 232, 1); -- Big blue marble
+ Renderer:Circle(0, 0, screenHeight/2); -- The "world"
+ --Renderer:End();
+
+ Renderer:PopTransform();
+end
+
+local tick = function(ticker, tickCount)
+ print("Tick: ", tickCount);
+
+
+ Renderer:Begin();
+ Renderer:Background(0, 0, 0); -- Black background
+
+ drawRectangles(255);
+ drawEllipses();
+ drawLines();
+ Renderer:End();
+end
+
+
+glViewport(0,0,screenWidth,screenHeight);
+glMatrixMode(GL_PROJECTION);
+glLoadIdentity();
+
+local ratio = screenWidth/screenHeight;
+glFrustumf(-ratio, ratio, -1, 1, 1, 10);
+
+
+-- Now, finally do some drawing
+tick(RealDisplay, 1);
+
+
+-- Sleep for a few seconds so we can see the results
+local seconds = 3
+print( string.format("Sleeping for %d seconds...", seconds ));
+ffi.C.sleep( seconds )
+
File renamed without changes.
Oops, something went wrong.

0 comments on commit 05273f2

Please sign in to comment.