Ok, this is in Java JOGL, but conceptually still the same. In my initialization code I have
IntBuffer fbo = IntBuffer.allocate(1);
gl.glGenFramebuffersEXT(1, fbo);
gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, fbo.get(0));
int[] tex = new int[1];
gl.glGenTextures(1, tex, 0);
gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, width, height, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, null);
gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
gl.glBindTexture(GL.GL_TEXTURE_2D, tex[0]);
gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, GL.GL_COLOR_ATTACHMENT0_EXT, GL.GL_TEXTURE_2D, tex[0], 0);
IntBuffer fboDepth = IntBuffer.allocate(1);
gl.glGenRenderbuffersEXT(1, fboDepth);
gl.glBindRenderbufferEXT(GL.GL_RENDERBUFFER_EXT, fboDepth.get(0)); gl.glRenderbufferStorageEXT(GL.GL_RENDERBUFFER_EXT, GL.GL_DEPTH_COMPONENT, width, height);
gl.glFramebufferRenderbufferEXT(GL.GL_FRAMEBUFFER_EXT, GL.GL_DEPTH_ATTACHMENT_EXT, GL.GL_RENDERBUFFER_EXT, fboDepth.get(0));
int status = gl.glCheckFramebufferStatusEXT(GL.GL_FRAMEBUFFER_EXT);
if (status != GL.GL_FRAMEBUFFER_COMPLETE_EXT) {
System.out.println("error creating FBO");
}
gl.glBindTexture(GL.GL_TEXTURE_2D, 0);
gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0);
gl.glBindRenderbufferEXT(GL.GL_RENDERBUFFER_EXT, 0);
Then in the main display loop I have:
gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS);
gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, fbo.get(0);
gl.glBindTexture(GL.GL_TEXTURE_2D, tex[0]);
gl.glViewport(0, 0, width, height);
// here I have code to draw my heatmap.
// it just draws a bunch of circles and blends them together.
// The coordinates of the circles are specified in x,y,z
// coordinates, not screen points (because they are shown on
// the surface of the earth).
gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0);
Then I get stuck. Basically I would like to take the x,y,z coordinates of the heatmap circles and drawn them back onto the main display (and I’ll apply a fragment shader when I draw them back).
I don’t know if I need to be drawing to a texture here, if I need to draw to a 3D texture, or if I can somehow read back the rgba of each of the points (and associated each value with its x,y,z coordinate)…
Any help would be appreciated. thanks.