Blitz3D+ Command Reference

RenderWorldEditorView view

Parameters

view - World Editor view handle

Description

Asks the debug host to render its world into the bound Canvas.

The render is asynchronous and shows the host's actual target world. Repeated calls coalesce while one render is pending.

Handles are context-owned and reject stale or wrong-kind values.

For the full story, see the Debug World Editor guide.

Requires Extended mode.

See also: CreateWorldEditorView, SetWorldEditorViewCamera, WorldEditorViewState.

Example

; OpenWorldEditorSession Example - launch this Extended program from DebugWorld.
Const EVENT_GADGET_ACTION=$401
Const EVENT_WINDOW_CLOSE=$803

Function SessionArgument$()
    command$=CommandLine$():position=Instr(Lower(command),"--session")
    If position=0 Then Return ""
    position=position+9
    While position<=Len(command) And Mid(command,position,1)=" ":position=position+1:Wend
    If Mid(command,position,1)=Chr(34) Then
        finish=Instr(command,Chr(34),position+1)
        Return Mid(command,position+1,finish-position-1)
    EndIf
    Return Mid(command,position)
End Function

descriptor$=SessionArgument()
If descriptor="" Then RuntimeError "This custom editor must be launched by DebugWorld"
session=OpenWorldEditorSession(descriptor)
If session=0 Then RuntimeError WorldEditorSessionError()

window=CreateWindow("Custom World Editor",100,100,800,520,0,15)
canvas=CreateCanvas(0,38,ClientWidth(window),ClientHeight(window)-38,window)
SetGadgetLayout canvas,1,1,1,1
pauseButton=CreateButton("Pause",8,6,90,27,window)
continueButton=CreateButton("Continue",106,6,90,27,window)
projectionButton=CreateButton("Orthographic",204,6,120,27,window)
view=CreateWorldEditorView(session,canvas)
SetWorldEditorViewCamera view,0,3,-8,.2,0,5
projection=1
SetWorldEditorViewProjection view,projection,24,True
running=True:request=0
While running
    event=WaitEvent(16)
    If event=EVENT_WINDOW_CLOSE Then running=False
    If event=EVENT_GADGET_ACTION And EventSource()=projectionButton Then
        projection=3-projection
        SetWorldEditorViewProjection view,projection,24,True
        If projection=1 Then SetGadgetText projectionButton,"Orthographic" Else SetGadgetText projectionButton,"Perspective"
    EndIf
    If event=EVENT_GADGET_ACTION And request=0 Then
        payload=CreateJsonObject()
        If EventSource()=pauseButton Then request=SendWorldEditorRequest(session,"pause",payload)
        If EventSource()=continueButton Then request=SendWorldEditorRequest(session,"continue",payload)
        FreeJson payload
    EndIf
    If request<>0 And WorldEditorRequestState(request)>=WORLD_EDITOR_REQUEST_SUCCEEDED Then
        FreeWorldEditorRequest request:request=0
    EndIf
    state=WorldEditorSessionState(session)
    If state=WORLD_EDITOR_SESSION_CLOSED Or state=WORLD_EDITOR_SESSION_FAILED Then running=False
    RenderWorldEditorView view
Wend
If request<>0 Then CancelWorldEditorRequest request:FreeWorldEditorRequest request
FreeWorldEditorView view
CloseWorldEditorSession session
FreeGadget window
End

Index