Request RenderOnce in OpenGLWidget example

This commit is contained in:
Francisco Vallarino 2021-09-24 13:53:41 -03:00
parent 3f7acc98ed
commit afc6a56ae7
2 changed files with 8 additions and 5 deletions

View File

@ -32,10 +32,12 @@ related tasks.
In the example the `init` function takes care of loading the vertex and fragment
shaders that will be used for rendering, and also for allocating the Vertex
Array Object and Vertex Buffer Object. The corresponding ids are stored in the
widget's state for further usage. As in other widgets, it is important to
implement merge to keep this information when the UI is rebuilt. The `dispose`
function releases these OpenGL resources.
Array Object and Vertex Buffer Object. The ids of these buffers are stored in
the widget's state for further usage, and a `RenderOnce` request is made to make
sure the initial version of the widget is displayed correctly. The `dispose`
function, also using `RunInRenderThread`, takes care of releasing these OpenGL
resources. As in other widgets, it is important to implement merge to keep the
current widget state when the UI is rebuilt.
### Rendering passes

View File

@ -88,10 +88,11 @@ makeOpenGLWidget color state = widget where
reqs = [RunInRenderThread widgetId path disposeOpenGL]
handleMessage wenv node target msg = case cast msg of
Just (OpenGLWidgetInit shaderId vao vbo) -> Just (resultNode newNode) where
Just (OpenGLWidgetInit shaderId vao vbo) -> Just result where
newState = OpenGLWidgetState True shaderId vao vbo
newNode = node
& L.widget .~ makeOpenGLWidget color newState
result = resultReqs newNode [RenderOnce]
_ -> Nothing
getSizeReq wenv node = (sizeReqW, sizeReqH) where