Wt: Wt::WGLWidget Class Reference

Wt 4.10.4

Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
Wt::WGLWidget Class Reference

GL support class. More...

`#include <Wt/WGLWidget.h>`

Inheritance diagram for Wt::WGLWidget:
[legend]

## Classes
class | ArrayBuffer
| Reference to a javascript ArrayBuffer class. More...
class | AttribLocation
| Reference to a shader attribute location. More...
class | Buffer
| Reference to a WebGLBuffer class. More...
class | Framebuffer
| Reference to a WebGLFramebuffer class. More...
class | GlObject
| Abstract base class for all GL objects. More...
class | JavaScriptMatrix4x4
| A client-side JavaScript matrix. More...
class | JavaScriptVector
| A client-side JavaScript vector. More...
class | Program
| Reference to a WebGLProgram class. More...
class | Renderbuffer
| Reference to a WebGLRenderbuffer class. More...
class | Shader
| Reference to a WebGLShader class. More...
class | Texture
| Reference to a WebGLTexture class. More...
class | UniformLocation
| Reference to a WebGLUniformLocation class. More...

## Public Types
enum | GLenum
| The enormous GLenum. More...
typedef GLRenderOption | RenderOption
| Typedef for enum Wt::GLRenderOption.
typedef GLClientSideRenderer | ClientSideRenderer
| Typedef for enum Wt::GLClientSideRenderer.
Public Types inherited from Wt::WObject
typedef void(WObject::*) | Method()
| Typedef for a WObject method without arguments.

