Class Screen¶
Defined in File screen.h
Page Contents
Inheritance Relationships¶
Base Type¶
public nanogui::Widget
(Class Widget)
Class Documentation¶
-
class
Screen
: public nanogui::Widget¶ Represents a display surface (i.e. a full-screen or windowed GLFW window) and forms the root element of a hierarchy of nanogui widgets.
Public Functions
-
Screen
(const Vector2i &size, const std::string &caption, bool resizable = true, bool fullscreen = false, int colorBits = 8, int alphaBits = 8, int depthBits = 24, int stencilBits = 8, int nSamples = 0, unsigned int glMajor = 3, unsigned int glMinor = 3)¶ Create a new Screen instance
- Parameters
size
: Size in pixels at 96 dpi (on high-DPI screens, the actual resolution in terms of hardware pixels may be larger by an integer factor)caption
: Window title (in UTF-8 encoding)resizable
: If creating a window, should it be resizable?fullscreen
: Specifies whether to create a windowed or full-screen viewcolorBits
: Number of bits per pixel dedicated to the R/G/B color componentsalphaBits
: Number of bits per pixel dedicated to the alpha channeldepthBits
: Number of bits per pixel dedicated to the Z-bufferstencilBits
: Number of bits per pixel dedicated to the stencil buffer (recommended to set this to 8. NanoVG can draw higher-quality strokes using a stencil buffer)nSamples
: Number of MSAA samples (set to 0 to disable)glMajor
: The requested OpenGL Major version number. Default is 3, if changed the value must correspond to a forward compatible core profile (for portability reasons). For example, set this to 4 and glMinor to 1 for a forward compatible core OpenGL 4.1 profile. Requesting an invalid profile will result in no context (and therefore no GUI) being created.glMinor
: The requested OpenGL Minor version number. Default is 3, if changed the value must correspond to a forward compatible core profile (for portability reasons). For example, set this to 1 and glMajor to 4 for a forward compatible core OpenGL 4.1 profile. Requesting an invalid profile will result in no context (and therefore no GUI) being created.
-
virtual
~Screen
()¶ Release all resources.
-
const std::string &
caption
() const¶ Get the window title bar caption.
-
void
setCaption
(const std::string &caption)¶ Set the window title bar caption.
-
void
setVisible
(bool visible)¶ Set the top-level window visibility (no effect on full-screen windows)
-
virtual void
drawContents
()¶ Draw the window contents put your OpenGL draw calls here.
-
float
pixelRatio
() const¶ Return the ratio between pixel and device coordinates (e.g. >= 2 on Mac Retina displays)
-
virtual bool
dropEvent
(const std::vector<std::string>&)¶ Handle a file drop event.
-
virtual bool
keyboardEvent
(int key, int scancode, int action, int modifiers)¶ Default keyboard event handler.
-
virtual bool
keyboardCharacterEvent
(unsigned int codepoint)¶ Text input event handler: codepoint is native endian UTF-32 format.
-
GLFWwindow *
glfwWindow
()¶ Return a pointer to the underlying GLFW window data structure.
-
NVGcontext *
nvgContext
()¶ Return a pointer to the underlying nanoVG draw context.
-
void
setShutdownGLFWOnDestruct
(bool v)¶
-
bool
shutdownGLFWOnDestruct
()¶
-
void
performLayout
()¶ Compute the layout of all widgets.
-
Screen
()¶ Default constructor.
Performs no initialization at all. Use this if the application is responsible for setting up GLFW, OpenGL, etc.
In this case, override Screen and call initalize() with a pointer to an existing
GLFWwindow
instanceYou will also be responsible in this case to deliver GLFW callbacks to the appropriate callback event handlers below
-
bool
cursorPosCallbackEvent
(double x, double y)¶
-
bool
mouseButtonCallbackEvent
(int button, int action, int modifiers)¶
-
bool
keyCallbackEvent
(int key, int scancode, int action, int mods)¶
-
bool
charCallbackEvent
(unsigned int codepoint)¶
-
bool
dropCallbackEvent
(int count, const char **filenames)¶
-
bool
scrollCallbackEvent
(double x, double y)¶
-
bool
resizeCallbackEvent
(int width, int height)¶
-
void
drawWidgets
()¶
-