Jump to content
  • Advertisement
Sign in to follow this  

opengl in a dialog

This topic is 4968 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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!