Class GLCanvas

Inheritance Relationships

Base Type

Class Documentation

class GLCanvas : public nanogui::Widget

Canvas widget for rendering OpenGL content. This widget was contributed by Jan Winkler.

Canvas widget that can be used to display arbitrary OpenGL content. This is useful to display and manipulate 3D objects as part of an interactive application. The implementation uses scissoring to ensure that rendered objects don’t spill into neighboring widgets.

Usage

Override nanogui::GLCanvas::drawGL() in subclasses to provide custom drawing code. See Example 4.

Public Functions

GLCanvas(Widget *parent)

Creates a GLCanvas attached to the specified parent.

Parameters

const Color &backgroundColor() const

Returns the background color.

void setBackgroundColor(const Color &backgroundColor)

Sets the background color.

void setDrawBorder(const bool bDrawBorder)

Set whether to draw the widget border or not.

const bool &drawBorder() const

Return whether the widget border gets drawn or not.

virtual void draw(NVGcontext *ctx)

Draw the canvas.

virtual void drawGL()

Draw the GL scene. Override this method to draw the actual GL content.

virtual void save(Serializer &s) const

Save the state of this GLCanvas to the specified Serializer.

virtual bool load(Serializer &s)

Set the state of this GLCanvas from the specified Serializer.

Protected Functions

void drawWidgetBorder(NVGcontext *ctx) const

Internal helper function for drawing the widget border.

Protected Attributes

Color mBackgroundColor

The background color (what is used with glClearColor).

bool mDrawBorder

Whether to draw the widget border or not.