Formatting.

This commit is contained in:
Camilla Berglund 2012-05-07 00:11:51 +02:00
parent d0c298de6e
commit 26fc5cacda

View File

@ -149,38 +149,44 @@ static int getPixelFormatAttrib(_GLFWwindow* window, int pixelFormat, int attrib
static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found) static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
{ {
_GLFWfbconfig* result; _GLFWfbconfig* fbconfigs;
PIXELFORMATDESCRIPTOR pfd; PIXELFORMATDESCRIPTOR pfd;
int i, count; int i, available;
*found = 0; *found = 0;
if (window->WGL.ARB_pixel_format) if (window->WGL.ARB_pixel_format)
count = getPixelFormatAttrib(window, 1, WGL_NUMBER_PIXEL_FORMATS_ARB); {
available = getPixelFormatAttrib(window,
1,
WGL_NUMBER_PIXEL_FORMATS_ARB);
}
else else
{ {
count = DescribePixelFormat(window->WGL.DC, available = DescribePixelFormat(window->WGL.DC,
1, 1,
sizeof(PIXELFORMATDESCRIPTOR), sizeof(PIXELFORMATDESCRIPTOR),
NULL); NULL);
} }
if (!count) if (!available)
{ {
_glfwSetError(GLFW_OPENGL_UNAVAILABLE, "Win32/WGL: No pixel formats found"); _glfwSetError(GLFW_OPENGL_UNAVAILABLE, "Win32/WGL: No pixel formats found");
return NULL; return NULL;
} }
result = (_GLFWfbconfig*) malloc(sizeof(_GLFWfbconfig) * count); fbconfigs = (_GLFWfbconfig*) malloc(sizeof(_GLFWfbconfig) * available);
if (!result) if (!fbconfigs)
{ {
_glfwSetError(GLFW_OUT_OF_MEMORY, _glfwSetError(GLFW_OUT_OF_MEMORY,
"Win32/WGL: Failed to allocate _GLFWfbconfig array"); "Win32/WGL: Failed to allocate _GLFWfbconfig array");
return NULL; return NULL;
} }
for (i = 1; i <= count; i++) for (i = 1; i <= available; i++)
{ {
_GLFWfbconfig* fbconfig = fbconfigs + *found;
if (window->WGL.ARB_pixel_format) if (window->WGL.ARB_pixel_format)
{ {
// Get pixel format attributes through WGL_ARB_pixel_format // Get pixel format attributes through WGL_ARB_pixel_format
@ -203,41 +209,41 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
continue; continue;
} }
result[*found].redBits = fbconfig->redBits =
getPixelFormatAttrib(window, i, WGL_RED_BITS_ARB); getPixelFormatAttrib(window, i, WGL_RED_BITS_ARB);
result[*found].greenBits = fbconfig->greenBits =
getPixelFormatAttrib(window, i, WGL_GREEN_BITS_ARB); getPixelFormatAttrib(window, i, WGL_GREEN_BITS_ARB);
result[*found].blueBits = fbconfig->blueBits =
getPixelFormatAttrib(window, i, WGL_BLUE_BITS_ARB); getPixelFormatAttrib(window, i, WGL_BLUE_BITS_ARB);
result[*found].alphaBits = fbconfig->alphaBits =
getPixelFormatAttrib(window, i, WGL_ALPHA_BITS_ARB); getPixelFormatAttrib(window, i, WGL_ALPHA_BITS_ARB);
result[*found].depthBits = fbconfig->depthBits =
getPixelFormatAttrib(window, i, WGL_DEPTH_BITS_ARB); getPixelFormatAttrib(window, i, WGL_DEPTH_BITS_ARB);
result[*found].stencilBits = fbconfig->stencilBits =
getPixelFormatAttrib(window, i, WGL_STENCIL_BITS_ARB); getPixelFormatAttrib(window, i, WGL_STENCIL_BITS_ARB);
result[*found].accumRedBits = fbconfig->accumRedBits =
getPixelFormatAttrib(window, i, WGL_ACCUM_RED_BITS_ARB); getPixelFormatAttrib(window, i, WGL_ACCUM_RED_BITS_ARB);
result[*found].accumGreenBits = fbconfig->accumGreenBits =
getPixelFormatAttrib(window, i, WGL_ACCUM_GREEN_BITS_ARB); getPixelFormatAttrib(window, i, WGL_ACCUM_GREEN_BITS_ARB);
result[*found].accumBlueBits = fbconfig->accumBlueBits =
getPixelFormatAttrib(window, i, WGL_ACCUM_BLUE_BITS_ARB); getPixelFormatAttrib(window, i, WGL_ACCUM_BLUE_BITS_ARB);
result[*found].accumAlphaBits = fbconfig->accumAlphaBits =
getPixelFormatAttrib(window, i, WGL_ACCUM_ALPHA_BITS_ARB); getPixelFormatAttrib(window, i, WGL_ACCUM_ALPHA_BITS_ARB);
result[*found].auxBuffers = fbconfig->auxBuffers =
getPixelFormatAttrib(window, i, WGL_AUX_BUFFERS_ARB); getPixelFormatAttrib(window, i, WGL_AUX_BUFFERS_ARB);
result[*found].stereo = fbconfig->stereo =
getPixelFormatAttrib(window, i, WGL_STEREO_ARB); getPixelFormatAttrib(window, i, WGL_STEREO_ARB);
if (window->WGL.ARB_multisample) if (window->WGL.ARB_multisample)
{ {
result[*found].samples = fbconfig->samples =
getPixelFormatAttrib(window, i, WGL_SAMPLES_ARB); getPixelFormatAttrib(window, i, WGL_SAMPLES_ARB);
} }
else else
result[*found].samples = 0; fbconfig->samples = 0;
} }
else else
{ {
@ -267,32 +273,32 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
if (pfd.iPixelType != PFD_TYPE_RGBA) if (pfd.iPixelType != PFD_TYPE_RGBA)
continue; continue;
result[*found].redBits = pfd.cRedBits; fbconfig->redBits = pfd.cRedBits;
result[*found].greenBits = pfd.cGreenBits; fbconfig->greenBits = pfd.cGreenBits;
result[*found].blueBits = pfd.cBlueBits; fbconfig->blueBits = pfd.cBlueBits;
result[*found].alphaBits = pfd.cAlphaBits; fbconfig->alphaBits = pfd.cAlphaBits;
result[*found].depthBits = pfd.cDepthBits; fbconfig->depthBits = pfd.cDepthBits;
result[*found].stencilBits = pfd.cStencilBits; fbconfig->stencilBits = pfd.cStencilBits;
result[*found].accumRedBits = pfd.cAccumRedBits; fbconfig->accumRedBits = pfd.cAccumRedBits;
result[*found].accumGreenBits = pfd.cAccumGreenBits; fbconfig->accumGreenBits = pfd.cAccumGreenBits;
result[*found].accumBlueBits = pfd.cAccumBlueBits; fbconfig->accumBlueBits = pfd.cAccumBlueBits;
result[*found].accumAlphaBits = pfd.cAccumAlphaBits; fbconfig->accumAlphaBits = pfd.cAccumAlphaBits;
result[*found].auxBuffers = pfd.cAuxBuffers; fbconfig->auxBuffers = pfd.cAuxBuffers;
result[*found].stereo = (pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE; fbconfig->stereo = (pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE;
// PFD pixel formats do not support FSAA // PFD pixel formats do not support FSAA
result[*found].samples = 0; fbconfig->samples = 0;
} }
result[*found].platformID = i; fbconfig->platformID = i;
(*found)++; (*found)++;
} }
return result; return fbconfigs;
} }