I am attempting to make a custom GLWindow class that includes all of my setting up of my OpenGL window. However, I also want to include the WndProc callback function for messages being sent to the window in my GLWindow class.
GLWindow.h:
class GLWindow
{
private:
HWND hWnd;
HDC hDC;
HGLRC hRC;
public:
GLWindow();
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
bool Create();
~GLWindow();
}
GLWindow.cpp:
GLWindow::GLWindow()
{
}
bool GLWindow::Create(int width, int height, char * title, bool fullscreen)
{
WNDCLASSEX window;
HINSTANCE hInstance;
hInstance = GetModuleHandle(NULL);
window.cbSize = sizeof(WNDCLASSEX);
window.cbClsExtra = 0;
window.cbWndExtra = 0;
window.hbrBackground = NULL;
window.hIcon = LoadIcon(NULL, IDI_APPLICATION);
window.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
window.hCursor = LoadCursor(NULL, IDC_ARROW);
window.hInstance = hInstance;
window.lpfnWndProc = GLWindow::WndProc; // ERROR
}
GLWindow::~GLWindow()
{
}
The Error is that a value of type "LRESULT (__stdcall GLWindow::*)(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)" cannot be assigned to an entity of type "WNDPROC."
I can't figure it out
I've gotten this to work when WndProc shares the same .cpp file as the WinMain function, but it seems as if the scope throws it off.