Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7629589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:52:23+00:00 2026-05-31T05:52:23+00:00

Some time ago I started working on OpenGL(3.3) renderer for MFC program.Everything was fine

  • 0

Some time ago I started working on OpenGL(3.3) renderer for MFC program.Everything was fine till I decided to run some OpenGL debugging tools to see if I have some silent errors.I used
gDEBugger .Running gDebug program analyzing tool I immediately started getting errors of the following type:

Debug String: Detected error: The debugged process asked for an extension function pointer (glGenBuffers) from one render context, but called this function pointer in another render context (context #2)

In fact every GLEW method gets this error.Now I started looking for a problem in forums and also on MSDN and I found some people mention that in Windows environment some GLEW methods pointers should be redefined.Also I stumbled upon this tutorial which shows how pretty every GLEW method is redefined using Windows OpenGL methods like these:

void CGLRenderer::InitAPI()
{
  // Program
  glCreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram");
  glDeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram");
  glUseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram");
  ...
  ....

My OpenGL context set-up looks like this:

   bool OpenGLMain::create30Context(HDC device_context){
//this->hwnd=hwnd;


hdc=device_context;//GetDC(hwnd);

hdcGlobal=&hdc;


   PIXELFORMATDESCRIPTOR kPFD;
   memset(&kPFD,0,sizeof(PIXELFORMATDESCRIPTOR));
   kPFD.nSize=sizeof(PIXELFORMATDESCRIPTOR);
   kPFD.nVersion=1;
   kPFD.dwFlags=
   PFD_DRAW_TO_WINDOW|
   PFD_SUPPORT_OPENGL|
   PFD_GENERIC_ACCELERATED|
   PFD_DOUBLEBUFFER;
   kPFD.iPixelType=PFD_TYPE_RGBA;
   kPFD.cColorBits=32;
   kPFD.cDepthBits=32;
   kPFD.cStencilBits=8;
   kPFD.iLayerType=PFD_MAIN_PLANE;

   int iPixelFormat=ChoosePixelFormat(hdc,&kPFD);
   if(iPixelFormat==0){
 //  ReleaseDC(window,gs_hWindowDC);
   return false;
   }
  BOOL bSuccess=SetPixelFormat(hdc,iPixelFormat,&kPFD);
  if(!bSuccess){
  // ReleaseDC(window,gs_hWindowDC);
   return false;
   }

   /////////init opengl context

  HGLRC tempOpenGLContext=wglCreateContext(hdc);/////Openggl 2.1
  wglMakeCurrent(hdc,tempOpenGLContext);////male openGL 2.1 context current and active
  GLenum error =glewInit();

  if(error!=GLEW_OK){
   return false;
  }
   /////////context setup///////
   int attributes[]={
   WGL_CONTEXT_MAJOR_VERSION_ARB,3,
   WGL_CONTEXT_MINOR_VERSION_ARB,2,
   WGL_CONTEXT_FLAGS_ARB,WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,0


                    };


   if(wglewIsSupported("WGL_ARB_create_context")==1){

   hrc=wglCreateContextAttribsARB(hdc,NULL,attributes);///create OpenGL 3x context based on the supplied attributes
   wglMakeCurrent(NULL,NULL);//remove temp context
   wglDeleteContext(tempOpenGLContext);
   wglMakeCurrent(hdc,hrc);


  }else{
   hrc=tempOpenGLContext;////if no support for OGL 3x detected roll back to 2.0
  }
   /////////version check///////////////
   int glVersion[2]={-1,-1};
   glGetIntegerv(GL_MAJOR_VERSION,&glVersion[0]);
   glGetIntegerv(GL_MINOR_VERSION,&glVersion[1]);

     std::cout<<"Using openGL"<<glVersion[0]<<"."<<glVersion[1]<<
     std::endl;     
 OutputDebugString(L"Using OPENGL version:"+glVersion[0]);

return true;
  }

Now I am really confused at this point because in fact the program runs fine inside VisualStudio without redefining all these GLEW methods.But it shows the empty screen (no geometry) if I run the executable directly.Also in all the other examples and tutorials I have ever read it had never been mentioned that one has to reset pointers on GLEW API methods.So my question is if anybody can point out to the right way to integrate OpenGL 3.3 in Windows API because it seems that there are many ways doing it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:52:24+00:00Added an answer on May 31, 2026 at 5:52 am

    The function pointers you get are based on the current context. That is, it is entirely possible for you to get different function pointers for different OpenGL contexts. gDEBugger is telling you that it has detected that you’re using function pointers with a different context from the one used to acquire them. Which is not guaranteed to work.

    That being said, it generally will work. It won’t work if the two contexts aren’t from the same vendor (and probably for the same GPU or SLI/CrossFire GPU setup). But if they are, it should be fine.

    GLEW, as I understand it, doesn’t have a way to accommodate two different contexts that don’t use the same function pointers. You would have to call glewInit every time you changed contexts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started using Sandcastle some time ago to generate a Documentation Website for one
OK, I am officially flabbergasted. I started an IOS project some time ago, and
I started using jQuery Mobile some time ago, and as those that know jQuery
I have started in web development not long time ago. I know some stuff
I've started using Vim some time ago. So far - I enjoyed my experience
Some time ago I started a project in which I needed to do the
I found this call in an app I started managing some time ago: /usr/bin/sftp
I started web development some time ago, but have invested essentially all my time
I started a website some time ago using the wrong CHARSET in my DB
I started to learn everything connected with Azure platform a little time ago. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.