 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
FLEXPLAN3D
Joined: 25 Feb 2011 Posts: 22
|
Posted: Mon Jan 25, 2021 10:17 pm Post subject: Opengl Extensions |
|
|
This question is probably for Silverfrost Developers.
The clearwin support for Opengl has not kept pace with the more recent extensions to the Opengl API.
In particular the number of wgl function prototypes in the WINGDI.H are now very limited.
One feature that I would like to make use of, which pretty well all graphic cards support, is multi-sampling which is an anti-aliasing feature which smooths jagged lines. This requires the setting up of a multisampled frame buffer.
The Opengl documentation shows that this can be set up with the appropriate wgl function calls or more simply using the GLUT library to initialise the display.
Neither of these options seem to currently available with the Silverfrost compilers.
Is there any way that multi-sampling can be implemented at present ?
Ideally an extra argument to the %og statement would be useful
eg. %^og[stencil,double,depth32,multisample4] |
|
Back to top |
|
 |
DanRRight

Joined: 10 Mar 2008 Posts: 2274 Location: South Pole, Antarctica
|
Posted: Tue Jan 26, 2021 7:25 am Post subject: |
|
|
You don't have glut32.dll ? |
|
Back to top |
|
 |
PaulLaidler Site Admin

Joined: 21 Feb 2005 Posts: 6821 Location: Salford, UK
|
Posted: Tue Jan 26, 2021 8:23 am Post subject: |
|
|
FLEXPLAN3D
Could you provide links to the functions that you want to use?
If they are not already in opengl.ins then it should be a simple matter to add them.
Providing support via the %gl options may be possible. Again some illustrative C code would help. |
|
Back to top |
|
 |
FLEXPLAN3D
Joined: 25 Feb 2011 Posts: 22
|
Posted: Sat Jan 30, 2021 11:30 am Post subject: Opengl Extensions |
|
|
This code to set multisampling is taken from Opengl Superbible by R wright. I cannot get it to compile with SCC compiler.
I think if this worked I could access the multi-sampling I require.
As you can see it needs quite a few extra wgl functions.
#include <windows.h>
//extract from GLTools.h
int gltIsWGLExtSupported(HDC hDC, const char *szExtension);
// extract from WGLEXT.h
extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC, int, int, UINT, const int *, int *);
extern BOOL WINAPI wglChoosePixelFormatARB (HDC, const int *, const FLOAT *, UINT, int *, UINT *);
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
// Find the best available pixelformat, including if Multisample is available
void FindBestPF(HDC hDC, int *nRegularFormat, int *nMSFormat);
///////////////////////////////////////////////////////////////////////////////
// Select pixelformat with desired attributes
// Returns the best available "regular" pixel format, and the best available
// Multisampled pixelformat (0 if not available)
void FindBestPF(HDC hDC, int *nRegularFormat, int *nMSFormat)
{
*nRegularFormat = 0;
*nMSFormat = 0;
// easy check, just look for the entrypoint
if(gltIsWGLExtSupported(hDC, "WGL_ARB_pixel_format"))
if(wglGetPixelFormatAttribivARB == NULL)
wglGetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
wglGetProcAddress("wglGetPixelFormatAttribivARB");
// First try to use new extended wgl way
if(wglGetPixelFormatAttribivARB != NULL)
{
// Only care about these attributes
int nBestMS = 0;
int i;
int iResults[9];
int iAttributes [9] = { WGL_SUPPORT_OPENGL_ARB, // 0
WGL_ACCELERATION_ARB, // 1
WGL_DRAW_TO_WINDOW_ARB, // 2
WGL_DOUBLE_BUFFER_ARB, // 3
WGL_PIXEL_TYPE_ARB, // 4
WGL_DEPTH_BITS_ARB, // 5
WGL_STENCIL_BITS_ARB, // 6
WGL_SAMPLE_BUFFERS_ARB, // 7
WGL_SAMPLES_ARB }; // 8
// How many pixelformats are there?
int nFormatCount[] = { 0 };
int attrib[] = { WGL_NUMBER_PIXEL_FORMATS_ARB };
wglGetPixelFormatAttribivARB(hDC, 1, 0, 1, attrib, nFormatCount);
// Loop through all the formats and look at each one
for(i = 0; i < nFormatCount[0]; i++)
{
// Query pixel format
wglGetPixelFormatAttribivARB(hDC, i+1, 0, 9, iAttributes, iResults);
// Match? Must support OpenGL AND be Accelerated AND draw to Window
if(iResults[0] == 1 && iResults[1] == WGL_FULL_ACCELERATION_ARB && iResults[2] == 1)
if(iResults[3] == 1) // Double buffered
if(iResults[4] == WGL_TYPE_RGBA_ARB) // Full Color
if(iResults[5] >= 16) // Any Depth greater than 16
if(iResults[6] > 0) // Any Stencil depth (not zero)
{
// We have a candidate, look for most samples if multisampled
if(iResults[7] == 1) // Multisampled
{
if(iResults[8] > nBestMS) // Look for most samples
{
*nMSFormat = i; // Multisamples
nBestMS = iResults[8]; // Looking for the best
}
}
else // Not multisampled
{
// Good enough for "regular". This will fall through
*nRegularFormat = i |
|
Back to top |
|
 |
PaulLaidler Site Admin

Joined: 21 Feb 2005 Posts: 6821 Location: Salford, UK
|
Posted: Sat Jan 30, 2021 5:11 pm Post subject: |
|
|
FLEXPLAN3D
Your post may have been truncated. If it is very large then you could use something like DropBox. |
|
Back to top |
|
 |
FLEXPLAN3D
Joined: 25 Feb 2011 Posts: 22
|
Posted: Sat Jan 30, 2021 8:18 pm Post subject: Opengl Extensions |
|
|
Paul
My apologies - here is the missing bit.
I can send a file if you wish, but I don't have a contact e-mail for you.
Thanks
Bob
}
}
}
}
else
{
// Old fashioned way...
// or multisample
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA, // Full color
32, // Color depth
0,0,0,0,0,0,0, // Ignored
0,0,0,0, // Accumulation buffer
24, // Depth bits
8, // Stencil bits
0,0,0,0,0,0 }; // Some used, some not
*nRegularFormat = ChoosePixelFormat(hDC, &pfd);
}
} |
|
Back to top |
|
 |
PaulLaidler Site Admin

Joined: 21 Feb 2005 Posts: 6821 Location: Salford, UK
|
Posted: Tue Mar 30, 2021 1:02 pm Post subject: |
|
|
Bob
I have had a look at your code.
I can get it to compile by downloading wglext.h from the Internet and by commenting out the call to wglGetProcAddress (which would not be needed if the relevant DLL is available at link time).
Sorry but I don't see any way to progress from this point. |
|
Back to top |
|
 |
FLEXPLAN3D
Joined: 25 Feb 2011 Posts: 22
|
Posted: Tue Mar 30, 2021 4:18 pm Post subject: |
|
|
Paul
Thanks for looking at it - if you can think of any other way of implemented multi-sampling I would still be interested.
Bob |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|