Sign in to follow this  

I need to copy datas from a buffer to texture object

This topic is 1953 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The most obvious answer would be a call to glCopyTexImage2D, or something similar, after "unbinding" your FBO.
If this is not what you are looking for, could you tell us a little more on this new texture? What format is it? Is it also used with an FBO?

Share this post


Link to post
Share on other sites
[quote name='Ignifex' timestamp='1344422418' post='4967333']
Is it also used with an FBO?
[/quote]

No ,it's just a common texture.

To be honest ,What I want to do is blending all the objects rendered by it's depth ,stencil ,alpha and some thing else. my self.

I got a way to do what I want to do ,But there are extra works to do ,not so directly ..

Share this post


Link to post
Share on other sites
What do you mean by visiting the data of the Frame Buffer? Do you wish to use the data on the CPU?
If that is the case, then I'm afraid it won't be fast. The best you can do is glGetTexImage, which returns the image's pixels to memory.

Simply copying data from one texture to another should, and I am only 90% sure, dependent on the internal texture formats, be done entirely on the GPU and should not take up too much time.

If you are looking for advice on the fastest way to do something, you will need to be a little more specific on what you have and what you want to do with it.

Share this post


Link to post
Share on other sites
[quote name='Ignifex' timestamp='1344513077' post='4967736']
What do you mean by visiting the data of the Frame Buffer? Do you wish to use the data on the CPU?
[/quote]

No I don't use the datas in CPU but GPU -GLSL

I need control if the right pixel of an element such as a triangle will be draw to the frame buffer.

Share this post


Link to post
Share on other sites
It is this:

There are two elemets A and B .
1.We render A to the Frame Buffer - yes then the Frame Buffer contains pixel of A , some pixels's alpha are zero and some are not..
2.We render B to the Frame Buffer - and how ever - if the alpha in Frame Buffer is zero ,the pixels at the same position(2D) of B will be draw to the FrameBuffer else not.

May be we can use stencil values but there are some reason I don't want to do like this.

Any way ?

Share this post


Link to post
Share on other sites
With an FBO, you can bind textures as color and depth attachements, and get the pixels in the texture(s) "automatically", without doing an explicit copy.

With modern hardware, this should be very efficient.

Share this post


Link to post
Share on other sites
If you only need information from your alpha channel, after your first render of A, then it might be sufficient to use some properly set up alpha blending. Try using the destination alpha to blend with in glBlendFunc.

If that is not sufficient, I see several other options. The problem is mainly that you cannot read from and write to the same FBO. Several workarounds:
- As you mentioned, copy the data to another texture and use this texture during the render of B. Not really fast imo.
- Use 2 FBO's. You use a separate renderpass where you render A's "alpha" as a greyvalue to the second FBO. Then you can use this data while rendering A and B to the first FBO.
- Use one FBO with two color targets. This works, is probably the fastest if simple blending is not sufficient, but is a bit difficult to set up properly.

Apart from these, I don't see a fast way to get what you want. However, I believe you should be able to achieve what you want using alpha blending.

Share this post


Link to post
Share on other sites
[quote name='Ignifex' timestamp='1344610547' post='4968092']
If you only need information from your alpha channel, after your first render of A, then it might be sufficient to use some properly set up alpha blending. Try using the destination alpha to blend with in glBlendFunc.

If that is not sufficient, I see several other options. The problem is mainly that you cannot read from and write to the same FBO. Several workarounds:
- As you mentioned, copy the data to another texture and use this texture during the render of B. Not really fast imo.
- Use 2 FBO's. You use a separate renderpass where you render A's "alpha" as a greyvalue to the second FBO. Then you can use this data while rendering A and B to the first FBO.
- Use one FBO with two color targets. This works, is probably the fastest if simple blending is not sufficient, but is a bit difficult to set up properly.

Apart from these, I don't see a fast way to get what you want. However, I believe you should be able to achieve what you want using alpha blending.
[/quote]

Maybe I understand now ,let me have a try.

Thank you very much.

Share this post


Link to post
Share on other sites

This topic is 1953 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this