## Public Member Functions
| WGLWidget ()
| Construct a GL widget.
| ~WGLWidget ()
| Destructor.
void | setRenderOptions (WFlags< GLRenderOption > options)
| Sets the rendering option.
void | repaintGL (WFlags< GLClientSideRenderer > which)
| Request invocation of resizeGL, paintGL and/or updateGL.
bool | restoringContext () const
| Returns whether a lost context is in the process of being restored.
void | resize (const WLength &width, const WLength &height) override
| Resizes the widget.
void | setClientSideMouseHandler (const std::string &handlerCode)
| Set a custom mouse handler based on the given JavaScript code.
void | setClientSideLookAtHandler (const JavaScriptMatrix4x4 &m, double lX, double lY, double lZ, double uX, double uY, double uZ, double pitchRate, double yawRate)
| Add a mouse handler to the widget that looks at a given point.
void | setClientSideWalkHandler (const JavaScriptMatrix4x4 &m, double frontStep, double rotStep)
| Add a mouse handler to the widget that allows 'walking' in the scene.
void | setAlternativeContent (std::unique_ptr< WWidget > alternative)
| Sets the content to be displayed when WebGL is not available.
JSlot & | repaintSlot ()
| A JavaScript slot that repaints the widget when triggered.
void | enableClientErrorChecks (bool enable=true)
| enable client-side error messages (read detailed doc!)
void | injectJS (const std::string &jsString)
| Inject JavaScript into the current js-stream.
GL methods
The GL methods are mostly 1-on-1 translated to the identical JavaScript call in WebGL. You can use the GL methods in your resizeGL(), paintGL() and updateGL() specializations. Wt takes care that data, arguments, ... are transfered to the client side and that the equivalent JavaScript WebGL funtion is executed when using client-side rendering. When using server-side rendering, the appropriate OpenGL functions are called.
void | activeTexture (GLenum texture)
| GL function to activate an existing texture.
void | attachShader (Program program, Shader shader)
| GL function to attach a shader to a program.
void | bindAttribLocation (Program program, unsigned index, const std::string &name)
| GL function to bind an attribute to a given location.
void | bindBuffer (GLenum target, Buffer buffer)
| GL function to bind a buffer to a target.
void | bindFramebuffer (GLenum target, Framebuffer framebuffer)
| GL function to bind a frame buffer to a target.
void | bindRenderbuffer (GLenum target, Renderbuffer renderbuffer)
| GL function to bind a render buffer to a target.
void | bindTexture (GLenum target, Texture texture)
| GL function to bind a texture to a target.
void | blendColor (double red, double green, double blue, double alpha)
| GL function to set the blending color.
void | blendEquation (GLenum mode)
| GL function to set the blending equation.
void | blendEquationSeparate (GLenum modeRGB, GLenum modeAlpha)
| GL function that sets separate blending functions for RGB and alpha.
void | blendFunc (GLenum sfactor, GLenum dfactor)
| GL function to configure the blending function.
void | blendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
| GL function that configures the blending function.
void | bufferData (GLenum target, int size, GLenum usage)
| glBufferData - create and initialize a buffer object's data store
void | bufferData (GLenum target, ArrayBuffer res, GLenum usage)
| glBufferData - create and initialize a buffer object's data store from an ArrayBuffer
void | bufferData (GLenum target, ArrayBuffer res, unsigned arrayBufferOffset, unsigned arrayBufferSize, GLenum usage)
| glBufferData - create and initialize a buffer object's data store from an ArrayBuffer
void | bufferSubData (GLenum target, unsigned offset, ArrayBuffer res)
| Initialize a buffer object's data store from an ArrayBuffer.
void | bufferSubData (GLenum target, unsigned offset, ArrayBuffer res, unsigned arrayBufferOffset, unsigned size)
| Initialize a buffer object's data store from an ArrayBuffer.
template<typename Iterator >
void | bufferDatafv (GLenum target, const Iterator begin, const Iterator end, GLenum usage, bool binary=false)
| GL function that loads float or double data in a VBO.
template<typename Iterator >
void | bufferDataiv (GLenum target, const Iterator begin, const Iterator end, GLenum usage, GLenum type)
| GL function that loads integer data in a VBO.
template<typename Iterator >
void | bufferSubDatafv (GLenum target, unsigned offset, const Iterator begin, const Iterator end, bool binary=false)
| GL function that updates an existing VBO with new float or double data.
template<typename Iterator >
void | bufferSubDataiv (GLenum target, unsigned offset, const Iterator begin, Iterator end, GLenum type)
| GL function that updates an existing VBO with new integer data.
void | bufferDatafv (GLenum target, const std::vector< float > &buffer, GLenum usage, bool binary=false)
| GL function that loads float or double data in a VBO.
void | clearBinaryResources ()
| remove all binary buffer resources
void | bufferDataiv (GLenum target, std::vector< int > &buffer, GLenum usage, GLenum type)
| GL function that updates an existing VBO with new integer data.
void | bufferSubDatafv (GLenum target, unsigned offset, const std::vector< float > &buffer, bool binary=false)
| GL function that updates an existing VBO with new float data.
void | bufferSubDataiv (GLenum target, unsigned offset, std::vector< int > &buffer, GLenum type)
| GL function that loads integer data in a VBO.
void | clear (WFlags< GLenum > mask)
| GL function that clears the given buffers.
void | clearColor (double r, double g, double b, double a)
| GL function that sets the clear color of the color buffer.
void | clearDepth (double depth)
| GL function that configures the depth to be set when the depth buffer is cleared.
void | clearStencil (int s)
| GL function.
void | colorMask (bool red, bool green, bool blue, bool alpha)
| GL function.
void | compileShader (Shader shader)
| GL function to compile a shader.
void | copyTexImage2D (GLenum target, int level, GLenum internalformat, int x, int y, unsigned width, unsigned height, int border)
| GL function to copy a texture image.
void | copyTexSubImage2D (GLenum target, int level, int xoffset, int yoffset, int x, int y, unsigned width, unsigned height)
| GL function that copies a part of a texture image.
Buffer | createBuffer ()
| GL function that creates an empty VBO.
Framebuffer | createFramebuffer ()
| GL function that creates a frame buffer object.
Program | createProgram ()
| GL function that creates an empty program.
Renderbuffer | createRenderbuffer ()
| GL function that creates a render buffer object.
Shader | createShader (GLenum shader)
| GL function that creates an empty shader.
Texture | createTexture ()
| GL function that creates an empty texture.
Texture | createTextureAndLoad (const std::string &url)
| GL function that creates an image texture.
std::unique_ptr< WPaintDevice > | createPaintDevice (const WLength &width, const WLength &height)
| returns an paintdevice that can be used to paint a GL texture
void | cullFace (GLenum mode)
| GL function that configures the backface culling mode.
void | deleteBuffer (Buffer buffer)
| GL function that deletes a VBO.
void | deleteFramebuffer (Framebuffer framebuffer)
| GL function that deletes a frame buffer.
void | deleteProgram (Program program)
| GL function that deletes a program.
void | deleteRenderbuffer (Renderbuffer renderbuffer)
| GL function that deletes a render buffer.
void | deleteShader (Shader shader)
| GL function that depetes a shader.
void | deleteTexture (Texture texture)
| GL function that deletes a texture.
void | depthFunc (GLenum func)
| GL function to set the depth test function.
void | depthMask (bool flag)
| GL function that enables or disables writing to the depth buffer.
void | depthRange (double zNear, double zFar)
| GL function that specifies to what range the normalized [-1,1] z values should match.
void | detachShader (Program program, Shader shader)
| GL function that detaches a shader from a program.
void | disable (GLenum cap)
| GL function to disable features.
void | disableVertexAttribArray (AttribLocation index)
| GL function to disable the vertex attribute array.
void | drawArrays (GLenum mode, int first, unsigned count)
| GL function to draw a VBO.
void | drawElements (GLenum mode, unsigned count, GLenum type, unsigned offset)
| GL function to draw indexed VBOs.
void | enable (GLenum cap)
| GL function to enable features.
void | enableVertexAttribArray (AttribLocation index)
| GL function to enable the vertex attribute array.
void | finish ()
| GL function to wait until given commands are executed.
void | flush ()
| GL function to force execution of GL commands in finite time.
void | framebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, Renderbuffer renderbuffer)
| GL function to attach the given renderbuffer to the currently bound frame buffer.
void | framebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, Texture texture, int level)
| GL function to render directly into a texture image.
void | frontFace (GLenum mode)
| GL function that specifies which side of a triangle is the front side.
void | generateMipmap (GLenum target)
| GL function that generates a set of mipmaps for a texture object.
AttribLocation | getAttribLocation (Program program, const std::string &attrib)
| GL function to retrieve an attribute's location in a Program.
UniformLocation | getUniformLocation (Program program, const std::string &location)
| GL function to retrieve a Uniform's location in a Program.
void | hint (GLenum target, GLenum mode)
| GL function to give hints to the render pipeline.
void | lineWidth (double width)
| GL function to set the line width.
void | linkProgram (Program program)
| GL function to link a program.
void | pixelStorei (GLenum pname, int param)
| GL function to set the pixel storage mode.
void | polygonOffset (double factor, double units)
| GL function to apply modifications to Z values.
void | renderbufferStorage (GLenum target, GLenum internalformat, unsigned width, unsigned height)
| GL function to allocate the appropriate amount of memory for a render buffer.
void | sampleCoverage (double value, bool invert)
| GL function to set multisample parameters.
void | scissor (int x, int y, unsigned width, unsigned height)
| GL function to define the scissor box.
void | shaderSource (Shader shader, const std::string &src)
| GL function to set a shader's source code.
void | stencilFunc (GLenum func, int ref, unsigned mask)
| GL function to set stencil test parameters.
void | stencilFuncSeparate (GLenum face, GLenum func, int ref, unsigned mask)
| GL function to set stencil test parameters for front and/or back stencils.
void | stencilMask (unsigned mask)
| GL function to control which bits are to be written in the stencil buffer.
void | stencilMaskSeparate (GLenum face, unsigned mask)
| GL function to control which bits are written to the front and/or back stencil buffers.
void | stencilOp (GLenum fail, GLenum zfail, GLenum zpass)
| GL function to set stencil test actions.
void | stencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
| GL function to set front and/or back stencil test actions separately.
void | texImage2D (GLenum target, int level, GLenum internalformat, unsigned width, unsigned height, int border, GLenum format)
| GL function to reserve space for a 2D texture, without specifying its contents.
void | texImage2D (GLenum target, int level, GLenum internalformat, GLenum format, GLenum type, WImage *image)
| GL function to load a 2D texture from a WImage.
void | texImage2D (GLenum target, int level, GLenum internalformat, GLenum format, GLenum type, WVideo *video)
| GL function to load a 2D texture from a WVideo.
void | texImage2D (GLenum target, int level, GLenum internalformat, GLenum format, GLenum type, std::string filename)
| GL function to load a 2D texture from a file.
void | texImage2D (GLenum target, int level, GLenum internalformat, GLenum format, GLenum type, WPaintDevice *paintdevice)
| GL function to load a 2D texture from a WPaintDevice.
void | texImage2D (GLenum target, int level, GLenum internalformat, GLenum format, GLenum type, Texture texture)
| GL function to load a 2D texture loaded with createTextureAndLoad()
void | texParameteri (GLenum target, GLenum pname, GLenum param)
| GL function to set texture parameters.
void | uniform1f (const UniformLocation &location, double x)
| GL function to set the value of a uniform variable of the current program.
template<typename FloatArray >
void | uniform1fv (const UniformLocation &location, const FloatArray *value)
| GL function to set the value of a uniform variable of the current program.
void | uniform1fv (const UniformLocation &location, const JavaScriptVector &v)
| GL function to set the value of a uniform variable of the current program.
void | uniform1i (const UniformLocation &location, int x)
| GL function to set the value of a uniform variable of the current program.
template<typename IntArray >
void | uniform1iv (const UniformLocation &location, const IntArray *value)
| GL function to set the value of a uniform variable of the current program.
void | uniform2f (const UniformLocation &location, double x, double y)
| GL function to set the value of a uniform variable of the current program.
template<typename FloatArray >
void | uniform2fv (const UniformLocation &location, const FloatArray *value)
| GL function to set the value of a uniform variable of the current program.
void | uniform2fv (const UniformLocation &location, const JavaScriptVector &v)
| GL function to set the value of a uniform variable of the current program.
void | uniform2i (const UniformLocation &location, int x, int y)
| GL function to set the value of a uniform variable of the current program.
template<typename IntArray >
void | uniform2iv (const UniformLocation &location, const IntArray *value)
| GL function to set the value of a uniform variable of the current program.
void | uniform3f (const UniformLocation &location, double x, double y, double z)
| GL function to set the value of a uniform variable of the current program.
template<typename FloatArray >
void | uniform3fv (const UniformLocation &location, const FloatArray *value)
| GL function to set the value of a uniform variable of the current program.
void | uniform3fv (const UniformLocation &location, const JavaScriptVector &v)
| GL function to set the value of a uniform variable of the current program.
void | uniform3i (const UniformLocation &location, int x, int y, int z)
| GL function to set the value of a uniform variable of the current program.
template<typename IntArray >
void | uniform3iv (const UniformLocation &location, const IntArray *value)
| GL function to set the value of a uniform variable of the current program.
void | uniform4f (const UniformLocation &location, double x, double y, double z, double w)
| GL function to set the value of a uniform variable of the current program.
template<typename FloatArray >
void | uniform4fv (const UniformLocation &location, const FloatArray *value)
| GL function to set the value of a uniform variable of the current program.
void | uniform4fv (const UniformLocation &location, const JavaScriptVector &v)
| GL function to set the value of a uniform variable of the current program.
void | uniform4i (const UniformLocation &location, int x, int y, int z, int w)
| GL function to set the value of a uniform variable of the current program.
template<typename IntArray >
void | uniform4iv (const UniformLocation &location, const IntArray *value)
| GL function to set the value of a uniform variable of the current program.
template<typename MatrixType >
void | uniformMatrix2fv (const UniformLocation &location, bool transpose, const MatrixType *value)
| GL function to set the value of a uniform matrix of the current program.
template<typename MatrixType >
void | uniformMatrix2 (const UniformLocation &location, const WGenericMatrix< MatrixType, 2, 2 > &m)
| GL function to set the value of a uniform matrix of the current program.
template<typename MatrixType >
void | uniformMatrix3fv (const UniformLocation &location, bool transpose, const MatrixType *value)
| GL function to set the value of a uniform matrix of the current program.
template<typename MatrixType >
void | uniformMatrix3 (const UniformLocation &location, const WGenericMatrix< MatrixType, 3, 3 > &m)
| GL function to set the value of a uniform matrix of the current program.
template<typename MatrixType >
void | uniformMatrix4fv (const UniformLocation &location, bool transpose, const MatrixType *value)
| GL function to set the value of a uniform matrix of the current program.
template<typename MatrixType >
void | uniformMatrix4 (const UniformLocation &location, const WGenericMatrix< MatrixType, 4, 4 > &m)
| GL function to set the value of a uniform matrix of the current program.
void | uniformMatrix4 (const UniformLocation &location, const JavaScriptMatrix4x4 &m)
| GL function to set the value of a uniform matrix of the current program.
void | useProgram (Program program)
| GL function to set the current active shader program.
void | validateProgram (Program program)
| GL function to validate a program.
void | vertexAttrib1f (AttribLocation location, double x)
| GL function to set the value of an attribute of the current program.
template<typename FloatArray >
void | vertexAttrib1fv (AttribLocation location, const FloatArray *values)
| GL function to set the value of an attribute of the current program.
void | vertexAttrib2f (AttribLocation location, double x, double y)
| GL function to set the value of an attribute of the current program.
template<typename FloatArray >
void | vertexAttrib2fv (AttribLocation location, const FloatArray *values)
| GL function to set the value of an attribute of the current program.
void | vertexAttrib3f (AttribLocation location, double x, double y, double z)
| GL function to set the value of an attribute of the current program.
template<typename FloatArray >
void | vertexAttrib3fv (AttribLocation location, const FloatArray *values)
| GL function to set the value of an attribute of the current program.
void | vertexAttrib4f (AttribLocation location, double x, double y, double z, double w)
| GL function to set the value of an attribute of the current program.
template<typename FloatArray >
void | vertexAttrib4fv (AttribLocation location, const FloatArray *values)
| GL function to set the value of an attribute of the current program.
void | vertexAttribPointer (AttribLocation location, int size, GLenum type, bool normalized, unsigned stride, unsigned offset)
| GL function to bind a VBO to an attribute.
void | viewport (int x, int y, unsigned width, unsigned height)
| GL function to set the viewport.
Client-side vectors and matrices
These methods can be used to modify vectors and matrices client-side, to change the GL uniforms without a roundtrip to the server.
JavaScriptMatrix4x4 | createJavaScriptMatrix4 ()
| Create a matrix that can be manipulated in client-side JavaScript.
void | addJavaScriptMatrix4 (JavaScriptMatrix4x4 &m)
| Register a matrix with this WGLWidget.
void | initJavaScriptMatrix4 (JavaScriptMatrix4x4 &m)
| Initialize the client-side JavaScript for the given JavaScriptMatrix4x4.
template<typename MatrixType >
void | setJavaScriptMatrix4 (JavaScriptMatrix4x4 &jsm, const WGenericMatrix< MatrixType, 4, 4 > &m)
| Set the value of a client-side JavaScript matrix created by createJavaScriptMatrix4x4()
JavaScriptVector | createJavaScriptVector (unsigned length)
| Create a vector of a certain length that can be manipulated in client-side JavaScript.
void | addJavaScriptVector (JavaScriptVector &v)
| Register a vector with this WGLWidget.
void | initJavaScriptVector (JavaScriptVector &v)
| Initialize the client-side JavaScript for the given JavaScriptVector.
void | setJavaScriptVector (JavaScriptVector &jsv, const std::vector< float > &v)
| Set the value of a client-side JavaScript vector created by createJavaScriptVector()
Public Member Functions inherited from Wt::WInteractWidget
| WInteractWidget ()
| Create an InteractWidget.
EventSignal< WKeyEvent > & | keyWentDown ()
| Event signal emitted when a keyboard key is pushed down.
EventSignal< WKeyEvent > & | keyPressed ()
| Event signal emitted when a "character" was entered.
EventSignal< WKeyEvent > & | keyWentUp ()
| Event signal emitted when a keyboard key is released.
EventSignal & | enterPressed ()
| Event signal emitted when enter was pressed.
EventSignal & | escapePressed ()
| Event signal emitted when escape was pressed.
EventSignal< WMouseEvent > & | clicked ()
| Event signal emitted when the primary mouse button was clicked on this widget.
EventSignal< WMouseEvent > & | doubleClicked ()
| Event signal emitted when the primary mouse button was double clicked on this widget.
EventSignal< WMouseEvent > & | mouseWentDown ()
| Event signal emitted when a mouse button was pushed down on this widget.
EventSignal< WMouseEvent > & | mouseWentUp ()
| Event signal emitted when a mouse button was released on this widget.
EventSignal< WMouseEvent > & | mouseWentOut ()
| Event signal emitted when the mouse went out of this widget.
EventSignal< WMouseEvent > & | mouseWentOver ()
| Event signal emitted when the mouse entered this widget.
EventSignal< WMouseEvent > & | mouseMoved ()
| Event signal emitted when the mouse moved over this widget.
EventSignal< WMouseEvent > & | mouseDragged ()
| Event signal emitted when the mouse is dragged over this widget.
EventSignal< WMouseEvent > & | mouseWheel ()
| Event signal emitted when the mouse scroll wheel was used.
EventSignal< WTouchEvent > & | touchStarted ()
| Event signal emitted when a finger is placed on the screen.
EventSignal< WTouchEvent > & | touchEnded ()
| Event signal emitted when a finger is removed from the screen.
EventSignal< WTouchEvent > & | touchMoved ()
| Event signal emitted when a finger, which is already placed on the screen, is moved across the screen.
EventSignal< WGestureEvent > & | gestureStarted ()
| Event signal emitted when a gesture is started.
EventSignal< WGestureEvent > & | gestureChanged ()
| Event signal emitted when a gesture is changed.
EventSignal< WGestureEvent > & | gestureEnded ()
| Event signal emitted when a gesture is ended.
void | setDraggable (const std::string &mimeType, WWidget *dragWidget=nullptr, bool isDragWidgetOnly=false, WObject *sourceWidget=nullptr)
| Configure dragging for drag and drop.
void | unsetDraggable ()
| Disable drag & drop for this widget.
void | setMouseOverDelay (int delay)
| Sets a delay for the mouse over event.
int | mouseOverDelay () const
| Returns the mouse over signal delay.
virtual void | setPopup (bool popup) override
| Lets the widget overlay over other sibling widgets.
virtual void | load () override
| Loads content just before the widget is used.
virtual bool | isEnabled () const override
| Returns whether the widget is enabled.
Public Member Functions inherited from Wt::WWebWidget
| WWebWidget ()
| Construct a WebWidget.
virtual std::vector< WWidget * > | children () const override
| Returns child widgets.
Signal & | childrenChanged ()
| Signal emitted when children have been added or removed.
virtual void | setPositionScheme (PositionScheme scheme) override
| Sets the CSS position scheme.
virtual PositionScheme | positionScheme () const override
| Returns the CSS position scheme.
virtual void | setOffsets (const WLength &offset, WFlags< Side > sides=AllSides) override
| Sets CSS offsets for a non-statically positioned widget.
virtual WLength | offset (Side s) const override
| Returns a CSS offset.
virtual WLength | width () const override
| Returns the width.
virtual WLength | height () const override
| Returns the height.
virtual void | setMinimumSize (const WLength &width, const WLength &height) override
| Sets a minimum size.
virtual WLength | minimumWidth () const override
| Returns the minimum width.
virtual WLength | minimumHeight () const override
| Returns the minimum height.
virtual void | setMaximumSize (const WLength &width, const WLength &height) override
| Sets a maximum size.
virtual WLength | maximumWidth () const override
| Returns the maximum width.
virtual WLength | maximumHeight () const override
| Returns the maximum height.
virtual void | setLineHeight (const WLength &height) override
| Sets the CSS line height for contained text.
virtual WLength | lineHeight () const override
| Returns the CSS line height for contained text.
virtual void | setFloatSide (Side s) override
| Specifies a CSS float side.
virtual Side | floatSide () const override
| Returns the CSS float side.
virtual void | setClearSides (WFlags< Side > sides) override
| Sets the sides that should be cleared of floats.
virtual WFlags< Side > | clearSides () const override
| Returns the sides that should remain empty.
virtual void | setMargin (const WLength &margin, WFlags< Side > sides=AllSides) override
| Sets CSS margins around the widget.
virtual WLength | margin (Side side) const override
| Returns a CSS margin set.
virtual void | setHiddenKeepsGeometry (bool enabled) override
| Sets whether the widget keeps its geometry when hidden.
virtual bool | hiddenKeepsGeometry () const override
| Returns whether the widget keeps its geometry when hidden.
virtual void | setHidden (bool hidden, const WAnimation &animation=WAnimation()) override
| Hides or shows the widget.
virtual bool | isHidden () const override
| Returns whether the widget is set hidden.
virtual bool | isVisible () const override
| Returns whether the widget is visible.
virtual void | setDisabled (bool disabled) override
| Sets whether the widget is disabled.
virtual bool | isDisabled () const override
| Returns whether the widget is set disabled.
virtual bool | isPopup () const override
| Returns whether the widget is overlayed.
virtual void | setInline (bool isInline) override
| Sets whether the widget is displayed inline or as a block.
virtual bool | isInline () const override
| Returns whether the widget is displayed inline or as block.
virtual void | setDecorationStyle (const WCssDecorationStyle &style) override
| Sets a CSS decoration style.
virtual WCssDecorationStyle & | decorationStyle () override
| Returns the decoration style of this widget.
virtual void | setStyleClass (const WString &styleClass) override
| Sets (one or more) CSS style classes.
virtual WString | styleClass () const override
| Returns the CSS style class.
virtual void | addStyleClass (const WString &styleClass, bool force=false) override
| Adds a CSS style class.
virtual void | removeStyleClass (const WString &styleClass, bool force=false) override
| Removes a CSS style class.
virtual bool | hasStyleClass (const WString &styleClass) const override
| Returns whether the widget has a style class.
virtual void | setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength()) override
| Sets the vertical alignment.
virtual AlignmentFlag | verticalAlignment () const override
| Returns the vertical alignment.
virtual WLength | verticalAlignmentLength () const override
| Returns the fixed vertical alignment that was set.
virtual void | setToolTip (const WString &text, TextFormat textFormat=TextFormat::Plain) override
| Sets a tooltip.
virtual void | setDeferredToolTip (bool enable, TextFormat textFormat=TextFormat::Plain) override
| Enable deferred tooltip.
virtual WString | toolTip () const override
| Returns the tooltip.
virtual void | refresh () override
| Refresh the widget.
virtual void | setAttributeValue (const std::string &name, const WString &value) override
| Sets an attribute value.
virtual WString | attributeValue (const std::string &name) const override
| Returns an attribute value.
virtual void | setJavaScriptMember (const std::string &name, const std::string &value) override
| Sets a JavaScript member.
virtual std::string | javaScriptMember (const std::string &name) const override
| Returns the value of a JavaScript member.
virtual void | callJavaScriptMember (const std::string &name, const std::string &args) override
| Calls a JavaScript member.
virtual bool | loaded () const override
| Returns whether this widget has been loaded.
virtual void | setId (const std::string &id) override
| Sets the CSS Id.
virtual WWidget * | find (const std::string &name) override
| Finds a descendent widget by name.
virtual WWidget * | findById (const std::string &id) override
| Finds a descendent widget by id.
virtual void | setSelectable (bool selectable) override
| Sets as selectable.
virtual void | doJavaScript (const std::string &javascript) override
| Executes the given JavaScript statements when the widget is rendered or updated.
virtual const std::string | id () const override
| Returns the (unique) identifier for this object.
void | setLoadLaterWhenInvisible (bool)
| Change the way the widget is loaded when invisible.
std::string | htmlTagName () const
| returns the current html tag name
void | setHtmlTagName (const std::string &tag)
| set the custom HTML tag name
virtual void | setCanReceiveFocus (bool enabled) override
| Sets whether the widget can receive focus.
virtual bool | canReceiveFocus () const override
| Returns whether the widget can receive focus.
virtual bool | setFirstFocus () override
| Set focus on the widget's first descendant.
virtual void | setFocus (bool focus) override
| Sets focus.
virtual bool | hasFocus () const override
| Returns whether the widget currently has the focus.
virtual void | setTabIndex (int index) override
| Sets the tab index.
virtual int | tabIndex () const override
| Returns the tab index.
EventSignal & | blurred ()
| Signal emitted when the widget lost focus.
EventSignal & | focussed ()
| Signal emitted when the widget recieved focus.
virtual bool | scrollVisibilityEnabled () const final override
| Returns whether scroll visibility detection is enabled for this widget.
virtual void | setScrollVisibilityEnabled (bool enabled) final override
| Sets whether scroll visibility detection is enabled for this widget.
virtual int | scrollVisibilityMargin () const final override
| Returns the margin around the viewport within which the widget is considered visible.
virtual void | setScrollVisibilityMargin (int margin) final override
| Sets the margin around the viewport within which the widget is considered visible.
virtual Signal< bool > & | scrollVisibilityChanged () final override
| Signal triggered when the scroll visibility of this widget changes.
virtual bool | isScrollVisible () const final override
| Returns whether this widget is currently considered scroll visible.
virtual void | setThemeStyleEnabled (bool enabled) final override
| Sets whether theme styling for a widget is enabled or disabled.
virtual bool | isThemeStyleEnabled () const final override
| Returns whether this widget is currently styled by the chosen theme.
virtual void | setObjectName (const std::string &name) override
| Sets an object name.
void | setFocus ()
| Sets focus.
Public Member Functions inherited from Wt::WWidget
virtual | ~WWidget ()
| Destructor.
WWidget * | parent () const
| Returns the parent widget.
virtual std::unique_ptr< WWidget > | removeWidget (WWidget *widget)
| Removes a child widget.
template<typename Widget >
std::unique_ptr< Widget > | removeWidget (Widget *widget)
| Removes a child widget.
std::unique_ptr< WWidget > | removeFromParent ()
| Removes the widget from its parent.
void | setWidth (const WLength &width)
| Sets the width.
void | setHeight (const WLength &height)
| Sets the height.
virtual void | positionAt (const WWidget *widget, Orientation orientation=Orientation::Vertical)
| Positions a widget next to another widget.
virtual void | toggleStyleClass (const WString &styleClass, bool add, bool force=false)
| Toggles a CSS style class.
std::string | jsRef () const
| Returns a JavaScript expression to the corresponding DOM node.
void | setFocus ()
| Sets focus.
virtual void | acceptDrops (const std::string &mimeType, const WString &hoverStyleClass=WString())
| Sets a mime type to be accepted for dropping.
virtual void | stopAcceptDrops (const std::string &mimeType)
| Indicates that a mime type is no longer accepted for dropping.
virtual void | htmlText (std::ostream &out)
| Streams the (X)HTML representation.
bool | isRendered () const
| Returns whether the widget is rendered.
void | hide ()
| Hides the widget.
void | animateHide (const WAnimation &animation)
| Hides the widget using an animation.
void | show ()
| Shows the widget.
void | animateShow (const WAnimation &animation)
| Shows the widget using an animation.
void | enable ()
| Enables the widget.
void | disable ()
| Disable thes widget.
bool | layoutSizeAware () const
| Returns whether the widget is layout size aware.
Public Member Functions inherited from Wt::WObject
void | addChild (std::unique_ptr< WObject > child)
| Add a child WObject whose lifetime is determined by this WObject.
template<typename Child >
Child * | addChild (std::unique_ptr< Child > child)
| Add a child WObject, returning a raw pointer.
std::unique_ptr< WObject > | removeChild (WObject *child)
| Remove a child WObject, so its lifetime is no longer determined by this WObject.
template<typename Child >
std::unique_ptr< Child > | removeChild (Child *child)
| Remove a child WObject, so its lifetime is no longer determined by this WObject.
virtual std::string | objectName () const
| Returns the object name.
void | resetLearnedSlots ()
| Resets learned stateless slot implementations.
template<class T >
void | resetLearnedSlot (void(T::*method)())
| Resets a learned stateless slot implementation.
template<class T >
WStatelessSlot * | implementStateless (void(T::*method)())
| Declares a slot to be stateless and learn client-side behaviour on first invocation.
template<class T >
WStatelessSlot * | implementStateless (void(T::*method)(), void(T::*undoMethod)())
| Declares a slot to be stateless and learn client-side behaviour in advance.
void | isNotStateless ()
| Marks the current function as not stateless.
template<class T >
WStatelessSlot * | implementJavaScript (void(T::*method)(), const std::string &jsCode)
| Provides a JavaScript implementation for a method.
Public Member Functions inherited from Wt::Core::observable
| observable () noexcept
| Default constructor.
virtual | ~observable ()
| Destructor.
template<typename... Args, typename C >
auto | bindSafe (void(C::*method)(Args...)) noexcept
| Protects a method call against object destruction.
template<typename... Args, typename C >
auto | bindSafe (void(C::*method)(Args...) const) const noexcept
| Protects a const method call against object destruction.
template<typename Function >
auto | bindSafe (const Function &function) noexcept
| Protects a function against object destruction.

