I am working on a program to read a stream of raw (Bayer CFA) images from disk, demosaic, timestamp, jpeg and save to an output disk.
I am using OpenGL and GLSL to accomplish the first 2 steps: I read the raw image array into a texture, display it in a quad that fills the viewport, and apply a program (vertex and fragment shaders) to do the demosaic and display to the framebuffer. (customized pipeline) That works fine.
I also can write the date and time as text to the bottom of a screen using a bitmap font as a texture from which I pull individual chars to construct the string. (standard pipeline)
Problem comes in when I try to put the timestamp on the image: If the shaders are active (i.e., UseProgram() in place), then the image shows up fine; but, the text is garbled. If I turn off the shaders (i.e., comment out UseProgram()), then the image shows up as a raw mosaic, and the timestamp is fine.
How can I apply the shader only to the image, and then blend in the timestamp?
I asked an expert and he said to do it in 2 passes: 1) image render with shader code and 2) timestamp render without. OpenTK code is as below, where ProgramObject is the vertex and fragment shaders for demosaicing the Texture called textureMosaic, and texFont is a class encapsulating the code to render a string from a bitmap font loaded as a Texture. Key point is to save and restore the fixed-function pipeline by bracketing the use of the shader program with PushAttrib/PushClientAttrib and then PopAttrib/PopClientAttrib: