Hi
My application had one canvas on which I was drawing using the GLSL shaders. I was reading a dataset and it was displayed on that canvas. This thing is workign prefectly well!!
Now I have to add another canvas to it so that we can see two datasets simultaniously on the screen.
The name of my 1st canvas class is COpenGLCanvas.
The name of my 2nd canvas class is COpenGLCanvas2.
both of them have the following functions:
initilizeGL () --> called automatically on the initilization of the canvas
resizeGL()
paintGL() --> when the canvas needs to be redrawn.
Some code of the paintGL() in the second canvas (i.e. COpenGLCanvas) is creating trouble and complains that cannot read from the location.... and the program terminates. The code is given below:
glViewport(0, 0, fbWidth, fbHeight);
glUseProgram(0);
for (int pass = 0; pass < 2; ++pass) {
switch (pass) {
case 0: // render back depth into framebuffer 0
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer0);
glDepthFunc(GL_GREATER);
glClearDepth(0.0f);
glCullFace(GL_FRONT);
break;
case 1: // render front depth into framebuffer 1
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer1);
glDepthFunc(GL_LESS);
glClearDepth(1.0f);
glCullFace(GL_BACK);
break;
}
glClear(GL_DEPTH_BUFFER_BIT);
if (volume.cubeQuads2 > 0) {
glBindBuffer(GL_ARRAY_BUFFER, volume.vbCubes2);
glVertexPointer(3, GL_FLOAT, 0, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, volume.ibCubes2);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawElements(GL_QUADS, volume.cubeQuads2 * 4, GL_UNSIGNED_INT, 0);
//ERROR OCCOURS HERE WHEN THE PROGRAM GOES FROM THE ABOVE LINE TO NEXT. it screams about inability to read from the location: (
glDisableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
Approx similar code from the first canvas works and produces a kool output
here is the code that works fine :
glViewport(0, 0, fbWidth, fbHeight);
glUseProgram(0);
for (int pass = 0; pass < 2; ++pass) {
switch (pass) {
case 0: // render back depth into framebuffer 0
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer0);
glDepthFunc(GL_GREATER);
glClearDepth(0.0f);
glCullFace(GL_FRONT);
break;
case 1: // render front depth into framebuffer 1
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer1);
glDepthFunc(GL_LESS);
glClearDepth(1.0f);
glCullFace(GL_BACK);
break;
}
glClear(GL_DEPTH_BUFFER_BIT);
if (volume.cubeQuads > 0) {
glBindBuffer(GL_ARRAY_BUFFER, volume.vbCubes);
glVertexPointer(3, GL_FLOAT, 0, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, volume.ibCubes);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawElements(GL_QUADS, volume.cubeQuads * 4, GL_UNSIGNED_INT, 0);
glDisableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
}
thanks in advance
[Edited by - me_here_me on May 21, 2007 5:14:21 AM]