|
From: David E. <eg...@go...> - 2008-10-19 02:20:14
|
Dear Mesa Users,
I have what I expect is a typical usage scenario, but I'm having a
hard time getting all of the pieces to fall into place. I would like
to use Mesa to load up many textures and models and then use them to
render images of various resolutions on user request. My first
attempt to order things was as follows:
[A] context = OSMesaCreateContextExt(OSMESA_RGBA, 0, 0, 0, NULL);
[B] glGenTextures(1, &tex_id1); glBindTexture(GL_TEXTURE_2D, tex_id1); ...
glGenTextures(1, &tex_id2); glBindTexture(GL_TEXTURE_2D, tex_id2); ...
[C] OSMesaMakeCurrent(
context, render_buffer, GL_UNSIGNED_BYTE,
w, h),
[D] glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, (GLfloat)w, 0.0, (GLfloat)h);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(QUADS);...glEnd(); glFlush();
glReadPixels()..
However, I found that repeated calls to glGenTextures() all yielded
texture id's of 0. I then moved the ordering to the following:
[A] context = OSMesaCreateContextExt(OSMESA_RGBA, 0, 0, 0, NULL);
[C1] OSMesaMakeCurrent(
context, render_buffer, GL_UNSIGNED_BYTE,
1, 1),
[B] glGenTextures(1, &tex_id1); glBindTexture(GL_TEXTURE_2D, tex_id1); ...
glGenTextures(1, &tex_id2); glBindTexture(GL_TEXTURE_2D, tex_id2); ...
[C2] OSMesaMakeCurrent(
context, render_buffer, GL_UNSIGNED_BYTE,
w, h),
[D] glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, (GLfloat)w, 0.0, (GLfloat)h);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(QUADS);...glEnd(); glFlush();
glReadPixels()..
This "fixed" the repeated calls to glGenTextures - they produce
distinct texture ids as advertised. However, C2 appears to have only
partially worked. The glClear() does indeed wipe all pixels in the
newly enlarged render buffer, but the output from glBegin()...glEnd()
is confined to the original 1 pixel! Is it intended that one cannot
re-bind a context created with OSMesaCreateContext(Ext) to multiple
buffers over time?
If it helps to know, I'm using Mesa 6.4.2 (it's the default on my system).
-David
|