## Protected Member Functions
virtual void | initializeGL ()
| Initialize the GL state when the widget is first shown.
virtual void | resizeGL (int width, int height)
| Act on resize events.
virtual void | paintGL ()
| Update the client-side painting function.
virtual void | updateGL ()
| Update state set in initializeGL()
virtual void | render (WFlags< RenderFlag > flags) override
| Renders the widget.
virtual void | layoutSizeChanged (int width, int height) override
| Virtual method that indicates a size change.
Protected Member Functions inherited from Wt::WInteractWidget
virtual void | propagateSetEnabled (bool enabled) override
| Propagates that a widget was enabled or disabled through children.
Protected Member Functions inherited from Wt::WWebWidget
virtual void | enableAjax () override
| Progresses to an Ajax-enabled widget.
virtual WStatelessSlot * | getStateless (Method method) override
| On-demand stateless slot implementation.
Protected Member Functions inherited from Wt::WWidget
void | setLayoutSizeAware (bool sizeAware)
| Sets the widget to be aware of its size set by a layout manager.
| WWidget ()
| Creates a widget.
virtual void | dropEvent (WDropEvent dropEvent)
| Handles a drop event.
virtual int | boxPadding (Orientation orientation) const
| Returns the widget's built-in padding.
virtual int | boxBorder (Orientation orientation) const
| Returns the widget's built-in border width.
void | scheduleRender (WFlags< RepaintFlag > flags=None)
| Schedules rerendering of the widget.
Protected Member Functions inherited from Wt::WObject

