summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-03-17 05:13:12 +0100
committerMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-03-17 08:13:49 +0100
commit3aa298e010ebee976a889a0094f14f09a7151c3a (patch)
treeef1cbf9a8bb31ce463d93b8123b48305e0435f9e /chart2
parent40ea5e9dd0eff66728d1d2d7aac41349a14de594 (diff)
move the windows multisample code to OpenGLContext
Change-Id: I531d058ff00b3b6eaf2bf7c889589058b1be7bd0
Diffstat (limited to 'chart2')
-rwxr-xr-xchart2/source/view/main/OpenGLRender.cxx201
-rwxr-xr-xchart2/source/view/main/OpenGLRender.hxx9
2 files changed, 0 insertions, 210 deletions
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index f97f50619b56..6f86dee459ee 100755
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -771,207 +771,6 @@ void OpenGLRender::SetLine2DWidth(int width)
m_fLineWidth = std::max((float)width / OPENGL_SCALE_VALUE, 0.001f);
}
-#if defined( _WIN32 )
-static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- switch (message)
- {
- case WM_CREATE:
- return 0;
- case WM_CLOSE:
- PostQuitMessage(0);
- return 0;
- case WM_DESTROY:
- return 0;
- case WM_KEYDOWN:
- switch(wParam)
- {
- case VK_ESCAPE:
- PostQuitMessage(0);
- return 0;
-
- case VK_SPACE:
- break;
- }
- default:
- return DefWindowProc(hwnd, message, wParam, lParam);
- }
-}
-
-bool OpenGLRender::InitMultisample(PIXELFORMATDESCRIPTOR pfd)
-{
- HWND hWnd = NULL;
- //create a temp windwo to check whether support multi-sample, if support, get the format
- if (InitTempWindow(&hWnd, m_iWidth, m_iHeight, pfd) < 0)
- {
- SAL_WARN("chart2.opengl", "Can't create temp window to test");
- return false;
- }
-
- // See If The String Exists In WGL!
- if (!WGLisExtensionSupported("WGL_ARB_multisample"))
- {
- mbArbMultisampleSupported = false;
- SAL_WARN("chart2.opengl", "Device doesn't support multi sample");
- return false;
- }
- // Get Our Pixel Format
- PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
- if (!wglChoosePixelFormatARB)
- {
- mbArbMultisampleSupported = false;
- return false;
- }
- // Get Our Current Device Context
- HDC hDC = GetDC(hWnd);
-
- int pixelFormat;
- int valid;
- UINT numFormats;
- float fAttributes[] = {0,0};
- // These Attributes Are The Bits We Want To Test For In Our Sample
- // Everything Is Pretty Standard, The Only One We Want To
- // Really Focus On Is The SAMPLE BUFFERS ARB And WGL SAMPLES
- // These Two Are Going To Do The Main Testing For Whether Or Not
- // We Support Multisampling On This Hardware.
- int iAttributes[] =
- {
- WGL_DRAW_TO_WINDOW_ARB,GL_TRUE,
- WGL_SUPPORT_OPENGL_ARB,GL_TRUE,
- WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB,
- WGL_COLOR_BITS_ARB,24,
- WGL_ALPHA_BITS_ARB,8,
- WGL_DEPTH_BITS_ARB,16,
- WGL_STENCIL_BITS_ARB,0,
- WGL_DOUBLE_BUFFER_ARB,GL_TRUE,
- WGL_SAMPLE_BUFFERS_ARB,GL_TRUE,
- WGL_SAMPLES_ARB,8,
- 0,0
- };
- // First We Check To See If We Can Get A Pixel Format For 4 Samples
- valid = wglChoosePixelFormatARB(hDC, iAttributes, fAttributes, 1, &pixelFormat, &numFormats);
- // If We Returned True, And Our Format Count Is Greater Than 1
- if (valid && numFormats >= 1)
- {
- mbArbMultisampleSupported = true;
- m_iArbMultisampleFormat = pixelFormat;
- wglMakeCurrent(NULL, NULL);
- wglDeleteContext(glWin.hRC);
- ReleaseDC(hWnd, glWin.hDC);
- DestroyWindow(hWnd);
- return mbArbMultisampleSupported;
- }
- // Our Pixel Format With 4 Samples Failed, Test For 2 Samples
- iAttributes[19] = 2;
- valid = wglChoosePixelFormatARB(hDC, iAttributes, fAttributes, 1, &pixelFormat, &numFormats);
- if (valid && numFormats >= 1)
- {
- mbArbMultisampleSupported = true;
- m_iArbMultisampleFormat = pixelFormat;
- wglMakeCurrent(NULL, NULL);
- wglDeleteContext(glWin.hRC);
- ReleaseDC(hWnd, glWin.hDC);
- DestroyWindow(hWnd);
- return mbArbMultisampleSupported;
- }
- // Return The Valid Format
- wglMakeCurrent(NULL, NULL);
- wglDeleteContext(glWin.hRC);
- ReleaseDC(hWnd, glWin.hDC);
- DestroyWindow(hWnd);
- return mbArbMultisampleSupported;
-}
-
-bool OpenGLRender::GetMSAASupport()
-{
- return mbArbMultisampleSupported;
-}
-
-int OpenGLRender::GetMSAAFormat()
-{
- return m_iArbMultisampleFormat;
-}
-
-//TODO: moggi: why the hell do we need another implementation here?
-int OpenGLRender::InitTempWindow(HWND *hwnd, int width, int height, PIXELFORMATDESCRIPTOR inPfd)
-{
- PIXELFORMATDESCRIPTOR pfd = inPfd;
- int pfmt;
- int ret;
- WNDCLASS wc;
- wc.style = 0;
- wc.lpfnWndProc = WndProc;
- wc.cbClsExtra = wc.cbWndExtra = 0;
- wc.hInstance = NULL;
- wc.hIcon = NULL;
- wc.hCursor = NULL;
- wc.hbrBackground = NULL;
- wc.lpszMenuName = NULL;
- wc.lpszClassName = (LPCSTR)"GLRenderer";
- RegisterClass(&wc);
- *hwnd = CreateWindow(wc.lpszClassName, NULL, WS_DISABLED, 0, 0, width, height, NULL, NULL, wc.hInstance, NULL);
- glWin.hDC = GetDC(*hwnd);
- pfmt = ChoosePixelFormat(glWin.hDC, &pfd);
- if (!pfmt)
- {
- return -1;
- }
- ret = SetPixelFormat(glWin.hDC, pfmt, &pfd);
- if(!ret)
- {
- return -1;
- }
- glWin.hRC = wglCreateContext(glWin.hDC);
- if(!(glWin.hRC))
- {
- return -1;
- }
- ret = wglMakeCurrent(glWin.hDC, glWin.hRC);
- if(!ret)
- {
- return -1;
- }
- return 0;
-}
-
-bool OpenGLRender::WGLisExtensionSupported(const char *extension)
-{
- const size_t extlen = strlen(extension);
- const char *supported = NULL;
-
- // Try To Use wglGetExtensionStringARB On Current DC, If Possible
- PROC wglGetExtString = wglGetProcAddress("wglGetExtensionsStringARB");
-
- if (wglGetExtString)
- supported = ((char*(__stdcall*)(HDC))wglGetExtString)(wglGetCurrentDC());
- // If That Failed, Try Standard Opengl Extensions String
- if (supported == NULL)
- supported = (char*)glGetString(GL_EXTENSIONS);
- // If That Failed Too, Must Be No Extensions Supported
- if (supported == NULL)
- return 0;
-
- // Begin Examination At Start Of String, Increment By 1 On False Match
- for (const char* p = supported; ; p++)
- {
- // Advance p Up To The Next Possible Match
- p = strstr(p, extension);
-
- if (p == NULL)
- return 0; // No Match
-
- // Make Sure That Match Is At The Start Of The String Or That
- // The Previous Char Is A Space, Or Else We Could Accidentally
- // Match "wglFunkywglExtension" With "wglExtension"
-
- // Also, Make Sure That The Following Character Is Space Or NULL
- // Or Else "wglExtensionTwo" Might Match "wglExtension"
- if ((p==supported || p[-1]==' ') && (p[extlen]=='\0' || p[extlen]==' '))
- return 1; // Match
- }
-}
-#endif
-
void OpenGLRender::SetColor(sal_uInt32 color, sal_uInt8 nAlpha)
{
sal_uInt8 r = (color & 0x00FF0000) >> 16;
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index 8140bf9adf3b..725e32ef2a15 100755
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -79,11 +79,6 @@ public:
void SetLine2DColor(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b, sal_uInt8 nAlpha);
void SetLine2DWidth(int width);
BitmapEx GetAsBitmap();
-#if defined( _WIN32 )
- bool InitMultisample(PIXELFORMATDESCRIPTOR pfd);
- bool GetMSAASupport();
- int GetMSAAFormat();
-#endif
void SetColor(sal_uInt32 color, sal_uInt8 nAlpha);
int Bubble2DShapePoint(float x, float y, float directionX, float directionY);
int RenderBubble2FBO(int wholeFlag);
@@ -117,10 +112,6 @@ private:
int CreateTextureObj(int width, int height);
int CreateRenderObj(int width, int height);
int CreateFrameBufferObj();
-#if defined( _WIN32 )
- int InitTempWindow(HWND *hwnd, int width, int height, PIXELFORMATDESCRIPTOR inPfd);
- bool WGLisExtensionSupported(const char *extension);
-#endif
int CreateMultiSampleFrameBufObj();
int Create2DCircle(int detail);