Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics
[Home] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Member Functions | Protected Attributes

vlWin32::Win32Context Class Reference

The Win32Context class implements an OpenGLContext using the Win32 API. More...

#include <Win32Context.hpp>

Inheritance diagram for vlWin32::Win32Context:
vl::OpenGLContext vl::Object vlMFC::MFCWindow vlWin32::Win32Window

List of all members.

Public Member Functions

 Win32Context ()
 Win32Context (int w, int h)
virtual HWND hwnd () const =0
HDC hdc () const
HGLRC hglrc () const
void shareOpenGLResources (HGLRC hGLRC)
 Use this function when you want two OpenGL contexts to share their resources (display lists, textures, shader objects, buffer objects etc.) Equivalent to wglShareLists(this->hglrc(), hGLRC)
void makeCurrent ()
 Sets the OpenGL context as current for the calling thread.
void update ()
 If the OpenGLContext is a widget this function requests a redraw.
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.
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.
void setMouseVisible (bool visible)
 If the OpenGL context is a widget this function sets whether the mouse is visible over it or not.
void setMousePosition (int x, int y)
 If the OpenGL context is a widget this function sets the mouse position.
void setPosition (int x, int y)
 If the OpenGL context is a widget this function sets its position.
vl::ivec2 position () const
 If the OpenGL context is a widget this function returns its position.
void setSize (int w, int h)
 The actual size of the OpenGL context, i.e.
vl::ivec2 size () const
 The actual size of the OpenGL context, i.e. the client area if this is a window.
void setWindowSize (int w, int h)
 Sets the size of the window. Note that if this Win32Window has window decorations the actual OpenGL context will be smaller than the given w and h parameters.
vl::ivec2 windowSize () const
 Returns the size of the window and not the client area.
bool setFullscreen (bool fullscreen_on)
 If the OpenGL context is a widget this function requests a maximization to fullscreen.
void quitApplication ()
 Calls the PostQuitMessage(0) function (Win32 API).
const std::vector< int > & contextAttribs () const
 Context attributes used when creating an OpenGL 3.x / 4.x context.
std::vector< int > & contextAttribs ()
 Context attributes used when creating an OpenGL 3.x / 4.x context.
void setContextAttribs (const int *attribs)
 Context attributes used when creating an OpenGL 3.x / 4.x context.

Protected Member Functions

bool init (HGLRC share_context, const vl::String &title, const vl::OpenGLContextFormat &fmt, int x, int y, int width, int height)

Protected Attributes

std::vector< int > mContextAttribs
HDC mHDC
HGLRC mHGLRC
vl::ivec2 mNormPosit
vl::ivec2 mNormSize
unsigned int mNormFlags

Detailed Description

The Win32Context class implements an OpenGLContext using the Win32 API.


Constructor & Destructor Documentation

vlWin32::Win32Context::Win32Context (  ) [inline]
vlWin32::Win32Context::Win32Context ( int  w,
int  h 
) [inline]

Member Function Documentation

virtual HWND vlWin32::Win32Context::hwnd (  ) const [pure virtual]

Implemented in vlWin32::Win32Window, and vlMFC::MFCWindow.

HDC vlWin32::Win32Context::hdc (  ) const [inline]
HGLRC vlWin32::Win32Context::hglrc (  ) const [inline]
void Win32Context::shareOpenGLResources ( HGLRC  hGLRC )

Use this function when you want two OpenGL contexts to share their resources (display lists, textures, shader objects, buffer objects etc.) Equivalent to wglShareLists(this->hglrc(), hGLRC)

Remarks:
If you want to share resources among two or more OpenGL contexts, you must call this function before you start creating any resources.
void Win32Context::makeCurrent (  ) [virtual]

Sets the OpenGL context as current for the calling thread.

Implements vl::OpenGLContext.

void Win32Context::update (  ) [virtual]

If the OpenGLContext is a widget this function requests a redraw.

Reimplemented from vl::OpenGLContext.

void Win32Context::swapBuffers (  ) [virtual]

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

Implements vl::OpenGLContext.

void Win32Context::setWindowTitle ( const vl::String  ) [virtual]

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

Reimplemented from vl::OpenGLContext.

void Win32Context::show (  ) [virtual]

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

Reimplemented from vl::OpenGLContext.

void Win32Context::hide (  ) [virtual]

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

Reimplemented from vl::OpenGLContext.

void Win32Context::getFocus (  ) [virtual]

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

Reimplemented from vl::OpenGLContext.

void Win32Context::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.

void Win32Context::setMousePosition ( int  ,
int   
) [virtual]

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

Reimplemented from vl::OpenGLContext.

void Win32Context::setPosition ( int  ,
int   
) [virtual]

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

Reimplemented from vl::OpenGLContext.

vl::ivec2 Win32Context::position (  ) const [virtual]

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

Reimplemented from vl::OpenGLContext.

void Win32Context::setSize ( int  w,
int  h 
) [virtual]

The actual size of the OpenGL context, i.e.

the client area if this is a window. Note that if this Win32Window has window decorations the actual window size will be bigger than the given w and h parameters.

Reimplemented from vl::OpenGLContext.

vl::ivec2 Win32Context::size (  ) const

The actual size of the OpenGL context, i.e. the client area if this is a window.

void Win32Context::setWindowSize ( int  w,
int  h 
)

Sets the size of the window. Note that if this Win32Window has window decorations the actual OpenGL context will be smaller than the given w and h parameters.

vl::ivec2 Win32Context::windowSize (  ) const

Returns the size of the window and not the client area.

Use the size() method if you need the size of the actual OpenGL rendering context.

Note:
windowSize() can be different from size() because of the space taken by the window caption and decorations.
bool Win32Context::setFullscreen ( bool   ) [virtual]

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

Reimplemented from vl::OpenGLContext.

void Win32Context::quitApplication (  ) [virtual]

Calls the PostQuitMessage(0) function (Win32 API).

Reimplemented from vl::OpenGLContext.

const std::vector<int>& vlWin32::Win32Context::contextAttribs (  ) const [inline]

Context attributes used when creating an OpenGL 3.x / 4.x context.

The flags must be the ones specified by http://www.opengl.org/registry/specs/ARB/wgl_create_context.txt

std::vector<int>& vlWin32::Win32Context::contextAttribs (  ) [inline]

Context attributes used when creating an OpenGL 3.x / 4.x context.

The flags must be the ones specified by http://www.opengl.org/registry/specs/ARB/wgl_create_context.txt

void Win32Context::setContextAttribs ( const int *  attribs )

Context attributes used when creating an OpenGL 3.x / 4.x context.

The flags must be the ones specified by http://www.opengl.org/registry/specs/ARB/wgl_create_context.txt

bool Win32Context::init ( HGLRC  share_context,
const vl::String title,
const vl::OpenGLContextFormat fmt,
int  x,
int  y,
int  width,
int  height 
) [protected]

Member Data Documentation

std::vector<int> vlWin32::Win32Context::mContextAttribs [protected]
HDC vlWin32::Win32Context::mHDC [protected]
HGLRC vlWin32::Win32Context::mHGLRC [protected]
unsigned int vlWin32::Win32Context::mNormFlags [protected]

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

Visualization Library v2010.11.1125 Reference Documentation
Copyright 2005-2009 Michele Bosi. All rights reserved.
Updated on Fri Nov 26 2010 10:33:57.
Permission is granted to use this page to write and publish articles regarding Visualization Library.