WGL - Pixel Format Attributes?

Hi Again Folks:

I’m running a 3 year old GTX 880M.

My friends have asked me to show them the graphics stuff I’ve been learning.

I tried to run my rotating tennis court splash screen on their Windows 10 PC that has two Radeon HD 6850 cards.

WglChoosePixelFormatARB() failed.

These are 6 year old cards, but they do a capable job running a recently released game he likes, World of Warships.

He told me he keeps the drivers current.

After I started an embarrassing thread in this forum a couple of weeks ago, I now always pass the pixel format attributes to the OpenGL setup function. Here’s an attribute list I often pass to wglChoosePixelFormatARB():

	const int int_pixel_format_attrib_list_with_aa[] =
	{
		WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
		WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
		WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
		WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
		WGL_COLOR_BITS_ARB, 32,
		WGL_DEPTH_BITS_ARB, 24,
		WGL_STENCIL_BITS_ARB, 8,
		WGL_SAMPLE_BUFFERS_ARB, GL_TRUE,
		WGL_SAMPLES_ARB, aa_sample_size,
		0
	};

First, do you see any fundamental issues I need to address? For example common attributes that I should be setting or attributes that require other attributes to mean anything.

I’ve Googled the Radeon HD 6850. The specs I’ve found talk about clock speeds, available resolutions and memory sizes, but I’ve found nothing about bits of color, depth or stencil supported.

I’m assuming pixel formats can be specified to take advantage of higher spec GPUs while maintaining compatibility with older hardware.

If I understand correctly, the list can include the same pixel format attribute repeated with a sequence of less demanding values. The idea being that wglChoosePixelFormatARB() will try to find the best pixel formats that can run on the system’s available hardware.

I believe a sequence inside the list like:

		WGL_COLOR_BITS_ARB, 32,
		WGL_COLOR_BITS_ARB, 24,
		WGL_COLOR_BITS_ARB, 16,
		WGL_COLOR_BITS_ARB, 8,

will take advantage of a GPU that can handle 32 bits of color, yet still run with a card with 16 bits of color.

Is that correct?

If that’s right, there are depth and stencil bits, and probably other attributes, to specify multiple settings for as well.

Anyway, I only visit my friends once a week, at most, so I’d like to maximize my chance of getting this to run on my next trip.

I don’t need this working pre-OpenGL 3.3.

I’d appreciate guidance, or perhaps a look at the attribute lists other’s are passing to wglChoosePixelFormatARB() to allow an application to run on a variety of GPUs.

  Thanks
  Larry

[QUOTE=larryl;1287442]I now always pass the pixel format attributes to the OpenGL setup function. Here’s an attribute list I often pass to wglChoosePixelFormatARB():

    const int int_pixel_format_attrib_list_with_aa[] =
    {
        WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
        WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
        WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
        WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
        WGL_COLOR_BITS_ARB, 32,
        WGL_DEPTH_BITS_ARB, 24,
        WGL_STENCIL_BITS_ARB, 8,
        WGL_SAMPLE_BUFFERS_ARB, GL_TRUE,
        WGL_SAMPLES_ARB, aa_sample_size,
        0
    };

First, do you see any fundamental issues I need to address?[/QUOTE]

WGL_COLOR_BITS_ARB excludes the alpha bitplanes. So I’d provide 24 for it, and set
WGL_ALPHA_BITS_ARB to 8.

Also for starters, delete the WGL_SAMPLES_ARB line, and request WGL_SAMPLE_BUFFERS FALSE … unless you know that card supports MSAA at a given samples/pixel rate. For details, see WGL_ARB_pixel_format.

That said…

