# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes

# vlGLUT::GLUTWindow Class Reference

The GLUTWindow class implements an OpenGLContext using the GLUT API. More...

`#include <GLUTWindow.hpp>`

Inheritance diagram for vlGLUT::GLUTWindow:

List of all members.

## Public Member Functions

| GLUTWindow ()
| GLUTWindow (const vl::String &title, const vl::OpenGLContextFormat &info, int x, int y, int width, int height)
bool | initGLUTWindow (const vl::String &title, const vl::OpenGLContextFormat &info, int x, int y, int width, int height)
| Initializes and shows a GLUT window.
| ~GLUTWindow ()
virtual void | setMouseVisible (bool visible)
| If the OpenGL context is a widget this function sets whether the mouse is visible over it or not.
virtual void | setMousePosition (int x, int y)
| If the OpenGL context is a widget this function sets the mouse position.
void | quitApplication ()
| Quits the progra calling the C function exit(0).
void | update ()
| If the OpenGLContext is a widget this function requests a redraw and generates an updateEvent().
bool | setFullscreen (bool fs)
| If the OpenGL context is a widget this function requests a maximization to fullscreen.
void | makeCurrent ()
| Sets the OpenGL context as current for the calling thread.
void | updateOverlay ()
void | swapBuffers ()
| Swaps the back and front buffers to present the last rendering.
void | setWindowTitle (const vl::String &title)
| If the OpenGL context is a top window this function sets its title.
int | handle () const
void | setPosition (int x, int y)
| If the OpenGL context is a widget this function sets its position.
void | setSize (int w, int h)
| If the OpenGL context is a widget this function sets its size.
vl::ivec2 | position () const
| If the OpenGL context is a widget this function returns its position.
vl::ivec2 | size () const
void | show ()
| If the OpenGL context is a widget this function makes it visible to the user.
void | hide ()
| If the OpenGL context is a widget this function makes it invisible to the user.
void | getFocus ()
| If the OpenGL context is a widget this function requests the mouse focus on it.

## Protected Member Functions

void | destroyWindow ()
void | initKeymap ()
vl::EKey | mapAsciiKey (unsigned char ascii)
void | updateModifiers ()

## Static Protected Member Functions

static vl::EKey | mapSpecialKey (int special_key)
static void | glut_keyboard_func (unsigned char ch, int x, int y)
static void | glut_keyboard_up_func (unsigned char ch, int x, int y)
static void | glut_special_func (int key, int x, int y)
static void | glut_special_up_func (int key, int x, int y)
static void | glut_mouse_func (int button, int state, int x, int y)
static void | glut_motion_func (int x, int y)
static void | glut_passive_motion_func (int x, int y)
static void | glut_mouse_wheel_func (int a, int rotation, int c, int d)
static void | glut_visibility_func (int visibility)
static void | glut_reshape_func (int w, int h)
static void | glut_display_func ()
static void | glut_close_func ()
static void | glut_wmclose_func ()
static void | glut_idle_func ()

## Protected Attributes

std::map< unsigned char, vl::EKey > | mKeymap
int | mHandle
bool | mInited

## Static Protected Attributes

static std::map< int, GLUTWindow * > | mWinMap

## Detailed Description

The GLUTWindow class implements an OpenGLContext using the GLUT API.

Definition at line 59 of file GLUTWindow.hpp.

## Constructor & Destructor Documentation

GLUTWindow::GLUTWindow | ( | ) |

Definition at line 43 of file GLUTWindow.cpp.

References mHandle, and mInited.

GLUTWindow::GLUTWindow | ( | const vl::String & | title,
|  | const vl::OpenGLContextFormat & | info,
|  | int | x,
|  | int | y,
|  | int | width,
|  | int | height
| ) |  |

Definition at line 49 of file GLUTWindow.cpp.

References initGLUTWindow(), mHandle, and mInited.

vlGLUT::GLUTWindow::~GLUTWindow | ( | ) | `[inline]`

Definition at line 69 of file GLUTWindow.hpp.

