Jump to content
  • Advertisement
Sign in to follow this  
golgoth

OpenGL GLSL access!

This topic is 4748 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 all! can we access variables in opengl form a shader? abstract: uniform float a; uniform float b; varying float c; void main() { c = a + b; } how can we acess "c" once the shader is done? THX

Share this post


Link to post
Share on other sites
Advertisement
Output whatever data you want from the pixel shader. Use glReadPixels to read it back. It probably won't be very fast so that may not be suitable for whatever it is you're trying to do. If you don't need to access the data on the CPU (ie: use the data in another shader) you can use glCopyTexImage2D or glCopyTexSubImage2D (or the 1D or 3D equivalents) to copy it to a texture. Or you can use the GL_EXT_framebuffer_object extension to render directly into a texture. If you do need the data on the CPU you can use the GL_ARB_pixel_buffer_object extension to use glReadPixels asynchronously, which may offer some speed gains depending on your situation.

EDIT: Just a note... there is no glCopyTexImage3D, only glCopyTexSubImage3D. There is a 1D version of both though.

Share this post


Link to post
Share on other sites
Thx Kalidor!

since my process is done in one pass only, i think this wont fit! but thx for confirming there is no other ways around!

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!