Discussion:
glPolygonOffset not supported on Windows?
(too old to reply)
Robert Small
2013-09-04 23:43:12 UTC
Permalink
Windows 7 + DelphiXE4

I have a problem with two spheres (both same size, one red the other
green). When they are drawn at the same location the resultant sphere
is drawn with a speckled appearance.

A bit of reseach found the "Z fighting" problem, together with the
solution of using glPolygonOffset.

The Delphi supplied OpenGL header doesn't include glPolygonOffset so I
add all the code necessary.

And it all works as expected.

But wait, there is a problem.

When I setup my on screen rendering, I call ChoosePixelFormat and
specify
PFDFlags := PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or
PFD_DOUBLEBUFFER;
PFDPixelType := PFD_TYPE_RGBA;
PFDColorBits := 24;
PFDDepthBits := 32;

which is working OK.

In order to do a hard copy print, I Clean up and terminate Screen DC
and RC and then Create an off screen buffer, Select a pixel format,
Create and bind an OpenGL rendering context.
The pixel format is specified as
PFDFlags := PFD_DRAW_TO_BITMAP or PFD_SUPPORT_OPENGL;

I then call wglGetProcAddress('glPolygonOffset') but this fails with
error 127 The specified procedure could not be found.

According to the MSDN help for wglGetProcAddress

The OpenGL library supports multiple implementations of its functions.
Extension functions supported in one rendering context are not
necessarily available in a separate rendering context. Thus, for a
given rendering context in an application, use the function addresses
returned by the wglGetProcAddress function only.

The extension function addresses are unique for each pixel format. All
rendering contexts of a given pixel format share the same extension
function addresses.
--
Bob Small
Robert Small
2013-09-05 01:12:28 UTC
Permalink
Post by Robert Small
Windows 7 + DelphiXE4
I have a problem with two spheres (both same size, one red the other
green). When they are drawn at the same location the resultant sphere
is drawn with a speckled appearance.
A bit of reseach found the "Z fighting" problem, together with the
solution of using glPolygonOffset.
The Delphi supplied OpenGL header doesn't include glPolygonOffset so I
add all the code necessary.
And it all works as expected.
But wait, there is a problem.
When I setup my on screen rendering, I call ChoosePixelFormat and
specify
PFDFlags := PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or
PFD_DOUBLEBUFFER;
PFDPixelType := PFD_TYPE_RGBA;
PFDColorBits := 24;
PFDDepthBits := 32;
which is working OK.
In order to do a hard copy print, I Clean up and terminate Screen DC
and RC and then Create an off screen buffer, Select a pixel format,
Create and bind an OpenGL rendering context.
The pixel format is specified as
PFDFlags := PFD_DRAW_TO_BITMAP or PFD_SUPPORT_OPENGL;
I then call wglGetProcAddress('glPolygonOffset') but this fails with
error 127 The specified procedure could not be found.
According to the MSDN help for wglGetProcAddress
The OpenGL library supports multiple implementations of its functions.
Extension functions supported in one rendering context are not
necessarily available in a separate rendering context. Thus, for a
given rendering context in an application, use the function addresses
returned by the wglGetProcAddress function only.
The extension function addresses are unique for each pixel format. All
rendering contexts of a given pixel format share the same extension
function addresses.
Problem solved.

I used
GL_LibHandle := LoadLibrary('OpenGL32.dll');
glPolygonOffset := GetProcAddress(GL_LibHandle,'glPolygonOffset');
instead of
glPolygonOffset := wglGetProcAddress('glPolygonOffset')
and it all works OK.
--
Bob Small
Nobody
2013-09-05 16:59:46 UTC
Permalink
Post by Robert Small
The Delphi supplied OpenGL header doesn't include glPolygonOffset so I
add all the code necessary.
That's odd. glPolygonOffset() is from OpenGL 1.1, and exported directly
from opengl32.dll; using wglGetProcAddress() is unnecessary (and may not
even work; wglGetProcAddress isn't supposed to be used for core functions).
Loading...