您好我正在尝试使用Luagl弄乱像素和东西但是遇到了gl.DrawPixel()参数的一些问题,这些问题没有被过度记录。
如何为这个gl.DrawPixel()函数使用lua表?
这是我目前尝试做的,窗口显示但没有显示上下文,因为它是灰色而不是黑色也没有显示像素。
这是我的代码:
require("luagl")
require("wx")
require("math")
frame = nil
button = nil
testx = 0
testy = 0
checkimage = {0,100,0};
function render()
context:SetCurrent(canvas)
gl.ClearColor(0,0,0,0)
--gl.PixelStore(gl.GL_UNPACK_ALIGNMENT, 1)
--gl.ShadeModel(gl.GL_FLAT)
gl.Clear("COLOR_BUFFER_BIT, DEPTH_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()
gl.DrawPixels(0,100, gl.RGB, gl.UNSIGNED_BYTE,checkimage[0])
canvas:SwapBuffers()
end
function main()
frame = wx.wxFrame( wx.NULL ,
wx.wxID_ANY,
"Messing Around" ,
wx.wxDefaultPosition,
wx.wxSize(640,480),
wx.wxDEFAULT_FRAME_STYLE )
--~ button = wx.wxButton(frame , wx.wxID_NO,
--~ "bULLOCKS!", wx.wxDefaultPosition,
--~ wx.wxDefaultSize,wx.wxBU_EXACTFIT,
--~ wx.wxDefaultValidator, "Name")
local filemenu = wx.wxMenu()
filemenu:Append(wx.wxID_EXIT, "Exit" , "Quiting this shit!")
local helpmenu = wx.wxMenu()
helpmenu:Append(wx.wxID_ABOUT, "Blah!", "Hah!")
local menubar = wx.wxMenuBar()
menubar:Append(filemenu , "&file")
menubar:Append(helpmenu , "&Help")
frame:SetMenuBar(menubar)
frame:CreateStatusBar(1)
frame:SetStatusText("Welcome to WxLua")
--button = wx.wxButton(panel,0 ,"Hellobutton")
--button:SetDefault()
frame:Connect(wx.wxID_EXIT, wx.wxEVT_COMMAND_MENU_SELECTED,
function (event) frame:Close(true) end )
frame:Connect(wx.wxID_ABOUT , wx.wxEVT_COMMAND_MENU_SELECTED,
function(event)
wx.wxMessageBox('Blah and more blah with blah',
wx.wxOK + wx.wxICON_INFORMATION ,
frame)
end )
canvas = wx.wxGLCanvas(frame, wx.wxID_ANY,
wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxEXPAND)
context = wx.wxGLContext(canvas)
canvas:Connect(wx.wxEVT_PAINT, render)
canvas:Refresh()
frame:Show(true)
end
main()
wx.wxGetApp():MainLoop()