Download Now
Forums

    Reference Codebot.Render.Controls.pas

    Part of the Codebot Render Controls package

    The Codebot.Render.Controls unit gives you TGraphicsBox, a windowed control for showing OpenGL graphics inside your forms. When it is first shown, it creates an SDL window that fills the control, and SDL creates the OpenGL context for that window. At design time nothing is created, and the control paints an OpenGL logo instead.

    All rendering happens on a render thread of its own, with the context current. OnRenderStart is invoked once so you can create your OpenGL resources, OnRender is invoked for every frame with the size of the rendering area, and OnRenderStop is invoked once before the context is destroyed so you can free them. Canvas lets you draw vector graphics between BeginFrame and EndFrame. Because these events run on the render thread, they must not touch other controls directly, so use TThread.Queue or TThread.Synchronize when you need the main thread.

    If you need something to happen at a steady rate apart from drawing, such as physics, StartStepping runs a step thread that calls your event every interval, catching up on missed steps for up to a quarter of a second.

    Because the SDL window covers the control, SDL reads the keyboard and mouse over it. Before each frame the graphics box passes that input on in three ways. The usual LCL key and mouse events of the control are invoked on the main thread, and the render thread waits for them so they see the same input as the frame that follows. OnInput is invoked on the render thread with each SDL event. The keyboard, mouse, and joysticks of Codebot.Hardware are scanned. OnMouseEnter and OnMouseLeave are not invoked, and while the control has the focus the LCL does not see keys, so the Tab key and the shortcuts of the form don't work.

    TGraphicsBoxOptions chooses the depth bits, stencil bits, and multisampling of the context, and is only used once, just before the context is created. If the context can't be created or one of your events raises an exception, the render thread stops, Failed becomes True, ErrorMessage tells you why, and OnFailed is invoked on the main thread.

    Items 56 items

    NameKindLine
    TGraphicsBoxclass122
    BeginFrameprocedure175
    Createconstructor171
    Destroydestructor172
    DestroyWndprocedure164
    EndFrameprocedure177
    EraseBackgroundprocedure173
    Flipprocedure180
    Paintprocedure167
    PaintWindowprocedure166
    Resizeprocedure165
    StartSteppingprocedure185
    StopSteppingprocedure187
    WSRegisterClassprocedure163
    Alignproperty214
    Anchorsproperty215
    BorderSpacingproperty216
    Canvasproperty192
    Constraintsproperty217
    Contextproperty195
    ControlCanvasproperty169
    Enabledproperty218
    ErrorMessageproperty209
    Failedproperty206
    OnClickproperty221
    OnDblClickproperty222
    OnFailedproperty237
    OnInputproperty212
    OnKeyDownproperty223
    OnKeyUpproperty224
    OnMouseDownproperty226
    OnMouseEnterproperty227
    OnMouseLeaveproperty228
    OnMouseMoveproperty229
    OnMouseUpproperty230
    OnMouseWheelproperty231
    OnRenderproperty247
    OnRenderStartproperty240
    OnRenderStopproperty243
    OnResizeproperty232
    OnUTF8KeyPressproperty225
    Optionsproperty234
    Renderingproperty199
    Steppingproperty201
    TabStopproperty219
    Visibleproperty220
    TGraphicsBoxOptionsclass28
    Assignprocedure39
    Createconstructor38
    DepthBitsproperty42
    MultiSamplesproperty50
    MultiSamplingproperty47
    StencilBitsproperty45
    TGraphicsInputEventprocedural66
    TGraphicsRenderEventprocedural56
    TGraphicsStepEventprocedural61