max2d in a panel?
BlitzMax Forums/Brucey's Modules/max2d in a panel?
| ||
How do you put a max2d canvas into a panel instead of a new window? |
| ||
Parent the Panel to the window and then parent the canvas to the panelGlobal 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? |
| ||
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 |
| ||
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? |
| ||
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. |
| ||
heres the code: It doesnt seem to want to load a pixmap, map_pix is always NULL after trying to load a pixmap |
| ||
Ah... yes. You'll need to : Import BRL.JPGLoader Or whatever image loader you normally use (eg. BRL.PNGLoader, BaH.Magick, etc) |
| ||
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. |
| ||
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 |
| ||
Practise makes perfect ;-) |