Visualization Library 2.1.0

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

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
vlMFC::MFCWindow Class Reference

The MFCWindow class is an MFC CWnd with the functionalities of a Win32Context. More...

#include <MFCWindow.hpp>

+ Inheritance diagram for vlMFC::MFCWindow:

Public Member Functions

 MFCWindow ()
 
virtual ~MFCWindow ()
 
bool initMFCWindow (CWnd *parent, MFCWindow *share_context, const vl::String &title, const vl::OpenGLContextFormat &fmt, int x=0, int y=0, int width=640, int height=480)
 Creates the window and initializes the OpenGL rendering context. More...
 
HWND hwnd () const
 Returns the Win32 window handle. More...
 
afx_msg void OnPaint ()
 
afx_msg void OnDestroy ()
 
afx_msg int OnCreate (LPCREATESTRUCT lpCreateStruct)
 
afx_msg void OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags)
 
afx_msg void OnKeyUp (UINT nChar, UINT nRepCnt, UINT nFlags)
 
afx_msg void OnLButtonDblClk (UINT nFlags, CPoint point)
 
afx_msg void OnLButtonDown (UINT nFlags, CPoint point)
 
afx_msg void OnLButtonUp (UINT nFlags, CPoint point)
 
afx_msg void OnMButtonDblClk (UINT nFlags, CPoint point)
 
afx_msg void OnMButtonDown (UINT nFlags, CPoint point)
 
afx_msg void OnMButtonUp (UINT nFlags, CPoint point)
 
afx_msg void OnMouseMove (UINT nFlags, CPoint point)
 
afx_msg BOOL OnMouseWheel (UINT nFlags, short zDelta, CPoint pt)
 
afx_msg void OnRButtonDblClk (UINT nFlags, CPoint point)
 
afx_msg void OnRButtonDown (UINT nFlags, CPoint point)
 
afx_msg void OnRButtonUp (UINT nFlags, CPoint point)
 
afx_msg void OnSize (UINT nType, int cx, int cy)
 
afx_msg void OnDropFiles (HDROP hDropInfo)
 
- Public Member Functions inherited from vlWin32::Win32Context
 Win32Context ()
 
 Win32Context (int w, int h)
 
 ~Win32Context ()
 
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) More...
 
void makeCurrent ()
 Sets the OpenGL context as current for the calling thread. More...
 
void update ()
 If the OpenGLContext is a widget this function requests a redraw and generates an updateEvent(). More...
 
void swapBuffers ()
 Swaps the back and front buffers to present the last rendering. More...
 
void setWindowTitle (const vl::String &title)
 If the OpenGL context is a top window this function sets its title. More...
 
void show ()
 If the OpenGL context is a widget this function makes it visible to the user. More...
 
void hide ()
 If the OpenGL context is a widget this function makes it invisible to the user. More...
 
void getFocus ()
 If the OpenGL context is a widget this function requests the mouse focus on it. More...
 
void setMouseVisible (bool visible)
 If the OpenGL context is a widget this function sets whether the mouse is visible over it or not. More...
 
void setMousePosition (int x, int y)
 If the OpenGL context is a widget this function sets the mouse position. More...
 
void setPosition (int x, int y)
 If the OpenGL context is a widget this function sets its position. More...
 
vl::ivec2 position () const
 If the OpenGL context is a widget this function returns its position. More...
 
void setSize (int w, int h)
 The actual size of the OpenGL context, i.e. More...
 
vl::ivec2 size () const
 The actual size of the OpenGL context, i.e. the client area if this is a window. More...
 
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. More...
 
vl::ivec2 windowSize () const
 Returns the size of the window and not the client area. More...
 
bool setFullscreen (bool fullscreen_on)
 If the OpenGL context is a widget this function requests a maximization to fullscreen. More...
 
void quitApplication ()
 Calls the PostQuitMessage(0) function (Win32 API). More...
 
const std::vector< int > & contextAttribs () const
 Context attributes used when creating an OpenGL 3.x / 4.x context. More...
 
std::vector< int > & contextAttribs ()
 Context attributes used when creating an OpenGL 3.x / 4.x context. More...
 
void setContextAttribs (const int *attribs, int size)
 Context attributes used when creating an OpenGL 3.x / 4.x context. More...
 
- Public Member Functions inherited from vl::OpenGLContext
 OpenGLContext (int w=0, int h=0)
 Constructor. More...
 
 ~OpenGLContext ()
 Destructor. More...
 
bool initGLContext (bool log=true)
 Initializes the supported OpenGL extensions. More...
 
