00001
00006 #include "WGL.h"
00007
00008
00009 #ifdef ENABLE_OPENGL
00010
00011 using namespace jbxl;
00012 using namespace jbxwl;
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 HGLRC jbxwl::WGLCreateContext(CDC* pDC, PIXELFORMATDESCRIPTOR* param)
00023 {
00024 HGLRC hrc = NULL;
00025 BOOL ret = FALSE;
00026
00027
00028 int pixelformat = ::ChoosePixelFormat(pDC->GetSafeHdc(), param);
00029 if (pixelformat) ret = ::SetPixelFormat(pDC->GetSafeHdc(), pixelformat, param);
00030
00031 if (ret) {
00032 hrc = ::wglCreateContext(pDC->GetSafeHdc());
00033 if (hrc) {
00034 ret = ::wglMakeCurrent(pDC->GetSafeHdc(), hrc);
00035 if (!ret) {
00036 ::wglDeleteContext(hrc);
00037 hrc = NULL;
00038 }
00039 }
00040 }
00041 return hrc;
00042 }
00043
00044
00045
00046
00047 BOOL jbxwl::WGLGetCurrent(CDC* pDC, HGLRC hrc)
00048 {
00049 return ::wglMakeCurrent(pDC->GetSafeHdc(), hrc);
00050 }
00051
00052
00053
00054
00055
00056 void jbxwl::WGLDeleteContext(HGLRC hrc)
00057 {
00058 ::wglMakeCurrent(NULL, NULL);
00059 ::wglDeleteContext(hrc);
00060 }
00061
00062
00063
00064 #endif // ENABLE_OPENGL
00065
00066
00067
00068
00069