void OGL_GRAPHICS::SetUpOGLwindow(HWND OGLwnd,double HorizontaDim, double VerticalDim, DWORD projection, DWORD bkColor)
{
int pf,w,h,buf;
memset(&pfd,0,sizeof(PIXELFORMATDESCRIPTOR));
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_TYPE_RGBA;
pfd.cColorBits = 32;
pfd.cDepthBits = 32;
pfd.cStencilBits = 1;
pfd.cAuxBuffers = 0;
pfd.iLayerType = PFD_MAIN_PLANE;
glWnd = OGLwnd;
oWinDc = GetDC(glWnd);
pf = ChoosePixelFormat(oWinDc,&pfd);
SetPixelFormat(oWinDc,pf,&pfd);
if(!arbMultisampleSupported)
{
pf = ChoosePixelFormat(oWinDc,&pfd);
}
else
{
pf = arbMultisampleFormat;
}
OGLhdc = wglCreateContext(oWinDc); // create GL device context
wglMakeCurrent(oWinDc,OGLhdc); // and make it to the current
GetClientRectDimensions(glWnd,&w,&h);
glViewport(0,0,w,h); // define a view over the whole screen
glMatrixMode(GL_PROJECTION); // prepare and set Set Projection matrix
glLoadIdentity(); // initialize the matrix
glShadeModel(GL_SMOOTH);
if(!projection)
glOrtho(-HorizontaDim / 2.0,HorizontaDim / 2.0,-VerticalDim / 2.0,VerticalDim / 2.0,-10.0,10.0); // switch to orthographic projection
glWidth = HorizontaDim;
glHight = VerticalDim;
glMatrixMode(GL_MODELVIEW); // Switch back to model view matrix
glLoadIdentity(); // and initialize
glPixelStorei(GL_UNPACK_ALIGNMENT,1); // define pixel handling
glEnable(GL_STENCIL_TEST); // we will use the help of the stencil buffer
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); // set the global blending logic
glEnable(GL_MULTISAMPLE);
glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST);
glGetIntegerv(GL_SAMPLE_BUFFERS_ARB,&buf);
CreateColor(bkColor,&BackGroundRed,&BackGroundGreen,&BackGroundBlue);
glClearColor(BackGroundRed,BackGroundGreen,BackGroundBlue,0.0f); // define the clear color for the panel
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // clear video buffer and stencil buffer
glEnable(GL_LINE_SMOOTH);
glEnable(GL_POINT_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
glEnable(GL_POLYGON_SMOOTH);
glHint(GL_POLYGON_SMOOTH_HINT,GL_NICEST);
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
glEnable(GL_BLEND);
defaultFontID = PrepareOGLfonts(oWinDc,"Arial");
}