void logOpenGLInfo ()
 Logs some information about the OpenGL context. More...
 
const std::string & extensions () const
 Returns the list of OpenGL extensions supported separated by '|' characters. More...
 
bool isExtensionSupported (const char *ext_name)
 Returns true if the given extension is supported. More...
 
void * getProcAddress (const char *function_name)
 Returns the address of an OpenGL extension function. More...
 
FramebufferObjectleftFramebuffer ()
 The render target representing the default left framebuffer. More...
 
const FramebufferObjectleftFramebuffer () const
 The render target representing the default left framebuffer. More...
 
FramebufferObjectrightFramebuffer ()
 The render target representing the default right framebuffer (if a stereo OpenGL context is present). More...
 
const FramebufferObjectrightFramebuffer () const
 The render target representing the default right framebuffer (if a stereo OpenGL context is present). More...
 
FramebufferObjectframebuffer ()
 The default render target (always returns leftFramebuffer()). More...
 
const FramebufferObjectframebuffer () const
 The default render target (always returns leftFramebuffer()). More...
 
FramebufferObjectcreateFramebufferObject ()
 Equivalent to "createFramebufferObject(0,0);". More...
 
FramebufferObjectcreateFramebufferObject (int width, int height, EReadDrawBuffer draw_buffer=RDB_COLOR_ATTACHMENT0, EReadDrawBuffer read_buffer=RDB_COLOR_ATTACHMENT0)
 Creates a new FramebufferObject (framebuffer object FramebufferObject). More...
 
void destroyFramebufferObject (FramebufferObject *fbort)
 Destroys the specified FramebufferObject. More...
 
void destroyAllFramebufferObjects ()
 Removes all FramebufferObjects belonging to an OpenGLContext. More...
 
void destroyAllOpenGLResources ()
 Removes all OpenGL resources handled by the OpenGLContext. More...
 
virtual bool fullscreen () const
 If the OpenGL context is a widget this function returns whether it has been maximized to fullscreen. More...
 
int width () const
 Returns the width in pixels of an OpenGLContext. More...
 
int height () const
 Returns the height in pixels of an OpenGLContext. More...
 
virtual bool mouseVisible () const
 If the OpenGL context is a widget this function returns whether the mouse is visible over it or not. More...
 
void setVSyncEnabled (bool enable)
 If the OpenGL context is a widget this function enabled/disables double buffer swapping to the monitor's vertical synch. More...
 
bool vsyncEnabled () const
 If the OpenGL context is a widget this function returns whether vsync is enabled or not. More...
 
virtual void setContinuousUpdate (bool continuous)
 If the OpenGL context is a widget this function sets whether its area is continuously updated at each frame. More...
 
bool continuousUpdate () const
 If the OpenGL context is a widget this function returns whether its area is continuously updated at each frame. More...
 
void addEventListener (UIEventListener *el)
 Adds an UIEventListener to be notified of OpenGLContext related events. More...
 
void removeEventListener (UIEventListener *el)
 Removes an UIEventListener. More...
 
void eraseAllEventListeners ()
 Removes all UIEventListener previously registered. More...
 
const std::vector< ref< UIEventListener > > & eventListeners () const
 The currently UIEventListener registered to be notified of OpenGLContext related events. More...
 
const UIEventListenereventListener (int i) const
 Returns the i-th UIEventListener registered to an OpenGLContext. More...
 
UIEventListenereventListener (int i)
 Returns the i-th UIEventListener registered to an OpenGLContext. More...
 
int eventListenerCount () const
 Returns the number of UIEventListener registered to an OpenGLContext. More...
 
const OpenGLContextFormatopenglContextInfo () const
 Returns an OpenGLContextFormat structure describing an OpenGLContext. More...
 
void setOpenGLContextInfo (const OpenGLContextFormat &info)
 Sets the OpenGLContextFormat associated to an OpenGLContext. More...
 
void ignoreNextMouseMoveEvent ()
 Requests not to dispatch the next mouse move event. More...
 
void dispatchResizeEvent (int w, int h)
 Dispatches the UIEventListener::resizeEvent() notification to the subscribed UIEventListener objects. More...
 
void dispatchMouseMoveEvent (int x, int y)
 Dispatches the UIEventListener::mouseMoveEvent() notification to the subscribed UIEventListener objects. More...
 
void dispatchMouseUpEvent (EMouseButton button, int x, int y)
 Dispatches the UIEventListener::mouseUpEvent() notification to the subscribed UIEventListener objects. More...
 
