PDA

View Full Version : Rendering context on windows 2000 NULL.........



catchshailu
04-03-2003, 09:40 AM
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

Deiussum
04-03-2003, 10:03 AM
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.

HalcyonBlaze
04-03-2003, 10:36 AM
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

Deiussum
04-03-2003, 11:51 AM
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.

catchshailu
04-04-2003, 01:16 AM
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 \n ");
scanf("%c", &temp);
}

*hglrc = wglCreateContext( *hdc );
if(*hglrc == NULL)
{
printf("Rendering context not found \n ");
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?????

Deiussum
04-04-2003, 05:20 AM
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?