You can query the pixel formats that your GPU+driver supports and select one from there using wglGetPixelFormatAttrib[if]vARB. In fact, if you want a quick dump of what your GPU+driver can support, install GLEW and run it’s “visualinfo” tool. You’ll get a dump of the pixel formats supported that looks something like this:


 +-----+-------------------------+-----------------+----------+-----------------+----------+
 |     |          visual         |      color      | ax dp st |      accum      |   layer  |
 |  id | tp ac gd fm db sw st ms |  sz  r  g  b  a | bf th cl |  sz  r  g  b  a | ov un sw |
 +-----+-------------------------+-----------------+----------+-----------------+----------+
 |   1 | wp fu  .  i  .  .  .  . |  32  8  8  8  . |  4 24  . |  64 16 16 16 16 |  .  .  . |
 |   2 | wp fu  .  i  .  .  .  . |  32  8  8  8  8 |  4 24  . |  64 16 16 16 16 |  .  .  . |
 |   3 | wp fu  .  i  .  .  .  . |  32  8  8  8  . |  4 24  8 |  64 16 16 16 16 |  .  .  . |
 |   4 | wp fu  .  i  .  .  .  . |  32  8  8  8  8 |  4 24  8 |  64 16 16 16 16 |  .  .  . |
 |   5 | wp fu  .  i  .  .  .  . |  32  8  8  8  . |  4  .  . |  64 16 16 16 16 |  .  .  . |
 |   6 | wp fu  .  i  .  .  .  . |  32  8  8  8  8 |  4  .  . |  64 16 16 16 16 |  .  .  . |
 |   7 | wp fu  .  i  .  .  .  . |  32  8  8  8  . |  4  .  8 |  64 16 16 16 16 |  .  .  . |
 |   8 | wp fu  .  i  .  .  .  . |  32  8  8  8  8 |  4  .  8 |  64 16 16 16 16 |  .  .  . |
 |   9 | wp fu  .  i  y  x  .  . |  32  8  8  8  . |  4 24  . |  64 16 16 16 16 |  .  .  . |
 |  10 | wp fu  .  i  y  x  .  . |  32  8  8  8  8 |  4 24  . |  64 16 16 16 16 |  .  .  . |
 |  11 | wp fu  .  i  y  x  .  . |  32  8  8  8  . |  4 24  8 |  64 16 16 16 16 |  .  .  . |
 |  12 | wp fu  .  i  y  x  .  . |  32  8  8  8  8 |  4 24  8 |  64 16 16 16 16 |  .  .  . |
...
 |  41 | wp fu  .  i  y  x  .  4 |  32  8  8  8  . |  4 24  . |  64 16 16 16 16 |  .  .  . |
 |  42 | wp fu  .  i  y  x  .  4 |  32  8  8  8  8 |  4 24  . |  64 16 16 16 16 |  .  .  . |
 |  43 | wp fu  .  i  y  x  .  4 |  32  8  8  8  . |  4 24  8 |  64 16 16 16 16 |  .  .  . |
 |  44 | wp fu  .  i  y  x  .  4 |  32  8  8  8  8 |  4 24  8 |  64 16 16 16 16 |  .  .  . |
 |  45 | wp fu  .  i  y  x  .  4 |  32  8  8  8  . |  4  .  . |  64 16 16 16 16 |  .  .  . |
...

Here’s a partial key:


** visual ~= pixel format descriptor
** id       = visual id (integer from 1 - max visuals)
** tp       = type (wn: window, pb: pbuffer, wp: window & pbuffer, bm: bitmap)
** ac        = acceleration (ge: generic, fu: full, no: none)
** fm        = format (i: integer, f: float, c: color index)
** db        = double buffer (y = yes)
** sw       = swap method (x: exchange, c: copy, u: undefined)
** st        = stereo (y = yes)
** sz       = total # bits
** r        = # bits of red
** g        = # bits of green
** b        = # bits of blue
** a        = # bits of alpha
** axbf     = # aux buffers
** dpth     = # bits of depth
** stcl     = # bits of stencil

Also note that “ms” is the number of MSAA samples. These are the values that you can provide WGL_SAMPLES_ARB and get a matching pixel format. “.” in this column equates to no-MSAA (i.e. WGL_SAMPLE_BUFFERS_ARB FALSE).

Thanks Dark Photon:

Should I pass in any hard coded pixel format attributes, or take everything from values returned from wglGetPixelFormatAttribivARB()?

I’m triying a couple of things to get familiar with wglGetPixelFormatAttribivARB().