void dispatchMouseDownEvent (EMouseButton button, int x, int y)
 Dispatches the UIEventListener::mouseDownEvent() notification to the subscribed UIEventListener objects. More...
 
void dispatchMouseWheelEvent (int n)
 Dispatches the UIEventListener::mouseWheelEvent() notification to the subscribed UIEventListener objects. More...
 
void dispatchKeyPressEvent (unsigned short unicode_ch, EKey key)
 Dispatches the UIEventListener::keyPressEvent() notification to the subscribed UIEventListener objects. More...
 
void dispatchKeyReleaseEvent (unsigned short unicode_ch, EKey key)
 Dispatches the UIEventListener::keyReleaseEvent() notification to the subscribed UIEventListener objects. More...
 
void dispatchDestroyEvent ()
 Dispatches the UIEventListener::destroyEvent() notification to the subscribed UIEventListener(s), calls destroyAllOpenGLResources() and eraseAllEventListeners() This event must be issued just before the actual GL context is destroyed. More...
 
void dispatchUpdateEvent ()
 Dispatches the UIEventListener::updateEvent() notification to the subscribed UIEventListener objects. More...
 
void dispatchVisibilityEvent (bool visible)
 Dispatches the UIEventListener::visibilityEvent() notification to the subscribed UIEventListener objects. More...
 
void dispatchInitEvent ()
 Dispatches the UIEventListener::initEvent() notification to the subscribed UIEventListener objects. More...
 
void dispatchFileDroppedEvent (const std::vector< String > &files)
 Dispatches the UIEventListener::fileDroppedEvent() notification to the subscribed UIEventListener objects. More...
 
const std::set< EKey > & keyboard () const
 Returns the std::set containing the currently pressed keys. More...
 
bool isKeyPressed (EKey key) const
 Returns true if the given key is pressed. More...
 
void keyPress (EKey key)
 Inserts the specified key in the set of currently active keys - For internal use only. More...
 
void keyRelease (EKey key)
 Removes the specified key from the set of currently active keys - For internal use only. More...
 
bool isInitialized () const
 Returns true if the OpenGLContext is in an initialized state. More...
 
int vertexAttribCount () const
 The number (clamped to VA_MaxAttribCount) of generic vertex attributes as returned by glGet(GL_MAX_VERTEX_ATTRIBS) More...
 
int textureImageUnitCount () const
 The number (clamped to VL_MAX_TEXTURE_IMAGE_UNITS) of texture image units supported by the current hardware. More...
 
int textureCoordCount () const
 The number (clamped to VL_MAX_LEGACY_TEXTURE_UNITS) of fixed function pipeline texture units supported by the current hardware. More...
 
bool hasDoubleBuffer () const
 Returns true if an OpenGLContext supports double buffering. More...
 
void useGLSLProgram (const GLSLProgram *glsl)
 Activates the given GLSLProgram or unbinds the current one if glsl is NULL. More...
 
void bindVAS (const IVertexAttribSet *vas, bool use_vbo, bool force)
 Activates the specified vertex attribute set - For internal use only. More...
 
void bindVAS_Attribs (const IVertexAttribSet *vas, bool use_vbo)
 
void bindVAS_Fixed (const IVertexAttribSet *vas, bool use_vbo)
 
void bindVAS_Reset ()
 
void applyEnables (const EnableSet *cur)
 Applies an EnableSet to an OpenGLContext - Typically for internal use only. More...
 
void applyRenderStates (const RenderStateSet *cur, const Camera *camera)
 Applies a RenderStateSet to an OpenGLContext - Typically for internal use only. More...
 
void resetEnables ()
 Resets all the interanal enable-tables - For internal use only. More...
 
void resetRenderStates ()
 Resets all the interanal render-states-tables - For internal use only. More...
 
void setDefaultRenderState (const RenderStateSlot &rs_slot)
 Defines the default render state slot to be used by the opengl context. More...
 
const RenderStateSlotdefaultRenderState (ERenderState rs)
 Returns the default render state slot used by VL when a specific render state type is left undefined. More...
 
void resetContextStates (EResetContextStates start_or_finish)
 Resets the OpenGL states necessary to begin and finish a rendering. - For internal use only. More...
 
void setTexUnitBinding (int unit_i, ETextureDimension target)
 Declares that texture unit unit_i is currently bound to the specified texture target. - For internal use only. More...
 
ETextureDimension texUnitBinding (int unit_i) const
 Returnes the texture target currently active for the specified texture unit. - For internal use only. More...
 
const GLSLProgramglslProgram () const
 