## Member Function Documentation

bool GLUTWindow::initGLUTWindow | ( | const vl::String & | title,
|  | const vl::OpenGLContextFormat & | info,
|  | int | x,
|  | int | y,
|  | int | width,
|  | int | height
| ) |  |

Initializes and shows a GLUT window.

*

*

*

*

*

*

*

*

*

*

*

*

*

*

Definition at line 57 of file GLUTWindow.cpp.

References vl::OpenGLContextFormat::accumRGBABits(), vl::OpenGLContextFormat::depthBufferBits(), vl::OpenGLContextFormat::doubleBuffer(), vl::OpenGLContextFormat::fullscreen(), glut_close_func(), glut_display_func(), glut_idle_func(), glut_keyboard_func(), glut_keyboard_up_func(), glut_motion_func(), glut_mouse_func(), glut_mouse_wheel_func(), glut_passive_motion_func(), glut_reshape_func(), glut_special_func(), glut_special_up_func(), glut_visibility_func(), glut_wmclose_func(), handle(), vl::OpenGLContext::initGLContext(), initKeymap(), vl::OpenGLContext::mFullscreen, mHandle, vl::OpenGLContextFormat::multisample(), mWinMap, NULL, vl::OpenGLContextFormat::rgbaBits(), vl::OpenGLContext::setOpenGLContextInfo(), vl::OpenGLContext::setVSyncEnabled(), vl::OpenGLContextFormat::stencilBufferBits(), vl::OpenGLContextFormat::stereo(), vl::String::toStdString(), and vl::OpenGLContextFormat::vSync().

Referenced by GLUTWindow().

void GLUTWindow::setMouseVisible | ( | bool | ) | `[virtual]`

If the OpenGL context is a widget this function sets whether the mouse is visible over it or not.

Reimplemented from vl::OpenGLContext.

Definition at line 314 of file GLUTWindow.cpp.

References vl::OpenGLContext::mMouseVisible.

void GLUTWindow::setMousePosition | ( | int | ,
|  | int |
| ) |  | `[virtual]`

If the OpenGL context is a widget this function sets the mouse position.

Reimplemented from vl::OpenGLContext.

Definition at line 323 of file GLUTWindow.cpp.

void vlGLUT::GLUTWindow::quitApplication | ( | ) | `[inline, virtual]`

Quits the progra calling the C function exit(0).

Reimplemented from vl::OpenGLContext.

Definition at line 79 of file GLUTWindow.hpp.

void GLUTWindow::update | ( | ) | `[virtual]`

If the OpenGLContext is a widget this function requests a redraw and generates an updateEvent().

Implements vl::OpenGLContext.

Definition at line 328 of file GLUTWindow.cpp.

References handle().

bool GLUTWindow::setFullscreen | ( | bool | ) | `[virtual]`

If the OpenGL context is a widget this function requests a maximization to fullscreen.

Reimplemented from vl::OpenGLContext.

Definition at line 283 of file GLUTWindow.cpp.

References handle(), vl::OpenGLContext::height(), vl::OpenGLContext::mFullscreen, NULL, and vl::OpenGLContext::width().

void GLUTWindow::makeCurrent | ( | ) | `[virtual]`

Sets the OpenGL context as current for the calling thread.

Implements vl::OpenGLContext.

Definition at line 334 of file GLUTWindow.cpp.

References handle().

void GLUTWindow::updateOverlay | ( | ) |

Definition at line 350 of file GLUTWindow.cpp.

void GLUTWindow::swapBuffers | ( | ) | `[virtual]`

Swaps the back and front buffers to present the last rendering.

Implements vl::OpenGLContext.

Definition at line 355 of file GLUTWindow.cpp.

void GLUTWindow::setWindowTitle | ( | const vl::String & | ) | `[virtual]`

If the OpenGL context is a top window this function sets its title.

Reimplemented from vl::OpenGLContext.

Definition at line 388 of file GLUTWindow.cpp.

References handle(), and vl::String::toStdString().