## Additional Inherited Members
Static Public Member Functions inherited from Wt::WWebWidget
static std::string | jsStringLiteral (const std::string &v, char delimiter='\'')
| Turn a CharEncoding::UTF8 encoded string into a JavaScript string literal.
Static Public Member Functions inherited from Wt::WWidget
static WString | tr (const char *key)
| Short hand for WString::tr()
Static Public Member Functions inherited from Wt::WObject
Static Public Attributes inherited from Wt::WWidget
Protected Types inherited from Wt::WWebWidget
Protected Types inherited from Wt::WWidget
Protected Attributes inherited from Wt::WInteractWidget
Static Protected Attributes inherited from Wt::WInteractWidget
Static Protected Attributes inherited from Wt::WWidget

## Detailed Description

GL support class.

The WGLWidget class is an interface to the HTML5 WebGL infrastructure for client-side rendering, and OpenGL for server-side rendering. Its API is based on the WebGL API. To fully understand WebGL, it is recommended to read the WebGL standard in addition to this documentation.

The most recent version of the WebGL specification can be found here: http://www.khronos.org/registry/webgl/specs/latest/1.0/

The goal of the WGLWidget class is to provide a method to render 3D structures in the browser, where rendering and rerendering is normally done at the client side in JavaScript without interaction from the server, in order to obtain a smooth user interaction. Unless the scene requires server-side updates, there is no communication with the server.

The rendering interface resembles to OpenGL ES, the same standard as WebGL is based on. This is a stripped down version of the normal OpenGL as we usually find them on desktops. Many stateful OpenGL features are not present in OpenGL ES: no modelview and camera transformation stacks, no default lighting models, no support for other rendering methods than through VBOs, ... Therefore much existing example code for OpenGL applications and shaders will not work on WebGL without modifications. The 'learning webgl' web site at http://learningwebgl.com/ is a good starting point to get familiar with WebGL.

To use a WGLWidget, you must derive from it and reimplement the painter methods. Usually, you will always need to implement initializeGL() and paintGL(). Optionally, you may choose to implement resizeGL() (if your widget does not have a fixed size), and updateGL(). If you need to modify the painting methods, a repaint is triggered by calling the repaintGL() method. The default behaviour for any of these four painting functions is to do nothing.

The four painter methods (initializeGL(), resizeGL(), paintGL() and updateGL()) all record JavaScript which is sent to the browser. The JavaScript code of paintGL() is cached client-side, and may be executed many times, e.g. to repaint a scene from different viewpoints. The JavaScript code of initializeGL(), resizeGL() and updateGL() are intended for OpenGL state updates, and is therefore only executed once on the client and is then discarded.

There are four painting methods that you may implement in a specialization of this class. The purpose of these functions is to register what JavaScript code has to be executed to render a scene. Through invocations of the WebGL functions documented below, Wt records the JavaScript calls that have to be invoked in the browser.

- initializeGL(): this function is executed after the GL context has been initialized. It is also executed when the `webglcontextrestored` signal is fired. You can distinguish between the first initialization and restoration of context using restoringContext(). This is the ideal location to compose shader programs, send VBO's to the client, extract uniform and attribute locations, ... Due to the presence of VBO's, this function may generate a large amount of data to the client.
- resizeGL(): this function is executed whenever the canvas dimensions change. A change in canvas size will require you to invoke the viewport() function again, as well as recalculate the projection matrices (especially when the aspect ratio has changed). The resizeGL() function is therefore the ideal location to set those properties. The resizeGL() function is invoked automatically on every resize, and after the first initializeGL() invocation. Additional invocations may be triggered by calling repaint() with the RESIZE_GL flag.
- paintGL(): this is the main scene drawing function. Through its execution, Wt records what has to be done to render a scene, and it is executed every time that the scene is to be redrawn. You can use the VBO's and shaders prepared in the initializeGL() phase. Usually, this function sets uniforms and attributes, links attributes to VBO's, applies textures, and draws primitives. You may also create local programs, buffers, ... Remember that this function is executed a lot of times, so every buffer/program created in this function should also be destroyed to avoid memory leaks. This function is transmitted once to the client, and is executed when the scene needs to be redrawn. Redraws may be triggered from mouse events, timer triggers, events on e.g. a video element, or whatever other event. The paintGL() function can be updated through invoking repaintGL() with the PAINT_GL flag.
- updateGL(): VBO's, programs, uniforms, GL properties, or anything else set during intializeGL() are not necessarily immutable. If you want to change, add, remove or reconfigure those properties, the execution of an updateGL() function can be triggered by invoking repaintGL() with the UPDATE_GL flag. This signals that updateGL() needs to be evaluated - just once. It is possible that the paintGL() function also requires updates as consequence of the changes in the updateGL() function; in this case, you should also set the PAINT_GL flag of repaintGL().

The GL functions are intended to be used exclusively from within the invocation of the four callback functions mentioned above. In order to manually trigger the execution of these function, use the repaintGL().

A WGLWidget must be given a size explicitly, or must be put inside a layout manager that manages its width and height. The behaviour of a WGLWidget that was not given a size is undefined.

### Binary buffer transfers

In bufferDatafv(), there is an additional boolean argument where you can indicate that you want the data to be transferred to the client in binary form. A WMemoryResource is created for each of these buffers. If you know all previous resources are not required in the client anymore, you can free memory with the method clearBinaryResources() (the memory is also managed, so this is not neccesary). If you want to manage these resources entirely by yourself, the following method can be used.

Using createAndLoadArrayBuffer(), you can load an array buffer in binary format from an URL. This will cause the client to fetch the given URL, and make the contents of the file available in an ArrayBuffer, which can then be used by BufferData() to bind them to an OpenGL buffer. This is ideal to load VBO buffers in a faster way, as it avoids converting floats to text strings on the server and then back to floats on the client. You can combine this with the use of WResource (e.g. WMemoryResource) to send an std::vector of vertices to the client. Note that using ArrayBuffer is not possible when you want a fall-back in the form of server-side rendering.

### Client side matrices and vectors.

The WGLWidget provides the WGLWidget::JavaScriptMatrix4x4 class as a mechanism to use client-side modifiable matrices in the render functions. These matrices can be used identically to the 'constant', with the advantage that there is no need to have a roundtrip to the server to redraw the scene when they are changed. As such, they are ideal for mouse-based camera manipulations, timer triggered animations, or object manipulations.

There's also support for client-side modifiable vectors, with WGLWidget::JavaScriptVector.

## Member Enumeration Documentation

## ◆ GLenum

enum Wt::WGLWidget::GLenum

The enormous GLenum.

This enum contains all numeric constants defined by the WebGL standard, see: http://www.khronos.org/registry/webgl/specs/latest/1.0/#WEBGLRENDERINGCONTEXT

## Constructor & Destructor Documentation

## ◆ WGLWidget()

Wt::WGLWidget::WGLWidget | ( |  | ) |

Construct a GL widget.

Before the first rendering, you must apply a size to the WGLWidget.

## Member Function Documentation

## ◆ activeTexture()

void Wt::WGLWidget::activeTexture | ( | GLenum | texture | ) |

GL function to activate an existing texture.

glActiveTexture() OpenGL ES manpage

## ◆ addJavaScriptMatrix4()

void Wt::WGLWidget::addJavaScriptMatrix4 | ( | JavaScriptMatrix4x4 & | m | ) |

Register a matrix with this WGLWidget.

You can call this outside of resizeGL(), paintGL(), updateGL() or initializeGL() methods. After a JavaScriptMatrix4x4 is added to a WGLWidget, its jsRef() becomes valid, and can be used in a JSlot, for example.

## ◆ addJavaScriptVector()

void Wt::WGLWidget::addJavaScriptVector | ( | JavaScriptVector & | v | ) |

Register a vector with this WGLWidget.

You can call this outside of resizeGL(), paintGL(), updateGL() or initializeGL() methods. After a JavaScriptVector is added to a WGLWidget, its jsRef() becomes valid, and can be used in a JSlot, for example.

## ◆ attachShader()

void Wt::WGLWidget::attachShader | ( | Program | program,
|  | Shader | shader )

GL function to attach a shader to a program.

glAttachShader() OpenGL ES manpage

## ◆ bindAttribLocation()

void Wt::WGLWidget::bindAttribLocation | ( | Program | program,
|  | unsigned | index,
|  | const std::string & | name )

GL function to bind an attribute to a given location.

glBindAttribLocation() OpenGL ES manpage

## ◆ bindBuffer()

void Wt::WGLWidget::bindBuffer | ( | GLenum | target,
|  | Buffer | buffer )

GL function to bind a buffer to a target.

glBindBuffer() OpenGL ES manpage

## ◆ bindFramebuffer()

void Wt::WGLWidget::bindFramebuffer | ( | GLenum | target,
|  | Framebuffer | framebuffer )

GL function to bind a frame buffer to a target.

glBindFramebuffer() OpenGL ES manpage

## ◆ bindRenderbuffer()

void Wt::WGLWidget::bindRenderbuffer | ( | GLenum | target,
|  | Renderbuffer | renderbuffer )

GL function to bind a render buffer to a target.

glBindRenderbuffer() OpenGL ES manpage

## ◆ bindTexture()

void Wt::WGLWidget::bindTexture | ( | GLenum | target,
|  | Texture | texture )

GL function to bind a texture to a target.

glBindTexture() OpenGL ES manpage

## ◆ blendColor()

void Wt::WGLWidget::blendColor | ( | double | red,
|  | double | green,
|  | double | blue,
|  | double | alpha )

GL function to set the blending color.

glBlendColor() OpenGL ES manpage

## ◆ blendEquation()

void Wt::WGLWidget::blendEquation | ( | GLenum | mode | ) |

GL function to set the blending equation.

glBlendEquation() OpenGL ES manpage

## ◆ blendEquationSeparate()

void Wt::WGLWidget::blendEquationSeparate | ( | GLenum | modeRGB,
|  | GLenum | modeAlpha )

GL function that sets separate blending functions for RGB and alpha.

glBlendEquationSeparate() OpenGL ES manpage

## ◆ blendFunc()

void Wt::WGLWidget::blendFunc | ( | GLenum | sfactor,
|  | GLenum | dfactor )

GL function to configure the blending function.

glBlendFunc() OpenGL ES manpage

## ◆ blendFuncSeparate()

void Wt::WGLWidget::blendFuncSeparate | ( | GLenum | srcRGB,
|  | GLenum | dstRGB,
|  | GLenum | srcAlpha,
|  | GLenum | dstAlpha )

GL function that configures the blending function.

glBlendFuncSeparate() OpenGL ES manpage

## ◆ bufferData() [1/3]

void Wt::WGLWidget::bufferData | ( | GLenum | target,
|  | ArrayBuffer | res,
|  | GLenum | usage )

glBufferData - create and initialize a buffer object's data store from an ArrayBuffer

Set the size and contents of the currently bound WebGLBuffer object to be a copy of the given ArrayBuffer.

glBufferData() OpenGL ES manpage

Note: an ArrayBuffer refers to a javascript object, which cannot be used for server-side rendering. If a server-side fallback will be used, then bufferDatafv() should be used with the additional boolean argument to indicate binary transfer of the data in case of client-side rendering.

See also
  createAndLoadArrayBuffer

## ◆ bufferData() [2/3]

void Wt::WGLWidget::bufferData | ( | GLenum | target,
|  | ArrayBuffer | res,
|  | unsigned | arrayBufferOffset,
|  | unsigned | arrayBufferSize,
|  | GLenum | usage )

glBufferData - create and initialize a buffer object's data store from an ArrayBuffer

Set the size of the currently bound WebGLBuffer object to arrayBufferSize, and copy the contents of the ArrayBuffer to the buffer, starting at the given offset.

glBufferData() OpenGL ES manpage

Note: not functional for a server-side fall-back (see bufferData(GLenum target, ArrayBuffer res, GLenum usage) for more info)

See also
  createAndLoadArrayBuffer

## ◆ bufferData() [3/3]

