1 (edited by kimgar 2007-04-16 04:54:24)

Topic: splitscreen irrlicht/html (url)

is it possible at all, to create a splitscreen kind of application with irrlicht on one side and a webpage on the other?

i've had a look at highGUI, maxGUI and the splitscreen example, but i must say i am a little confused.
time is kind of short, so before i burn too much time trying to achieve the impossible, it would be really wonderful if someone could just confirm wether this was possible or not ?

Re: splitscreen irrlicht/html (url)

yes.  you need to manually pass on any events to Irrlicht.  here is the modified MaxGUI example:

' this is an example showing how to display Irrlicht in a panel on a MaxGUI form.  i have modified it a bit
' by adding an eventreceiver to the Irrlicht instance to show how MaxGUI and Irrlicht events can coexist.
' it is important to note that there still is probably some issues to work out, but for now this works.
'
' NOTE: press the 'w' key to toggle wireframe

Strict 
Framework Irrlicht.Core
Import brl.eventqueue

Import BRL.Basic
Import BRL.Win32MaxGUI

Local window:TGadget
Local panel:TGadget

Local windowWidth:Int = 640
Local windowHeight:Int = 380

window=CreateWindow("Irrlicht Win32 BlitzMax window example",100,100,windowWidth,windowHeight,Null,WINDOW_TITLEBAR | WINDOW_CLIENTCOORDS | WINDOW_HIDDEN)

' create window To put irrlicht in
Local hIrrlichtWindow:TGadget=CreatePanel(50,80,320,220,window,PANEL_ACTIVE|PANEL_BORDER)

Local HTMLWindow:TGadget=CreateHTMLView(380,80,250,220,window)

' create ok button
Local Ok:TGadget=CreateButton("OK - Close",windowWidth - 160,windowHeight - 40,150,30,window)

Local go:TGadget=CreateButton("GO URL",windowWidth - 320,windowHeight - 40,150,30,window)

' this is not in the original, but is here to show you can have a textbox and enter into it
' without the events posting to Irrlicht
Local tb:TGadget=CreateTextField(windowWidth - 260,windowHeight - 70,250,20,window)

' create some text
CreateLabel("This is Irrlicht running inside a Win32 MaxGUI window.",20,20,400,40,window)
    
Local param:SIrrlichtCreationParameters=SIrrlichtCreationParameters.create()
param.setWindowId(QueryGadget(hIrrlichtWindow,QUERY_HWND))
param.setDriverType(EDT_OPENGL)

' create the device from the params object
Local device:IrrlichtDevice= ..
    IrrlichtDevice.createFromParams(param)

' the original does not have this.  this is just to show that you can mix events between MaxGUI and Irrlicht.
Type MyEventReceiver Extends IEventReceiver

    Field box:ISceneNode

    Method setBox(b:ISceneNode)
        box=b
    EndMethod

    Method OnEvent:Int(event:SEvent)

        ' check If user presses the key 'W'
        If event.getEventType()=EET_KEY_INPUT_EVENT And event.getKeyPressedDown()=False
        
            Local key:Int=event.getKeyInputKey()

            Select key
                ' switch wire frame mode
                Case EKEY_KEY_W  
                    box.setMaterialFlag(EMF_WIREFRAME, box.getMaterial(0).getWireframe()=False)
                    Return True    
            EndSelect            
        EndIf
        
        Return False
    EndMethod

    ' we must override the generate function in order for instantiation to work properly
    ' must return IEventReceiver
    Function generate:IEventReceiver()
        Return New MyEventReceiver
    EndFunction
EndType

' setup a simple 3d scene

Local smgr:ISceneManager=device.getSceneManager()
Local driver:IVideoDriver=device.getVideoDriver()

Local cam:ICameraSceneNode=smgr.addCameraSceneNode();
cam.setTarget(_VECTOR3DF(0,0,0))

Local anim:ISceneNodeAnimator=smgr.createFlyCircleAnimator(_VECTOR3DF(0,10,0),30.0)
cam.addAnimator(anim)
anim.drop()

Local cube:ISceneNode=smgr.addCubeSceneNode(25)
cube.setMaterialTexture(0,driver.getTexture("../media/rockwall.bmp"))
cube.setMaterialFlag(EMF_LIGHTING,False)

smgr.addSkyBoxSceneNode( ..
    driver.getTexture("../media/irrlicht2_up.jpg"), ..
    driver.getTexture("../media/irrlicht2_dn.jpg"), ..
    driver.getTexture("../media/irrlicht2_lf.jpg"), ..
    driver.getTexture("../media/irrlicht2_rt.jpg"), ..
    driver.getTexture("../media/irrlicht2_ft.jpg"), ..
    driver.getTexture("../media/irrlicht2_bk.jpg"))

' create the event receiver that toggles wireframe
Local receiver:IEventReceiver=IEventReceiver.create(MyEventReceiver.generate)
MyEventReceiver(receiver).setBox(cube)
device.setEventReceiver(receiver)

' show And execute dialog
ShowGadget(window)

' do message queue

' Instead of this, you can also simply use your own message loop
' using GetMessage, DispatchMessage And whatever. Calling
' Device->run() will cause Irrlicht To dispatch messages internally too. 
' You need Not call Device->run() If you want To do your own message 
' dispatching loop, but Irrlicht will Not be able To fetch
' user Input Then And you have To do it on your own using the BlitzMax
' event mechanism.

While(device.run())

    driver.beginScene(True, True)
    smgr.drawAll()
    driver.endScene()

    If PeekEvent() Then 
        PollEvent()
        Select EventID()
            Case EVENT_WINDOWCLOSE
                Exit
            Case EVENT_GADGETACTION
                If EventSource()=Ok
                    PostEvent(CreateEvent(EVENT_WINDOWCLOSE,Ok))
                ElseIf EventSource()=go
                    Local url:String
                    If GadgetText(tb)<>"" Then url=GadgetText(tb) Else url="http://www.blitzmax.com"
                    HtmlViewGo( HTMLWindow,url )                
                ElseIf EventSource()=tb
                    'Print "textbox"
                Else ' pass it on to Irrlicht
                    ' you would need to determine the event and pass it on
                    Local event:SEvent=SEvent.create()
                    event.setEventType(EET_KEY_INPUT_EVENT)
                    event.setKeyInputKey(EKEY_KEY_W)
                    device.postEventFromUser(event)                
                EndIf
            Default
                'PostEvent(CreateEvent(EventID()),True)
If EventID()=EVENT_KEYDOWN
    Local event:SEvent=SEvent.create()
    event.setEventType(EET_KEY_INPUT_EVENT)
    event.setKeyInputKey(EventData())
    device.postEventFromUser(event)                
EndIf
        End Select
    End If        
    
Wend

' the alternative, own message dispatching loop without Device->run() would
' look like this:

Rem
While True
    If PeekEvent() Then 
        PollEvent()
        Select EventID()
        Case EVENT_WINDOWCLOSE
            Exit
        Case EVENT_GADGETACTION        
            If EventSource()=Ok
                PostEvent(CreateEvent(EVENT_WINDOWCLOSE,Ok))
            End If
        End Select
    End If        
    '// advance virtual time
    device.GetTimer().Tick()
    '// draw engine picture
    driver.beginScene(True, True, 0)
    smgr.drawAll()
    driver.endScene()
Wend
EndRem

device.closeDevice()
device.drop()

3 (edited by kimgar 2007-04-16 07:14:52)

Re: splitscreen irrlicht/html (url)

aah, that is just wonderful news gman!

i will check out your code right away!

thank's alot for the speedy, to-the-point answer as always!