int vlGLUT::GLUTWindow::handle | ( | ) | const`[inline]`

Definition at line 93 of file GLUTWindow.hpp.

Referenced by destroyWindow(), getFocus(), hide(), initGLUTWindow(), makeCurrent(), position(), setFullscreen(), setPosition(), setSize(), setWindowTitle(), show(), size(), and update().

void GLUTWindow::setPosition | ( | int | ,
|  | int |
| ) |  | `[virtual]`

If the OpenGL context is a widget this function sets its position.

Reimplemented from vl::OpenGLContext.

Definition at line 399 of file GLUTWindow.cpp.

References handle().

void GLUTWindow::setSize | ( | int | ,
|  | int |
| ) |  | `[virtual]`

If the OpenGL context is a widget this function sets its size.

Reimplemented from vl::OpenGLContext.

Definition at line 410 of file GLUTWindow.cpp.

References handle().

vl::ivec2 GLUTWindow::position | ( | ) | const`[virtual]`

If the OpenGL context is a widget this function returns its position.

Reimplemented from vl::OpenGLContext.

Definition at line 421 of file GLUTWindow.cpp.

References handle().

vl::ivec2 GLUTWindow::size | ( | ) | const

Definition at line 435 of file GLUTWindow.cpp.

References handle().

void GLUTWindow::show | ( | ) | `[virtual]`

If the OpenGL context is a widget this function makes it visible to the user.

Reimplemented from vl::OpenGLContext.

Definition at line 360 of file GLUTWindow.cpp.

References handle().

void GLUTWindow::hide | ( | ) | `[virtual]`

If the OpenGL context is a widget this function makes it invisible to the user.

Reimplemented from vl::OpenGLContext.

Definition at line 371 of file GLUTWindow.cpp.

References handle().

void GLUTWindow::getFocus | ( | ) | `[virtual]`

If the OpenGL context is a widget this function requests the mouse focus on it.

Reimplemented from vl::OpenGLContext.

Definition at line 382 of file GLUTWindow.cpp.

References handle().

void GLUTWindow::destroyWindow | ( | ) | `[protected]`

Definition at line 340 of file GLUTWindow.cpp.

References handle().

void GLUTWindow::initKeymap | ( | ) | `[protected]`

Definition at line 449 of file GLUTWindow.cpp.

References vl::Key_0, vl::Key_1, vl::Key_2, vl::Key_3, vl::Key_4, vl::Key_5, vl::Key_6, vl::Key_7, vl::Key_8, vl::Key_9, vl::Key_A, vl::Key_Ampersand, vl::Key_Asterisk, vl::Key_At, vl::Key_B, vl::Key_BackSlash, vl::Key_BackSpace, vl::Key_C, vl::Key_Caret, vl::Key_Colon, vl::Key_Comma, vl::Key_D, vl::Key_Delete, vl::Key_Dollar, vl::Key_E, vl::Key_Equal, vl::Key_Escape, vl::Key_Exclam, vl::Key_F, vl::Key_G, vl::Key_Greater, vl::Key_H, vl::Key_Hash, vl::Key_I, vl::Key_J, vl::Key_K, vl::Key_L, vl::Key_LeftBracket, vl::Key_LeftParen, vl::Key_Less, vl::Key_M, vl::Key_Minus, vl::Key_N, vl::Key_O, vl::Key_P, vl::Key_Period, vl::Key_Plus, vl::Key_Q, vl::Key_Question, vl::Key_Quote, vl::Key_QuoteDbl, vl::Key_QuoteLeft, vl::Key_R, vl::Key_Return, vl::Key_RightBracket, vl::Key_RightParen, vl::Key_S, vl::Key_Semicolon, vl::Key_Slash, vl::Key_Space, vl::Key_T, vl::Key_Tab, vl::Key_U, vl::Key_Underscore, vl::Key_V, vl::Key_W, vl::Key_X, vl::Key_Y, vl::Key_Z, and mKeymap.

Referenced by initGLUTWindow().