GLSLProgramglslProgram ()
 
bool isCleanState (bool verbose)
 Checks whether the OpenGL state is clean or not. More...
 
const fvec3normal () const
 
const fvec4color () const
 
const fvec3secondaryColor () const
 
const fvec4vertexAttribValue (int i) const
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Protected Member Functions

void destroyGLContext ()
 
void countAndCapture ()
 
void countAndRelease ()
 
- Protected Member Functions inherited from vlWin32::Win32Context
bool initWin32GLContext (HGLRC share_context, const vl::String &title, const vl::OpenGLContextFormat &fmt, int x, int y, int width, int height)
 
- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

Protected Attributes

int mMouseDownCount
 
- Protected Attributes inherited from vlWin32::Win32Context
std::vector< int > mContextAttribs
 
HDC mHDC
 
HGLRC mHGLRC
 
vl::ivec2 mNormPosit
 
vl::ivec2 mNormSize
 
unsigned int mNormFlags
 
- Protected Attributes inherited from vl::OpenGLContext
ref< FramebufferObjectmLeftFramebuffer
 
ref< FramebufferObjectmRightFramebuffer
 
std::vector< ref< FramebufferObject > > mFramebufferObject
 
std::vector< ref< UIEventListener > > mEventListeners
 
std::set< EKeymKeyboard
 
OpenGLContextFormat mGLContextInfo
 
int mVertexAttribCount
 
int mTextureImageUnitCount
 
int mTextureCoordCount
 
bool mMouseVisible
 
bool mContinuousUpdate
 
bool mIgnoreNextMouseMoveEvent
 
bool mFullscreen
 
bool mHasDoubleBuffer
 
bool mIsInitialized
 
std::string mExtensions
 
RenderStateSlot mDefaultRenderStates [RS_RenderStateCount]
 
ref< NaryQuickMap< EEnable, EEnable, EN_EnableCount > > mCurrentEnableSet
 
ref< NaryQuickMap< EEnable, EEnable, EN_EnableCount > > mNewEnableSet
 
ref< NaryQuickMap< ERenderState, RenderStateSlot, RS_RenderStateCount > > mCurrentRenderStateSet
 
ref< NaryQuickMap< ERenderState, RenderStateSlot, RS_RenderStateCount > > mNewRenderStateSet
 
ETextureDimension mTexUnitBinding [VL_MAX_TEXTURE_IMAGE_UNITS]
 
ref< GLSLProgrammGLSLProgram
 
bool mGLSLUpdated
 
const IVertexAttribSetmCurVAS
 
VertexArrayInfo mVertexArray
 
VertexArrayInfo mNormalArray
 
VertexArrayInfo mColorArray
 
VertexArrayInfo mSecondaryColorArray
 
VertexArrayInfo mFogArray
 
VertexArrayInfo mTexCoordArray [VA_MaxTexCoordCount]
 
VertexArrayInfo mVertexAttrib [VA_MaxAttribCount]
 
fvec3 mNormal
 
fvec4 mColor
 
fvec3 mSecondaryColor
 
fvec4 mVertexAttribValue [VA_MaxAttribCount]
 
GLuint mDefaultVAO
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Static Protected Attributes

static CString mClassName
 

Additional Inherited Members

- Static Public Member Functions inherited from vl::OpenGLContext
static bool areUniformsColliding (const UniformSet *u1, const UniformSet *u2)
 Returns true if the two UniformSet contain at least one Uniform variable with the same name. More...
 

Detailed Description

The MFCWindow class is an MFC CWnd with the functionalities of a Win32Context.

Definition at line 47 of file MFCWindow.hpp.

Constructor & Destructor Documentation

◆ MFCWindow()

vlMFC::MFCWindow::MFCWindow ( )
inline

Definition at line 50 of file MFCWindow.hpp.

References vl::Object::setAutomaticDelete().

◆ ~MFCWindow()

MFCWindow::~MFCWindow ( )
virtual

Definition at line 82 of file MFCWindow.cpp.

Member Function Documentation

◆ countAndCapture()

void MFCWindow::countAndCapture ( )
protected

Definition at line 175 of file MFCWindow.cpp.

◆ countAndRelease()

void MFCWindow::countAndRelease ( )
protected

Definition at line 182 of file MFCWindow.cpp.

◆ destroyGLContext()

void MFCWindow::destroyGLContext ( )
protected

Definition at line 111 of file MFCWindow.cpp.

References NULL.

◆ hwnd()

HWND vlMFC::MFCWindow::hwnd ( ) const
inlinevirtual

