Sign in to follow this  

opengl in a dialog

This topic is 4665 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

would it be possible to use opengl in a dialog created by CreateDialog? if so then how would you go about it..? i have tried the code below but glGetError returns GL_INVALID_OPERATION #include <windows.h> #include <gl/gl.h> // LINK: opengl32.lib #include "resource.h" // contains a dialog(centered,system model,visible) BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp) { switch(msg) { case WM_INITDIALOG: return TRUE; case WM_QUIT: case WM_CLOSE: case WM_DESTROY: EndDialog(hwnd,0); PostQuitMessage(0); return TRUE; default: return FALSE; } } int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE,LPSTR,int) { HDC hdc = NULL; MSG msg = {0,0,0,0}; HWND hwnd = NULL; HGLRC hrc = NULL; PIXELFORMATDESCRIPTOR pfd; hwnd = CreateDialog(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),NULL,DlgProc); hdc = GetDC(hwnd); ZeroMemory(&pfd,sizeof(PIXELFORMATDESCRIPTOR)); pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); pfd.nVersion = 1; pfd.iPixelType = PFD_TYPE_RGBA; pfd.dwFlags = PFD_SUPPORT_OPENGL|PFD_DRAW_TO_WINDOW|PFD_DOUBLEBUFFER; pfd.cColorBits = 16; pfd.cDepthBits = 16; SetPixelFormat(hdc,ChoosePixelFormat(hdc,&pfd),&pfd); wglCreateContext(hdc); wglMakeCurrent(hdc,hrc); glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT); SwapBuffers(hdc); GetCurrentError(); while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } wglMakeCurrent(NULL,NULL); wglDeleteContext(hrc); DeleteDC(hdc); return (int)msg.wParam; }

Share this post


Link to post
Share on other sites

This topic is 4665 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this