<?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 — iB3D and MaxGui Improved Sample !]]></title>
		<link>https://gprogs.com/viewtopic.php?id=338</link>
		<atom:link href="https://gprogs.com/extern.php?action=feed&amp;tid=338&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in iB3D and MaxGui Improved Sample !.]]></description>
		<lastBuildDate>Tue, 26 Aug 2008 12:31:54 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[iB3D and MaxGui Improved Sample !]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=1296#p1296</link>
			<description><![CDATA[<p>Hey guys!</p><p>I finally found a way to resize the GUI instantly inside the canvas !<br />It&#039;s incredible, but it really works !</p><p>Here&#039;s how to do, gman didn&#039;t included the IDriver.OnResize(size) function, that one was needed to resize the 3d view without having to restart...</p><p>Open C:\Program Files\blitzmax\mod\irrlicht.mod\core.mod\video\ivideodriver_wrap.h</p><p>After :<br /></p><div class="codebox"><pre><code>    IImage* IrrVideo_IVideoDriver_createImageFromStream(IVideoDriver* driver,IReadFile* file)
    {
        if (driver)
            return driver-&gt;createImageFromFile(file);
        else
            return 0;
    }</code></pre></div><p>Add the following :<br /></p><div class="codebox"><pre><code>    void IrrVideo_IVideoDriver_OnResize(IVideoDriver* driver, s32 width, s32 height)
    {
        if (driver) {
            dimension2d&lt;s32&gt; size(width, height);
            driver-&gt;OnResize(size);
        }
    }</code></pre></div><p>Save And Close.</p><p>Open C:\Program Files\blitzmax\mod\irrlicht.mod\core.mod\video\ivideodriver_wrap.bmx</p><p>After :<br /></p><div class="codebox"><pre><code>Function IrrVideo_IVideoDriver_createImageFromFile:Int(pIVideoDriver:Int, filename$z) &#039; returns IImage*</code></pre></div><p>Add the following :<br /></p><div class="codebox"><pre><code>Function IrrVideo_IVideoDriver_OnResize(pIVideoDriver:Int, width:Int, height:Int)</code></pre></div><p>Save And Close</p><p>Open C:\Program Files\blitzmax\mod\irrlicht.mod\core.mod\video\ivideodriver.bmx</p><p>After :<br /></p><div class="codebox"><pre><code>    Method createImageFromFile:IImage(filename:String)
        Return IImage.createFromHandle(IrrVideo_IVideoDriver_createImageFromFile(handle,filename))
    EndMethod</code></pre></div><p>Add the following :<br /></p><div class="codebox"><pre><code>    Method OnResize(width:Int, height:Int)
        IrrVideo_IVideoDriver_OnResize(handle, width, height) &#039; returns IImage*
    End Method</code></pre></div><p>Compile the modules.<br />Here&#039;s the full code to test :</p><div class="codebox"><pre><code>&#039; this is an example showing how to display Irrlicht in a panel on a MaxGUI form.  i have modified it a bit
&#039; by adding an eventreceiver to the Irrlicht instance to show how MaxGUI and Irrlicht events can coexist.
&#039; it is important to note that there still is probably some issues to work out, but for now this works.
&#039;
&#039; NOTE: press the &#039;w&#039; key to toggle wireframe

SuperStrict 
Framework Irrlicht.B3D

Import BRL.Basic
Import BRL.Win32MaxGUI
Import BRL.EventQueue

Local window:TGadget&#039; Author: robobimbo

Local windowWidth:Int = 800
Local windowHeight:Int = 600

window = CreateWindow(&quot;MyApp&quot;, 100, 100,  ..
    windowWidth, windowHeight, Null)&#039;,WINDOW_TITLEBAR | WINDOW_CLIENTCOORDS | WINDOW_HIDDEN)

&#039; create window To put irrlicht in
Global hIrrlichtWindow:TGadget = CreatePanel(0, 0, 800, 600, window, PANEL_ACTIVE | PANEL_BORDER)

Global param:SIrrlichtCreationParameters = SIrrlichtCreationParameters.Create()
param.setWindowId(QueryGadget(hIrrlichtWindow,QUERY_HWND))
param.setDriverType(EDT_OPENGL)

&#039; create the device from the params object and initialize iB3D
ib3d_Graphics3DParams(param)

&#039; setup a simple 3d scene

Local cam:CAMERA = ib3d_CreateCamera()
Local LIGHT1:LIGHT = ib3d_CreateLight()
ib3d_LightColor(LIGHT1, 255, 255, 255)
ib3d_LightRange(LIGHT1, 60)
ib3d_LightCastShadows(LIGHT1,True)
ib3d_PositionEntity(LIGHT1, 30, 0, 0)
ib3d_LightAmbientColor(LIGHT1,0,0,0)
Local plane:MESH = ib3d_CreatePlane(100, 100, 1, 1)
ib3d_PositionEntity(plane, 30, - 10, 30)
ib3d_PointEntity cam, plane
Local cube:PRIMITIVE = ib3d_CreateCube()
ib3d_PositionEntity(cube, 30, - 5, 30)
ib3d_NameEntity(cube, &quot;CUBE&quot;)
ib3d_MoveEntity(cam, 0, 5, 0)

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

&#039; do message queue

Local bWireFrame:Int = False

While (True)

    ib3d_TurnEntity cube, 0, 2, 0
    ib3d_UpdateWorld()
    ib3d_RenderWorld()

    If PeekEvent() Then 
        PollEvent()
        Select EventID()
            Case EVENT_WINDOWSIZE
                Local devce:ib3d_engine = _g_ib3d_engine
                Local driver:IVideoDriver = devce.Driver
                SetGadgetShape(hIrrlichtWindow, 0, 0, ClientWidth(window), ClientHeight(window))
                ib3d_CameraViewport(cam, 0, 0, ClientWidth(window), ClientHeight(window))
                driver.OnResize(ClientWidth(window),ClientHeight(window))
                If ClientWidth(hIrrlichtWindow) &gt; ClientHeight(hIrrlichtWindow)
                    ib3d_CameraAspectRatio(cam, 1.0 * (ClientWidth(hIrrlichtWindow) / ClientHeight(hIrrlichtWindow)))
                Else
                    ib3d_CameraAspectRatio(cam, 1.0 * (ClientHeight(hIrrlichtWindow) / ClientWidth(hIrrlichtWindow)))
                EndIf
                SetGadgetText(window,ClientWidth(window) + &quot; x &quot; + ClientHeight(window))
            Case EVENT_WINDOWCLOSE
                Exit
            Case EVENT_GADGETACTION
            Default
                ActivateGadget(hIrrlichtWindow)
                If EventID()=EVENT_KEYDOWN And EventData()=KEY_W
                    bWireFrame = Not bWireFrame
                    &#039;ib3d_EntityFX(cube,EMF_WIREFRAME,bWireFrame)                    
                EndIf
        End Select
    End If
    
Wend</code></pre></div><p>Now, launch the program and resize... WOOT WOOT ! IT WORKS !</p><p>That&#039;s it guys, ENJOY ! <img src="https://gprogs.com/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /></p>]]></description>
			<author><![CDATA[null@example.com (Eltran)]]></author>
			<pubDate>Tue, 26 Aug 2008 12:31:54 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=1296#p1296</guid>
		</item>
	</channel>
</rss>