void Wt::WGLWidget::bufferData | ( | GLenum | target,
|  | int | size,
|  | GLenum | usage )

glBufferData - create and initialize a buffer object's data store

Set the size of the currently bound WebGLBuffer object for the passed target. The buffer is initialized to 0.

glBufferData() OpenGL ES manpage

## ◆ bufferDatafv() [1/2]

template<typename Iterator >

void Wt::WGLWidget::bufferDatafv | ( | GLenum | target,
|  | const Iterator | begin,
|  | const Iterator | end,
|  | GLenum | usage,
|  | bool | binary = false )

GL function that loads float or double data in a VBO.

Unlike the C version, we can't accept a void * here. We must be able to interpret the buffer's data in order to transmit it to the JS side.

Later we may also want versions with strides and offsets to cope with more complex buffer layouts that we typically see on desktop WebGL apps; suggestions to improve this are welcome

Note: prefer bufferDatafv(GLenum target, const std::vector<float> &buffer, GLenum usage, bool binary)

glBufferData() OpenGL ES manpage

## ◆ bufferDatafv() [2/2]

void Wt::WGLWidget::bufferDatafv | ( | GLenum | target,
|  | const std::vector< float > & | buffer,
|  | GLenum | usage,
|  | bool | binary = false )

GL function that loads float or double data in a VBO.

glBufferData() OpenGL ES manpage

## ◆ bufferDataiv() [1/2]

template<typename Iterator >

void Wt::WGLWidget::bufferDataiv | ( | GLenum | target,
|  | const Iterator | begin,
|  | const Iterator | end,
|  | GLenum | usage,
|  | GLenum | type )

GL function that loads integer data in a VBO.

Note: prefer bufferDataiv(GLenum target, std::vector<int> &buffer, GLenum usage, GLenum type)

glBufferData() OpenGL ES manpage

## ◆ bufferDataiv() [2/2]

void Wt::WGLWidget::bufferDataiv | ( | GLenum | target,
|  | std::vector< int > & | buffer,
|  | GLenum | usage,
|  | GLenum | type )

GL function that updates an existing VBO with new integer data.

glBufferData() OpenGL ES manpage

## ◆ bufferSubData() [1/2]

void Wt::WGLWidget::bufferSubData | ( | GLenum | target,
|  | unsigned | offset,
|  | ArrayBuffer | res )

Initialize a buffer object's data store from an ArrayBuffer.

Load the data of the currently bound WebGLBuffer object from the given ArrayBuffer. The first byte of the resource data will be written at the given offset of the currently bound buffer.

glBufferSubData() OpenGL ES manpage

Note: not functional for a server-side fall-back (see bufferData(GLenum target, ArrayBuffer res, GLenum usage) for more info)

See also
  createAndLoadArrayBuffer

## ◆ bufferSubData() [2/2]

void Wt::WGLWidget::bufferSubData | ( | GLenum | target,
|  | unsigned | offset,
|  | ArrayBuffer | res,
|  | unsigned | arrayBufferOffset,
|  | unsigned | size )

Initialize a buffer object's data store from an ArrayBuffer.

Load the data of the currently bound WebGLBuffer object from the given ArrayBuffer. The byte at position arrayBufferOffset will be written to the currently bound buffer at position offset.

glBufferSubData() OpenGL ES manpage

Note: not functional for a server-side fall-back (see bufferData(GLenum target, ArrayBuffer res, GLenum usage) for more info)

See also
  createAndLoadArrayBuffer

## ◆ bufferSubDatafv() [1/2]

template<typename Iterator >

void Wt::WGLWidget::bufferSubDatafv | ( | GLenum | target,
|  | unsigned | offset,
|  | const Iterator | begin,
|  | const Iterator | end,
|  | bool | binary = false )

GL function that updates an existing VBO with new float or double data.

Note: prefer bufferSubDatafv(GLenum target, unsigned offset, const std::vector<float> &buffer, bool binary)

glBufferSubData() OpenGL ES manpage

## ◆ bufferSubDatafv() [2/2]

void Wt::WGLWidget::bufferSubDatafv | ( | GLenum | target,
|  | unsigned | offset,
|  | const std::vector< float > & | buffer,
|  | bool | binary = false )

GL function that updates an existing VBO with new float data.

glBufferSubData() OpenGL ES manpage

## ◆ bufferSubDataiv() [1/2]

template<typename Iterator >

void Wt::WGLWidget::bufferSubDataiv | ( | GLenum | target,
|  | unsigned | offset,
|  | const Iterator | begin,
|  | Iterator | end,
|  | GLenum | type )

GL function that updates an existing VBO with new integer data.

Note: prefer void bufferSubDataiv(GLenum target, unsigned offset, std::vector<int> &buffer, GLenum type)

glBufferSubData() OpenGL ES manpage

## ◆ bufferSubDataiv() [2/2]

void Wt::WGLWidget::bufferSubDataiv | ( | GLenum | target,
|  | unsigned | offset,
|  | std::vector< int > & | buffer,
|  | GLenum | type )

GL function that loads integer data in a VBO.

glBufferSubData() OpenGL ES manpage

## ◆ clear()

void Wt::WGLWidget::clear | ( | WFlags< GLenum > | mask | ) |

GL function that clears the given buffers.

glClear() OpenGL ES manpage

## ◆ clearBinaryResources()

void Wt::WGLWidget::clearBinaryResources | ( |  | ) |

remove all binary buffer resources

Removes all WMemoryResources that were allocated when calling bufferDatafv with binary=true. This is not required, since the resources are also managed, but if you are sure they will not be used anymore in the client, this can help free some memory.

## ◆ clearColor()

void Wt::WGLWidget::clearColor | ( | double | r,
|  | double | g,
|  | double | b,
|  | double | a )

GL function that sets the clear color of the color buffer.

glClearColor() OpenGL ES manpage

## ◆ clearDepth()

void Wt::WGLWidget::clearDepth | ( | double | depth | ) |

GL function that configures the depth to be set when the depth buffer is cleared.

glClearDepthf() OpenGL ES manpage

## ◆ clearStencil()

void Wt::WGLWidget::clearStencil | ( | int | s | ) |

GL function.

glClearStencil() OpenGL ES manpage

## ◆ colorMask()

void Wt::WGLWidget::colorMask | ( | bool | red,
|  | bool | green,
|  | bool | blue,
|  | bool | alpha )

GL function.

glColorMask() OpenGL ES manpage

## ◆ compileShader()

void Wt::WGLWidget::compileShader | ( | Shader | shader | ) |

GL function to compile a shader.

glCompileShader() OpenGL ES manpage

## ◆ copyTexImage2D()

void Wt::WGLWidget::copyTexImage2D | ( | GLenum | target,
|  | int | level,
|  | GLenum | internalformat,
|  | int | x,
|  | int | y,
|  | unsigned | width,
|  | unsigned | height,
|  | int | border )

GL function to copy a texture image.

glCopyTexImage2D() OpenGL ES manpage

## ◆ copyTexSubImage2D()

void Wt::WGLWidget::copyTexSubImage2D | ( | GLenum | target,
|  | int | level,
|  | int | xoffset,
|  | int | yoffset,
|  | int | x,
|  | int | y,
|  | unsigned | width,
|  | unsigned | height )

GL function that copies a part of a texture image.

glCopyTexSubImage2D() OpenGL ES manpage

## ◆ createBuffer()

Buffer Wt::WGLWidget::createBuffer | ( |  | ) |

GL function that creates an empty VBO.

glGenBuffers() OpenGL ES manpage

## ◆ createFramebuffer()

Framebuffer Wt::WGLWidget::createFramebuffer | ( |  | ) |

GL function that creates a frame buffer object.

glGenFramebuffers() OpenGL ES manpage

## ◆ createJavaScriptMatrix4()

JavaScriptMatrix4x4 Wt::WGLWidget::createJavaScriptMatrix4 | ( |  | ) |

Create a matrix that can be manipulated in client-side JavaScript.

This is a shorthand for creating a JavaScriptMatrix4x4, then adding it to a WGLWidget with addJavaScriptMatrix4, and initializing it with initJavaScriptMatrix4.

This method should only be called in initializeGL(), updateGL() or resizeGL().

## ◆ createJavaScriptVector()

JavaScriptVector Wt::WGLWidget::createJavaScriptVector | ( | unsigned | length | ) |

Create a vector of a certain length that can be manipulated in client-side JavaScript.

This is a shorthand for creating a JavaScriptVector, then adding it to a WGLWidget with addJavaScriptVector, and initializing it with initJavaScriptVector.

This method should only be called in initializeGL(), updateGL() or resizeGL().

## ◆ createPaintDevice()

std::unique_ptr< WPaintDevice > Wt::WGLWidget::createPaintDevice | ( | const WLength & | width,
|  | const WLength & | height )

returns an paintdevice that can be used to paint a GL texture

If the client has a webGL enabled browser this function returns a WCanvasPaintDevice.

If server-side rendering is used as fallback then this function returns a WRasterImage.

## ◆ createProgram()

Program Wt::WGLWidget::createProgram | ( |  | ) |

GL function that creates an empty program.

glCreateProgram() OpenGL ES manpage

## ◆ createRenderbuffer()

Renderbuffer Wt::WGLWidget::createRenderbuffer | ( |  | ) |

GL function that creates a render buffer object.

glGenRenderbuffers() OpenGL ES manpage

## ◆ createShader()

Shader Wt::WGLWidget::createShader | ( | GLenum | shader | ) |

GL function that creates an empty shader.

glCreateShader() OpenGL ES manpage

## ◆ createTexture()

Texture Wt::WGLWidget::createTexture | ( |  | ) |

GL function that creates an empty texture.

glGenTextures() OpenGL ES manpage

## ◆ createTextureAndLoad()

Texture Wt::WGLWidget::createTextureAndLoad | ( | const std::string & | url | ) |

GL function that creates an image texture.

glGenTextures() OpenGL ES manpage

## ◆ cullFace()

void Wt::WGLWidget::cullFace | ( | GLenum | mode | ) |

GL function that configures the backface culling mode.

glCullFace() OpenGL ES manpage

## ◆ deleteBuffer()

void Wt::WGLWidget::deleteBuffer | ( | Buffer | buffer | ) |

GL function that deletes a VBO.

glDeleteBuffers() OpenGL ES manpage

## ◆ deleteFramebuffer()

void Wt::WGLWidget::deleteFramebuffer | ( | Framebuffer | framebuffer | ) |

GL function that deletes a frame buffer.

glDeleteFramebuffers() OpenGL ES manpage

## ◆ deleteProgram()

void Wt::WGLWidget::deleteProgram | ( | Program | program | ) |

GL function that deletes a program.

glDeleteProgram() OpenGL ES manpage

## ◆ deleteRenderbuffer()

void Wt::WGLWidget::deleteRenderbuffer | ( | Renderbuffer | renderbuffer | ) |

GL function that deletes a render buffer.

glDeleteRenderbuffers() OpenGL ES manpage

## ◆ deleteShader()

void Wt::WGLWidget::deleteShader | ( | Shader | shader | ) |

GL function that depetes a shader.

glDeleteShader() OpenGL ES manpage

## ◆ deleteTexture()

void Wt::WGLWidget::deleteTexture | ( | Texture | texture | ) |

GL function that deletes a texture.

glDeleteTextures() OpenGL ES manpage

## ◆ depthFunc()

void Wt::WGLWidget::depthFunc | ( | GLenum | func | ) |

GL function to set the depth test function.

glDepthFunc() OpenGL ES manpage

## ◆ depthMask()

void Wt::WGLWidget::depthMask | ( | bool | flag | ) |

GL function that enables or disables writing to the depth buffer.

glDepthMask() OpenGL ES manpage

## ◆ depthRange()

