Hi,
how can I create an opengl device context, which does not cover the whole window, sothat i can also create some windows buttons. This this temporary not possible because the glcontext overlapps the buttons.
I guess i have to set the dc to the rect i want the glcontext to be.
This is my creation function:
HINSTANCE hInstance = GetModuleHandle(NULL);
WNDCLASS wc;
wc.style = CS_HREDRAW|CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDC_ARROW);
wc.hCursor = LoadCursor(NULL, IDI_APPLICATION);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = szAppName;
RegisterClass(&wc);
hWnd = CreateWindow(szAppName, L"Image Capture", WS_OVERLAPPEDWINDOW,
0, 0, 740, 480,
0, 0, hInstance, 0);
CreateWindow(L"BUTTON", L"Webcam",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
0, 0, 100, 40,
hWnd,
(HMENU) ID_BUTTON1,
hInstance, NULL);
CreateWindow(L"BUTTON", L"Load Bmp",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
0, 40, 100, 40,
hWnd,
(HMENU) ID_BUTTON2,
hInstance, NULL);
hDC = GetDC(hWnd);
static PIXELFORMATDESCRIPTOR pfd; // pfd Tells Windows How We Want Things To Be
memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); //size
pfd.nVersion = 1; //version
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; //flags
pfd.iPixelType = PFD_TYPE_RGBA; //rgba
pfd.cColorBits = 32; //color bits
pfd.cRedBits = 8;
pfd.cGreenBits = 8;
pfd.cBlueBits = 8;
pfd.cAlphaBits = 8;
pfd.cDepthBits = 24; //depth bits
pfd.cStencilBits = 8; //stencil bits
pfd.iLayerType = PFD_MAIN_PLANE;
int PixelFormat = ChoosePixelFormat(hDC, &pfd);
SetPixelFormat(hDC, PixelFormat,&pfd);
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC);
glViewport(100, 0, 640, 480);
ShowWindow(hWnd, TRUE);
UpdateWindow(hWnd);
return true;