I'm trying to make a map editor... and I have a main canvas where I show all the stuff... but I also have some canvases for previewing some objects that are going to be placed...
It all works on until I show up the preview canvas... then it starts to draw it but somehow it also draws that convas on the main canvas...
Here is a screen shot
Here are some code that migh me helpful to understand
UpdateObjects(5) is for showing some objects and UpdateObjects(4) is for hiding them
It all works on until I show up the preview canvas... then it starts to draw it but somehow it also draws that convas on the main canvas...
Here is a screen shot
Here are some code that migh me helpful to understand
Function MainWindowCanvasRender() SetGraphics CanvasGraphics( MainCanvas) SetCanvasGraphics(MainCanvas,ClientWidth(MainCanvas),ClientHeight(MainCanvas),16,0,60) cam.update() If Renderer_flat = 1 UpdateObjects(5) Else UpdateObjects(4) EndIf CameraClsMode cam.cam,True,True Wireframe(False) UpdateObjects(1) HideEntity grid UpdateWorld() RenderWorld() 'Second Pass ShowEntity grid EntityColor grid , 155 , 155 , 155 If Renderer_wire = 1 updateobjects(5) Else updateobjects(4) EndIf CameraClsMode cam.cam , False , False Wireframe(True) UpdateObjects(2) UpdateWorld() RenderWorld() 'Third Pass If Renderer_points = 1 updateobjects(5) Else updateobjects(4) EndIf CameraClsMode cam.cam,False,False HideEntity grid Points_mode(1) UpdateObjects(3) UpdateWorld() RenderWorld() updateobjects(5) Flip End Function Function TexturesWndCanvasRender() Local g:Int = 0 For Local canvas:Tgadget = EachIn TexturesWnd_CanvasList Select EventSource() Case canvas SetGraphics CanvasGraphics(canvas) Local obj_tex:Tobject_texture = Tobject_texture(Object_TextureList.ValueAtIndex(g)) Local scalex:Float = Float(GadgetWidth(canvas))/Float(ImageWidth(obj_tex.img)) Local scaley:Float = Float(GadgetWidth(canvas))/Float(ImageHeight(obj_tex.img)) SetScale(scalex,scaley) SetColor 255,255,255 DrawImage obj_tex.img,0,0 If obj_tex.selected = 1 SetColor 0,0,255 SetLineWidth(5) SetScale 1,1 DrawLine(0,0,ImageWidth(obj_tex.img),0) DrawLine(0,0,0,ImageHeight(obj_tex.img)) DrawLine(ImageWidth(obj_tex.img),ImageWidth(obj_tex.img),ImageWidth(obj_tex.img),0) DrawLine(ImageWidth(obj_tex.img),ImageWidth(obj_tex.img),0,ImageWidth(obj_tex.img)) EndIf Flip EndSelect g = g + 1 Next End Function Function EditTreeWndPreviewCanvasRender() Cls SetCanvasGraphics(EditTreeWnd_PreviewCanvas,ClientWidth(EditTreeWnd_PreviewCanvas),ClientHeight(EditTreeWnd_PreviewCanvas),16,0,60) 'UpdateObjects(4) If CreateTreeWnd_Model <> Null Then ShowEntity CreateTreeWnd_Model CameraViewport (EditTreeWnd_Cam.cam,0,0,ClientWidth(EditTreeWnd_PreviewCanvas),ClientHeight(EditTreeWnd_PreviewCanvas)) UpdateWorld() RenderWorld() 'DebugStop 'SetGraphics CanvasGraphics(EditTreeWnd_PreviewCanvas) 'DrawText "Press Escape To Exit",0,0 Flip End Function Function CreateTreeWndPreviewCanvasRender() Cls SetCanvasGraphics(CreateTreeWnd_PreviewCanvas,ClientWidth(EditTreeWnd_PreviewCanvas),ClientHeight(EditTreeWnd_PreviewCanvas),16,0,60) 'UpdateObjects(4) If CreateTreeWnd_Model <> Null Then ShowEntity CreateTreeWnd_Model CameraViewport (CreateTreeWnd_Cam.cam,0,0,ClientWidth(CreateTreeWnd_PreviewCanvas),ClientHeight(EditTreeWnd_PreviewCanvas)) UpdateWorld() RenderWorld() 'DebugStop 'SetGraphics CanvasGraphics(EditTreeWnd_PreviewCanvas) 'DrawText "Press Escape To Exit",0,0 Flip End Function Function SetCanvasGraphics(canvas:Tgadget,width:Int,height:Int,depth:Int,mode:Int,rate:Int) SetGraphicsDriver GLMax2DDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER TGlobal.width=width TGlobal.height=height TGlobal.depth=depth TGlobal.mode=mode TGlobal.rate=rate SetGraphics CanvasGraphics(canvas) TGlobal.GraphicsInit() ClearTextureFilters() End Function
UpdateObjects(5) is for showing some objects and UpdateObjects(4) is for hiding them