Returns the Win32 window handle.

Implements vlWin32::Win32Context.

Definition at line 58 of file MFCWindow.hpp.

◆ initMFCWindow()

bool MFCWindow::initMFCWindow ( CWnd *  parent,
MFCWindow share_context,
const vl::String title,
const vl::OpenGLContextFormat fmt,
int  x = 0,
int  y = 0,
int  width = 640,
int  height = 480 
)

Creates the window and initializes the OpenGL rendering context.

Definition at line 94 of file MFCWindow.cpp.

References vlWin32::Win32Context::hglrc(), and NULL.

◆ OnCreate()

int MFCWindow::OnCreate ( LPCREATESTRUCT  lpCreateStruct)

Definition at line 87 of file MFCWindow.cpp.

◆ OnDestroy()

void MFCWindow::OnDestroy ( )

Definition at line 134 of file MFCWindow.cpp.

◆ OnDropFiles()

void MFCWindow::OnDropFiles ( HDROP  hDropInfo)

Definition at line 257 of file MFCWindow.cpp.

◆ OnKeyDown()

void MFCWindow::OnKeyDown ( UINT  nChar,
UINT  nRepCnt,
UINT  nFlags 
)

Definition at line 159 of file MFCWindow.cpp.

References vl::Key_None, and vlWin32::translateKeyEvent().

◆ OnKeyUp()

void MFCWindow::OnKeyUp ( UINT  nChar,
UINT  nRepCnt,
UINT  nFlags 
)

Definition at line 167 of file MFCWindow.cpp.

References vl::Key_None, and vlWin32::translateKeyEvent().

◆ OnLButtonDblClk()

void MFCWindow::OnLButtonDblClk ( UINT  nFlags,
CPoint  point 
)

Definition at line 192 of file MFCWindow.cpp.

References vl::LeftButton.

◆ OnLButtonDown()

void MFCWindow::OnLButtonDown ( UINT  nFlags,
CPoint  point 
)

Definition at line 198 of file MFCWindow.cpp.

References vl::LeftButton.

◆ OnLButtonUp()

void MFCWindow::OnLButtonUp ( UINT  nFlags,
CPoint  point 
)

Definition at line 204 of file MFCWindow.cpp.

References vl::LeftButton.

◆ OnMButtonDblClk()

void MFCWindow::OnMButtonDblClk ( UINT  nFlags,
CPoint  point 
)

Definition at line 210 of file MFCWindow.cpp.

References vl::MiddleButton.

◆ OnMButtonDown()

void MFCWindow::OnMButtonDown ( UINT  nFlags,
CPoint  point 
)

Definition at line 216 of file MFCWindow.cpp.

References vl::MiddleButton.

◆ OnMButtonUp()

void MFCWindow::OnMButtonUp ( UINT  nFlags,
CPoint  point 
)

Definition at line 222 of file MFCWindow.cpp.

References vl::MiddleButton.

◆ OnMouseMove()

void MFCWindow::OnMouseMove ( UINT  nFlags,
CPoint  point 
)

Definition at line 228 of file MFCWindow.cpp.

◆ OnMouseWheel()

BOOL MFCWindow::OnMouseWheel ( UINT  nFlags,
short  zDelta,
CPoint  pt 
)

Definition at line 233 of file MFCWindow.cpp.

◆ OnPaint()

void MFCWindow::OnPaint ( )

Definition at line 140 of file MFCWindow.cpp.

References NULL.

◆ OnRButtonDblClk()

void MFCWindow::OnRButtonDblClk ( UINT  nFlags,
CPoint  point 
)

Definition at line 239 of file MFCWindow.cpp.

References vl::RightButton.

◆ OnRButtonDown()

void MFCWindow::OnRButtonDown ( UINT  nFlags,
CPoint  point 
)

Definition at line 245 of file MFCWindow.cpp.

References vl::RightButton.

◆ OnRButtonUp()

void MFCWindow::OnRButtonUp ( UINT  nFlags,
CPoint  point 
)

Definition at line 251 of file MFCWindow.cpp.

References vl::RightButton.

◆ OnSize()

void MFCWindow::OnSize ( UINT  nType,
int  cx,
int  cy 
)

Definition at line 272 of file MFCWindow.cpp.

Member Data Documentation

◆ mClassName

CString MFCWindow::mClassName
staticprotected

Definition at line 93 of file MFCWindow.hpp.

◆ mMouseDownCount

int vlMFC::MFCWindow::mMouseDownCount
protected

Definition at line 92 of file MFCWindow.hpp.


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