#include "celengine/gl.h"#include "wglext.h"#include <windows.h>#include <cstdio>#include <vector>Include dependency graph for wglext.cpp:

Go to the source code of this file.
Functions | |
| int | FindFormatFloat (HDC hDC) |
| void | InitWGLExtensions (HINSTANCE appInstance) |
| static void | WGLCallback (HWND wnd) |
| bool | WGLExtensionSupported (const string &extName) |
| static LRESULT CALLBACK | WGLWindProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
Variables | |
| static vector< string > | supportedExtensions |
| PFNWGLCHOOSEPIXELFORMATARBPROC | wglChoosePixelFormatARB = NULL |
| PFNWGLCREATEPBUFFERARBPROC | wglCreatePbufferARB = NULL |
| PFNWGLDESTROYPBUFFERARBPROC | wglDestroyPbufferARB = NULL |
| PFNWGLGETEXTENSIONSSTRINGARBPROC | wglGetExtensionsStringARB = NULL |
| PFNWGLGETPBUFFERDCARBPROC | wglGetPbufferDCARB = NULL |
| PFNWGLGETPIXELFORMATATTRIBFVARBPROC | wglGetPixelFormatAttribfvARB = NULL |
| PFNWGLGETPIXELFORMATATTRIBIVARBPROC | wglGetPixelFormatAttribivARB = NULL |
| PFNWGLQUERYPBUFFERARBPROC | wglQueryPbufferARB = NULL |
| PFNWGLRELEASEPBUFFERDCARBPROC | wglReleasePbufferDCARB = NULL |
|
|
Definition at line 43 of file wglext.cpp. References WGL_ACCUM_BITS_ARB, WGL_ALPHA_BITS_ARB, WGL_BIND_TO_TEXTURE_RGB_ARB, WGL_BLUE_BITS_ARB, WGL_COLOR_BITS_ARB, WGL_DEPTH_BITS_ARB, WGL_DRAW_TO_PBUFFER_ARB, WGL_GREEN_BITS_ARB, WGL_PIXEL_TYPE_ARB, WGL_RED_BITS_ARB, WGL_STENCIL_BITS_ARB, WGL_SUPPORT_OPENGL_ARB, WGL_TYPE_RGBA_FLOAT_ATI, wglChoosePixelFormatARB, and wglGetPixelFormatAttribivARB. 00044 {
00045 int ifmtList[] = {
00046 WGL_DRAW_TO_PBUFFER_ARB, TRUE,
00047 WGL_SUPPORT_OPENGL_ARB, TRUE,
00048 //WGL_DOUBLE_BUFFER_ARB, TRUE,
00049 WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_FLOAT_ATI,
00050 WGL_DEPTH_BITS_ARB, 24,
00051 WGL_COLOR_BITS_ARB, 0,
00052 WGL_RED_BITS_ARB, 16,
00053 WGL_GREEN_BITS_ARB, 16,
00054 WGL_BLUE_BITS_ARB, 16,
00055 WGL_ALPHA_BITS_ARB, 0,
00056 WGL_ACCUM_BITS_ARB, 0,
00057 WGL_STENCIL_BITS_ARB, 8,
00058 WGL_BIND_TO_TEXTURE_RGB_ARB, TRUE,
00059 0
00060 };
00061
00062 int pixelFormatIndex = -1;
00063 int pixFormats[256];
00064 unsigned int numFormats;
00065
00066 wglChoosePixelFormatARB(hDC, ifmtList, NULL, 256, pixFormats, &numFormats);
00067
00068 if (numFormats != 0)
00069 {
00070 for (unsigned int i = 0; i < numFormats; i++)
00071 {
00072 int results[7];
00073 int query[] = { WGL_COLOR_BITS_ARB,
00074 WGL_DEPTH_BITS_ARB,
00075 WGL_STENCIL_BITS_ARB,
00076 WGL_RED_BITS_ARB,
00077 WGL_GREEN_BITS_ARB,
00078 WGL_BLUE_BITS_ARB,
00079 WGL_ALPHA_BITS_ARB };
00080
00081 wglGetPixelFormatAttribivARB(hDC, pixFormats[i], 0,
00082 7, query, results);
00083
00084 // Select an fp16 format. No existing hardware fully supports
00085 // fp32 render targets (no alpha blending, etc.), and fp16 is
00086 // probably good enough anyway.
00087 if (results[0] == 64 && results[3] == 16)
00088 return pixFormats[i];
00089 }
00090 }
00091
00092 return -1;
00093 }
|
|
|
Definition at line 231 of file wglext.cpp. References appInstance, and WGLWindProc(). Referenced by WinMain(). 00232 {
00233 WNDCLASS wglClass = {
00234 0, WGLWindProc, 0, 0, appInstance, NULL, NULL, NULL, NULL, "InitWGL"
00235 };
00236 ATOM classId = RegisterClass(&wglClass);
00237 HWND hwnd = CreateWindow("InitWGL", "",
00238 0, 0, 0, 0, 0,
00239 (HWND) NULL,
00240 (HMENU) NULL,
00241 appInstance,
00242 NULL);
00243 }
|
|
|
Definition at line 98 of file wglext.cpp. References HDC(), supportedExtensions, wglChoosePixelFormatARB, wglCreatePbufferARB, wglDestroyPbufferARB, wglGetExtensionsStringARB, wglGetPbufferDCARB, wglGetPixelFormatAttribfvARB, wglGetPixelFormatAttribivARB, wglQueryPbufferARB, and wglReleasePbufferDCARB. Referenced by WGLWindProc(). 00099 {
00100 if (wnd == NULL)
00101 return;
00102
00103 HDC hdc = GetDC(wnd);
00104
00105 if (hdc == NULL)
00106 return;
00107
00108 PIXELFORMATDESCRIPTOR pfd = {
00109 sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
00110 1, // version number
00111 PFD_DRAW_TO_WINDOW | // support window
00112 PFD_SUPPORT_OPENGL | // support OpenGL
00113 PFD_DOUBLEBUFFER, // double buffered
00114 PFD_TYPE_RGBA, // RGBA type
00115 24, // 24-bit color depth
00116 0, 0, 0, 0, 0, 0, // color bits ignored
00117 0, // no alpha buffer
00118 0, // shift bit ignored
00119 0, // no accumulation buffer
00120 0, 0, 0, 0, // accum bits ignored
00121 24, // 24-bit z-buffer
00122 0, // no stencil buffer
00123 0, // no auxiliary buffer
00124 PFD_MAIN_PLANE, // main layer
00125 0, // reserved
00126 0, 0, 0 // layer masks ignored
00127 };
00128
00129 unsigned int pixelFormat = ChoosePixelFormat(hdc, &pfd);
00130
00131 DescribePixelFormat(hdc, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
00132 if (!SetPixelFormat(hdc, pixelFormat, &pfd))
00133 return;
00134
00135 HGLRC context = wglCreateContext(hdc);
00136 if (context == NULL)
00137 return;
00138
00139 wglMakeCurrent(hdc, context);
00140
00141 wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC) wglGetProcAddress("wglGetExtensionsStringARB");
00142 if (wglGetExtensionsStringARB == NULL)
00143 return;
00144
00145 const char *ext = wglGetExtensionsStringARB(hdc);
00146 char buff[100];
00147
00148 if (ext == NULL)
00149 return;
00150
00151 while (*ext != '\0')
00152 {
00153 // TODO: This is prone to buffer overflows if the driver reports a
00154 // bad extension string.
00155 sscanf(ext, "%s", buff);
00156
00157 // Check for required extension and fill in pointers
00158 if (strcmp(buff, "WGL_ARB_pixel_format") == 0)
00159 {
00160 wglGetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC) wglGetProcAddress("wglGetPixelFormatAttribivARB");
00161 wglGetPixelFormatAttribfvARB = (PFNWGLGETPIXELFORMATATTRIBFVARBPROC) wglGetProcAddress("wglGetPixelFormatAttribfvARB");
00162 wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC) wglGetProcAddress("wglChoosePixelFormatARB");
00163
00164 if (wglChoosePixelFormatARB != NULL &&
00165 wglGetPixelFormatAttribivARB != NULL &&
00166 wglGetPixelFormatAttribfvARB != NULL)
00167 {
00168 supportedExtensions.push_back(buff);
00169 }
00170 }
00171 else if (strcmp(buff, "WGL_ARB_pbuffer") == 0)
00172 {
00173 wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC) wglGetProcAddress("wglCreatePbufferARB");
00174 wglGetPbufferDCARB = (PFNWGLGETPBUFFERDCARBPROC) wglGetProcAddress("wglGetPbufferDCARB");
00175 wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC) wglGetProcAddress("wglReleasePbufferDCARB");
00176 wglDestroyPbufferARB = (PFNWGLDESTROYPBUFFERARBPROC) wglGetProcAddress("wglDestroyPbufferARB");
00177 wglQueryPbufferARB = (PFNWGLQUERYPBUFFERARBPROC) wglGetProcAddress("wglQueryPbufferARB");
00178 if (wglCreatePbufferARB != NULL &&
00179 wglGetPbufferDCARB != NULL &&
00180 wglReleasePbufferDCARB != NULL &&
00181 wglDestroyPbufferARB != NULL &&
00182 wglQueryPbufferARB != NULL)
00183 {
00184 supportedExtensions.push_back(buff);
00185 }
00186 }
00187 else if (strcmp(buff, "WGL_ARB_multisample") == 0)
00188 {
00189 //wglSampleCoverageARB = (PFNWGLSAMPLECOVERAGEARBPROC) wglGetProcAddres("wglSampleCoverageARB");
00190 supportedExtensions.push_back(buff);
00191 }
00192 else if (strcmp(buff, "WGL_ATI_pixel_format_float") == 0)
00193 {
00194 supportedExtensions.push_back(buff);
00195 }
00196 else if (strcmp(buff, "WGL_ARB_render_texture") == 0)
00197 {
00198 }
00199
00200 ext += strlen(buff) + 1;
00201 }
00202
00203 // Close down this context
00204 wglMakeCurrent(NULL, NULL);
00205 wglDeleteContext(context);
00206 ReleaseDC(wnd, hdc);
00207 }
|
|
|
Definition at line 246 of file wglext.cpp. References supportedExtensions. Referenced by SetDCPixelFormat(). 00247 {
00248 for (unsigned int i = 0; i < supportedExtensions.size(); i++)
00249 {
00250 if (supportedExtensions[i] == extName)
00251 return true;
00252 }
00253
00254 return false;
00255 }
|
|
||||||||||||||||||||
|
Definition at line 211 of file wglext.cpp. References WGLCallback(). Referenced by InitWGLExtensions(). 00212 {
00213 switch (uMsg)
00214 {
00215 case WM_CREATE:
00216 {
00217 CREATESTRUCT *cs = (CREATESTRUCT *) lParam;
00218 WGLCallback(hwnd);
00219 return -1;
00220 }
00221
00222 default:
00223 return DefWindowProc(hwnd, uMsg, wParam, lParam);
00224 }
00225
00226 return 0;
00227 }
|
|
|
Definition at line 21 of file wglext.cpp. Referenced by WGLCallback(), and WGLExtensionSupported(). |
|
|
Definition at line 31 of file wglext.cpp. Referenced by FindFormatFloat(), SetDCPixelFormat(), and WGLCallback(). |
|
|
Definition at line 34 of file wglext.cpp. Referenced by WGLCallback(). |
|
|
Definition at line 37 of file wglext.cpp. Referenced by WGLCallback(). |
|
|
Definition at line 26 of file wglext.cpp. Referenced by WGLCallback(). |
|
|
Definition at line 35 of file wglext.cpp. Referenced by WGLCallback(). |
|
|
Definition at line 30 of file wglext.cpp. Referenced by WGLCallback(). |
|
|
Definition at line 29 of file wglext.cpp. Referenced by ChooseBestMSAAPixelFormat(), FindFormatFloat(), and WGLCallback(). |
|
|
Definition at line 38 of file wglext.cpp. Referenced by WGLCallback(). |
|
|
Definition at line 36 of file wglext.cpp. Referenced by WGLCallback(). |
1.4.1