PDA

View Full Version : Need Suggestion



awhig
07-07-2009, 05:49 PM
Hello All,

My aim is to render a series of video frames and side by side process them using GLSL shader programming.

My interface is in MFC (SDI -- Single Doc Interface). Recently, I have been facing problem in displaying video frames once the shader code is invoked.

The problem is that a scene is rendered on MFC screen (or interface), but iff a shader code is invoked, then the next frame disappears and is substituted by the shader generated color and remains there forever.

I wrote a couple of posts regarding that. Got helpful responses but still the problem lingers.
1. http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=260014#Post2600 14

2. http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=259755#Post2597 55


A random search through archived posts in this forum reasoned for the problem that when a shader writes to a buffer through gl_FragData[x] , it remains there and since the context is single it is shared by both on-screen and off-screen frame buffer.

The details of my problem are in the above links.
In short what is happening is:

a. I get data for a new frame.
b. Render on screen using glDrawPixels(..)
c. Switch to off-screen frame buffer.
d. Set up Two textures, bind them to GL_TEXTURE0 and 1 resp.
e. Attach them to FBO
f. call shader to compute. [The shader works on the attached texture and the data therein are completely independent of current image frame rendered]

g. Swicth back to Main Frame buffer. i.e glFrameBufferEXT(..,0);

h. Restore viewport settings and repeat all steps for next frame.


Now if I do not call my shader program, the images in sequence are rendered correctly. But if I enable shader, then the color computed by it is rendered and stays there forever.

For code and details, they have been posted alread in forum as pointed to by the links of my previous posts.

As far as the suggestion I need is whether to go for MDI (Multiple document Interface -- mfc) as it will give multiple context and that one context (or thread) can be used for shader computation .... what do you say ?

Or is there any other method that I can use that requires only single MFC context?

Thank you for your time.

yooyo
07-08-2009, 06:14 AM
You still didnt solve that problem!?
Maybe you change some opengl when you use shaders. Examine your code and see whats changed.
For example.. you need to call glBindFramebufferEXT(fbo_id) to use FBO and glBindFramebufferEXT(0) to switch to main buffer. Also.. to enable using shaders glUseProgramObjectARB(prog_id) and to switchback on fixed pipeline call glUseProgramObjectARB(0).

Did you change glColor, or some other attribute?
Do you use rectangle textures?
Do you use regular (power of two) textures?
Do you take care of texture targets? Like..


glBindTexture(GL_TEXTURE2D, tex1);
// some code
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, tex2); // this is bug.. texture2d have priority over rectangle texture.




glBindTexture(GL_TEXTURE2D, tex1);
// some code
glBindTexture(GL_TEXTURE2D, 0); // this is correct..
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, tex2);
// some code
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);

awhig
07-10-2009, 08:13 PM
Solved.

@yoyoo
I checked thoroughly after reading your post. Thank you very much for your timely responses and valuable time.

But , the actual cause was due to non-changing Rendering contexts attached to same DC.

Nevertheless, your responses prompted me to go through my code again. Partial credit to you. :)

Again thanks for your time.