bool get_pixel_format_attributes(HDC hdc, bool Linear)
{

	int const Attrib[] = { WGL_NUMBER_PIXEL_FORMATS_ARB };
	int format_count = 0;
	int zero_based_format_count = 0;

	BOOL result = wglGetPixelFormatAttribivARB(hdc, 1, 0, 1, Attrib, 
                                                                &format_count);

	BOOL result_zero = wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, Attrib,
                                                     &zero_based_format_count);

	int const stencil_bits_attrib_2[] = { WGL_STENCIL_BITS_ARB };
	int stencil_bits_value_2 = 0;
	BOOL result_2 = wglGetPixelFormatAttribivARB(hdc, 1, 0, 1, 
                                                         stencil_bits_attrib_2, 
                                                         &stencil_bits_value_2);

	int const Attrib_3[] = {WGL_DRAW_TO_WINDOW_ARB,
				WGL_SUPPORT_OPENGL_ARB,
				WGL_DOUBLE_BUFFER_ARB,
				WGL_PIXEL_TYPE_ARB,
				WGL_COLOR_BITS_ARB,
				WGL_DEPTH_BITS_ARB,
				WGL_STENCIL_BITS_ARB,
				WGL_SAMPLE_BUFFERS_ARB,
				WGL_SAMPLES_ARB};

	int value_3[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
	BOOL result_3 = wglGetPixelFormatAttribivARB(hdc, 1, 0, 9, Attrib_3, 
                                                                    value_3);

	return GL_TRUE;
}

Here are the debugger’s watch window values for some of the attributes:

		format_count	721	int
		zero_based_format_count	721	int
		stencil_bits_value_2	0	int
-		value_3	0x012fe64c {1, 1, 0, 8235, 32, 24, 0, 0, 0}	int[9]
		[0]	1	int
		[1]	1	int
		[2]	0	int
		[3]	8235	int
		[4]	32	int
		[5]	24	int
		[6]	0	int
		[7]	0	int
		[8]	0	int

I noticed while the index is one based, the format count comes out the same, 721, with an index of 0 or 1. Does an index of 0 return the format count by default?

WGL_DEPTH_BITS_ARB is the last query that returns what looks like a valid value, 24, when passed in as part of a list, or as the first value of a single element list.

WGL_STENCIL_BITS_ARB is listed in the link, you provided as a valid attribute, yet wglGetPixelFormatAttribivARB() returns 0 for its value.

The image I want to display looks terrible without anti-aliasing. wglGetPixelFormatAttribivARB() returns 0 forWGL_STENCIL_BITS_ARB, WGL_SAMPLE_BUFFERS_ARB and WGL_SAMPLES_ARB.

WGL_SAMPLE_BUFFERS_ARB and WGL_SAMPLES_ARB aren’t in the list of attributes in the link. Is that document current?

What do I need to do to find the anti alias values?

As always, I appreciate your assistance.

  Thanks
  Larry

[QUOTE=larryl;1287485]
WGL_SAMPLE_BUFFERS_ARB and WGL_SAMPLES_ARB aren’t in the list of attributes in the link. Is that document current?[/QUOTE]
WGL_SAMPLE_BUFFERS_ARB and WGL_SAMPLES_ARB are described in the ARB_multisample specification. However, ARB_multisample is written against EXT_pixel_format rather than ARB_pixel_format.

Thanks Again GClements:

I’m having a terrible time trying to find a reference to wglGetPixelFormatAttribivEXT(). I have the same problem searching the web for the reference to wglGetPixelFormatAttribivARB(), unless I use the link Dark Photon provided in his response earlier in this thread.

If I forget an index name in Windows SetWindowLongPtr() arguments, I can google “SetWindowLongPtr” and at or near the top of the search results page, in a prominent position, is a link to that function’s reference page where I can find the relevant information.

I searched for “wglGetPixelFormatAttribivARB” and “wglGetPixelFormatAttribivEXT” in Google and on the page this forum’s “Documentation” button links. Lot’s of references to forum posts and stuff, but I don’t see a page that describes the parameters either of these two functions use.

How would a person find a reference page if they don’t have Dark Photon’s post from yesterday?

I need that information if I’m going to get wglGetPixelFormatAttribivEXT() working.

In the absence of a reference page, I’m assuming the arguments that work for wglGetPixelFormatAttribivARB() will work the same way for wglGetPixelFormatAttribivEXT().

Here’s some code I’ve altered in the function I showed in my last post:

int const Attrib_3[] = { WGL_DRAW_TO_WINDOW_ARB,
                        WGL_SUPPORT_OPENGL_ARB,
                        WGL_DOUBLE_BUFFER_ARB,
                        WGL_PIXEL_TYPE_ARB,
                        WGL_COLOR_BITS_ARB,
                        WGL_DEPTH_BITS_ARB,
                        WGL_STENCIL_BITS_ARB };

