MiniB3D and wxMax

BlitzMax Forums/MiniB3D Module/MiniB3D and wxMax

Chapman7(Posted 2008) [#1]
Does anyone have any tutorials on how to integrate MiniB3D into wxMax instead of MaxGUI? I have been working on this for a couple days and still have not found any luck.


Chapman7(Posted 2008) [#2]


I have that so far, still need help. I do not know what I should change it to instead of Max2D


Brucey(Posted 2008) [#3]
Okay... this is your example with modifications based partly on the maxgui example :

If you want the 3d canvas to scale with the window you'll probably need to connect the size event and set TGlobal's width and height to match the new values.

Note that there are currently issues using a fullscreen-mode canvas with wxMax, in that input events seem to get lost somewhere. If you are only using it in a Window, it works fine.


Chapman7(Posted 2008) [#4]
I am still not getting any sort of render in the canvas. I will work with it a bit and if I get it, I will post it for others.


Brucey(Posted 2008) [#5]
Hmm... worked here on Mac (so I assumed it should work for Win32 too)... I'll need some time to set up my Parallels to have the latest everything in order to try it there...


Chapman7(Posted 2008) [#6]
What version of MiniB3D do you have?


Yahfree(Posted 2008) [#7]
Nothing is rendered here...

Windows XP, 3ghz P4 processer, NVIDIA 9600 GT video card


Difference(Posted 2008) [#8]
I have fixed the example posted by Brucey by sticking a TGLobal.EnableStates() in the draw method.
It now works on my intel macbook running Windows XP.

This is overkill because it seems EnableStates() only needs to be called once.
I'm not sure where to put it so that it happens once, after init(), but before render()

The modified render method looks like this:

	Method Render()
		SetGraphics CanvasGraphics2D( Self )
		TGlobal.EnableStates()
		Draw()
		Flip
	End Method



Brucey(Posted 2008) [#9]
You could always wrap it in a global variable test?
	Method Render()
		SetGraphics CanvasGraphics2D( Self )
		Global enabled:int
		If Not enabled Then
			enabled = True
			TGlobal.EnableStates()
		End If
		Draw()
		Flip
	End Method

I've not see EnableStates used before. Where/when would you normally call that?


Difference(Posted 2008) [#10]
EnableStates is called during Graphics3D(). I don't think it's ment to be called outside minib3d. It tells opengl to enable different features. Some state settings are missing resulting in garbled output in your original example above.

I found out that in your example it's simply called to early for some implementations. (all windows versions? )

It just needs to be called a little later in the application startup sequence.


Brucey(Posted 2008) [#11]
it's simply called to early for some implementations.

Quite likely.
Different platforms expect different things to have happened by the time you come to use particular APIs.

I suppose that's what makes cross-platform programming so much fun :-)


johnnyfreak(Posted 2009) [#12]
Running brucey's example (with fix added) i get a "runtime exception: unhandled memory exception error" on RenderWorld. why?

If i run the first code i'have no errors but no render, only black rect.


dav3d(Posted 2009) [#13]
Running brucey's example (with fix added) i get a "runtime exception: unhandled memory exception error" on RenderWorld. why?

Try adding TGlobal.GraphicsInit() to the Render method.

By the way, I can't figure out how to render textures. I'm only getting white surfaces.


johnnyfreak(Posted 2009) [#14]
Thanks! Now i can use minib3d and wxMax. for texturese, same problem here :(


Volker(Posted 2009) [#15]
No textures here too...


dav3d(Posted 2009) [#16]
I got it! :)

The textures have to be loaded after the graphics were initialized, which is after the first run of the Render Method. Also the graphics must be initialized once only.

Field initialized_graphics:Int=False

Method Render()
	
	If Not initialized_graphics Then
		TGlobal.GraphicsInit()
		EntityTexture cube,LoadTexture("path\to\texture.png")
		initialized_graphics=True
	End If
	
	Draw()
	Flip
End Method

Makes sense right?


Volker(Posted 2009) [#17]
Yeah, that's it.
Great!
[Edit]
Has anyone tested it with an textured mesh?
My whole screen ist flickering while LoadMesh.


johnnyfreak(Posted 2009) [#18]
thanks!


dav3d(Posted 2009) [#19]
My whole screen ist flickering while LoadMesh.

What exactly do you mean? Your screen shouldn't refresh at all while executing a LoadMesh call (except you do it in a separate thread). The mesh I tried (.b3d) worked well.

Besides of that I noticed that all meshes must be created after the GraphicsInit() or they'll get overwritten by other meshes.


Volker(Posted 2009) [#20]
My whole screen, not just the WxFrame, flashed black and white
and the app freezed under Vista.

that all meshes must be created after the GraphicsInit() or they'll get overwritten by other meshes

This was the point. ALL meshes.
Not just overwritten, it caused some more serious errors.

The cube, sphere and cylinder were created in OnInit().
The other mesh was loaded in Render()
If I move them in Render() after the second "TGlobal.GraphicsInit()"
then it works. Don't know why..

My failing Code:



dav3d(Posted 2009) [#21]
Nice to hear it worked.

I'm not familiar with OpenGL but the problem seems to be that with the second GraphicsInit() the previous setup gets lost but isn't freed up properly as the graphics are never finished correctly, so some objects and settings still reside in the memory and interfere the rendering.

By the way, the first GraphicsInit() (at OnInit()) isn't necessary if you're anyways reinitializing the graphics in the Render method.


Volker(Posted 2009) [#22]
Has anyone got this working with Max2D?
BeginMax2D() and EndMax2D() do not work
with the canvas.


klepto2(Posted 2009) [#23]
For using Max2d just load the GLMAX2DDriver:

SetGraphicsDriver GLMax2DDriver()


Volker(Posted 2009) [#24]
Thanks for the fast answer.
But I get
Compile Error: Duplicate identifier 'GLMax2DDriver' in modules 'brl.glmax2d' and 'wx.wxglmax2d'
If commenting out "Import wx.wxglmax2D" wxGLCanvas is not found..


klepto2(Posted 2009) [#25]
I'don't know exactly, but you may change in minib3d.mod:

import brl.glmax2d to import wx.wxglmax2d and recompile the module.


Volker(Posted 2009) [#26]
Just tested. No changes :-(