void Wt::WGLWidget::depthRange | ( | double | zNear,
|  | double | zFar )

GL function that specifies to what range the normalized [-1,1] z values should match.

glDepthRangef() OpenGL ES manpage

## ◆ detachShader()

void Wt::WGLWidget::detachShader | ( | Program | program,
|  | Shader | shader )

GL function that detaches a shader from a program.

glDetachShader() OpenGL ES manpage

## ◆ disable()

void Wt::WGLWidget::disable | ( | GLenum | cap | ) |

GL function to disable features.

glDisable() OpenGL ES manpage

## ◆ disableVertexAttribArray()

void Wt::WGLWidget::disableVertexAttribArray | ( | AttribLocation | index | ) |

GL function to disable the vertex attribute array.

glDisableVertexAttribArray() OpenGL ES manpage

## ◆ drawArrays()

void Wt::WGLWidget::drawArrays | ( | GLenum | mode,
|  | int | first,
|  | unsigned | count )

GL function to draw a VBO.

glDrawArrays() OpenGL ES manpage

## ◆ drawElements()

void Wt::WGLWidget::drawElements | ( | GLenum | mode,
|  | unsigned | count,
|  | GLenum | type,
|  | unsigned | offset )

GL function to draw indexed VBOs.

glDrawElements() OpenGL ES manpage

## ◆ enable()

void Wt::WGLWidget::enable | ( | GLenum | cap | ) |

GL function to enable features.

glEnable() OpenGL ES manpage

## ◆ enableClientErrorChecks()

void Wt::WGLWidget::enableClientErrorChecks | ( | bool | enable = true | ) |

enable client-side error messages (read detailed doc!)

This option will add client-side code to check the result of every WebGL call, and will popup an error dialog if a WebGL call returned an error. The JavaScript then invokes the client-side debugger. This code is intended to test your application, and should not be used in production.

## ◆ enableVertexAttribArray()

void Wt::WGLWidget::enableVertexAttribArray | ( | AttribLocation | index | ) |

GL function to enable the vertex attribute array.

glEnableVertexAttribArray() OpenGL ES manpage

## ◆ finish()

void Wt::WGLWidget::finish | ( |  | ) |

GL function to wait until given commands are executed.

This call is transfered to JS, but the server will never wait on this call.

glFinish() OpenGL ES manpage

## ◆ flush()

void Wt::WGLWidget::flush | ( |  | ) |

GL function to force execution of GL commands in finite time.

glFlush() OpenGL ES manpage

## ◆ framebufferRenderbuffer()

void Wt::WGLWidget::framebufferRenderbuffer | ( | GLenum | target,
|  | GLenum | attachment,
|  | GLenum | renderbuffertarget,
|  | Renderbuffer | renderbuffer )

GL function to attach the given renderbuffer to the currently bound frame buffer.

glFramebufferRenderbuffer() OpenGL ES manpage

## ◆ framebufferTexture2D()

void Wt::WGLWidget::framebufferTexture2D | ( | GLenum | target,
|  | GLenum | attachment,
|  | GLenum | textarget,
|  | Texture | texture,
|  | int | level )

GL function to render directly into a texture image.

glFramebufferTexture2D() OpenGL ES manpage

## ◆ frontFace()

void Wt::WGLWidget::frontFace | ( | GLenum | mode | ) |

GL function that specifies which side of a triangle is the front side.

glFrontFace() OpenGL ES manpage

## ◆ generateMipmap()

void Wt::WGLWidget::generateMipmap | ( | GLenum | target | ) |

GL function that generates a set of mipmaps for a texture object.

glGenerateMipmap() OpenGL ES manpage

## ◆ getAttribLocation()

AttribLocation Wt::WGLWidget::getAttribLocation | ( | Program | program,
|  | const std::string & | attrib )

GL function to retrieve an attribute's location in a Program.

glGetAttribLocation() OpenGL ES manpage

## ◆ getUniformLocation()

UniformLocation Wt::WGLWidget::getUniformLocation | ( | Program | program,
|  | const std::string & | location )

GL function to retrieve a Uniform's location in a Program.

glGetUniformLocation() OpenGL ES manpage

## ◆ hint()

void Wt::WGLWidget::hint | ( | GLenum | target,
|  | GLenum | mode )

GL function to give hints to the render pipeline.

glHint() OpenGL ES manpage

## ◆ initializeGL()

virtual void Wt::WGLWidget::initializeGL | ( |  | ) |
| protectedvirtual

Initialize the GL state when the widget is first shown.

initializeGL() is called when the widget is first rendered, and when the webglcontextrestored signal is fired. You can distinguish between the first initialization and context restoration using restoringContext(). It usually creates most of the GL related state: shaders, VBOs, uniform locations, ...

If this state is to be updated during the lifetime of the widget, you should specialize the updateGL() to accomodate for this.

Reimplemented in Wt::Chart::WCartesian3DChart.

## ◆ initJavaScriptMatrix4()

void Wt::WGLWidget::initJavaScriptMatrix4 | ( | JavaScriptMatrix4x4 & | m | ) |

Initialize the client-side JavaScript for the given JavaScriptMatrix4x4.

If the given matrix is not associated with a widget yet, it will be added to this widget.

If the given matrix has already been added to a WGLWidget, then this WGLWidget should be the same as the one you call initJavaScriptMatrix4 on.

This method should only be called in initializeGL(), updateGL() or resizeGL().

## ◆ initJavaScriptVector()

void Wt::WGLWidget::initJavaScriptVector | ( | JavaScriptVector & | v | ) |

Initialize the client-side JavaScript for the given JavaScriptVector.

If the given vector is not associated with a widget yet, it will be added to this widget.

If the given vector has already been added to a WGLWidget, then this WGLWidget should be the same as the one you call initJavaScriptVector on.

This method should only be called in initializeGL(), updateGL() or resizeGL().

## ◆ injectJS()

void Wt::WGLWidget::injectJS | ( | const std::string & | jsString | ) |

Inject JavaScript into the current js-stream.

Careful: this method directly puts the given jsString into the JavaScript stream, whatever state it current has. For example, if called in initGL(), it will put the jsString into the client-side initGL() code.

## ◆ layoutSizeChanged()

virtual void Wt::WGLWidget::layoutSizeChanged | ( | int | width,
|  | int | height )
| overrideprotectedvirtual

Virtual method that indicates a size change.

This method propagates the client-side width and height of the widget when the widget is contained by a layout manager and setLayoutSizeAware(true) was called.

See also
  setLayoutSizeAware()

Reimplemented from Wt::WWidget.

## ◆ lineWidth()

void Wt::WGLWidget::lineWidth | ( | double | width | ) |

GL function to set the line width.

glLineWidth() OpenGL ES manpage

## ◆ linkProgram()

void Wt::WGLWidget::linkProgram | ( | Program | program | ) |

GL function to link a program.

glLinkProgram() OpenGL ES manpage

## ◆ paintGL()

virtual void Wt::WGLWidget::paintGL | ( |  | ) |
| protectedvirtual

Update the client-side painting function.

This method is invoked client-side when a repaint is required, i.e. when the repaintSlot() (a JavaScript-side JSlot) is triggered. Typical examples are: after mouse-based camera movements, after a timed update of a camera or an object's position, after a resize event (resizeGL() will also be called then), after an animation event, ... In many cases, this function will be executed client-side many many times.

Using the GL functions from this class, you construct a scene. The implementation tracks all JavaScript calls that need to be performed to draw the scenes, and will replay them verbatim on every trigger of the repaintSlot(). There are a few mechanisms that may be employed to change what is rendered without updating the paintGL() cache:

- Client-side matrices may be used to change camera viewpoints, manipilate separate object's model transformation matrices, ...
- Shader sources can be updated without requiring the paint function to be renewed

Updating the paintGL() cache is usually not too expensive; the VBOs, which are large in many cases, are already at the client side, while the paintGL() code only draws the VBOs. Of course, if you have to draw many separate objects, the paintGL() JS code may become large and updating is more expensive.

In order to update the paintGL() cache, call repaintGL() with the PAINT_GL parameter, which will cause the invocation of this method.

Reimplemented in Wt::Chart::WCartesian3DChart.

## ◆ pixelStorei()

void Wt::WGLWidget::pixelStorei | ( | GLenum | pname,
|  | int | param )

GL function to set the pixel storage mode.

glPixelStorei() OpenGL ES manpage

## ◆ polygonOffset()

void Wt::WGLWidget::polygonOffset | ( | double | factor,
|  | double | units )

GL function to apply modifications to Z values.

glPolygonOffset() OpenGL ES manpage

## ◆ render()

virtual void Wt::WGLWidget::render | ( | WFlags< RenderFlag > | flags | ) |
| overrideprotectedvirtual

Renders the widget.

This function renders the widget (or an update for the widget), after this has been scheduled using scheduleRender().

The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.

Reimplemented from Wt::WWebWidget.

## ◆ renderbufferStorage()

void Wt::WGLWidget::renderbufferStorage | ( | GLenum | target,
|  | GLenum | internalformat,
|  | unsigned | width,
|  | unsigned | height )

GL function to allocate the appropriate amount of memory for a render buffer.

glSampleCoverage() OpenGL ES manpage

## ◆ repaintGL()

void Wt::WGLWidget::repaintGL | ( | WFlags< GLClientSideRenderer > | which | ) |

Request invocation of resizeGL, paintGL and/or updateGL.

If invoked with PAINT_GL, the client-side cached paint function is updated. If invoked with RESIZE_GL or UPDATE_GL, the code will be executed once.

If invoked with multiple flags set, the order of execution will be updateGL(), resizeGL(), paintGL().

## ◆ repaintSlot()

JSlot & Wt::WGLWidget::repaintSlot | ( |  | ) |

A JavaScript slot that repaints the widget when triggered.

This is useful for client-side initiated repaints. You may e.g. use this if you write your own client-side mouse handler, or if you updated a texture, or if you're playing a video texture.

## ◆ resize()

void Wt::WGLWidget::resize | ( | const WLength & | width,
|  | const WLength & | height )
| overridevirtual

Resizes the widget.

Specifies a fixed size for this widget, setting CSS `width` and `height` properties. By default a widget has automatic width and height, which sets a size for the widget following CSS rules.

When the widget is not managed by a layout manager, the automatic (natural) size of a widget depends on whether they widget is a block or inline widget:

- a block widget takes by default the width of the parent, and the height that it needs based on its contents
- an inline widget takes the width and height that it needs based on its contents (possibly wrapping over multiple lines). The width and height of an inline widget cannot be changed (by the letter of CSS, although most browsers will react to it in varying ways).

When inserted in a layout manager, the size set will be used as a widget's preferred size, but the widget may be given a different size by the layout manager based on available space and stretch factors. The actual size given by a layout manager may be retrieved by making the widget "layout size aware", using setLayoutSizeAware(). If you have defined a `"wtResize()"` JavaScript method for the widget, then this method will also be called.

The default width and height of a widget is WLength::Auto.

See also
  width(), height()

Reimplemented from Wt::WWebWidget.

## ◆ resizeGL()

virtual void Wt::WGLWidget::resizeGL | ( | int | width,
|  | int | height )
| protectedvirtual

Act on resize events.

Usually, this method only contains functions to set the viewport and the projection matrix (as this is aspect ration dependent).

resizeGL() is rendered after initializeGL, and whenever widget is resized. After this method finishes, the widget is repainted with the cached client-side paint function.

Reimplemented in Wt::Chart::WCartesian3DChart.

## ◆ restoringContext()

bool Wt::WGLWidget::restoringContext | ( |  | ) | const

Returns whether a lost context is in the process of being restored.

You can check for this in initializeGL(), to handle the first initialization and restoration of context differently.

## ◆ sampleCoverage()