vl::EKey GLUTWindow::mapAsciiKey | ( | unsigned char | ascii ) | `[protected]`

Definition at line 554 of file GLUTWindow.cpp.

References vl::Key_Unknown, and mKeymap.

Referenced by glut_keyboard_func(), and glut_keyboard_up_func().

vl::EKey GLUTWindow::mapSpecialKey | ( | int | special_key ) | `[static, protected]`

Definition at line 565 of file GLUTWindow.cpp.

References vl::Key_Down, vl::Key_End, vl::Key_F1, vl::Key_F10, vl::Key_F11, vl::Key_F12, vl::Key_F2, vl::Key_F3, vl::Key_F4, vl::Key_F5, vl::Key_F6, vl::Key_F7, vl::Key_F8, vl::Key_F9, vl::Key_Home, vl::Key_Insert, vl::Key_Left, vl::Key_PageDown, vl::Key_PageUp, vl::Key_Right, vl::Key_Unknown, and vl::Key_Up.

Referenced by glut_special_func(), and glut_special_up_func().

void GLUTWindow::updateModifiers | ( | ) | `[protected]`

Definition at line 597 of file GLUTWindow.cpp.

References vl::Key_Alt, vl::Key_Ctrl, vl::Key_Shift, vl::OpenGLContext::keyPress(), and vl::OpenGLContext::keyRelease().

Referenced by glut_keyboard_func(), glut_keyboard_up_func(), glut_mouse_func(), glut_mouse_wheel_func(), glut_special_func(), and glut_special_up_func().

void GLUTWindow::glut_keyboard_func | ( | unsigned char | ch,
|  | int | x,
|  | int | y
| ) |  | `[static, protected]`

Definition at line 611 of file GLUTWindow.cpp.

References vl::OpenGLContext::dispatchKeyPressEvent(), mapAsciiKey(), mWinMap, updateModifiers(), and VL_CHECK.

Referenced by initGLUTWindow().

void GLUTWindow::glut_keyboard_up_func | ( | unsigned char | ch,
|  | int | x,
|  | int | y
| ) |  | `[static, protected]`

Definition at line 620 of file GLUTWindow.cpp.

References vl::OpenGLContext::dispatchKeyReleaseEvent(), mapAsciiKey(), mWinMap, updateModifiers(), and VL_CHECK.

Referenced by initGLUTWindow().

void GLUTWindow::glut_special_func | ( | int | key,
|  | int | x,
|  | int | y
| ) |  | `[static, protected]`

Definition at line 629 of file GLUTWindow.cpp.

References vl::OpenGLContext::dispatchKeyPressEvent(), mapSpecialKey(), mWinMap, updateModifiers(), and VL_CHECK.

Referenced by initGLUTWindow().

void GLUTWindow::glut_special_up_func | ( | int | key,
|  | int | x,
|  | int | y
| ) |  | `[static, protected]`

Definition at line 638 of file GLUTWindow.cpp.

References vl::OpenGLContext::dispatchKeyReleaseEvent(), mapSpecialKey(), mWinMap, updateModifiers(), and VL_CHECK.

Referenced by initGLUTWindow().

void GLUTWindow::glut_mouse_func | ( | int | button,
|  | int | state,
|  | int | x,
|  | int | y
| ) |  | `[static, protected]`

Definition at line 647 of file GLUTWindow.cpp.

References vl::OpenGLContext::dispatchMouseDownEvent(), vl::OpenGLContext::dispatchMouseUpEvent(), vl::LeftButton, vl::MiddleButton, mWinMap, vl::RightButton, vl::UnknownButton, updateModifiers(), and VL_CHECK.

Referenced by initGLUTWindow().

void GLUTWindow::glut_motion_func | ( | int | x,
|  | int | y
| ) |  | `[static, protected]`

Definition at line 669 of file GLUTWindow.cpp.

References vl::OpenGLContext::dispatchMouseMoveEvent(), mWinMap, and VL_CHECK.

Referenced by initGLUTWindow().

