osgViewer.GraphicsWindow

class osgViewer.GraphicsWindow
Represents

c++ class

Wraps

osgViewer::GraphicsWindow

Bases

osg.GraphicsContext, osgGA.GUIActionAdapter

Base class for providing Windowing API agnostic access to creating and managing graphics window and events. Note, the osgViewer.GraphicsWindow is subclassed from osg.GraphicsContext, and to provide an implementation you’ll need to implement its range of pure virtual functions, you’ll find these all have naming convention methodNameImplementation(..). osgViewer.GraphicsWindow adds the event queue on top of the osg.GraphicsContext, thereby adding a mechanism for adapting Windowing events as well as basics graphics context work, you should wire up custom GraphicsWindowImplementation to push their events through into the osgGA.EventQueue.

Here is example of getting default GraphicsWindow and setup cursor appearance:

-- Control cursor appearance on desktop platforms via osgViewer.GraphicsWindow.

-- Get the first (Toolbox's default) window of default global viewer
--      evi.os() returns platform name as string (windows, macos, linux. ios, android or undefined)
--      Cursor will be hidden on desktop platforms
local graphicsWindow = nil
if evi.os() == "macos" or evi.os() == "linux" or evi.os() == "windows" then
    graphicsWindow = viewer:getWindows():at(0)
end

local function enable()
    if graphicsWindow then
        graphicsWindow:setCursor(osgViewer.GraphicsWindow.LeftArrowCursor)
    end
end

local function disable()
    if graphicsWindow then
        graphicsWindow:setCursor(osgViewer.GraphicsWindow.NoCursor)
    end
end

local cursor = {
    enable      = enable,
    disable     = disable,
}

cursor.disable()
-- cursor.enable()

return cursor

Methods:

:setEventQueue(osgGA.EventQueue queue)

Параметры

queue (osgGA.EventQueue) –

:getEventQueue()

Тип результата

osgGA.EventQueue

:checkEvents()

Check events, return true if events have been received.

Тип результата

bool

:setWindowRectangle(int x, int y, int width, int height)

Set the window’s position and size.

Параметры
  • x (int) –

  • y (int) –

  • width (int) –

  • height (int) –

:setWindowRectangleImplementation(int x, int y, int width, int height)

Implementation of setWindowRectangle, should be implemented by derived classes

Параметры
  • x (int) –

  • y (int) –

  • width (int) –

  • height (int) –

Тип результата

bool

:getWindowRectangle()

Get the window’s position and size.

:setWindowDecoration(bool wd)

Set Window decoration.

Параметры

wd (bool) –

:setWindowDecorationImplementation(bool wd)

Implementation of setWindowDecoration, should be implemented by derived classes

Параметры

wd (bool) –

Тип результата

bool

:getWindowDecoration()

Set Window decoration.

Тип результата

bool

:grabFocus()

Get focus.

:grabFocusIfPointerInWindow()

Get focus on if the pointer is in this window.

:raiseWindow()

Raise the window to the top.

:setWindowName(std.string name)

Set the name of the window

Параметры

name (std.string) –

:getWindowName()

Return the name of the window

Тип результата

std.string

:useCursor(bool cursorOn)

Switch on/off the cursor.

Параметры

cursorOn (bool) –

:setCursor(osgViewer.GraphicsWindow.MouseCursor cursor)

Set mouse cursor to a specific shape.

Параметры

cursor (osgViewer.GraphicsWindow.MouseCursor) –

:setSyncToVBlank(bool on)

Set sync-to-vblank.

Параметры

on (bool) –

:getSyncToVBlank()

Тип результата

bool

:setSwapGroup(bool on, GLenum.Value group, GLenum.Value barrier)

Set swap group.

Параметры
:getSwapGroup()

:valid()

Return whether a valid and usable osg.GraphicsContext has been created.

Тип результата

bool