From 3bf9df6b2785fa6d951086978a3e66f49427166a Mon Sep 17 00:00:00 2001 From: FluorescentCIAAfricanAmerican <0934gj3049fk@protonmail.com> Date: Wed, 22 Apr 2020 12:56:21 -0400 Subject: 1 --- utils/mxtk/mxglwindow.cpp | 190 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 utils/mxtk/mxglwindow.cpp (limited to 'utils/mxtk/mxglwindow.cpp') diff --git a/utils/mxtk/mxglwindow.cpp b/utils/mxtk/mxglwindow.cpp new file mode 100644 index 0000000..03121a8 --- /dev/null +++ b/utils/mxtk/mxglwindow.cpp @@ -0,0 +1,190 @@ +// +// mxToolKit (c) 1999 by Mete Ciragan +// +// file: mxGlWindow.cpp +// implementation: Win32 API +// last modified: Apr 21 1999, Mete Ciragan +// copyright: The programs and associated files contained in this +// distribution were developed by Mete Ciragan. The programs +// are not in the public domain, but they are freely +// distributable without licensing fees. These programs are +// provided without guarantee or warrantee expressed or +// implied. +// +#include "mxtk/mxGlWindow.h" +#include +//#include hdc = GetDC ((HWND) getHandle ())) == NULL) + { + error = true; + goto done; + } + + int pfm; + if ((pfm = ChoosePixelFormat (d_this->hdc, &pfd)) == 0) + { + error = true; + goto done; + } + + if (SetPixelFormat (d_this->hdc, pfm, &pfd) == FALSE) + { + error = true; + goto done; + } + + DescribePixelFormat (d_this->hdc, pfm, sizeof (pfd), &pfd); + + if ((d_this->hglrc = wglCreateContext (d_this->hdc)) == 0) + { + error = true; + goto done; + } + + if (!wglMakeCurrent (d_this->hdc, d_this->hglrc)) + { + error = true; + goto done; + } + + setType (MX_GLWINDOW); + setDrawFunc (0); + +done: + if (error) + delete this; +} + + + +mxGlWindow::~mxGlWindow () +{ + if (d_this->hglrc) + { + wglMakeCurrent (NULL, NULL); + //wglDeleteContext (d_this->hglrc); + } + + if (d_this->hdc) + ReleaseDC ((HWND) getHandle (), d_this->hdc); + + delete d_this; +} + + + +int +mxGlWindow::handleEvent (mxEvent *event) +{ + return 0; +} + + + +void +mxGlWindow::redraw () +{ + makeCurrent (); + if (d_drawFunc) + d_drawFunc (); + else + draw (); + swapBuffers (); +} + + + +void +mxGlWindow::draw () +{ +} + + + +int +mxGlWindow::makeCurrent () +{ + if (wglMakeCurrent (d_this->hdc, d_this->hglrc)) + return 1; + + return 0; +} + + + +int +mxGlWindow::swapBuffers () +{ + if (SwapBuffers (d_this->hdc)) + return 1; + + return 0; +} + + + +void +mxGlWindow::setDrawFunc (void (*func) (void)) +{ + d_drawFunc = func; +} + + + +void +mxGlWindow::setFormat (int mode, int colorBits, int depthBits) +{ + g_formatMode = mode; + g_formatColorBits = colorBits; + g_formatDepthBits = depthBits; +} -- cgit v1.2.3