void GLUTWindow::glut_passive_motion_func | ( | int | x,
|  | int | y
| ) |  | `[static, protected]`

Definition at line 680 of file GLUTWindow.cpp.

References vl::OpenGLContext::dispatchMouseMoveEvent(), mInited, mWinMap, and VL_CHECK.

Referenced by initGLUTWindow().

void GLUTWindow::glut_mouse_wheel_func | ( | int | a,
|  | int | rotation,
|  | int | c,
|  | int | d
| ) |  | `[static, protected]`

Definition at line 695 of file GLUTWindow.cpp.

References vl::OpenGLContext::dispatchMouseWheelEvent(), mWinMap, updateModifiers(), and VL_CHECK.

Referenced by initGLUTWindow().

void GLUTWindow::glut_visibility_func | ( | int | visibility ) | `[static, protected]`

Definition at line 705 of file GLUTWindow.cpp.

References vl::OpenGLContext::dispatchVisibilityEvent(), mWinMap, and VL_CHECK.

Referenced by initGLUTWindow().

void GLUTWindow::glut_reshape_func | ( | int | w,
|  | int | h
| ) |  | `[static, protected]`

Definition at line 715 of file GLUTWindow.cpp.

References vl::OpenGLContext::dispatchInitEvent(), vl::OpenGLContext::dispatchResizeEvent(), vl::OpenGLContext::framebuffer(), mInited, mWinMap, and VL_CHECK.

Referenced by initGLUTWindow().

void GLUTWindow::glut_display_func | ( | ) | `[static, protected]`

Definition at line 733 of file GLUTWindow.cpp.

References vl::OpenGLContext::dispatchRunEvent(), mWinMap, and VL_CHECK.

Referenced by initGLUTWindow().

void GLUTWindow::glut_close_func | ( | ) | `[static, protected]`

Definition at line 746 of file GLUTWindow.cpp.

References vl::OpenGLContext::dispatchDestroyEvent(), mHandle, mInited, mKeymap, mWinMap, and VL_CHECK.

Referenced by glut_wmclose_func(), and initGLUTWindow().

void GLUTWindow::glut_wmclose_func | ( | ) | `[static, protected]`

Definition at line 762 of file GLUTWindow.cpp.

References glut_close_func().

Referenced by initGLUTWindow().

void GLUTWindow::glut_idle_func | ( | ) | `[static, protected]`

Definition at line 767 of file GLUTWindow.cpp.

References mWinMap.

Referenced by initGLUTWindow().

## Member Data Documentation

std::map<unsigned char, vl::EKey> vlGLUT::GLUTWindow::mKeymap`[protected]`

Definition at line 157 of file GLUTWindow.hpp.

Referenced by glut_close_func(), initKeymap(), and mapAsciiKey().

int vlGLUT::GLUTWindow::mHandle`[protected]`

Definition at line 158 of file GLUTWindow.hpp.

Referenced by glut_close_func(), GLUTWindow(), and initGLUTWindow().

bool vlGLUT::GLUTWindow::mInited`[protected]`

Definition at line 159 of file GLUTWindow.hpp.

Referenced by glut_close_func(), glut_passive_motion_func(), glut_reshape_func(), and GLUTWindow().

std::map< int, GLUTWindow * > GLUTWindow::mWinMap`[static, protected]`

Definition at line 161 of file GLUTWindow.hpp.

Referenced by glut_close_func(), glut_display_func(), glut_idle_func(), glut_keyboard_func(), glut_keyboard_up_func(), glut_motion_func(), glut_mouse_func(), glut_mouse_wheel_func(), glut_passive_motion_func(), glut_reshape_func(), glut_special_func(), glut_special_up_func(), glut_visibility_func(), and initGLUTWindow().

The documentation for this class was generated from the following files:

- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGLUT/GLUTWindow.hpp
- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGLUT/GLUTWindow.cpp

Visualization Library v2011.09.1162 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu Jan 26 2012 00:45:01.
Permission is granted to use this page to write and publish articles regarding Visualization Library.