wxMax + Blitz3D SDK
BlitzMax Forums/Brucey's Modules/wxMax + Blitz3D SDK
| ||
I'm trying to get wxMax and the Blitz3D SDK to work together. It's all working pretty well, but I'm having trouble getting keyboard input from B3D. This is my code: Strict Import wx.wxApp Import wx.wxFrame Import wx.wxPanel Import wx.wxSystemSettings Import wx.wxTimer Import Blitz3D.Blitz3DSDK Type MyApp Extends wxApp Field frame:MyFrame Method OnInit:Int() frame = MyFrame(New MyFrame.Create(,,"wxMax + Blitz3D", 100, 100, 640, 480, wxDEFAULT_FRAME_STYLE)) SetTopWindow(frame) frame.CenterOnScreen() frame.show() Return True EndMethod EndType Type MyFrame Extends wxFrame Field panel:wxPanel Field light:Int, camera:Int, cube:Int Field Timer:wxTimer Field sys:wxSystemSettings = New wxSystemSettings Field rendertime:Int = MilliSecs() Method OnInit() Timer = New wxTimer.Create(Self) Local w:Int, h:Int GetClientSize(w, h) panel = New wxPanel.Create(Self, wxID_ANY, 0, 0, w, h) Local hWnd:Int = Int(panel.GetHandle()) bbSetBlitz3DHWND(hWnd) bbSetBlitz3DEventCallback(Int Byte Ptr BBEventHandler) bbBeginBlitz3D bbGraphics3D Sys.GetMetric(wxSYS_SCREEN_X), Sys.GetMetric(wxSYS_SCREEN_Y), 0, 2 bbViewport 0, 0, w, h light = bbCreateLight() camera = bbCreateCamera() cube=bbCreateCube() bbPositionEntity(camera,0,0,-4) ConnectAny(wxEVT_TIMER, OnTick) Timer.Start(30) EnablePolledInput() EndMethod Function OnQuit(event:wxEvent) wxWindow(event.parent).Close(True) EndFunction Function BBEventHandler(hwnd,msg,wp,lp) "win32" bbSystemEmitOSEvent hwnd,msg,wp,lp,Null Return -1 EndFunction Function OnTick(event:wxEvent) If (MilliSecs()-(MyFrame(event.parent).rendertime)<10) Return Local w:Int, h:Int MyFrame(event.parent).panel.GetSize(w, h) MyFrame(event.parent).DrawWorld(w, h) MyFrame(event.parent).rendertime=MilliSecs() EndFunction Method DrawWorld(w, h) bbViewport 0, 0, w, h bbCameraViewport camera, 0, 0, w, h bbTurnEntity(cube,1,2,3) bbRenderWorld bbText(10, 10, MouseX() + ", " + MouseY()) bbFlip EndMethod EndType New MyApp.run() Sorry if it's messy. I just threw it together for this post. The mouse input works fine, and I can get the mouse coordinates, but I can't get any keyboard input, and MouseXSpeed(), and MouseYSpeed() don't seem to work. I was told that changing the event handler to the following works in C++, and allows you to get keyboard input. Function BBEventHandler(hwnd,msg,wp,lp) "win32" MSWWindowProc((WXUINT)msg, (WXWPARAM)wp, (WXLPARAM)lp); Return -1 End Function I can't seem to work out how to get this working in BlitzMax. Does anyone have any ideas, or know of another way to get this all working? Thanks! Robbie. |
| ||
Interesting! I can't test this, but you might want to try connecting up to wxKeyEvents - ie, use wxWidgets for your keyboard processing. See "Handling Keyboard Events" in the wxWidgets programming pdf "Cross-Platform GUI Programming with wxWidgets". |