int value_3[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
BOOL result_3 = wglGetPixelFormatAttribivARB(hdc, 1, 0, 7, Attrib_3, value_3);

int Attrib_4[] = { WGL_SAMPLE_BUFFERS_ARB,
WGL_SAMPLES_ARB };

int value_4[] = { 0, 0, 0, 0 };
BOOL result_4 = wglGetPixelFormatAttribivEXT(hdc, 1, 0, 2, Attrib_4, value_4);

The wglGetPixelFormatAttribivARB() call seems to work fine.

The attribute list argument, 5ht argument, for wglGetPixelFormatAttribivARB() is a const int * and for wglGetPixelFormatAttribivEXT() it’s int *, but otherwise I have no reason to believe they don’t work the same way.

Except for this exception thrown by wglGetPixelFormatAttribivEXT().

Exception thrown at 0x00000000 in <app name>.exe
0xC0000005: Access violation executing location 0x00000000

There’s something in that code wglGetPixelFormatAttribivEXT() doesn’t like.

A link to wglGetPixelFormatAttribivEXT() would be valuable.

Instructions on how I find that link would be priceless.

Sorry for bitching, I do appreciate all the help everybody on this forum has given me this year.

  Thanks
  Larry

(The solution[noparse]:)[/noparse] Here’s are some very useful Google searches:

[ul]
[li]<TERM> [noparse]site:opengl.org inurl:registry[/noparse] [/li][li]<TERM> [noparse]site:opengl.org inurl:wiki[/noparse] [/li][li]<TERM> [noparse]site:opengl.org inurl:discussion_boards[/noparse] [/li][/ul]

Use the first one to search for APIs you suspect are mentioned either in an OpenGL spec or in an OpenGL extension spec.

When searching for GL function, drop the leading “gl” if it has one, as these sources omit that (for instance, search for “VertexAttribPointer”, not “glVertexAttribPointer”.

Now for the APIs you’re referring to, here are some searches to try:

[ul]
[li]wglGetPixelFormatAttribivEXT [noparse]site:opengl.org inurl:registry[/noparse] [/li][li]wglGetPixelFormatAttribivARB [noparse]site:opengl.org inurl:registry[/noparse] [/li][li]WGL_SAMPLE_BUFFERS_ARB [noparse]site:opengl.org inurl:registry[/noparse] [/li][/ul]

Well, it depends on how flexible your application can be and how demanding it can be in terms of capabilities.

If you’re requesting a standard 24/8 color/alpha and 24/8 depth/stencil double-buffer without MSAA which pretty well any GPU should have, you might just want to try that combo and assert that you got it. However, if you’d like to (for instance) optionally support MSAA (16x, 8x, 4x, or 2x, depending on what’s supported), you can make those 1 or 2 params dynamic and iterate until you successfully find a format. That’s a very reasonable solution.

Then again, if your application is super-picky and very flexible, you could go full-out and query all the attributes (that you care about) of all the pixel formats that are available, sift through them, and manually pick the one you want. GLFW does this.

In any case, you can download the GLFW, GLEW, or freeglut source code for to take a look at working code that does this WGL pixel format querying and choosing already for you. No sense in re-inventing the wheel. Alternatively, just check out this page in the OpenGL Wiki: Creating an OpenGL Context (WGL). There’s also a section here on how to enable multisampling to a window using WGL: Multisampling#Microsoft Windows (using wgl)

Keep in mind you’re only querying the values for one specific pixel format. It could very well that that pixel format doesn’t support stencil but some other pixel formats do.

Put that in a loop and check all the pixel formats. …or install GLEW, run it’s “visualinfo” tool, and let it dump out those pixel formats for you.

Thanks Dark Photon:

I’m not there yet.

I’ve downloaded both GLFW and GLEW, and built both from source.

Windows search facility can’t find “GetPixelFormatAttrib” or “ChoosePixelFormat” when searching either folder these were built in.

I don’t mind re-inventing the wheel, that can be educational and stimulate a lot of questions.

Like these:

I’m now defining my pixel format attribute array like this:

const int experimntal_attributes[] =
{
    WGL_DRAW_TO_WINDOW_ARB, 1,
    WGL_SUPPORT_OPENGL_ARB, 1,
    WGL_DOUBLE_BUFFER_ARB,  1,
    WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
    WGL_COLOR_BITS_ARB, find_attribute_value(hdc, WGL_COLOR_BITS_ARB, 64, 8),
    WGL_ALPHA_BITS_ARB, find_attribute_value(hdc, WGL_ALPHA_BITS_ARB, 64, 8),
    // WGL_DEPTH_BITS_ARB, 24,
    WGL_DEPTH_BITS_ARB, find_attribute_value(hdc, WGL_DEPTH_BITS_ARB, 64, 8),
    WGL_STENCIL_BITS_ARB, find_attribute_value(hdc, WGL_STENCIL_BITS_ARB, 64, 8),
    WGL_SAMPLE_BUFFERS_ARB, find_attribute_value(hdc, WGL_SAMPLE_BUFFERS_ARB, 1, 1),
    WGL_SAMPLES_ARB, find_attribute_value(hdc, WGL_SAMPLES_ARB, 64, 8),
    0
};

My goal is to find the pixel format attributes the installed card can use, so for testing I started looking at 64 bits and dropped values until wglChoosePixelFormatARB() was satisfied with the value for the attribute. I’ll start with realistic values for production code.

Here’s find_attribute_value():

int find_attribute_value(HDC hdc, int attribute_id, int initial_attribute_value,
                                                                                             int step_down_value)
{
    bool pixel_format_is_valid = false;
    int return_val = 0;
    int attribute_value = initial_attribute_value;
    int number_of_formats_found = 0;
    int pixel_format[] = {
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
    };
    BOOL choose_format_result = false;

#ifdef _DEBUG
    std::string attribute_name;
    pixel_format_attribute_ARB_id_to_text(attribute_id, &attribute_name);
#endif

    int pixel_format_attrib_list[] = { attribute_id, attribute_value, 0 };

    if (step_down_value > 0)
    {
        choose_format_result = wglChoosePixelFormatARB(hdc,
            pixel_format_attrib_list,
            // iPixelFormatAttribList, // Integer attribute pairs
            NULL,					// Floating attribute pairs
            10,	// Max num of formats that can be stored next argument.
            pixel_format,	// List of acceptable formats go here.
            (UINT*)&number_of_formats_found);	// Number of formats saved in list.

        if (choose_format_result && (number_of_formats_found > 0))
        {
            pixel_format_is_valid = true;
        }

        while (!pixel_format_is_valid & (attribute_value > 0))
        {
            attribute_value -= step_down_value;

            // Create a loop scoped format attribute list.
            int pixel_format_attrib_list[] = { attribute_id, attribute_value, 0 };

            choose_format_result = wglChoosePixelFormatARB(hdc,
                pixel_format_attrib_list,	// Integer attribute pairs
                NULL,						// Floating attribute pairs
                10,							// Max num of formats that can be stored next argument.
                pixel_format,				// List of acceptable formats go here.
                (UINT*)&number_of_formats_found);	// Number of formats saved in list.

            if (choose_format_result && (number_of_formats_found > 0))
            {
                pixel_format_is_valid = true;
            }
        }

        return_val = attribute_value;
    }

    return return_val;
}

Any suggestions for this code are, of course, appreciated.

The function works when I hard code the WGL_DEPTH_BITS_ARB to 24. Notice that’s been commented out. We’ll get back to that later.

I’m using this page as a reference, although this page says these are not really user references:

OpenGL application programmers should not expect an extension’s specification to fully justify why the functionality exists or how an OpenGL application would go about using the functionality.

But it’s all I can find, so it’s all I can use.

Here are some questions about wglChoosePixelFormatARB():

    BOOL wglChoosePixelFormatARB(HDC hdc,
                                 const int *piAttribIList,
                                 const FLOAT *pfAttribFList,
                                 UINT nMaxFormats,
                                 int *piFormats,
                                 UINT *nNumFormats);

What’s with all the different formats that are returned for one attribute?

When a valid number for WGL_COLOR_BITS_ARB was found the piFormats array had 10 items in it, from 1 to 10, with 0 for the 11th element. When I set nMaxFormats to 40 and made piFormats 41 elements long the array had elements from 1 to 40.

When the WGL_ALPHA_BITS_ARB value settled on 8 the array of formats was 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 0.

WGL_DEPTH_BITS_ARB settled on 32, the array was 200, 202, 204, 206, 208, 210, 0, 0, 0, 0, 0. nNumFormats is 6.

WGL_STENCIL_BITS_ARB came out as 8 with an array of 3, 4, 9, 10, 15, 16, 21, 22, 27, 28, 0.

WGL_SAMPLES_ARB was 16, the array was 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 0.

What are the numbers in the piFormats array telling me? Anything I should be doing with them?

The way I’m using it, the WGL_DEPTH_BITS_ARB returns 32 but the when the full pixel format attribute array is passed to it wglChoosePixelFormatARB() says no format’s were found. The OpenGL setup works when I pass a depth of 24.

Do I need to find a format number that each of these attribute - value pairs have in common, then use the corresponding value for each attribute and use those for a final call to wglChoosePixelFormatARB()?

I assume I’m the only person who has ever been confused by what I’m seeing.

I’ll have a lot more questions after I understand what’s going on here.

I’d appreciate an explanation. Please type slowly and use small words.

  Thanks
  Larry

GLEW itself doesn’t get involved in creating contexts, but the visualinfo and glewinfo utilities do (see the corresponding files in the src subdirectory).

For GLFW, see src/wgl_context.c.

GLFW doesn’t use ChoosePixelFormat() or wglChoosePixelFormat(); it uses either wglGetPixelFormatAttribivARB() or DescribePixelFormat() to query the number of available formats, then uses the same function to query the attributes of each format in turn. Once it has that information, it chooses the closest match (see _glfwChooseFBConfig() in src/context.c).

Those are the format codes, which can be passed to e.g. DescribePixelFormat() or wglGetPixelFormatAttribivARB() to query the format or to SetPixelFormat() to select the format.

That means that there is exists a format with 32 depth bits, and no format with more (you count down until you get at least one match).

Finding formats which satisfy a single constraint isn’t particularly useful. There’s at least one format with 32 depth bits. There’s at least one format with 8 stencil bits. There probably aren’t any formats with 32 depth bits and 8 stencil bits (it’s typically a choice between 32 depth + 0 stencil and 24 depth + 8 stencil).

No. You need to either

[ul]
[li] request all of the desired attributes at the same time with [wgl]ChoosePixelFormat(), or
[/li][li] use the GLFW approach of iterating through all known formats and choosing the best one (for whatever definition of “best” you prefer).
[/li][/ul]

Asking the OS to choose for you is simpler, but it requires some intuition about what requests might be satisfied. You need a last-resort format which has only the attributes which are absolutely necessary. You can make additional requests for formats with more features, but asking for too much may mean you end up with nothing. You can try taking your best-so-far request and asking for something slightly better, “hill-climbing” until you find the best that’s on offer; but that can get stuck in a local (false) maximum.

Querying every available format and ranking them according to some scoring system is more work, but provides the most flexibility.

Sorry, I mispoke. I meant to write GLFW and GLUT (e.g. freeglut). For GLFW, see ./src/wgl_context.c and ./src/wgl_context.h (as GClements mentioned). For freeglut, see ./src/mswin/fg_main_mswin.c. And even in GLEW you can find some of this (in glewinfo.c, glewinfo_tail.c, visualinfo.c, and glew.c) for the tools, as GClements also mentioned.

Just search for “PixelFormat” and see how they each do it. Then decide what approach you need for your application.

I don’t mind re-inventing the wheel, that can be educational and stimulate a lot of questions.

Definitely!

Thanks Dark Photon and GClements:

I messed up, and searched the directory I’d moved the WGFL binary to after I’d built it in the destination directory for the WGFL download.

Window’s search did identify WGFL source files that referenced these pixel format functions when I looked in WGFL’s download source directory.

I’m studying that code right now.

I’m wondering what the int iLayerPlane argument to wglGetPixelFormatAttribivARB() is all about. Googling “OpenGL Layer Plane” hasn’t led me to an answer.

I’m also wondering what the floating point attributes are that wglGetPixelFormatAttribfvARB() returns.

  Thanks
  Larry

It’s the overlay plane. Hardware overlays are additional framebuffers which are composited during scan-out. Overlays avoid the need to redraw all layers whenever one of them changes (which is useful if one of them contains video or animation). They may have a different format and/or colour space to the main plane (YCrCb overlays are common for video).