-rw-r--r-- | agg-plot/agg_platform_support_win32.cpp | 2 | ||||
-rw-r--r-- | agg-plot/agg_platform_support_x11.cpp | 2 | ||||
-rw-r--r-- | agg-plot/plot-window.cpp | 13 | ||||
-rw-r--r-- | agg-plot/xwin-show.cpp | 2 | ||||
-rw-r--r-- | pre3d/test.lua | 102 |
diff --git a/agg-plot/agg_platform_support_win32.cpp b/agg-plot/agg_platform_support_win32.cpp index 964ce7f9..3a8f52a9 100644 --- a/agg-plot/agg_platform_support_win32.cpp +++ b/agg-plot/agg_platform_support_win32.cpp @@ -1091,8 +1091,6 @@ namespace agg } } - pthread_mutex_unlock (m_specific->m_mutex); - return (int)msg.wParam; } diff --git a/agg-plot/agg_platform_support_x11.cpp b/agg-plot/agg_platform_support_x11.cpp index 0ea06846..8e9152a7 100644 --- a/agg-plot/agg_platform_support_x11.cpp +++ b/agg-plot/agg_platform_support_x11.cpp @@ -947,8 +947,6 @@ namespace agg XFreeGC(m_specific->m_display, m_specific->m_gc); XDestroyWindow(m_specific->m_display, m_specific->m_window); XCloseDisplay(m_specific->m_display); - - pthread_mutex_unlock (m_specific->m_mutex); return 0; } diff --git a/agg-plot/plot-window.cpp b/agg-plot/plot-window.cpp index defda309..8d747046 100644 --- a/agg-plot/plot-window.cpp +++ b/agg-plot/plot-window.cpp @@ -158,6 +158,8 @@ plot_window::start() gsl_shell_unref_plot (this->id); GSL_SHELL_UNLOCK(); } + + platform_support_unlock (this); } void * @@ -223,7 +225,7 @@ int plot_window_free (lua_State *L) { plot_window *win = plot_window::check (L, 1); - printf("freying plot window\n"); + printf("freeing plot window\n"); win->~plot_window(); return 0; } @@ -283,12 +285,19 @@ plot_window_index_protected (lua_State *L) { plot_window *win = plot_window::check(L, lua_upvalueindex(2)); + platform_support_lock (win); + + if (win->status != plot_window::running) + { + platform_support_unlock (win); + return luaL_error (L, "window is not active"); + } + int narg = lua_gettop (L); lua_pushvalue (L, lua_upvalueindex(1)); lua_insert (L, 1); - platform_support_lock (win); if (lua_pcall (L, narg, LUA_MULTRET, 0) != 0) { platform_support_unlock (win); diff --git a/agg-plot/xwin-show.cpp b/agg-plot/xwin-show.cpp index 72a2fea4..f96c401c 100644 --- a/agg-plot/xwin-show.cpp +++ b/agg-plot/xwin-show.cpp @@ -97,5 +97,7 @@ xwin_thread_function (void *_plot) GSL_SHELL_UNLOCK(); } + platform_support_unlock (&app); + return NULL; } diff --git a/pre3d/test.lua b/pre3d/test.lua index f137923a..f3149512 100644 --- a/pre3d/test.lua +++ b/pre3d/test.lua @@ -2,35 +2,7 @@ local Pre3d = require 'pre3d/pre3d' local ShapeUtils = require 'pre3d/pre3d_shape_utils' -local win = window('white') -win:transform(300, 300, 240, 240) - -renderer = Pre3d.Renderer(win) ---shape = ShapeUtils.makeSphere(1, 12, 12) --- shape = ShapeUtils.makeOctahedron() - ---[[ -ShapeUtils.linearSubdivideTri(shape) -ShapeUtils.forEachVertex(shape, - function(v, i, s) - -- TODO(deanm): inplace. - s.vertices[i] = Pre3d.Math.unitVector3d(v) - return false - end - ) --- We need to rebuild the normals after extruding the vertices. -ShapeUtils.rebuildMeta(shape) ---]] - -shape = ShapeUtils.makeXYFunction(|x,y| 1.2*exp(-x^2-y^2), -2, -2, 2, 2) - -renderer.draw_overdraw = false -renderer.draw_backfaces = true -renderer.fill_rgba = rgba(0x42/255, 0x82/255, 0xAA/255, 1) -renderer.stroke_rgba = rgb(0x66/255, 0x66/255, 0x66/255) - -local function setTransform(rx, ry) - local ct = renderer.camera.transform +local function setTransform(ct, rx, ry) ct:reset() ct:rotateZ(0) ct:rotateY(ry) @@ -38,20 +10,70 @@ local function setTransform(rx, ry) ct:translate(0, 0, -120) end -renderer.camera.focal_length = 30; -setTransform(-pi/2 - pi + pi/16, 0) - --- renderer.transform:translate( - -local function draw() +local function draw(renderer, shape) renderer:bufferShape(shape) renderer:drawBuffer() renderer:emptyBuffer() end -local N, tour = 128, 2*pi -for j=0, N do - local a = tour*j/N - setTransform(a, 0.15 * a) - draw() +function demo1() + local win = window('black') + win:transform(300, 300, 240, 240) + + local renderer = Pre3d.Renderer(win) + -- shape = ShapeUtils.makeSphere(1, 12, 12) + local shape = ShapeUtils.makeOctahedron() + + ShapeUtils.linearSubdivideTri(shape) + ShapeUtils.forEachVertex(shape, + function(v, i, s) + -- TODO(deanm): inplace. + s.vertices[i] = Pre3d.Math.unitVector3d(v) + return false + end + ) + -- We need to rebuild the normals after extruding the vertices. + ShapeUtils.rebuildMeta(shape) + + -- shape = ShapeUtils.makeXYFunction(|x,y| 1.2*exp(-x^2-y^2), -2, -2, 2, 2) + + renderer.draw_overdraw = false + renderer.draw_backfaces = true + renderer.fill_rgba = rgba(0x42/255, 0x82/255, 0xAA/255, 0.8) + renderer.stroke_rgba = rgb(0x66/255, 0x66/255, 0x66/255) + + renderer.camera.focal_length = 30; + + local N, tour = 256, 2*pi + for j=0, N do + local a = tour*j/N + setTransform(renderer.camera.transform, a, 0.15 * a) + draw(renderer, shape) + end +end + + +function demo2() + local win = window('white') + win:transform(300, 300, 240, 240) + + local renderer = Pre3d.Renderer(win) + -- local shape = ShapeUtils.makeSphere(1, 12, 12) + local shape = ShapeUtils.makeXYFunction(|x,y| 1.2*exp(-x^2-y^2), -2, -2, 2, 2) + + renderer.draw_overdraw = false + renderer.draw_backfaces = true + renderer.fill_rgba = rgba(0x42/255, 0x82/255, 0xAA/255, 1) + renderer.stroke_rgba = rgb(0x66/255, 0x66/255, 0x66/255) + + renderer.camera.focal_length = 30; + + local N, tour = 256, 2*pi + for j=0, N do + local a = tour*j/N + setTransform(renderer.camera.transform, a, 0.15 * a) + draw(renderer, shape) + end end + +demo1() |