[wxGLCanvas] GL commands don't work
ABE Hiroshi
hiroshi.abe at na-net.ornl.gov
Tue Jul 3 17:35:38 PDT 2007
Hi,
I'm working with a derived class from wxGLCanvas, named View3D class.
I wrote a code for taking snapshot of GL view as is shown in the
bottom of this mail.
It works fine when it is called from Main thread. But from a wxThread
derivative OpenGL commands seems not to work.
For example, if glGetIntergerv(GL_VIEWPORT, view) is called in
View3D::snapshot(), view[4] stores proper value when it called from
main thread but from child thread the command is ignored.
glReadPixels doesn't return any proper data either.
The code are work fine in MacOSX (wxWidgets 2.6.4) but in Windows.
The Env. is:
WIndows XP sp2
wxWidgets 2.6.3
Visual Express 2005
Is it possible that a child thread control the main thread's
GLcanvas? Or something is missing in my code?
It would be obliged if you tell me the solutions/advices on this.
Thank you very much.
wxImage*
View3D::snapshot() {
GLint view[4];
SetCurrent();
glGetIntegerv(GL_VIEWPORT, view);
size_t sz = 3*sizeof(char)* view[2]*view[3];
void* pixels = (char *)::malloc( sz );
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadBuffer(GL_FRONT);
glReadPixels( 0,0, view[2], view[3], GL_RGB, GL_UNSIGNED_BYTE,
pixels );
wxImage* img = new wxImage( (int)view[2], (int)view[3] );
img->SetData((unsigned char*)pixels);
*img = img->Mirror(false);
return img;
}
ABE Hiroshi
from Tokorozawa, JAPAN
More information about the wx-users
mailing list