<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[GMan's Mods & Stuff — Irrlicht with HighGUI]]></title>
		<link>https://gprogs.com/viewtopic.php?id=101</link>
		<atom:link href="https://gprogs.com/extern.php?action=feed&amp;tid=101&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Irrlicht with HighGUI.]]></description>
		<lastBuildDate>Fri, 01 Sep 2006 17:49:06 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Irrlicht with HighGUI]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=428#p428</link>
			<description><![CDATA[<div class="codebox"><pre><code>&#039; HighGUI inside a MaxGUI canvas with Irrlicht
&#039; Bashing together of examples (just as proof of concept) by WendellM - Aug 31, 2006
&#039; Requires BlitzMax, MaxGUI, Irrlicht, GMan&#039;s Irrlicht 1.0 wrapper, and Diablo&#039;s HighGUI 3

Framework gg.IrrBMAX

Import Diablo.HighGUI
Import BRL.Max2D
Import BRL.FreetypeFont
Import BRL.Basic
Import BRL.Win32MaxGUI
Import BRL.BMPLoader
Import BRL.JPGLoader

Import BRL.D3D7Max2D
Import BRL.GLMax2D

Local D3D = True &#039; choice of D3D or OpenGL, also used for Irrlicht init below
If D3D Then SetGraphicsDriver D3D7Max2DDriver() Else SetGraphicsDriver GLMax2DDriver()
&#039; Only D3D seems to work, but it should work with OpenGL as well (I haven&#039;t tried fixing)

Local windowWidth:Int = 800
Local windowHeight:Int = 600
Local window:TGadget=CreateWindow(&quot;Irrlicht Win32 BlitzMax meets HighGUI&quot;, ..
      20,35,windowWidth,windowHeight,Null,WINDOW_CLIENTCOORDS|WINDOW_HIDDEN|WINDOW_TITLEBAR)

Local hIrrlichtWindow:TGadget=CreatePanel(130,360,320,220,window,PANEL_ACTIVE)&#039;|PANEL_BORDER)

Local param:T_irrSIrrlichtCreationParameters=T_irrSIrrlichtCreationParameters.create()
param.setWindowId(QueryGadget(hIrrlichtWindow,QUERY_HWND))

If D3D Then
    param.setDriverType(EDT_DIRECT3D9)&#039;or whatever driver is desired
Else
    param.setDriverType(EDT_OPENGL)
EndIf

&#039; create the device from the params object
Local device:T_irrIrrlichtDevice= ..
    T_irrIrrlichtDevice.createFromParams(param)

&#039; the original does not have this.  this is just to show that you can mix events
&#039; between MaxGUI and Irrlicht.
Type MyEventReceiver Extends T_irrIEventReceiver

    Field box:T_irrISceneNode

    Method setBox(b:T_irrISceneNode)
        box=b
    EndMethod

    Method OnEvent:Int(event:T_irrSEvent)

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

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

    &#039; we must override the generate function in order for instantiation to work properly
    &#039; must return T_irrIEventReceiver
    Function generate:T_irrIEventReceiver()
        Return T_irrIEventReceiver(New MyEventReceiver)
    EndFunction
EndType


&#039; setup a simple 3d scene

Local smgr:T_irrISceneManager=device.getSceneManager()
Local driver:T_irrIVideoDriver=device.getVideoDriver()

Local cam:T_irrICameraSceneNode=smgr.addCameraSceneNode();
cam.setTarget(T_irrVector3df.createFromVals(0,0,0))

Local anim:T_irrISceneNodeAnimator = ..
       smgr.createFlyCircleAnimator(T_irrVector3df.createFromVals(0,10,0),30.0)
cam.addAnimator(anim)
anim.drop()

Local cube:T_irrISceneNode=smgr.addTestSceneNode(25)
cube.setMaterialTexture(0,driver.getTexture(&quot;irrlicht/rockwall.bmp&quot;))

smgr.addSkyBoxSceneNode( ..
    driver.getTexture(&quot;irrlicht/irrlicht2_up.jpg&quot;), ..
    driver.getTexture(&quot;irrlicht/irrlicht2_dn.jpg&quot;), ..
    driver.getTexture(&quot;irrlicht/irrlicht2_lf.jpg&quot;), ..
    driver.getTexture(&quot;irrlicht/irrlicht2_rt.jpg&quot;), ..
    driver.getTexture(&quot;irrlicht/irrlicht2_ft.jpg&quot;), ..
    driver.getTexture(&quot;irrlicht/irrlicht2_bk.jpg&quot;))

&#039; create the event receiver that toggles wireframe
Local receiver:T_irrIEventReceiver=T_irrIEventReceiver.create(MyEventReceiver.generate)
MyEventReceiver(receiver).setBox(cube)
device.setEventReceiver(receiver)

&#039; show And execute dialog
ShowGadget(window)

&#039; do message queue

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

SeedRnd(MilliSecs())
AppTitle = &quot;HighGUI 3: Example 1a - canvas&quot;

&#039;Local win :tgadget = CreateWindow( AppTitle, 10,10, 850, 650)
Local canvasgui:tgadget = CreateCanvas(0,0, 800,600, window )

SetGraphics CanvasGraphics(canvasgui)
EnablePolledInput &#039; &quot;undocumented&quot; function to allow canvas to received non-event input

SetMaskColor(255, 0, 255)

hi_THighGUI.Init(&quot;theme&quot;)

Incbin &quot;theme/background1.png&quot;
Global background:TImage = LoadImage(&quot;incbin::theme/background1.png&quot;)

Local buttonExit:hi_TButton = hi_CreateButton(&quot;Exit Button&quot;, 10, 10, 140, 28)
Local button1:hi_TButton = hi_CreateButton(&quot;Example Button 1&quot;, 10, 50, 140, 28)
Local button2:hi_TButton = hi_CreateButton(&quot;Example Button 2&quot;, 10, 90, 140, 28)
Local button3:hi_TButton = hi_CreateButton(&quot;Example Button 3&quot;, 10, 130, 140, 28)

Global running% = True

SetBlend(ALPHABLEND)
ShowMouse()

Local angle
While device.run()

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

    Cls
    DrawImage background, 0, 0
    
    hi_THighGUI.Render()
    hi_THighGUI.Update()

    SetColor 0, 0, 0
    DrawText &quot;FPS = &quot; + TFPSCounter.FPS, 11, 600 - GetImageFont().height() - 1
    SetColor 0, 173, 0
    DrawText &quot;FPS = &quot; + TFPSCounter.FPS, 10, 600 - GetImageFont().height() - 2
    SetColor 255, 255, 255
    
    Local mem% = GCMemAlloced()
    SetColor 0, 0, 0
    DrawText &quot;Mem = &quot; + mem, 11, 600 - (GetImageFont().height() * 2) - 1
    SetColor 0, 173, 0
    DrawText &quot;Mem = &quot; + mem, 10, 600 - (GetImageFont().height() * 2) - 2
    SetColor 255, 255, 255
    
    Flip 0
    
    TFPSCounter.Update()
    
    GCCollect()

    PollEvent()
    Select EventID()
        Case EVENT_WINDOWCLOSE
            Exit
        Default
            PostEvent(CreateEvent(EventID()),True)
    End Select

    &#039; HighGUI event handling needs to be improved here to avoid input from Irrlicht panel
    If buttonExit.IsPressed() Then End

Wend


&#039; the alternative, own message dispatching loop without Device-&gt;run() would
&#039; look like this:

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

device.closeDevice()
device.drop()
End

&#039; Lil helper
Type TFPSCounter
    
    Global FPS%, frameCounter%, frameTimer%, totalFrames%
    
    Function Update()
        frameCounter:+ 1
        totalFrames:+ 1
        If frameTimer &lt; MilliSecs()
            FPS = frameCounter
            frameTimer = 1000 + MilliSecs()
            frameCounter = 0 
        EndIf
    End Function
    
End Type</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (WendellM)]]></author>
			<pubDate>Fri, 01 Sep 2006 17:49:06 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=428#p428</guid>
		</item>
		<item>
			<title><![CDATA[Re: Irrlicht with HighGUI]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=426#p426</link>
			<description><![CDATA[<p>wow!&nbsp; very cool <img src="https://gprogs.com/img/smilies/smile.png" width="15" height="15" alt="smile" />&nbsp; do you have some sample code or a brief tutorial on how to do this?</p>]]></description>
			<author><![CDATA[null@example.com (gman)]]></author>
			<pubDate>Fri, 01 Sep 2006 11:54:07 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=426#p426</guid>
		</item>
		<item>
			<title><![CDATA[Irrlicht with HighGUI]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=423#p423</link>
			<description><![CDATA[]]></description>
			<author><![CDATA[null@example.com (WendellM)]]></author>
			<pubDate>Thu, 31 Aug 2006 20:31:36 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=423#p423</guid>
		</item>
	</channel>
</rss>
