PDA

View Full Version : extension support failure randomly ???



amitbd
05-13-2003, 09:32 PM
Hi,

I am using the wgl pbuffer extension using the standart method of extension retrieval.

randomly after about 1000 or more uses of the extension (or for some other weird reason) My GForce2/Geforce3 based graphic card stops supporting extensions in total :
all calls to wglGetProcAddress with any extension what so ever returns NULL.

this occurs not only localy in the using application but also effects other apps that try to work with extensions. standart OpenGL Code seems to work fine.

trying to work with a previous pointer to the extension results with massive increese of the computer memory. 10MBS for every use of the extension. this only happens after the first failure of the extension retrieval.

It would also help if anyone knows of a way to initialize the card via OpenGL so that if this problem occurs i will be able to reset everything and start the app again. instead of restarting the computer.

Please help,
Amit

rgpc
05-13-2003, 09:38 PM
Originally posted by amitbd:
randomly after about 1000 or more uses of the extension (or for some other weird reason) My GForce2/Geforce3 based graphic card stops supporting extensions in total :
all calls to wglGetProcAddress with any extension what so ever returns NULL.


Are you calling wglGetProcAddress repeatedly for the same extension in the same session? If so, why not just call it once, and be done with it. Once you have the extension pointer you don't need to ask for it again.

V-man
05-14-2003, 06:26 AM
>>>trying to work with a previous pointer to the extension results with massive increese of the computer memory. 10MBS for every use of the extension. this only happens after the first failure of the extension retrieval.<<<

Post your code where you destroy the p-buffer.

amitbd
05-14-2003, 08:56 AM
I have tried to do it once in the beginning of the the app and calling the extension using the previous pointer, however this resulted in the memory increase i talked about when rendering to the pbuffer.

another wierd thing is that using glReadPixels with GL_RGB returned an empty(black) frame where using it to with GL_DEPTH_COMPONENT returned valid data.

I will post my pbuffer destruction code tommorow when i get to work.

amitbd
05-14-2003, 08:58 PM
here is my pbuffer initialization , activation and destruction methods




void CPixelBuffer::Init(int w, int h, int colorBits, int depthBits, bool share)
{
int iAttributes[MAX_ATTRIBS*2] = {WGL_DRAW_TO_PBUFFER_ARB, true,
WGL_COLOR_BITS_ARB, colorBits,
WGL_DEPTH_BITS_ARB, depthBits,
WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
//WGL_SAMPLE_BUFFERS_EXT,1,
//WGL_SAMPLES_EXT, 2,
0,0};

float fAttributes[MAX_ATTRIBS*2] = {0};
int pFormats[MAX_PFORMATS];
int format;
unsigned int nFormats = 0;
HDC hDC;

// Save pbuffer settings
width = w;
height = h;
m_cBits = colorBits;
m_dBits = depthBits;
m_share = share;

// Retrieve device context of current window
hDC = wglGetCurrentDC();
if (!hDC)
hDC = ::CreateCompatibleDC(NULL);

// Select a pixel format based on the values in iAttributes
if (!wglChoosePixelFormatARB(hDC, iAttributes, fAttributes, MAX_PFORMATS, pFormats, &amp;nFormats))
return;

// Select first format
format = pFormats[0];

// Terminate attributes list at the beginning
iAttributes[0] = 0;

// Create the pbuffer
m_pbuf = wglCreatePbufferARB(hDC, format, width, height, iAttributes);
if (!m_pbuf)
return;

// Retrieve the device context of the pbuffer
m_DC = wglGetPbufferDCARB(m_pbuf);
if (!m_DC)
{
this->~CPixelBuffer();
return;
}

// Create a rendering context for the pbuffer
m_RC = wglCreateContext(m_DC);
if (!m_RC)
{
this->~CPixelBuffer();
return;
}

int size;
glGetIntegerv(GL_MAX_TEXTURE_SIZE,&amp;size);

if (share)
wglShareLists(wglGetCurrentContext(), m_RC);

// Success
m_isValid = true;
}

void CPixelBuffer::Activate()
{
if (m_isValid)
{
// Ensure pbuffer isn't already active (is active only if we have a saved DC or RC)
if (m_oldDC &amp;#0124; &amp;#0124; m_oldRC)
this->Deactivate();

// Save current device context and rendering context
m_oldDC = wglGetCurrentDC();
m_oldRC = wglGetCurrentContext();

// Make pbuffer device context and rendering context active
wglMakeCurrent(m_DC, m_RC);
}
}

void CPixelBuffer::Restore()
{
int lost = 0;

if (m_isValid)
{
// Check to see if pbuffer memory was lost due to a display mode change
wglQueryPbufferARB(m_pbuf, WGL_PBUFFER_LOST_ARB, &amp;lost);
if (lost)
{
// If so, destroy the pbuffer and create it again using the same settings
this->Release();
this->Init(width, height, m_cBits, m_dBits, m_share);
}
}
}

void CPixelBuffer: http://www.opengl.org/discussion_boards/ubb/biggrin.gifeactivate()
{
if (m_oldDC &amp;&amp; m_oldRC)
{
// Restore previous device context and rendering context
wglMakeCurrent(m_oldDC, m_oldRC);

m_oldDC = 0;
m_oldRC = 0;
}
}

void CPixelBuffer::Release()
{
// Restore previous rendering context
this->Deactivate();

// Delete pbuffer rendering context
wglDeleteContext(m_RC);

// Release the pbuffer device context
wglReleasePbufferDCARB(m_pbuf, m_DC);

// Destroy the pbuffer
wglDestroyPbufferARB(m_pbuf);

// pbuffer is no longer valid
m_isValid = false;
}

CPixelBuffer::~CPixelBuffer()
{
this->Release(); //return if pbuffer is activated

// Reset member variables to 0
width = 0;
height = 0;
m_cBits = 0;
m_dBits = 0;
m_RC = 0;
m_DC = 0;
m_pbuf = 0;
m_share = false;
m_isValid = false;
}



maybe this has to do with the pbuffer size i am creating - maximum of (2Kx1.5K)

All help is blessed,
Amit

V-man
05-15-2003, 04:26 AM
Well, before you destroy the buffer, you should call
wglMakeCurrent(NULL, NULL);

Also, before you create the p-buffer, you must call the above line again.

and from your code, it's hard to say what's going on.

It also looks like you are asking for a color buffer so if you can't get anything using glReadPixels ...

Humus
05-15-2003, 05:14 AM
Why would you need to call wglMakeCurrent(NULL, NULL) before creating a pBuffer?