MCPcopy Create free account
hub / github.com/crownengine/crown / create

Method create

3rdparty/bgfx/src/glcontext_wgl.cpp:114–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112 }
113
114 void GlContext::create(const Resolution& _resolution)
115 {
116 m_opengl32dll = bx::dlopen("opengl32.dll");
117 BGFX_FATAL(NULL != m_opengl32dll, Fatal::UnableToInitialize, "Failed to load opengl32.dll.");
118
119 wglGetProcAddress = bx::dlsym<PFNWGLGETPROCADDRESSPROC>(m_opengl32dll, "wglGetProcAddress");
120 BGFX_FATAL(NULL != wglGetProcAddress, Fatal::UnableToInitialize, "Failed get wglGetProcAddress.");
121
122 // If g_platformHooks.nwh is NULL, the assumption is that GL context was created
123 // by user (for example, using SDL, GLFW, etc.)
124 BX_WARN(NULL != g_platformData.nwh
125 , "bgfx::setPlatform with valid window is not called. This might "
126 "be intentional when GL context is created by the user."
127 );
128
129 if (NULL != g_platformData.nwh && NULL != g_platformData.context )
130 {
131 // user has provided a context and a window
132 wglMakeCurrent = (PFNWGLMAKECURRENTPROC)bx::dlsym(m_opengl32dll, "wglMakeCurrent");
133 BGFX_FATAL(NULL != wglMakeCurrent, Fatal::UnableToInitialize, "Failed get wglMakeCurrent.");
134
135 m_hdc = GetDC( (HWND)g_platformData.nwh);
136 BGFX_FATAL(NULL != m_hdc, Fatal::UnableToInitialize, "GetDC failed!");
137
138 HGLRC context = (HGLRC)g_platformData.context;
139 int result = wglMakeCurrent(m_hdc, context );
140 BGFX_FATAL(0 != result, Fatal::UnableToInitialize, "wglMakeCurrent failed!");
141
142 m_context = context;
143 }
144
145 if (NULL != g_platformData.nwh && NULL == g_platformData.context )
146 {
147 wglMakeCurrent = bx::dlsym<PFNWGLMAKECURRENTPROC>(m_opengl32dll, "wglMakeCurrent");
148 BGFX_FATAL(NULL != wglMakeCurrent, Fatal::UnableToInitialize, "Failed get wglMakeCurrent.");
149
150 wglCreateContext = bx::dlsym<PFNWGLCREATECONTEXTPROC>(m_opengl32dll, "wglCreateContext");
151 BGFX_FATAL(NULL != wglCreateContext, Fatal::UnableToInitialize, "Failed get wglCreateContext.");
152
153 wglDeleteContext = bx::dlsym<PFNWGLDELETECONTEXTPROC>(m_opengl32dll, "wglDeleteContext");
154 BGFX_FATAL(NULL != wglDeleteContext, Fatal::UnableToInitialize, "Failed get wglDeleteContext.");
155
156 m_hdc = GetDC( (HWND)g_platformData.nwh);
157 BGFX_FATAL(NULL != m_hdc, Fatal::UnableToInitialize, "GetDC failed!");
158
159 // Dummy window to peek into WGL functionality.
160 //
161 // An application can only set the pixel format of a window one time.
162 // Once a window's pixel format is set, it cannot be changed.
163 // MSDN: https://web.archive.org/web/20190207230357/https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-setpixelformat
164 HWND hwnd = CreateWindowA("STATIC"
165 , ""
166 , WS_POPUP|WS_DISABLED
167 , -32000
168 , -32000
169 , 0
170 , 0
171 , NULL

Callers

nothing calls this directly

Calls 6

dlopenFunction · 0.85
dlsymFunction · 0.85
createContextFunction · 0.85
memCopyFunction · 0.85
dumpExtensionsFunction · 0.70
EnumEnum · 0.70

Tested by

no test coverage detected