CG-多纹理输入

来源:互联网 发布:淘宝时光机链接 编辑:程序博客网 时间:2024/06/05 02:38
    如何在CG语言中进行多纹理输入

glGenTextures (2*range+1, Texture_Id);

    ////////////////////////////////////////////////////////////////////////////////////////////////////
    for(int i=0; i<2*range+1; i++)
    {
        glBindTexture (target, Texture_Id[i]);
        glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        glTexParameteri (target, GL_TEXTURE_WRAP_S,        GL_CLAMP_TO_EDGE);
        glTexParameteri (target, GL_TEXTURE_WRAP_T,        GL_CLAMP_TO_EDGE);
        glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
        glTexImage2D (target, 0, GL_FLOAT_RGBA16_NV, FileSize.x, FileSize.y, 0, 
            GL_RGBA, GL_HALF_FLOAT_NV, InRgba[Repro[curframe-start][i]-start]);
    }

    for(int i=0; i<2*range+1; i++)
    {
        char str[100];
        sprintf(str,"tex%d",i);
        CgFragmentParam_tex[i] = cgGetNamedParameter(CgFragmentProgram, str);
        checkForCgError("getting image parameter");

        cgGLSetTextureParameter(CgFragmentParam_tex[i], Texture_Id[i]);
        checkForCgError("setting texture 2D texture");
    }

    for(int i=0; i<2*range+1; i++)
    {
        cgGLEnableTextureParameter(CgFragmentParam_tex[i]);
        checkForCgError("enable texture texture");
    }