SetPixelFormat() fails on canvases

BlitzMax Forums/BlitzMax OpenGL Programming/SetPixelFormat() fails on canvases

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

All I have to do is add an antialias flag to the graphics module. Open the file glgraphics.win32.c and find the flags at the beginning, and make them look like this:
enum{
	_BACKBUFFER=	0x2,
	_ALPHABUFFER=	0x4,
	_DEPTHBUFFER=	0x8,
	_STENCILBUFFER=	0x10,
	_ACCUMBUFFER=	0x20,
	_ANTIALIAS2X=	0x40,
	_ANTIALIAS4X=	0x80,
	_ANTIALIAS8X=	0x100,
	_ANTIALIAS16X=	0x200,
};


Now anywhere the code says ChoosePixelFormat(), we want to use wglChoosePixelFormatARB().

wglChoosePixelFormatARB is an extension. You have to retrieve the function pointer with wglGetProcAddress(). Here is an example of another extensio file being called in the same source file:
typedef BOOL (APIENTRY * WGLSWAPINTERVALEXT) (int);

static int _setSwapInterval( int n ){
	WGLSWAPINTERVALEXT 	wglSwapIntervalEXT=(WGLSWAPINTERVALEXT)wglGetProcAddress("wglSwapIntervalEXT");
	if( wglSwapIntervalEXT ) wglSwapIntervalEXT( n );
}


I need to convert the antialias flags into a multisample value, but I can't make sense enough of C gibberish to do that. In basic it would just be this:
If (_ANTIALIAS2X & flags) multisample=2
If (_ANTIALIAS4X & flags) multisample=4
If (_ANTIALIAS8X & flags) multisample=8
If (_ANTIALIAS16X & flags) multisample=16


Finally, the function wglChoosePixelFormatARB has additional parameters. In my own code, it gets called like this:
wglChoosePixelFormatARB(hDC,[WGL_DRAW_TO_WINDOW_ARB,GL_TRUE,WGL_SUPPORT_OPENGL_ARB,GL_TRUE,WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB,WGL_COLOR_BITS_ARB,24,WGL_ALPHA_BITS_ARB,8,WGL_DEPTH_BITS_ARB,16,WGL_DOUBLE_BUFFER_ARB,GL_TRUE,WGL_SAMPLE_BUFFERS_ARB,GL_TRUE,WGL_SAMPLES_ARB,multisample,0,0],[0.0,0.0],1,Varptr lPixelFormat,Varptr numFormats)


So there you have it. Pretty easy to set up, but my limited knowledge of C prevents me from doing it. If this were set up correctly, Max GL graphics could have an optional antialias flag when initialized.