Hi all,
I want to render-to-vertex-array using pbo and vbo in a p-buffer. Here’s some code:
void test()
{
// pbuffer->Activate();
static bool done(false);
if (!done) {
BuildMesh();
done = true;
}
int vp[4];
glGetIntegerv(GL_VIEWPORT, vp);
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-1, 1, -1, 1, -1, 1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glEnable(texType);
glBindTexture(texType, hNodeTex[0]);
glBegin(GL_QUADS);
glColor3f(1.0f, 1.0f, 1.0f);
glTexCoord2f(0, 0); glVertex3f(-1, -1, 0);
glTexCoord2f(1, 0); glVertex3f( 1, -1, 0);
glTexCoord2f(1, 1); glVertex3f( 1, 1, 0);
glTexCoord2f(0, 1); glVertex3f(-1, 1, 0);
glEnd();
glDisable(texType);
GLfloat pixels[width*height*4];
glReadPixels(0, 0, width, height, GL_RGBA, GL_FLOAT, pixels);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glViewport(vp[0], vp[1], vp[2], vp[3]);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(4, GL_FLOAT, 0, pixels);
// pbuffer->Deactivate();
glDrawArrays(GL_QUADS, 0, width*height);
}
Activate and deactivate the p-buffer it doesn’t work. The p-buffer and normal window have different formats and sizes, but wglShareLists returns true (called at pbuffer creation). Activate and Deactivate just call wglMakeCurrent with the appropriate hdc and hglrc. Main window’s hdc and hglrc are stored at creation in the pbuffer object. Can these change over time? I thought they were constant once allocated. What else am I missing? Everything else, like window parameters etc are the same. Are vertex arrays (and vbo) shared via wglShareLists? I would’ve imagined so. Any hints?
Thanks in advance.