Hi Wolfgang, thank you for reply but I'm sorry I don't understand your
message, I'm a newbie in OpenGL and I'm no expert in context ecc
ecc...
Just to be clear, I'm using this code
OGLPlo = new COpenGLControl();
....
CString className = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW |
CS_OWNDC,NULL,(HBRUSH)StockObject(BLACK_BRUSH),NULL);
CreateEx( 0,className,"OpenGL",WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
| WS_CLIPCHILDREN,
rect,parent,0);
....
dc = new CClientDC(this);
....
openGLDevice.create(dc->m_hDC);
bool OpenGLDevice::create(HDC& deviceContext,int stencil)
{
if (!deviceContext)
{
return false;
}
if (!setDCPixelFormat(deviceContext,stencil))
{
return false;
}
renderContext = wglCreateContext(deviceContext);
wglMakeCurrent(deviceContext, renderContext);
OpenGLDevice::deviceContext = deviceContext;
return true;
}
....
"COpenGLControl::InitGL"
....
"COpenGLControl::OnSize"
.... <---- ERROR dc=0
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
....
Disegna_Barre();
....
SwapBuffers(dc->m_hDC);
Here there are the main instruction used to create the OpenGL windows,
it works fine in normal way (when the OnPaint is called from WM_PAINT)
but when I try to call OnPaint without WM_PAINT (I'm calling OnPaint
from a function inside the ogl class each time a new data is
available) the dc is ok before the OnPaint calling, after the dc=0 and
an error occours in
SwapBuffers(dc->m_hDC);
I hope make clear, thank you in advance
Alberto


|