I have finished c++ code and CG code in an exe program and they worked perfectly. But when I moved them to a dll, I find that CG program cannot be started.
Code is like this:
////////////////////////////////////
INIT CG ENV —>OK
////////////////////////////////////
BUILD 3 TEXTUREs —>OK
////////////////////////////////////
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_COLOR, GL_SRC_COLOR);
glDisable(GL_LIGHTING);
ViewOrtho();//change to ortho
if(m_bTexInit == FALSE)
{
cgGLSetTextureParameter(cgGetNamedParameter(g_CGMix_pixel, “decal_1”), BlurTexture[0] );
cgGLSetTextureParameter(cgGetNamedParameter(g_CGMix_pixel, “decal_2”), BlurTexture[1] );
cgGLSetTextureParameter(cgGetNamedParameter(g_CGMix_pixel, “decal_3”), BlurTexture[2] );
m_bTexInit = TRUE;
}
cgGLBindProgram( g_CGMix_pixel);
cgGLEnableProfile(g_CGprofile_pixel );
cgGLEnableTextureParameter( cgGetNamedParameter(g_CGMix_pixel, “decal_1”) );
cgGLEnableTextureParameter( cgGetNamedParameter(g_CGMix_pixel, “decal_2”) );
cgGLEnableTextureParameter( cgGetNamedParameter(g_CGMix_pixel, “decal_3”) );
cgGLSetManageTextureParameters(g_CGcontext, CG_TRUE);
/////////////////////////
Draw Scene
/////////////////////////
cgGLDisableTextureParameter( cgGetNamedParameter(g_CGMix_pixel, “decal_3”) );
cgGLDisableTextureParameter( cgGetNamedParameter(g_CGMix_pixel, “decal_2”) );
cgGLDisableTextureParameter( cgGetNamedParameter(g_CGMix_pixel, “decal_1”) );
cgGLDisableProfile(g_CGprofile_pixel );
ViewPerspective();
glEnable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
wglSwapBuffers(hdc);
I find that always the first texture was drawn,that mean,this texture set by:
cgGLSetTextureParameter(cgGetNamedParameter(g_CGMix_pixel, “decal_1”), BlurTexture[0] );
BlurTexture[0] will be drawn,If I change to:
cgGLSetTextureParameter(cgGetNamedParameter(g_CGMix_pixel, “decal_1”), BlurTexture[2] );
then BlurTexture[2] will be drawn.
I have spent about one week to solve this problem,but without any …
can any one help me?
thank you for any reply.