Jump to content
  • Advertisement
Sign in to follow this  
minnow

problem with glDrawBuffers

This topic is 4449 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

Hi there. I want to enable MRTs by the following code: GLenum buffers[4] = {GL_AUX0, GL_AUX1, GL_AUX2, GL_AUX3}; glDrawBuffers(numTargets, buffers); err=glGetError(); It always catches error---err!=GL_NO_ERROR Does anybody know why? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Here's the errors for that function:

GL_INVALID_ENUM is generated if one of the values in bufs is not an accepted value.

GL_INVALID_ENUM is generated if n is less than 0.

GL_INVALID_OPERATION is generated if a symbolic constant other than GL_NONE appears more than once in bufs.

GL_INVALID_OPERATION is generated if any of the entries in bufs (other than GL_NONE ) indicates a color buffer that does not exist in the current GL context.

GL_INVALID_VALUE is generated if n is greater than GL_MAX_DRAW_BUFFERS.

GL_INVALID_OPERATION is generated if glDrawBuffers is executed between the execution of glBegin and the corresponding execution of glEnd.


This should help you determine what's the cause. Of course you need to see what error your 'err' variable actually is (that would have helped us a lot more in your post).

Remember, when you get GL errors, take a peek in the man page of the GL call making the error to know what you are doing wrong.

Share this post


Link to post
Share on other sites
I checked the value of err, it's GL_INVALID_OPERATION(1282).

"GL_INVALID_OPERATION is generated if any of the entries in bufs (other than GL_NONE ) indicates a color buffer that does not exist in the current GL context"

But I still don't understand why the color buffer does not exist?

Share this post


Link to post
Share on other sites
I'm guessing because the context you are trying to execute the code in doesn't have them, I don't believe the display context has those buffers you have requested as active, I don't even think you can request they exist when you create it.

To have it work you'd have to either use an FBO with multiple colour attachments or pbuffers with them requested.

Share this post


Link to post
Share on other sites
Actually what I'm doing is to keep a k-element(k<=4) list for each pixel, and in fragment shader, there is a new value inserted in the list and an old value will be popped out. So I need use gl_FragData[0~3] to keep the list.

Should I create FBO and textures first, and then attach textures to color buffers?

Share this post


Link to post
Share on other sites
Thanks. The original problem is solved, but now new problem comes.

For application-created framebuffer objects, I can only use GL_COLOR_ATTACHMENTi_EXT instead of GL_AUXi to DrawBuffers, is this true? If so, in fragment shader(I use glsl), what Variables should I write the intermediate results to? gl_FragData is bound to GL_AUXi? (Actually, it works if using Cg, simply write results to result.color. Just want to know how to map it to GLSL).

Share this post


Link to post
Share on other sites
yes, you have to use GL_COLOR_ATTACHMENTi_EXT for the buffers, these will map to gl_FragData (and I assume the Cg colour will do the same) as the output maps to the currently bound active buffers, not any preprescribed buffers.

Share this post


Link to post
Share on other sites
Now I have the same problem in Enalis' post.

I wrote a short code which did the following thing:
1.draw a teapot;
2.in fragment shader, draw 2 different colors in gl_FragData[0] and gl_FragData[1], which map to GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT;
3.Map the two textures to screen space one by one and dislay.

Problems I found:
1. Only gl_FragData[0] is working. The final image only displays the color I give to gl_FragData[0], not the blending color. If I commend the color assignment to gl_FragData[1], the result is the same; If I commend gl_FragData[0], there is nothing to display.
2. texture gl_FragData[0] rendered to is not correct, the result image is a teapot plus a square. I don't know where does this square come from.

Please help.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!