void Wt::WGLWidget::sampleCoverage | ( | double | value,
|  | bool | invert )

GL function to set multisample parameters.

glSampleCoverage() OpenGL ES manpage

## ◆ scissor()

void Wt::WGLWidget::scissor | ( | int | x,
|  | int | y,
|  | unsigned | width,
|  | unsigned | height )

GL function to define the scissor box.

glScissor() OpenGL ES manpage

## ◆ setAlternativeContent()

void Wt::WGLWidget::setAlternativeContent | ( | std::unique_ptr< WWidget > | alternative | ) |

Sets the content to be displayed when WebGL is not available.

If Wt cannot create a working WebGL context, this content will be shown to the user. This may be a text explanation, or a pre-rendered image, or a video, a flash movie, ...

The default is a widget that explains to the user that he has no WebGL support.

## ◆ setClientSideLookAtHandler()

void Wt::WGLWidget::setClientSideLookAtHandler | ( | const JavaScriptMatrix4x4 & | m,
|  | double | lX,
|  | double | lY,
|  | double | lZ,
|  | double | uX,
|  | double | uY,
|  | double | uZ,
|  | double | pitchRate,
|  | double | yawRate )

Add a mouse handler to the widget that looks at a given point.

This will allow a user to change client-side matrix m with the mouse. M is a model transformation matrix, representing the viewpoint of the camera.

Through mouse operations, the camera can be changed by the user, but (lX, lY, lZ) will always be at the center of the display, (uX, uY, uZ) is considered to be the up direction, and the distance of the camera to (lX, lY, lZ) will never change.

Pressing the left mouse button and moving the mouse left/right will rotate the camera around the up (uX, uY, uZ) direction. Moving up/down will tilt the camera (causing it to move up/down to keep the lookpoint centered). The scroll wheel simulates zooming by scaling the scene.

pitchRate and yawRate control how much the camera will move per mouse pixel.

Usually this method is called after setting a camera transformation with a client-side matrix in initializeGL(). However, this function may also be called from outside the intializeGL()/paintGL()/updateGL() methods (but not before m was initialized).

## ◆ setClientSideMouseHandler()

void Wt::WGLWidget::setClientSideMouseHandler | ( | const std::string & | handlerCode | ) |

Set a custom mouse handler based on the given JavaScript code.

The handler code should be JavaScript code that produces an object when evaluated.

A mouse handler is an object that can implement one or more of the following functions:

- setTarget(target): This is called immediately when the mouse handler is added with an object that uniquely identifies the WGLWidget, and a paintGL() method.
- mouseDown(o, event): To handle the `mousedown` event. `o` is the `<canvas>` (client-side rendering) or `<img>` (server-side rendering) element corresponding to this WGLWidget. `event` is the `MouseEvent`.
- mouseUp(o, event): To handle the `mouseup` event. `o` is the `<canvas>` (client-side rendering) or `<img>` (server-side rendering) element corresponding to this WGLWidget. `event` is the `MouseEvent`.
- mouseDrag(o, event): Called when the mouse is dragged. `o` is the `<canvas>` (client-side rendering) or `<img>` (server-side rendering) element corresponding to this WGLWidget. `event` is the `MouseEvent`.
- mouseMove(o, event): Called when the mouse is moved. `o` is the `<canvas>` (client-side rendering) or `<img>` (server-side rendering) element corresponding to this WGLWidget. `event` is the `MouseEvent`.
- mouseWheel(o, event): Called when the mouse wheel is used. `o` is the `<canvas>` (client-side rendering) or `<img>` (server-side rendering) element corresponding to this WGLWidget. `event` is the `MouseEvent`.
- touchStart(o, event): To handle the `touchstart` event. `o` is the `<canvas>` (client-side rendering) or `<img>` (server-side rendering) element corresponding to this WGLWidget. `event` is the `TouchEvent`.
- touchEnd(o, event): To handle the `touchend` event. `o` is this `<canvas>` (client-side rendering) or `<img>` (server-side rendering) element corresponding to this WGLWidget. `event` is the `TouchEvent`.
- touchMoved(o, event): To handle the `touchmove` event. `o` is this `<canvas>` (client-side rendering) or `<img>` (server-side rendering) element corresponding to this WGLWidget. `event` is the `TouchEvent`.

For example, if we wanted to scale some object when we scroll, we could create a JavaScriptMatrix4x4 called `transform_:`

private:
JavaScriptMatrix4x4 transform_;
Wt::WGLWidget::JavaScriptMatrix4x4
A client-side JavaScript matrix.
Definition WGLWidget.h:501

We can add this in the constructor:

addJavaScriptMatrix4(transform_);
Wt::WGLWidget::addJavaScriptMatrix4
void addJavaScriptMatrix4(JavaScriptMatrix4x4 &m)
Register a matrix with this WGLWidget.

Then, in initializeGL(), we can initialize it and set the value:

initJavaScriptMatrix4(transform_);
setJavaScriptMatrix4(transform_, WMatrix4x4()); // Set to identity matrix
Wt::WGLWidget::setJavaScriptMatrix4
void setJavaScriptMatrix4(JavaScriptMatrix4x4 &jsm, const WGenericMatrix< MatrixType, 4, 4 > &m)
Set the value of a client-side JavaScript matrix created by createJavaScriptMatrix4x4()
Definition WGLWidget.h:2707
Wt::WGLWidget::initJavaScriptMatrix4
void initJavaScriptMatrix4(JavaScriptMatrix4x4 &m)
Initialize the client-side JavaScript for the given JavaScriptMatrix4x4.
Wt::WMatrix4x4
A value class that describes a 3D affine transformation matrix.
Definition WMatrix4x4.h:61

Then, still in initializeGL(), we can set a mouse handler as such:

setClientSideMouseHandler(std::string("(function(){") +
"var MouseHandler = function(transform) {"
"var target = null;"
"this.setTarget = function(newTarget) {"
"target = newTarget;"
"};"
"this.mouseWheel = function(o, event) {"
"var fix = jQuery.event.fix(event);"
"fix.preventDefault();"
"fix.stopPropagation();"
"var d = wheelDelta(event);"
"var s = Math.pow(1.2, d);"
"transform[0] *= s;" // Scale X
"transform[5] *= s;" // Scale Y
"transform[10] *= s;" // Scale Z
"target.paintGL();" // Repaint
"};"
"function wheelDelta(e) {"
"var delta = 0;"
"if (e.wheelDelta) {"
"delta = e.wheelDelta > 0 ? 1 : -1;"
"} else if (e.detail) {"
"delta = e.detail < 0 ? 1 : -1;"
"}"
"return delta;"
"}"
"};"
"return new MouseHandler(" + transform_.jsRef() + ");"
"})()");
Wt::WGLWidget::JavaScriptMatrix4x4::jsRef
std::string jsRef() const
Returns the JavaScript reference to this JavaScriptMatrix4x4.
Definition WGLWidget.h:533
Wt::WGLWidget::setClientSideMouseHandler
void setClientSideMouseHandler(const std::string &handlerCode)
Set a custom mouse handler based on the given JavaScript code.

All that's left to do then is to use this transform somewhere as a uniform variable, see getUniformLocation() and uniformMatrix4().

## ◆ setClientSideWalkHandler()

void Wt::WGLWidget::setClientSideWalkHandler | ( | const JavaScriptMatrix4x4 & | m,
|  | double | frontStep,
|  | double | rotStep )

Add a mouse handler to the widget that allows 'walking' in the scene.

This will allow a user to change client-side matrix m with the mouse. M is a model transformation matrix, representing the viewpoint of the camera.

Through mouse operations, the camera can be changed by the user, as if he is walking around on a plane.

Pressing the left mouse button and moving the mouse left/right will rotate the camera around Y axis. Moving the mouse up/down will move the camera in the Z direction (walking forward/backward). centered).

frontStep and rotStep control how much the camera will move per mouse pixel.

## ◆ setJavaScriptMatrix4()

template<typename MatrixType >

void Wt::WGLWidget::setJavaScriptMatrix4 | ( | JavaScriptMatrix4x4 & | jsm,
|  | const WGenericMatrix< MatrixType, 4, 4 > & | m )

Set the value of a client-side JavaScript matrix created by createJavaScriptMatrix4x4()

This method should only be called in initializeGL(), updateGL() or resizeGL().

## ◆ setJavaScriptVector()

void Wt::WGLWidget::setJavaScriptVector | ( | JavaScriptVector & | jsv,
|  | const std::vector< float > & | v )

Set the value of a client-side JavaScript vector created by createJavaScriptVector()

This method should only be called in initializeGL(), updateGL() or resizeGL().

## ◆ setRenderOptions()

void Wt::WGLWidget::setRenderOptions | ( | WFlags< GLRenderOption > | options | ) |

Sets the rendering option.

Use this method to configure whether client-side and/or server-side rendering can be used, and whether anti-aliasing should be enabled. The actual choice is also based on availability (respectively client-side or server-side).

The default value is to try both ClientSide or ServerSide rendering, and to enable anti-aliasing if available.

Note
  Options must be set before the widget is being rendered.

## ◆ shaderSource()

void Wt::WGLWidget::shaderSource | ( | Shader | shader,
|  | const std::string & | src )

GL function to set a shader's source code.

glShaderSource() OpenGL ES manpage

## ◆ stencilFunc()

void Wt::WGLWidget::stencilFunc | ( | GLenum | func,
|  | int | ref,
|  | unsigned | mask )

GL function to set stencil test parameters.

glStencilFunc() OpenGL ES manpage

## ◆ stencilFuncSeparate()

void Wt::WGLWidget::stencilFuncSeparate | ( | GLenum | face,
|  | GLenum | func,
|  | int | ref,
|  | unsigned | mask )

GL function to set stencil test parameters for front and/or back stencils.

glStencilFuncSeparate() OpenGL ES manpage

## ◆ stencilMask()

void Wt::WGLWidget::stencilMask | ( | unsigned | mask | ) |

GL function to control which bits are to be written in the stencil buffer.

glStencilMask() OpenGL ES manpage

## ◆ stencilMaskSeparate()

void Wt::WGLWidget::stencilMaskSeparate | ( | GLenum | face,
|  | unsigned | mask )

GL function to control which bits are written to the front and/or back stencil buffers.

glStencilMaskSeparate() OpenGL ES manpage

## ◆ stencilOp()

void Wt::WGLWidget::stencilOp | ( | GLenum | fail,
|  | GLenum | zfail,
|  | GLenum | zpass )

GL function to set stencil test actions.

glStencilOp() OpenGL ES manpage

## ◆ stencilOpSeparate()

void Wt::WGLWidget::stencilOpSeparate | ( | GLenum | face,
|  | GLenum | fail,
|  | GLenum | zfail,
|  | GLenum | zpass )

GL function to set front and/or back stencil test actions separately.

glStencilOpSeparate() OpenGL ES manpage

## ◆ texImage2D() [1/6]

void Wt::WGLWidget::texImage2D | ( | GLenum | target,
|  | int | level,
|  | GLenum | internalformat,
|  | GLenum | format,
|  | GLenum | type,
|  | std::string | filename )

GL function to load a 2D texture from a file.

glTexImage2D() OpenGL ES manpage

## ◆ texImage2D() [2/6]

void Wt::WGLWidget::texImage2D | ( | GLenum | target,
|  | int | level,
|  | GLenum | internalformat,
|  | GLenum | format,
|  | GLenum | type,
|  | Texture | texture )

GL function to load a 2D texture loaded with createTextureAndLoad()

This function must only be used for textures created with createTextureAndLoad()

Note: the WGLWidget implementation will delay rendering until all textures created with createTextureAndLoad() are loaded in the browser.

glTexImage2D() OpenGL ES manpage

