Kaydet (Commit) 1ca25043 authored tarafından Markus Mohrhard's avatar Markus Mohrhard Kaydeden (comit) Markus Mohrhard

support rendering to memory device contexts on Windows

Change-Id: I91fdd429663fae76bfe17d37de86d118621cf160
üst d9fff953
...@@ -156,6 +156,7 @@ public: ...@@ -156,6 +156,7 @@ public:
void requestLegacyContext(); void requestLegacyContext();
void requestSingleBufferedRendering(); void requestSingleBufferedRendering();
void requestVirtualDevice();
bool init(vcl::Window* pParent = 0); bool init(vcl::Window* pParent = 0);
bool init(SystemChildWindow* pChildWindow); bool init(SystemChildWindow* pChildWindow);
...@@ -211,6 +212,7 @@ private: ...@@ -211,6 +212,7 @@ private:
bool mbInitialized; bool mbInitialized;
bool mbRequestLegacyContext; bool mbRequestLegacyContext;
bool mbUseDoubleBufferedRendering; bool mbUseDoubleBufferedRendering;
bool mbRequestVirtualDevice;
}; };
#endif #endif
......
...@@ -37,7 +37,8 @@ OpenGLContext::OpenGLContext(): ...@@ -37,7 +37,8 @@ OpenGLContext::OpenGLContext():
m_pChildWindow(NULL), m_pChildWindow(NULL),
mbInitialized(false), mbInitialized(false),
mbRequestLegacyContext(false), mbRequestLegacyContext(false),
mbUseDoubleBufferedRendering(true) mbUseDoubleBufferedRendering(true),
mbRequestVirtualDevice(false)
{ {
} }
...@@ -77,6 +78,11 @@ void OpenGLContext::requestSingleBufferedRendering() ...@@ -77,6 +78,11 @@ void OpenGLContext::requestSingleBufferedRendering()
mbUseDoubleBufferedRendering = false; mbUseDoubleBufferedRendering = false;
} }
void OpenGLContext::requestVirtualDevice()
{
mbRequestVirtualDevice = true;
}
#if defined( _WIN32 ) #if defined( _WIN32 )
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
...@@ -182,7 +188,8 @@ bool WGLisExtensionSupported(const char *extension) ...@@ -182,7 +188,8 @@ bool WGLisExtensionSupported(const char *extension)
} }
} }
bool InitMultisample(PIXELFORMATDESCRIPTOR pfd, int& rPixelFormat, bool bUseDoubleBufferedRendering) bool InitMultisample(PIXELFORMATDESCRIPTOR pfd, int& rPixelFormat,
bool bUseDoubleBufferedRendering, bool bRequestVirtualDevice)
{ {
HWND hWnd = NULL; HWND hWnd = NULL;
GLWindow glWin; GLWindow glWin;
...@@ -235,6 +242,11 @@ bool InitMultisample(PIXELFORMATDESCRIPTOR pfd, int& rPixelFormat, bool bUseDoub ...@@ -235,6 +242,11 @@ bool InitMultisample(PIXELFORMATDESCRIPTOR pfd, int& rPixelFormat, bool bUseDoub
if (!bUseDoubleBufferedRendering) if (!bUseDoubleBufferedRendering)
iAttributes[1] = GL_FALSE; iAttributes[1] = GL_FALSE;
if (bRequestVirtualDevice)
{
iAttributes[2] = WGL_DRAW_TO_BITMAP_ARB;
}
bool bArbMultisampleSupported = true; bool bArbMultisampleSupported = true;
// First We Check To See If We Can Get A Pixel Format For 4 Samples // First We Check To See If We Can Get A Pixel Format For 4 Samples
...@@ -589,9 +601,7 @@ bool OpenGLContext::ImplInit() ...@@ -589,9 +601,7 @@ bool OpenGLContext::ImplInit()
{ {
sizeof(PIXELFORMATDESCRIPTOR), sizeof(PIXELFORMATDESCRIPTOR),
1, // Version Number 1, // Version Number
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL,
PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA, // Request An RGBA Format PFD_TYPE_RGBA, // Request An RGBA Format
(BYTE)32, // Select Our Color Depth (BYTE)32, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, 0, 0, 0, 0, 0, // Color Bits Ignored
...@@ -607,9 +617,18 @@ bool OpenGLContext::ImplInit() ...@@ -607,9 +617,18 @@ bool OpenGLContext::ImplInit()
0, 0, 0 // Layer Masks Ignored 0, 0, 0 // Layer Masks Ignored
}; };
if (mbUseDoubleBufferedRendering)
PixelFormatFront.dwFlags |= PFD_DOUBLEBUFFER;
if (mbRequestVirtualDevice)
PixelFormatFront.dwFlags |= PFD_DRAW_TO_BITMAP;
else
PixelFormatFront.dwFlags |= PFD_DRAW_TO_WINDOW;
// we must check whether can set the MSAA // we must check whether can set the MSAA
int WindowPix = 0; int WindowPix = 0;
bool bMultiSampleSupport = InitMultisample(PixelFormatFront, WindowPix, mbUseDoubleBufferedRendering); bool bMultiSampleSupport = InitMultisample(PixelFormatFront, WindowPix,
mbUseDoubleBufferedRendering, mbRequestVirtualDevice);
if (bMultiSampleSupport && WindowPix != 0) if (bMultiSampleSupport && WindowPix != 0)
{ {
m_aGLWin.bMultiSampleSupported = true; m_aGLWin.bMultiSampleSupported = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment