Jump to content
  • Advertisement
Sign in to follow this  
deavik

OpenGL Cg + GL bind texture to sampler

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

Hello, After a really busy school year (and summer) I am picking up on game development again. I was trying to make a CgFX-based rendering mechanism, but I have a problem with what Cg function binds a texture. My belief was that once you associate a CGparameter with a GL texture name, you can "activate" the sampler/parameter, and that binds and activates the texture units needed. The Cg manual says:
Quote:
Under OpenGL, the easiest way to achieve these goals is to call cgGLSetupSampler(param, textureID). This entry points binds the given texture, associates the texture handle with the given parameter, and initializes the sampler state by calling cgSetSamplerState().
Problem is, cgGLSetupSampler (Cg 1.5) doesn't seem to bind the texture at all and a glBindTexture call is necessary. This wouldn't be a big deal, except for the fact that if it is necessary to call glBindTexture I have to keep track of the texture targets of all my textures, which is slightly annoying. Is there any additional setup I'm missing? I already called cgGLSetManageTextureParameters(context, CG_TRUE); Thanks in advance! (I was surprised at how little support/documentation/discussion there is for Cg on the internet except for the manual/spec...)

Share this post


Link to post
Share on other sites
Advertisement
Unfortunately, the support here for Cg isn't much better. The best I can offer from what I've seen is a link to a tutorial on multi-texturing in Cg. It shows two valid ways to do it, so I think either one will work for you.

http://www.codesampler.com/oglsrc/oglsrc_10.htm#ogl_cg_multitexture

Share this post


Link to post
Share on other sites
Quote:
Original post by n00body
Unfortunately, the support here for Cg isn't much better. The best I can offer from what I've seen is a link to a tutorial on multi-texturing in Cg. It shows two valid ways to do it, so I think either one will work for you.

http://www.codesampler.com/oglsrc/oglsrc_10.htm#ogl_cg_multitexture

That was a nice pointer, thanks n00body... but unfortunately to use the "Cg" way it shows it uses cgGLEnableTextureParameter, for which you need a Cg program parameter (as opposed to effect parameter). Using a CgFX file, I don't have that...

I wish the functions would work as in the spec... or maybe i'm making a mistake which I can't identify because there aren't more examples...

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!