Multiple wxGLCanvas' in one Application?

BlitzMax Forums/Brucey's Modules/Multiple wxGLCanvas' in one Application?

Steffenk(Posted 2009) [#1]
Hi!

Your wxWidgets modules really do a great job, most of the time. And if they didn't, it's oftenly been by my own failure.
Now i've come to a point though where more experimenting just doesn't seem to fix my problem. I can't get a second wxGLCanvas running in a second wxDialog (and probably wouldn't if i tried it in the first dialog/frame as well).
My application is an integrated editor for my (console-style-RPG) game. The main wxFrame holds a menubar and the first wxGLCanvas with the main game screen. A dialog window called from the MenuBar serves to edit enemy types and now I want it to display a preview graphic of the current enemy type. So that's where I'd liked to have a second wxGLCanvas to display it. I've derived a second type from wxGLCanvas with it's own drawing commands in Render() etc. but it seems to draw nothing at all. The space where the wxGLCanvas should be is empty, i.e. one can only see what's in the window behind it. So it's actually more transparent.

I've also become a little skeptical about the performance of the wxGLCanvas, is it comparable to a normal Max2d window or remarkably slower?

Thanks for all your work for the Blitzmax community.


DavidDC(Posted 2009) [#2]
Well I just tested this under Blitzmax 1.30 (I haven't updated yet) and it works in XP. That is, you can have both a wxGLCanvas in main window AND a wxGLCanvas in a wxDialog sitting on top of the main window (see pic below).

I even applied transparency to the wxDialog as a whole and it displayed without a glitch.

Which surprised me actually as I've had trouble before doing this...

Are you setting the viewport? Which OS? What do your OnPaint routines look like? What about that GLShared texture-whatsit switch needed for the latest Blitzmax? Maybe that's an issue? Is your main window still rendering the first canvas via some kind of timer setup whilst you are trying to render the second?

I've not tested performance.




DreamLoader(Posted 2009) [#3]
actually i got the same problem,i need 2 canvas in the app,
one to edit map,one to use for minimap,no deep test for now,but
nice to share your experience.
@DavidDC
why not share your code?


DavidDC(Posted 2009) [#4]
I didn't post code as I have this compulsion to wrap wrappers :-) To get my code working you'd have to alter wx.mod/base.bmx and recompile and you *don't* want to do that!

But I'm not doing anything fancy...

My wxGLCanvas wrapper OnPaint looks like this:

I've had problems in the past getting multiple wxGlCanvases to behave on different tabs of a FlatTabber - so I know there are issues out there. I was kind of surprised when my test worked actually.


Steffenk(Posted 2009) [#5]
I'm not setting the viewport, may that be an issue?

	Method OnPaint(event:wxPaintEvent)
		Render()
	End Method
	
	Method Render() 
		SetGraphics CanvasGraphics2D( Self ) 
		
		Cls
		
		SetColor 255,0,0
		
		DrawRect 10 , 10 , 500 , 500
		
		Flip

	End Method


The first wxGLCanvas continues rendering (i think) through a timer (both Canvases use a timer). The OS is Windows XP, i haven't heard about that GLShared texture-switch yet, maybe i'll look into it this evening.

EDIT: The second Canvas starts working when I drag its Dialog on my second TFT monitor, which is also powered by another graphics adapter than the first monitor. This is scary.


DavidDC(Posted 2009) [#6]
I think the switch is called GLShareContexts()

I'd also try stopping the first timer (or just skipping the first canvas render) whilst the dialog is open just to see what happens.