[ZeroBrane Studio] Re: Who CAN make A demo of wxlua+OpenGL

  • From: Paul K <paul@xxxxxxxxxxxxx>
  • To: zerobrane@xxxxxxxxxxxxx
  • Date: Thu, 18 Jan 2018 09:44:35 -0800

You may need to resize the window, as it doesn't always refresh for me on the 
first paint event.

Just a quick follow-up: as wtj found after several experiments,
changing wxGLCanvas initialization to `local canvas =
wx.wxGLCanvas(frame)` fixes the initial rendering issues.

Paul.

On Wed, Jan 17, 2018 at 7:39 PM, Paul K <paul@xxxxxxxxxxxxx> wrote:
I see wxlua in zerobrane have wxgl binding, so Who CAN make A demo of 
wxlua+OpenGL

I have the following test script that is working for me (it requires
luagl library you can find online along with the binaries):

require("wx")
require("luagl")

local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "wxLua + LuaGL Demo",
wx.wxDefaultPosition, wx.wxSize(450, 450), wx.wxDEFAULT_FRAME_STYLE)
local canvas = wx.wxGLCanvas(frame, wx.wxID_ANY, {},
wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxEXPAND)
local context = wx.wxGLContext(canvas)
local function render()
  context:SetCurrent(canvas)

  gl.ClearColor(0, 0, 0, 0)
  gl.Clear(gl.COLOR_BUFFER_BIT)

  gl.Begin('TRIANGLES')
    gl.Vertex( 0,  0.75, 0)
    gl.Vertex(-0.75, -0.75, 0)
    gl.Vertex( 0.75, -0.75, 0)
  gl.End()

  canvas:SwapBuffers()
end

canvas:Connect(wx.wxEVT_PAINT, render)
frame:Show(true)
wx.wxGetApp():MainLoop()

You may need to resize the window, as it doesn't always refresh for me
on the first paint event.

Paul.

On Wed, Jan 17, 2018 at 7:15 PM, wtj <wtjcn@xxxxxxx> wrote:

I see wxlua in zerobrane have wxgl binding, so Who CAN make A demo of
wxlua+OpenGL,
wtj
邮箱:wtjcn@xxxxxxx

签名由 网易邮箱大师 定制

Other related posts: