max2d in a panel?

BlitzMax Forums/Brucey's Modules/max2d in a panel?

slenkar(Posted 2009) [#1]
How do you put a max2d canvas into a panel instead of a new window?


_Skully(Posted 2009) [#2]
Parent the Panel to the window and then parent the canvas to the panel

Global WinG_Main:TGadget=CreateWindow("App",0,0,ScreenWidth,ScreenHeight)
Global Panel_ToolBar:TGadget=CreatePanel(0,0,WinG_Main.ClientWidth(),WinG_Main.ClientHeight(),WinG_Main)
Global Canvas:TGadget = CreateCanvas(0,0,Panel_ToolBar.ClientWidth(),Panel_ToolBar.ClientHeight(),Panel_ToolBar,0)
Canvas.setlayout 1,1,1,1


{edit} oops... are you referring to wx?


Wiebo(Posted 2009) [#3]
You will need a wxGLcanvas, and draw to it using SetGraphics CanvasGraphics2D( Self )

There are 2 demo's:
wx.mod/samples/graphics_tests/
wx.mod/samples/glmax2d.bmx


slenkar(Posted 2009) [#4]
yes Wx :)

I got it to work now with the clock example but when I load an image it says its null
Is there a special way to load images?


Brucey(Posted 2009) [#5]
Is there a special way to load images?

Think of it as a normal Max2D graphics context.

Anything you can do with Max2D, you can do here.
Remember though that you'll have to have a "live" graphics instance for images to "load".

One way around the issue of only being able to load images after you create your "Graphics" is to pre-load them into Pixmaps, then you can LoadImage(mypixmap) instead.


slenkar(Posted 2009) [#6]
heres the code:


It doesnt seem to want to load a pixmap, map_pix is always NULL after trying to load a pixmap


Brucey(Posted 2009) [#7]
Ah... yes.

You'll need to :
Import BRL.JPGLoader


Or whatever image loader you normally use (eg. BRL.PNGLoader, BaH.Magick, etc)


Brucey(Posted 2009) [#8]
A small explanation about how "loaders" work.

At startup (of your application), each "loader" module announces itself to BlitzMax, and is added to a list of available loaders.

When it comes time to load something, each is tried in turn until one is able to successfully load the image.
If there are no loaders, or none of them can load the image, then the result of LoadPixmap/LoadImage is Null.


slenkar(Posted 2009) [#9]
oops sorry about that, Im just not used to using a framework

EDIT- I tried changing the framework command to Import
but then it complained about some C++ header files


Brucey(Posted 2009) [#10]
Practise makes perfect ;-)