## ◆ texImage2D() [3/6]

void Wt::WGLWidget::texImage2D | ( | GLenum | target,
|  | int | level,
|  | GLenum | internalformat,
|  | GLenum | format,
|  | GLenum | type,
|  | WImage * | image )

GL function to load a 2D texture from a WImage.

Note: WImage must be loaded before this function is executed.

glTexImage2D() OpenGL ES manpage

## ◆ texImage2D() [4/6]

void Wt::WGLWidget::texImage2D | ( | GLenum | target,
|  | int | level,
|  | GLenum | internalformat,
|  | GLenum | format,
|  | GLenum | type,
|  | WPaintDevice * | paintdevice )

GL function to load a 2D texture from a WPaintDevice.

glTexImage2D() OpenGL ES manpage

See also
  createPaintDevice()

## ◆ texImage2D() [5/6]

void Wt::WGLWidget::texImage2D | ( | GLenum | target,
|  | int | level,
|  | GLenum | internalformat,
|  | GLenum | format,
|  | GLenum | type,
|  | WVideo * | video )

GL function to load a 2D texture from a WVideo.

Note: the video must be loaded prior to calling this function. The current frame is used as texture image.

glTexImage2D() OpenGL ES manpage

## ◆ texImage2D() [6/6]

void Wt::WGLWidget::texImage2D | ( | GLenum | target,
|  | int | level,
|  | GLenum | internalformat,
|  | unsigned | width,
|  | unsigned | height,
|  | int | border,
|  | GLenum | format )

GL function to reserve space for a 2D texture, without specifying its contents.

This corresponds to calling the WebGL function void texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView pixels) with null as last parameters. The value of 'type' is then of no importance and is therefore omitted from this function.

glTexImage2D() OpenGL ES manpage

## ◆ texParameteri()

void Wt::WGLWidget::texParameteri | ( | GLenum | target,
|  | GLenum | pname,
|  | GLenum | param )

GL function to set texture parameters.

glTexParameter() OpenGL ES manpage

## ◆ uniform1f()

void Wt::WGLWidget::uniform1f | ( | const UniformLocation & | location,
|  | double | x )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform1fv() [1/2]

template<typename FloatArray >

void Wt::WGLWidget::uniform1fv | ( | const UniformLocation & | location,
|  | const FloatArray * | value )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform1fv() [2/2]

void Wt::WGLWidget::uniform1fv | ( | const UniformLocation & | location,
|  | const JavaScriptVector & | v )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform1i()

void Wt::WGLWidget::uniform1i | ( | const UniformLocation & | location,
|  | int | x )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform1iv()

template<typename IntArray >

void Wt::WGLWidget::uniform1iv | ( | const UniformLocation & | location,
|  | const IntArray * | value )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform2f()

void Wt::WGLWidget::uniform2f | ( | const UniformLocation & | location,
|  | double | x,
|  | double | y )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform2fv() [1/2]

template<typename FloatArray >

void Wt::WGLWidget::uniform2fv | ( | const UniformLocation & | location,
|  | const FloatArray * | value )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform2fv() [2/2]

void Wt::WGLWidget::uniform2fv | ( | const UniformLocation & | location,
|  | const JavaScriptVector & | v )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform2i()

void Wt::WGLWidget::uniform2i | ( | const UniformLocation & | location,
|  | int | x,
|  | int | y )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform2iv()

template<typename IntArray >

void Wt::WGLWidget::uniform2iv | ( | const UniformLocation & | location,
|  | const IntArray * | value )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform3f()

void Wt::WGLWidget::uniform3f | ( | const UniformLocation & | location,
|  | double | x,
|  | double | y,
|  | double | z )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform3fv() [1/2]

template<typename FloatArray >

void Wt::WGLWidget::uniform3fv | ( | const UniformLocation & | location,
|  | const FloatArray * | value )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform3fv() [2/2]

void Wt::WGLWidget::uniform3fv | ( | const UniformLocation & | location,
|  | const JavaScriptVector & | v )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform3i()

void Wt::WGLWidget::uniform3i | ( | const UniformLocation & | location,
|  | int | x,
|  | int | y,
|  | int | z )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform3iv()

template<typename IntArray >

void Wt::WGLWidget::uniform3iv | ( | const UniformLocation & | location,
|  | const IntArray * | value )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform4f()

void Wt::WGLWidget::uniform4f | ( | const UniformLocation & | location,
|  | double | x,
|  | double | y,
|  | double | z,
|  | double | w )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform4fv() [1/2]

template<typename FloatArray >

void Wt::WGLWidget::uniform4fv | ( | const UniformLocation & | location,
|  | const FloatArray * | value )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform4fv() [2/2]

void Wt::WGLWidget::uniform4fv | ( | const UniformLocation & | location,
|  | const JavaScriptVector & | v )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform4i()

void Wt::WGLWidget::uniform4i | ( | const UniformLocation & | location,
|  | int | x,
|  | int | y,
|  | int | z,
|  | int | w )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniform4iv()

template<typename IntArray >

void Wt::WGLWidget::uniform4iv | ( | const UniformLocation & | location,
|  | const IntArray * | value )

GL function to set the value of a uniform variable of the current program.

glUniform() OpenGL ES manpage

## ◆ uniformMatrix2()

template<typename MatrixType >

void Wt::WGLWidget::uniformMatrix2 | ( | const UniformLocation & | location,
|  | const WGenericMatrix< MatrixType, 2, 2 > & | m )

GL function to set the value of a uniform matrix of the current program.

This function renders the matrix in the proper row/column order.

glUniform() OpenGL ES manpage

## ◆ uniformMatrix2fv()

template<typename MatrixType >

void Wt::WGLWidget::uniformMatrix2fv | ( | const UniformLocation & | location,
|  | bool | transpose,
|  | const MatrixType * | value )

GL function to set the value of a uniform matrix of the current program.

Attention: The OpenGL ES specification states that transpose MUST be false.

glUniform() OpenGL ES manpage

## ◆ uniformMatrix3()

template<typename MatrixType >

void Wt::WGLWidget::uniformMatrix3 | ( | const UniformLocation & | location,
|  | const WGenericMatrix< MatrixType, 3, 3 > & | m )

GL function to set the value of a uniform matrix of the current program.

This function renders the matrix in the proper row/column order.

glUniform() OpenGL ES manpage

## ◆ uniformMatrix3fv()

template<typename MatrixType >

void Wt::WGLWidget::uniformMatrix3fv | ( | const UniformLocation & | location,
|  | bool | transpose,
|  | const MatrixType * | value )

GL function to set the value of a uniform matrix of the current program.

Attention: The OpenGL ES specification states that transpose MUST be false.

glUniform() OpenGL ES manpage

## ◆ uniformMatrix4() [1/2]

void Wt::WGLWidget::uniformMatrix4 | ( | const UniformLocation & | location,
|  | const JavaScriptMatrix4x4 & | m )

GL function to set the value of a uniform matrix of the current program.

glUniform() OpenGL ES manpage

## ◆ uniformMatrix4() [2/2]

template<typename MatrixType >

void Wt::WGLWidget::uniformMatrix4 | ( | const UniformLocation & | location,
|  | const WGenericMatrix< MatrixType, 4, 4 > & | m )

GL function to set the value of a uniform matrix of the current program.

This function renders the matrix in the proper row/column order.

glUniform() OpenGL ES manpage

## ◆ uniformMatrix4fv()

template<typename MatrixType >

void Wt::WGLWidget::uniformMatrix4fv | ( | const UniformLocation & | location,
|  | bool | transpose,
|  | const MatrixType * | value )

GL function to set the value of a uniform matrix of the current program.

Attention: The OpenGL ES specification states that transpose MUST be false.

glUniform() OpenGL ES manpage

## ◆ updateGL()

virtual void Wt::WGLWidget::updateGL | ( |  | ) |
| protectedvirtual

Update state set in initializeGL()

Invoked when repaint is called with the UPDATE_GL call.

This is intended to be executed when you want to change programs, 'constant' uniforms, or even VBO's, ... without resending already initialized data. It is a mechanism to make changes to what you've set in intializeGL(). For every server-side invocation of this method, the result will be rendered client-side exactly once.

Reimplemented in Wt::Chart::WCartesian3DChart.

## ◆ useProgram()

void Wt::WGLWidget::useProgram | ( | Program | program | ) |

GL function to set the current active shader program.

glUseProgram() OpenGL ES manpage

## ◆ validateProgram()

void Wt::WGLWidget::validateProgram | ( | Program | program | ) |

GL function to validate a program.

implementation note: there is currently not yet a method to read out the validation result.

glValidateProgram() OpenGL ES manpage

## ◆ vertexAttrib1f()

void Wt::WGLWidget::vertexAttrib1f | ( | AttribLocation | location,
|  | double | x )

GL function to set the value of an attribute of the current program.

glVertexAttrib() OpenGL ES manpage

## ◆ vertexAttrib1fv()

template<typename FloatArray >

void Wt::WGLWidget::vertexAttrib1fv | ( | AttribLocation | location,
|  | const FloatArray * | values )

GL function to set the value of an attribute of the current program.

glVertexAttrib() OpenGL ES manpage

## ◆ vertexAttrib2f()

void Wt::WGLWidget::vertexAttrib2f | ( | AttribLocation | location,
|  | double | x,
|  | double | y )

GL function to set the value of an attribute of the current program.

glVertexAttrib() OpenGL ES manpage

## ◆ vertexAttrib2fv()

template<typename FloatArray >

void Wt::WGLWidget::vertexAttrib2fv | ( | AttribLocation | location,
|  | const FloatArray * | values )

GL function to set the value of an attribute of the current program.

glVertexAttrib() OpenGL ES manpage

## ◆ vertexAttrib3f()

void Wt::WGLWidget::vertexAttrib3f | ( | AttribLocation | location,
|  | double | x,
|  | double | y,
|  | double | z )

GL function to set the value of an attribute of the current program.

glVertexAttrib() OpenGL ES manpage

## ◆ vertexAttrib3fv()

template<typename FloatArray >

void Wt::WGLWidget::vertexAttrib3fv | ( | AttribLocation | location,
|  | const FloatArray * | values )

GL function to set the value of an attribute of the current program.

glVertexAttrib() OpenGL ES manpage

## ◆ vertexAttrib4f()

void Wt::WGLWidget::vertexAttrib4f | ( | AttribLocation | location,
|  | double | x,
|  | double | y,
|  | double | z,
|  | double | w )

GL function to set the value of an attribute of the current program.

glVertexAttrib() OpenGL ES manpage

## ◆ vertexAttrib4fv()

template<typename FloatArray >

void Wt::WGLWidget::vertexAttrib4fv | ( | AttribLocation | location,
|  | const FloatArray * | values )

GL function to set the value of an attribute of the current program.

glVertexAttrib() OpenGL ES manpage

## ◆ vertexAttribPointer()

void Wt::WGLWidget::vertexAttribPointer | ( | AttribLocation | location,
|  | int | size,
|  | GLenum | type,
|  | bool | normalized,
|  | unsigned | stride,
|  | unsigned | offset )

GL function to bind a VBO to an attribute.

This function links the given attribute to the VBO currently bound to the ARRAY_BUFFER target.

The size parameter specifies the number of components per attribute (1 to 4). The type parameter is also used to determine the size of each component.

The size of a float is 8 bytes.

In WGLWidget, the size of an int is 4 bytes.

The stride is in bytes.

The maximum stride is 255.

glVertexAttribPointer() OpenGL ES manpage

## ◆ viewport()

void Wt::WGLWidget::viewport | ( | int | x,
|  | int | y,
|  | unsigned | width,
|  | unsigned | height )

GL function to set the viewport.

glViewport() OpenGL ES manpage