Rendering context on windows 2000 NULL.........

Hi there,
I m working on win2000 trying to display some grid made by some triangles(10000).But after drawing some triangles the application doesn’t get the rendering context.

HGLRC *hglrc;
*hglrc = wglCreateContext( *hdc );

The value of hglrc is NULL.
Help me out please…

Bye

After drawing triangles you don’t get a rendering context? That’s your problem right there you need to get a rendering context before you draw your triangles. And before wglCreateContext will work, you need to set the pixelformat of the HDC with the Choose/Describe/SetPixelFormat functions.

And i don’t think you want to be using pointers…well you might be able to but you typically don’t have to for getting rendering contexts

  • Halcyon

Good point Halcyon. Especially since he’s not allocating any memory for the pointer, but yet dereferencing it to store the HGLRC. In most cases that’s going to cause a page fault.

First of all thanks for ur replies…

My primary purpose of using pointers is to pass the empty HDC & HGLRC to function getHDCHGLRC() which gives me the both values so that i can use it when i need rendering context i.e

///////////////////////
getHDCHGLRC(&hdcglbvar, &hglrcglbvar);
wglMakeCurrent( hdcglbvar, hglrcglbvar );
/////////////////////

void getHDCHGLRC(HDC *hdc, HGLRC *hglrc)
{
char temp;

*hdc = getHDC();
if(*hdc == NULL)
{
	printf("could not get the device context 

“);
scanf(”%c", &temp);
}

*hglrc = wglCreateContext( *hdc );
if(*hglrc == NULL)
{
	printf("Rendering context not found 

");
exit(0);
}

}

Whenever i have to draw , i m calling getHDCHGLRC(…). & making current rendering context. Is this ok? or any other solution???

As far as Deiussum is saying abt the pixelformat setting ,?I have already done it while initializing the openGL. Do i need to do it each & every time…
Any suggestions???

If you’ve already set the pixelformat while initializing OpenGL, you should have already done a wglCreateContext. That only needs to be done when you initialize the window, so I’m not quite sure why you’re trying to create it again. Maybe what you want instead is wglMakeCurrent?