|
nux-1.14.0
|
Classes | |
| struct | _DndSourceFuncs |
Public Types | |
| typedef void(* | GrabReleaseCallback )(bool replaced, void *user_data) |
| typedef void(* | GrabReleaseCallback )(bool replaced, void *user_data) |
|
typedef struct nux::GraphicsDisplay::_DndSourceFuncs | DndSourceFuncs |
Public Member Functions | |
| bool | IsGfxInterfaceCreated () |
| bool | CreateOpenGLWindow (const TCHAR *WindowTitle, unsigned int WindowWidth, unsigned int WindowHeight, WindowStyle Style, const GraphicsDisplay *Parent, bool FullscreenFlag=false, bool create_rendering_data=true) |
| Create a window with and OpenGL context. | |
| bool | CreateFromOpenGLWindow (HWND WindowHandle, HDC WindowDCHandle, HGLRC OpenGLRenderingContext) |
| Create a GLWindow from a window and device context. | |
| void | DestroyOpenGLWindow () |
| void | SetWindowTitle (const TCHAR *Title) |
| void | SetWindowSize (int width, int height) |
| void | SetViewPort (int x, int y, int width, int height) |
| Point | GetMouseScreenCoord () |
| Point | GetMouseWindowCoord () |
| Point | GetWindowCoord () |
| Rect | GetWindowGeometry () |
| Rect | GetNCWindowGeometry () |
| void | MakeGLContextCurrent (bool b=true) |
| void | SwapBuffer (bool glswap=true) |
| void | GetSystemEvent (Event *evt) |
| Event & | GetCurrentEvent () |
| bool | isWindowMinimized () const |
| void | ShowWindow () |
| void | HideWindow () |
| bool | IsWindowVisible () |
| void | EnterMaximizeWindow () |
| void | ExitMaximizeWindow () |
| HWND | GetWindowHandle () const |
| HWND | GetParentWindowHandle () const |
| HDC | GetWindowHDC () const |
| bool | IsChildWindow () const |
| bool | HasVSyncSwapControl () const |
| void | EnableVSyncSwapControl () |
| void | DisableVSyncSwapControl () |
| float | GetFrameTime () const |
| void | ResetFrameTime () |
| GraphicsEngine * | GetGraphicsEngine () const |
| GpuDevice * | GetGpuDevice () const |
| bool | StartOpenFileDialog (FileDialogOption &fdo) |
| bool | StartSaveFileDialog (FileDialogOption &fdo) |
| bool | StartColorDialog (ColorDialogOption &cdo) |
| void | GetWindowSize (int &w, int &h) |
| int | GetWindowWidth () |
| int | GetWindowHeight () |
| void | ResetWindowSize () |
| Get the window size and reset the GraphicsEngine and GpuDevice accordingly. | |
| bool | HasFrameBufferSupport () |
| void | SetWindowCursor (HCURSOR cursor) |
| HCURSOR | GetWindowCursor () const |
| void | ProcessForeignWin32Event (HWND hWnd, MSG msg, WPARAM wParam, LPARAM lParam, Event *event) |
| LRESULT | ProcessWin32Event (HWND hWnd, t_u32 uMsg, WPARAM wParam, LPARAM lParam) |
| void | PauseThreadGraphicsRendering () |
| Pause graphics rendering. | |
| bool | IsPauseThreadGraphicsRendering () const |
| bool | GrabPointer (GrabReleaseCallback callback, void *data, bool replace_existing) |
| bool | UngrabPointer (void *data) |
| bool | PointerIsGrabbed () |
| bool | GrabKeyboard (GrabReleaseCallback callback, void *data, bool replace_existing) |
| bool | UngrabKeyboard (void *data) |
| bool | KeyboardIsGrabbed () |
| void * | KeyboardGrabData () |
| void * | PointerGrabData () |
| GLEWContext * | GetGLEWContext () |
| WGLEWContext * | GetWGLEWContext () |
| bool | HasXPendingEvent () const |
| Display * | GetX11Display () |
| bool | IsGfxInterfaceCreated () |
| bool | CreateOpenGLWindow (const TCHAR *WindowTitle, unsigned int WindowWidth, unsigned int WindowHeight, WindowStyle Style, const GraphicsDisplay *Parent, bool FullscreenFlag=false, bool create_rendering_data=true) |
| Create a window with and OpenGL context. | |
| bool | CreateFromOpenGLWindow (Display *X11Display, Window X11Window, GLXContext OpenGLContext) |
| Create a GLWindow from a display and window created externally. | |
| void | DestroyOpenGLWindow () |
| void | SetWindowTitle (const TCHAR *Title) |
| void | SetWindowSize (int width, int height) |
| Set the window size. | |
| void | SetWindowPosition (int width, int height) |
| Set the window position. | |
| void | SetViewPort (int x, int y, int width, int height) |
| Set the OpenGL Viewport. | |
| Point | GetMouseScreenCoord () |
| Point | GetMouseWindowCoord () |
| Point | GetWindowCoord () |
| Rect | GetWindowGeometry () |
| Rect | GetNCWindowGeometry () |
| void | MakeGLContextCurrent () |
| void | SwapBuffer (bool glswap=true) |
| void | GetSystemEvent (IEvent *evt) |
| int | GetGlXMajor () const |
| int | GetGlXMinor () const |
| IEvent & | GetCurrentEvent () |
| bool | isWindowMinimized () const |
| void | ShowWindow () |
| void | HideWindow () |
| bool | IsWindowVisible () |
| void | EnterMaximizeWindow () |
| void | ExitMaximizeWindow () |
| Window | GetWindowHandle () const |
| bool | IsChildWindow () const |
| bool | HasVSyncSwapControl () const |
| void | EnableVSyncSwapControl () |
| void | DisableVSyncSwapControl () |
| float | GetFrameTime () const |
| void | ResetFrameTime () |
| GraphicsEngine * | GetGraphicsEngine () const |
| GpuDevice * | GetGpuDevice () const |
| void | GetDesktopSize (int &w, int &h) |
| void | GetWindowSize (int &w, int &h) |
| int | GetWindowWidth () |
| int | GetWindowHeight () |
| void | ResetWindowSize () |
| Get the window size and reset the GraphicsEngine and GpuDevice accordingly. | |
| bool | HasFrameBufferSupport () |
| void | PauseThreadGraphicsRendering () |
| Pause graphics rendering. | |
| bool | IsPauseThreadGraphicsRendering () const |
| void | ProcessForeignX11Event (XEvent *xevent, IEvent *nux_event) |
| void | ProcessXEvent (XEvent xevent, bool foreign) |
| void | RecalcXYPosition (Window TheMainWindow, XEvent xevent, int &x, int &y) |
| void | RecalcXYPosition (int x_root, int y_root, int &x_recalc, int &y_recalc) |
| void | SendDndStatus (bool accept, DndAction action, Rect region) |
| void | SendDndFinished (bool accepted, DndAction performed_action) |
| std::list< char * > | GetDndMimeTypes () |
| char * | GetDndData (char *property) |
| void | StartDndDrag (const DndSourceFuncs &funcs, void *user_data) |
| bool | GrabPointer (GrabReleaseCallback callback, void *data, bool replace_existing) |
| bool | UngrabPointer (void *data) |
| bool | PointerIsGrabbed () |
| bool | GrabKeyboard (GrabReleaseCallback callback, void *data, bool replace_existing) |
| bool | UngrabKeyboard (void *data) |
| bool | KeyboardIsGrabbed () |
| void * | KeyboardGrabData () |
| void * | PointerGrabData () |
| GLEWContext * | GetGLEWContext () |
| GLXEWContext * | GetGLXEWContext () |
| NString | FindResourceLocation (const TCHAR *ResourceFileName, bool ErrorOnFail=false) |
| NString | FindUITextureLocation (const TCHAR *ResourceFileName, bool ErrorOnFail=false) |
| NString | FindShaderLocation (const TCHAR *ResourceFileName, bool ErrorOnFail=false) |
| NString | FindFontLocation (const TCHAR *ResourceFileName, bool ErrorOnFail=false) |
| const std::vector< NString > & | GetFontSearchPath () const |
| const std::vector< NString > & | GetShaderSearchPath () const |
| const std::vector< NString > & | GetUITextureSearchPath () const |
Public Attributes | |
| int | m_num_device_modes |
| Event * | event_ |
| IEvent * | m_pEvent |
Friends | |
| class | GraphicsEngine |
| class | DisplayAccessController |
Definition at line 55 of file GraphicsDisplayWin.h.
| bool nux::GraphicsDisplay::CreateFromOpenGLWindow | ( | HWND | WindowHandle, |
| HDC | WindowDCHandle, | ||
| HGLRC | OpenGLRenderingContext | ||
| ) |
Create a GLWindow from a window and device context.
| WindowHandle | Provided window. |
| WindowDCHandle | Provided device context. |
| OpenGLRenderingContext | And OpenGL rendering context. |
Definition at line 511 of file GraphicsDisplayWin.cpp.
{
// Do not make the opengl context current
// Do not swap the framebuffer
// Do not clear the depth or color buffer
// Do not enable/disable VSync
m_hWnd = WindowHandle;
_device_context = WindowDCHandle;
_opengl_rendering_context = OpenGLRenderingContext;
RECT rect;
::GetClientRect (m_hWnd, &rect);
m_WindowSize = Size (rect.right - rect.left, rect.bottom - rect.top);
m_ViewportSize = Size (rect.right - rect.left, rect.bottom - rect.top);
// The opengl context should be made current by an external entity.
m_GfxInterfaceCreated = true;
m_DeviceFactory = new GpuDevice (m_ViewportSize.width, m_ViewportSize.height, BITFMT_R8G8B8A8,
_device_context,
_opengl_rendering_context);
m_GraphicsContext = new GraphicsEngine (*this);
InitGlobalGrabWindow ();
return true;
}
| bool nux::GraphicsDisplay::CreateFromOpenGLWindow | ( | Display * | X11Display, |
| Window | X11Window, | ||
| GLXContext | OpenGLContext | ||
| ) |
Create a GLWindow from a display and window created externally.
| X11Display | Provided display. |
| X11Window | Provided window. |
Definition at line 523 of file GraphicsDisplayX11.cpp.
{
// Do not make the opengl context current
// Do not swap the framebuffer
// Do not clear the depth or color buffer
// Do not enable/disbale VSync
m_X11Display = X11Display;
m_X11Window = X11Window;
m_GLCtx = OpenGLContext;
m_X11Screen = DefaultScreen (m_X11Display);
Window root_return;
int x_return, y_return;
unsigned int width_return, height_return;
unsigned int border_width_return;
unsigned int depth_return;
XGetGeometry (X11Display, X11Window, &root_return, &x_return, &y_return, &width_return, &height_return, &border_width_return, &depth_return);
m_WindowSize = Size (width_return, height_return);
m_WindowPosition = Point (x_return, y_return);
m_ViewportSize = Size (width_return, height_return);
m_GfxInterfaceCreated = true;
// m_DeviceFactory = new GpuDevice (m_ViewportSize.GetWidth(), m_ViewportSize.GetHeight(), BITFMT_R8G8B8A8);
m_DeviceFactory = new GpuDevice (m_ViewportSize.width, m_ViewportSize.height, BITFMT_R8G8B8A8,
m_X11Display,
m_X11Window,
false,
_fb_config,
m_GLCtx,
1, 0, false);
m_GraphicsContext = new GraphicsEngine (*this);
InitGlobalGrabWindow ();
m_CreatedFromForeignWindow = true;
return true;
}
| bool nux::GraphicsDisplay::CreateOpenGLWindow | ( | const TCHAR * | WindowTitle, |
| unsigned int | WindowWidth, | ||
| unsigned int | WindowHeight, | ||
| WindowStyle | Style, | ||
| const GraphicsDisplay * | Parent, | ||
| bool | FullscreenFlag = false, |
||
| bool | create_rendering_data = true |
||
| ) |
Create a window with and OpenGL context.
| WindowTitle | The window title. |
| WindowWidth | Initial window width. |
| WindowHeight | Initial window height. |
| Style | The window style. |
| ParentWindow | The parent window. |
| FullscreenFlag | Full screen flag. |
Definition at line 167 of file GraphicsDisplayWin.cpp.
Referenced by nux::DisplayAccessController::CreateGLWindow().
{
NScopeLock Scope (&CreateOpenGLWindow_CriticalSection);
RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values
m_GfxInterfaceCreated = false;
// FIXME : put at the end
m_ViewportSize.width = WindowWidth;
m_ViewportSize.height = WindowHeight;
m_WindowSize.width = WindowWidth;
m_WindowSize.height = WindowHeight;
// end of fixme
WindowRect.left = (long) 0;
WindowRect.right = (long) m_ViewportSize.width;
WindowRect.top = (long) 0;
WindowRect.bottom = (long) m_ViewportSize.height;
m_fullscreen = FullscreenFlag; // Set The Global Fullscreen Flag
m_index_of_current_mode = -1; // assume -1 if the mode is not fullscreen
if (m_fullscreen) // Attempt Fullscreen Mode?
{
// check if resolution is supported
bool mode_supported = false;
for (int num_modes = 0 ; num_modes < m_num_gfx_device_modes; num_modes++)
{
if ((m_gfx_device_modes[num_modes].width == m_ViewportSize.width)
&& (m_gfx_device_modes[num_modes].height == m_ViewportSize.height)
&& (m_gfx_device_modes[num_modes].format == m_ScreenBitDepth))
{
mode_supported = true;
m_index_of_current_mode = num_modes;
break;
}
}
if (mode_supported == false)
{
if (inlWin32MessageBox (NULL, TEXT ("Info"), MBTYPE_Ok, MBICON_Information, MBMODAL_ApplicationModal,
TEXT ("The requested fullscreen mode is not supported by your monitor.\nUsing windowed mode instead.") ) == MBRES_Yes)
{
m_fullscreen = FALSE; // Windowed Mode Selected. Fullscreen = FALSE
}
}
DEVMODE dmScreenSettings; // Device Mode
memset (&dmScreenSettings, 0, sizeof (dmScreenSettings)); // Makes Sure Memory's Cleared
dmScreenSettings.dmSize = sizeof (dmScreenSettings); // Size Of The Devmode Structure
dmScreenSettings.dmPelsWidth = m_ViewportSize.width; // Selected Screen Width
dmScreenSettings.dmPelsHeight = m_ViewportSize.height; // Selected Screen Height
dmScreenSettings.dmBitsPerPel = m_ScreenBitDepth; // Selected Bits Per Pixel
dmScreenSettings.dmDisplayFrequency = 60;
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
if (ChangeDisplaySettings (&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
{
if (inlWin32MessageBox (NULL, TEXT ("Info"), MBTYPE_Ok, MBICON_Information, MBMODAL_ApplicationModal,
TEXT ("The requested fullscreen mode is not supported by your monitor.\nUsing windowed mode instead.") ) == MBRES_Yes)
{
m_fullscreen = FALSE; // Windowed Mode Selected. Fullscreen = FALSE
}
else
{
// Pop Up A Message Box Letting User Know The Program Is Closing.
MessageBox (NULL, "Program Will Now Close.", "ERROR", MB_OK | MB_ICONSTOP);
}
}
}
m_dwExStyle = 0;
m_dwStyle = 0;
if (m_fullscreen) // Are We Still In Fullscreen Mode?
{
m_dwExStyle = WS_EX_APPWINDOW; // Window Extended Style
m_dwStyle = WS_POPUP; // Windows Style
ShowCursor (FALSE); // Hide Mouse Pointer
}
else
{
// Window Extended Style
m_dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
// Windows Style
m_dwStyle = WS_OVERLAPPED; // Creates an overlapped window. An overlapped window has a title bar and a border
// See Win32 Window Hierarchy and Styles: http://msdn.microsoft.com/en-us/library/ms997562.aspx
//WS_EX_APPWINDOW // Forces a top-level window onto the taskbar when the window is visible
//WS_EX_WINDOWEDGE // Specifies that a window has a border with a raised edge
//WS_POPUP // Creates a pop-up window. This style cannot be used with the WS_CHILD style.
//WS_SYSMENU // Creates a window that has a window menu on its title bar. The WS_CAPTION style must also be specified.
//WS_SIZEBOX // Creates a window that has a sizing border. Same as the WS_THICKFRAME style.
//WS_CAPTION // Creates a window that has a title bar (includes the WS_BORDER style).
m_Style = Style;
if (Style == WINDOWSTYLE_TOOL)
{
m_dwExStyle = WS_EX_TOOLWINDOW;
m_dwStyle = WS_CAPTION | WS_SYSMENU;
}
else if (Style == WINDOWSTYLE_DIALOG)
{
m_dwExStyle = WS_EX_DLGMODALFRAME;
m_dwStyle = WS_CAPTION | WS_SYSMENU;
}
else if (Style == WINDOWSTYLE_NOBORDER)
{
m_dwExStyle = WS_EX_TOPMOST | WS_EX_TOOLWINDOW;
m_dwStyle = WS_POPUP;
}
else if (Style == WINDOWSTYLE_PANEL)
{
m_dwExStyle = 0; // Specifies that a window has a border with a raised edge
m_dwStyle = WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SIZEBOX;
}
else
{
// Normal Window: NormalWindow
m_dwExStyle = WS_EX_APPWINDOW | // Forces a top-level window onto the taskbar when the window is visible
WS_EX_WINDOWEDGE; // Specifies that a window has a border with a raised edge
m_dwStyle |= WS_CAPTION | // Creates a window that has a title bar.
WS_SYSMENU | // Creates a window that has a window menu on its title bar. The WS_CAPTION style must also be specified.
WS_THICKFRAME | // Creates a window that has a sizing border.
WS_MINIMIZEBOX | // Creates a window that has a minimize button.
WS_MAXIMIZEBOX | // Creates a window that has a maximize button.
WS_BORDER; // Creates a window that has a thin-line border.
}
}
// The AdjustWindowRectEx function calculates the required size of the window rectangle,
// based on the desired size of the client rectangle. The window rectangle can then be passed to
// the CreateWindowEx function to create a window whose client area is the desired size.
AdjustWindowRectEx (&WindowRect, m_dwStyle, FALSE, m_dwExStyle); // Adjust Window To True Requested Size
RECT rect;
rect.top = 0;
rect.bottom = WindowRect.bottom - WindowRect.top;
rect.left = 0;
rect.right = WindowRect.right - WindowRect.left;
int WindowX = 0;
int WindowY = 0;
if (Parent)
{
m_ParentWindow = Parent->GetWindowHandle();
GetWindowRect (m_ParentWindow, &rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
WindowX = rect.left + (width - (WindowRect.right - WindowRect.left) ) / 2;
WindowY = rect.top + (height - (WindowRect.bottom - WindowRect.top) ) / 2;
}
else if (!m_fullscreen)
{
ClipOrCenterRectToMonitor (&rect, 0);
WindowX = rect.left;
WindowY = rect.top;
}
m_WindowTitle = WindowTitle;
// Create The Window
if (! (m_hWnd = ::CreateWindowEx (m_dwExStyle, // Extended Style For The Window
WINDOW_CLASS_NAME, // Class Name
m_WindowTitle.GetTCharPtr(), // Window Title
m_dwStyle | // Defined Window Style
WS_CLIPSIBLINGS | // Required Window Style
WS_CLIPCHILDREN, // Required Window Style
WindowX, WindowY, // Window Position
WindowRect.right - WindowRect.left, // Calculate Window Width
WindowRect.bottom - WindowRect.top, // Calculate Window Height
m_ParentWindow, // No Parent Window
NULL, // No Menu
gGLWindowManager.GetInstance(), // Instance
NULL) ) ) // Dont Pass Anything To WM_CREATE
{
DestroyOpenGLWindow();
MessageBox (NULL, TEXT ("Window Creation Error."), TEXT ("ERROR"), MB_OK | MB_ICONERROR);
// Return FALSE
}
static PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
{
sizeof (PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
24, // cColorBits
// Specifies the number of color bitplanes in each color buffer.
// For RGBA pixel types, it is the size of the color buffer, excluding the alpha bitplanes.
// For color-index pixels, it is the size of the color-index buffer.
0, // cRedBits
// Specifies the number of red bitplanes in each RGBA color buffer.
0, // cRedShift
// Specifies the shift count for red bitplanes in each RGBA color buffer.
0, // cGreenBits
// Specifies the number of green bitplanes in each RGBA color buffer.
0, // cGreenShift
// Specifies the shift count for green bitplanes in each RGBA color buffer.
0, // cBlueBits
// Specifies the number of blue bitplanes in each RGBA color buffer.
0, // cBlueShift
// Specifies the shift count for blue bitplanes in each RGBA color buffer.
0, // cAlphaBits
// Specifies the number of alpha bitplanes in each RGBA color buffer. Alpha bitplanes are not supported.
0, // cAlphaShift
// Specifies the shift count for alpha bitplanes in each RGBA color buffer. Alpha bitplanes are not supported.
0, // cAccumBits
// Specifies the total number of bitplanes in the accumulation buffer.
0, // cAccumRedBits
// Specifies the number of red bitplanes in the accumulation buffer.
0, // cAccumGreenBits
// Specifies the number of green bitplanes in the accumulation buffer.
0, // cAccumBlueBits
// Specifies the number of blue bitplanes in the accumulation buffer.
0, // cAccumAlphaBits
// Specifies the number of alpha bitplanes in the accumulation buffer.
24,// cDepthBits
// Specifies the depth of the depth (z-axis) buffer.
8, // cStencilBits
// Specifies the depth of the stencil buffer.
0, // cAuxBuffers
// Specifies the number of auxiliary buffers. Auxiliary buffers are not supported.
PFD_MAIN_PLANE, // iLayerType
// Ignored. Earlier implementations of OpenGL used this member, but it is no longer used.
0, // bReserved
// Specifies the number of overlay and underlay planes. Bits 0 through 3 specify up to 15 overlay planes and bits 4 through 7 specify up to 15 underlay planes.
0, // dwLayerMask
// Ignored. Earlier implementations of OpenGL used this member, but it is no longer used.
0, // dwVisibleMask
// Specifies the transparent color or index of an underlay plane. When the pixel type is RGBA, dwVisibleMask is a transparent RGB color value. When the pixel type is color index, it is a transparent index value.
0, // dwDamageMask
// Ignored. Earlier implementations of OpenGL used this member, but it is no longer used.
};
if (! (_device_context = GetDC (m_hWnd) ) ) // Did We Get A Device Context?
{
DestroyOpenGLWindow();
MessageBox (NULL, TEXT ("Can't Create A GL Device Context."), TEXT ("ERROR"), MB_OK | MB_ICONERROR);
return FALSE;
}
if (! (m_PixelFormat = ChoosePixelFormat (_device_context, &pfd) ) ) // Did Windows Find A Matching Pixel Format?
{
DestroyOpenGLWindow();
MessageBox (NULL, TEXT ("Can't Find A Suitable PixelFormat."), TEXT ("ERROR"), MB_OK | MB_ICONERROR);
return FALSE;
}
if (!SetPixelFormat (_device_context, m_PixelFormat, &pfd) ) // Are We Able To Set The Pixel Format?
{
DestroyOpenGLWindow();
MessageBox (NULL, TEXT ("Can't Set The PixelFormat."), TEXT ("ERROR"), MB_OK | MB_ICONERROR);
return FALSE;
}
if (! (_opengl_rendering_context = wglCreateContext (_device_context) ) ) // Are We Able To Get A Rendering Context?
{
DestroyOpenGLWindow();
MessageBox (NULL, TEXT ("Can't Create A GL Rendering Context."), TEXT ("ERROR"), MB_OK | MB_ICONERROR);
return FALSE;
}
if (sMainGLRC == 0)
{
sMainGLRC = _opengl_rendering_context;
sMainDC = _device_context;
}
else
{
// wglMakeCurrent(_device_context, 0);
// // Make the newly created context share it resources with all the other OpenGL context
// if(wglShareLists(sMainGLRC, _opengl_rendering_context) == FALSE)
// {
// DWORD err = GetLastError();
// DestroyOpenGLWindow();
// MessageBox(NULL, TEXT("Can't share GL context."), TEXT("ERROR"), MB_OK|MB_ICONERROR);
// return FALSE;
// }
}
// This creates a warning. It is a 64-bits compatibility issue.
// When not in 64-bit you can disable the warning:
// Project Properties --> C/C++ tab --> General --> Select "NO" for - Detect 64-bit Portability Issues.
// See also SetWindowLongPtr
SetWindowLongPtr (m_hWnd, GWLP_USERDATA, (NUX_PTRSIZE_LONG) this);
//::ShowWindow(m_hWnd,SW_SHOW); // Show The Window
::SetForegroundWindow (m_hWnd); // Slightly Higher Priority
::SetFocus (m_hWnd); // Sets Keyboard Focus To The Window
MakeGLContextCurrent();
glClearColor (0.0, 0.0, 0.0, 0.0);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
SwapBuffer();
m_GfxInterfaceCreated = true;
//m_GLEWContext = new GLEWContext();
//m_WGLEWContext = new WGLEWContext();
HGLRC new_opengl_rendering_context = _opengl_rendering_context;
m_DeviceFactory = new GpuDevice (m_ViewportSize.width, m_ViewportSize.height, BITFMT_R8G8B8A8,
_device_context,
new_opengl_rendering_context,
1, 0, false);
if (new_opengl_rendering_context != 0)
{
_opengl_rendering_context = new_opengl_rendering_context;
}
m_GraphicsContext = new GraphicsEngine (*this, create_rendering_data);
//EnableVSyncSwapControl();
//DisableVSyncSwapControl();
InitGlobalGrabWindow ();
return true;
}
| bool nux::GraphicsDisplay::CreateOpenGLWindow | ( | const TCHAR * | WindowTitle, |
| unsigned int | WindowWidth, | ||
| unsigned int | WindowHeight, | ||
| WindowStyle | Style, | ||
| const GraphicsDisplay * | Parent, | ||
| bool | FullscreenFlag = false, |
||
| bool | create_rendering_data = true |
||
| ) |
Create a window with and OpenGL context.
| WindowTitle | The window title. |
| WindowWidth | Initial window width. |
| WindowHeight | Initial window height. |
| Style | The window style. |
| ParentWindow | The parent window. |
| FullscreenFlag | Full screen flag. |
| void nux::GraphicsDisplay::PauseThreadGraphicsRendering | ( | ) |
Pause graphics rendering.
Pause graphics rendering. This function also sets the current openGL context to 0 for this window. This is useful while a child window is being created and is sharing openGL objects with this context. For wglShareLists to work, both OpenGL context must be set to 0 in their respective thread. Send NUX_THREADMSG_START_RENDERING (PostThreadMessage) to this window to reactivate rendering.
Never call this function while doing rendering. Call it only when processing events.
Definition at line 2365 of file GraphicsDisplayWin.cpp.
{
m_PauseGraphicsRendering = true;
MakeGLContextCurrent (false);
}
| void nux::GraphicsDisplay::PauseThreadGraphicsRendering | ( | ) |
Pause graphics rendering.
Pause graphics rendering. This function also sets the current openGL context to 0 for this window. This is useful while a child window is being created and is sharing openGL objects with this context. For wglShareLists to work, both OpenGL context must be set to 0 in their respective thread. Send NUX_THREADMSG_START_RENDERING (PostThreadMessage) to this window to reactivate rendering.
Never call this function while doing rendering. Call it only when processing events.
| void nux::GraphicsDisplay::ResetWindowSize | ( | ) |
Get the window size and reset the GraphicsEngine and GpuDevice accordingly.
This is a passive way to set the window size through out the NuxGraphics system. This call gets the current window size and sets its accordingly to all sub-system.
| void nux::GraphicsDisplay::ResetWindowSize | ( | ) |
Get the window size and reset the GraphicsEngine and GpuDevice accordingly.
This is a passive way to set the window size through out the NuxGraphics system. This call gets the current window size and sets its accordingly to all sub-system.
Definition at line 577 of file GraphicsDisplayWin.cpp.
{
RECT rect;
::GetClientRect (m_hWnd, &rect);
m_WindowSize = Size (rect.right - rect.left, rect.bottom - rect.top);
m_ViewportSize = Size (rect.right - rect.left, rect.bottom - rect.top);
}
| void nux::GraphicsDisplay::SetWindowSize | ( | int | width, |
| int | height | ||
| ) |
Set the window size.
Actively set the window size to the provided parameters.