c++ - Windows 10 OpenGL BSOD, "Kernel Mode Trap" -


so, i'm building default context in opengl, (without extensions) , reason, window opens, bsod "unexpected kernel mode trap"

now, pretty default. i've used startup vs 2015 community win32 application, , applied opengl context code verbatim. includes message box supposedly should show me opengl version (4.4). however, opens blank, , upon closing, when should open opengl cs_dcown window, bsod.

just wondering if has insight command causing bsod, or if practices wrong?

i come direct3d9 background.

#include "stdafx.h" #include "puregl.h" #include <gl\gl.h>  #pragma comment (lib, "opengl32.lib");  #define max_loadstring 100  // global variables: hinstance hinst;                                // current instance wchar sztitle[max_loadstring];                  // title bar text wchar szwindowclass[max_loadstring];            // main window class name  // forward declarations of functions included in code module: atom                myregisterclass(hinstance hinstance); bool                initinstance(hinstance, int); lresult callback    wndproc(hwnd, uint, wparam, lparam);  int apientry wwinmain(_in_ hinstance hinstance, _in_opt_ hinstance hprevinstance, _in_ lpwstr lpcmdline, _in_ int ncmdshow) {     unreferenced_parameter(hprevinstance);     unreferenced_parameter(lpcmdline);      // todo: place code here.      // initialize global strings     loadstringw(hinstance, ids_app_title, sztitle, max_loadstring);     loadstringw(hinstance, idc_puregl, szwindowclass, max_loadstring);     myregisterclass(hinstance);      // perform application initialization:     if (!initinstance (hinstance, ncmdshow))     {         return false;     }      haccel hacceltable = loadaccelerators(hinstance, makeintresource(idc_puregl));      msg msg;      // main message loop:     while (getmessage(&msg, nullptr, 0, 0))     {         if (!translateaccelerator(msg.hwnd, hacceltable, &msg))         {             translatemessage(&msg);             dispatchmessage(&msg);         }     }      return (int) msg.wparam; }  atom myregisterclass(hinstance hinstance) {     wndclassexw wcex;         wcex.cbsize = sizeof(wndclassex);         wcex.style          = cs_owndc | cs_hredraw | cs_vredraw;     wcex.lpfnwndproc    = wndproc;     wcex.cbclsextra     = 0;     wcex.cbwndextra     = 0;     wcex.hinstance      = hinstance;     wcex.hicon          = loadicon(hinstance, makeintresource(idi_puregl));     wcex.hcursor        = loadcursor(nullptr, idc_arrow);     wcex.hbrbackground  = (hbrush)(color_window+1);     wcex.lpszmenuname   = makeintresourcew(idc_puregl);     wcex.lpszclassname  = szwindowclass;     wcex.hiconsm        = loadicon(wcex.hinstance, makeintresource(idi_small));      return registerclassexw(&wcex); }  bool initinstance(hinstance hinstance, int ncmdshow) {    hinst = hinstance; // store instance handle in our global variable     hwnd hwnd = createwindoww(szwindowclass, sztitle, ws_overlappedwindow,       cw_usedefault, 0, cw_usedefault, 0, nullptr, nullptr, hinstance, nullptr);     if (!hwnd)    {       return false;    }     showwindow(hwnd, ncmdshow);    updatewindow(hwnd);     return true; }  lresult callback wndproc(hwnd hwnd, uint message, wparam wparam, lparam lparam) {     pixelformatdescriptor pfd = {         sizeof(pixelformatdescriptor),         1,         pfd_draw_to_window | pfd_support_opengl | pfd_doublebuffer,         pfd_type_rgba,         32,         0, 0, 0, 0, 0, 0,         0,         0,         0,         0, 0, 0, 0,         24,         8,         0,         pfd_main_plane,         0,         0, 0, 0     };      hdc ourwindowhandletodevicecontext = getdc(hwnd);      int letwindowschoosethispixelformat;     letwindowschoosethispixelformat = choosepixelformat(ourwindowhandletodevicecontext, &pfd);     setpixelformat(ourwindowhandletodevicecontext, letwindowschoosethispixelformat, &pfd);      hglrc ouropenglrenderingcontext = wglcreatecontext(ourwindowhandletodevicecontext);     wglmakecurrent(ourwindowhandletodevicecontext, ouropenglrenderingcontext);      messageboxa(0, (char*)glgetstring(gl_version), "opengl version", 0);      wgldeletecontext(ouropenglrenderingcontext);     postquitmessage(0);      switch (message)     {     case wm_command:         {             int wmid = loword(wparam);             // parse menu selections:             switch (wmid)             {             case idm_exit:                 destroywindow(hwnd);                 break;             default:                 return defwindowproc(hwnd, message, wparam, lparam);             }         }         break;     case wm_paint:         {             paintstruct ps;             hdc hdc = beginpaint(hwnd, &ps);             // todo: add drawing code uses hdc here...             endpaint(hwnd, &ps);         }         break;     case wm_destroy:         postquitmessage(0);         break;     default:         return defwindowproc(hwnd, message, wparam, lparam);     }     return 0; } 

hardware details if known issues - amd fx 6300, asus radeon r9-285

as far understand, getdc should fail, because there's still no client area created window - first window message wm_nc_create, , client area manipulation.

you may execute d3d code after wm_create.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -