Jump to content
  • Advertisement
Sign in to follow this  
ZeDuS

OpenGL opengl cg program binding problems

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

i've recently added cg shaders to my engine, it works perfectly for the direct3d part of my engine, but i can't make it work properly on the opengl side. the problem is, that it seems that i fail to switch between the programs properly (bind). for example: i load one VertexProgram and one FragmentProgram that does simple coloring, then i load one Vertex Program and one FragmentProgram that does basic texturing. the last loaded VertexProgram still stays even after i try to bind the new one - this is what i do to bind: ///////////////////////////////////////////////////////////////////// bool CShaderVertexProgram_GL::Bind(CShaderUniforms* pShaderUniforms) { cgGLBindProgram(m_Program); //... here i deal with uniform and autouniform, irrelevant... cgGLEnableProfile(g_VertexProfile); return true; } //////////////////////////////////////////////////////////////////////// i do the same for FragmentProgram i tried also switching the order of bindprogram / enableprofile still doesn't work. can anyone here PLEASE tell me what i'm doing wrong? it's really driving me mad :(

Share this post


Link to post
Share on other sites
Advertisement

Try:

cgGLBindProgram(m_Program);
cgGLEnableProfile(g_VertexProfile);
//... here i deal with uniform and autouniform, irrelevant...

That's how I do it. Also one should of course check the values of m_Program and g_VertexProfile.

~SPH

Share this post


Link to post
Share on other sites
i already tried that ... :(

and the values of m_Program and g_VertexProfile look ok,
m_Program is 0x00000001 and g_VertexProfile is CG_PROFILE_VP40 (i got it by getting latest).

another weird thing is that i manage to get parameters from the program i bind (by doing things like:
"cgParam = cgGetNamedParameter(m_Program, pUniform->m_pchName);")

but the bound vertex program isn't USED (the fixed pipeline is used in the vertex processing) but for the fragment programs it DOES work and the bound fragment program is used...

Share this post


Link to post
Share on other sites
just wanted to say i solved it ;)

it was related to position invariance in the shaders...
(setting posinv in the args when loading the program, but not considering it in the cg shader code)
weird that cg doesn't TELL that an error occur *g

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!