- // look up all the uniform variable names we care about, so we don't
- // have to look them up every time we set them
- p->vp_EyePosition = cgGetNamedParameter(p->vprogram, "EyePosition");
- p->vp_FogPlane = cgGetNamedParameter(p->vprogram, "FogPlane");
- p->vp_LightDir = cgGetNamedParameter(p->vprogram, "LightDir");
- p->vp_LightPosition = cgGetNamedParameter(p->vprogram, "LightPosition");
- p->vp_ModelToLight = cgGetNamedParameter(p->vprogram, "ModelToLight");
- p->vp_TexMatrix = cgGetNamedParameter(p->vprogram, "TexMatrix");
- p->vp_BackgroundTexMatrix = cgGetNamedParameter(p->vprogram, "BackgroundTexMatrix");
- p->vp_ModelViewProjectionMatrix = cgGetNamedParameter(p->vprogram, "ModelViewProjectionMatrix");
- p->vp_ModelViewMatrix = cgGetNamedParameter(p->vprogram, "ModelViewMatrix");
-
- p->fp_Texture_First = cgGetNamedParameter(p->fprogram, "Texture_First");
- p->fp_Texture_Second = cgGetNamedParameter(p->fprogram, "Texture_Second");
- p->fp_Texture_GammaRamps = cgGetNamedParameter(p->fprogram, "Texture_GammaRamps");
- p->fp_Texture_Normal = cgGetNamedParameter(p->fprogram, "Texture_Normal");
- p->fp_Texture_Color = cgGetNamedParameter(p->fprogram, "Texture_Color");
- p->fp_Texture_Gloss = cgGetNamedParameter(p->fprogram, "Texture_Gloss");
- p->fp_Texture_Glow = cgGetNamedParameter(p->fprogram, "Texture_Glow");
- p->fp_Texture_SecondaryNormal = cgGetNamedParameter(p->fprogram, "Texture_SecondaryNormal");
- p->fp_Texture_SecondaryColor = cgGetNamedParameter(p->fprogram, "Texture_SecondaryColor");
- p->fp_Texture_SecondaryGloss = cgGetNamedParameter(p->fprogram, "Texture_SecondaryGloss");
- p->fp_Texture_SecondaryGlow = cgGetNamedParameter(p->fprogram, "Texture_SecondaryGlow");
- p->fp_Texture_Pants = cgGetNamedParameter(p->fprogram, "Texture_Pants");
- p->fp_Texture_Shirt = cgGetNamedParameter(p->fprogram, "Texture_Shirt");
- p->fp_Texture_FogMask = cgGetNamedParameter(p->fprogram, "Texture_FogMask");
- p->fp_Texture_Lightmap = cgGetNamedParameter(p->fprogram, "Texture_Lightmap");
- p->fp_Texture_Deluxemap = cgGetNamedParameter(p->fprogram, "Texture_Deluxemap");
- p->fp_Texture_Attenuation = cgGetNamedParameter(p->fprogram, "Texture_Attenuation");
- p->fp_Texture_Cube = cgGetNamedParameter(p->fprogram, "Texture_Cube");
- p->fp_Texture_Refraction = cgGetNamedParameter(p->fprogram, "Texture_Refraction");
- p->fp_Texture_Reflection = cgGetNamedParameter(p->fprogram, "Texture_Reflection");
- p->fp_Texture_ShadowMapRect = cgGetNamedParameter(p->fprogram, "Texture_ShadowMapRect");
- p->fp_Texture_ShadowMapCube = cgGetNamedParameter(p->fprogram, "Texture_ShadowMapCube");
- p->fp_Texture_ShadowMap2D = cgGetNamedParameter(p->fprogram, "Texture_ShadowMap2D");
- p->fp_Texture_CubeProjection = cgGetNamedParameter(p->fprogram, "Texture_CubeProjection");
- p->fp_Texture_ScreenDepth = cgGetNamedParameter(p->fprogram, "Texture_ScreenDepth");
- p->fp_Texture_ScreenNormalMap = cgGetNamedParameter(p->fprogram, "Texture_ScreenNormalMap");
- p->fp_Texture_ScreenDiffuse = cgGetNamedParameter(p->fprogram, "Texture_ScreenDiffuse");
- p->fp_Texture_ScreenSpecular = cgGetNamedParameter(p->fprogram, "Texture_ScreenSpecular");
- p->fp_Alpha = cgGetNamedParameter(p->fprogram, "Alpha");
- p->fp_BloomBlur_Parameters = cgGetNamedParameter(p->fprogram, "BloomBlur_Parameters");
- p->fp_ClientTime = cgGetNamedParameter(p->fprogram, "ClientTime");
- p->fp_Color_Ambient = cgGetNamedParameter(p->fprogram, "Color_Ambient");
- p->fp_Color_Diffuse = cgGetNamedParameter(p->fprogram, "Color_Diffuse");
- p->fp_Color_Specular = cgGetNamedParameter(p->fprogram, "Color_Specular");
- p->fp_Color_Glow = cgGetNamedParameter(p->fprogram, "Color_Glow");
- p->fp_Color_Pants = cgGetNamedParameter(p->fprogram, "Color_Pants");
- p->fp_Color_Shirt = cgGetNamedParameter(p->fprogram, "Color_Shirt");
- p->fp_DeferredColor_Ambient = cgGetNamedParameter(p->fprogram, "DeferredColor_Ambient");
- p->fp_DeferredColor_Diffuse = cgGetNamedParameter(p->fprogram, "DeferredColor_Diffuse");
- p->fp_DeferredColor_Specular = cgGetNamedParameter(p->fprogram, "DeferredColor_Specular");
- p->fp_DeferredMod_Diffuse = cgGetNamedParameter(p->fprogram, "DeferredMod_Diffuse");
- p->fp_DeferredMod_Specular = cgGetNamedParameter(p->fprogram, "DeferredMod_Specular");
- p->fp_DistortScaleRefractReflect = cgGetNamedParameter(p->fprogram, "DistortScaleRefractReflect");
- p->fp_EyePosition = cgGetNamedParameter(p->fprogram, "EyePosition");
- p->fp_FogColor = cgGetNamedParameter(p->fprogram, "FogColor");
- p->fp_FogHeightFade = cgGetNamedParameter(p->fprogram, "FogHeightFade");
- p->fp_FogPlane = cgGetNamedParameter(p->fprogram, "FogPlane");
- p->fp_FogPlaneViewDist = cgGetNamedParameter(p->fprogram, "FogPlaneViewDist");
- p->fp_FogRangeRecip = cgGetNamedParameter(p->fprogram, "FogRangeRecip");
- p->fp_LightColor = cgGetNamedParameter(p->fprogram, "LightColor");
- p->fp_LightDir = cgGetNamedParameter(p->fprogram, "LightDir");
- p->fp_LightPosition = cgGetNamedParameter(p->fprogram, "LightPosition");
- p->fp_OffsetMapping_Scale = cgGetNamedParameter(p->fprogram, "OffsetMapping_Scale");
- p->fp_PixelSize = cgGetNamedParameter(p->fprogram, "PixelSize");
- p->fp_ReflectColor = cgGetNamedParameter(p->fprogram, "ReflectColor");
- p->fp_ReflectFactor = cgGetNamedParameter(p->fprogram, "ReflectFactor");
- p->fp_ReflectOffset = cgGetNamedParameter(p->fprogram, "ReflectOffset");
- p->fp_RefractColor = cgGetNamedParameter(p->fprogram, "RefractColor");
- p->fp_Saturation = cgGetNamedParameter(p->fprogram, "Saturation");
- p->fp_ScreenCenterRefractReflect = cgGetNamedParameter(p->fprogram, "ScreenCenterRefractReflect");
- p->fp_ScreenScaleRefractReflect = cgGetNamedParameter(p->fprogram, "ScreenScaleRefractReflect");
- p->fp_ScreenToDepth = cgGetNamedParameter(p->fprogram, "ScreenToDepth");
- p->fp_ShadowMap_Parameters = cgGetNamedParameter(p->fprogram, "ShadowMap_Parameters");
- p->fp_ShadowMap_TextureScale = cgGetNamedParameter(p->fprogram, "ShadowMap_TextureScale");
- p->fp_SpecularPower = cgGetNamedParameter(p->fprogram, "SpecularPower");
- p->fp_UserVec1 = cgGetNamedParameter(p->fprogram, "UserVec1");
- p->fp_UserVec2 = cgGetNamedParameter(p->fprogram, "UserVec2");
- p->fp_UserVec3 = cgGetNamedParameter(p->fprogram, "UserVec3");
- p->fp_UserVec4 = cgGetNamedParameter(p->fprogram, "UserVec4");
- p->fp_ViewTintColor = cgGetNamedParameter(p->fprogram, "ViewTintColor");
- p->fp_ViewToLight = cgGetNamedParameter(p->fprogram, "ViewToLight");
- CHECKGLERROR
- if (developer.integer)
- Con_Printf("^5CG shader %s compiled.\n", permutationname);
- }
+ cgCompileProgram(p->fprogram);CHECKCGERROR
+ if (!cgIsProgramCompiled(p->fprogram))
+ {
+ CHECKCGERROR
+ cgDestroyProgram(p->fprogram);CHECKCGERROR
+ p->fprogram = 0;
+ }
+ else
+ {
+ cgGLLoadProgram(p->fprogram);CHECKCGERROR CHECKGLERROR
+ cgGLEnableProfile(fragmentProfile);CHECKCGERROR CHECKGLERROR
+ CHECKCGERROR
+ p->fp_Texture_First = cgGetNamedParameter(p->fprogram, "Texture_First");
+ p->fp_Texture_Second = cgGetNamedParameter(p->fprogram, "Texture_Second");
+ p->fp_Texture_GammaRamps = cgGetNamedParameter(p->fprogram, "Texture_GammaRamps");
+ p->fp_Texture_Normal = cgGetNamedParameter(p->fprogram, "Texture_Normal");
+ p->fp_Texture_Color = cgGetNamedParameter(p->fprogram, "Texture_Color");
+ p->fp_Texture_Gloss = cgGetNamedParameter(p->fprogram, "Texture_Gloss");
+ p->fp_Texture_Glow = cgGetNamedParameter(p->fprogram, "Texture_Glow");
+ p->fp_Texture_SecondaryNormal = cgGetNamedParameter(p->fprogram, "Texture_SecondaryNormal");
+ p->fp_Texture_SecondaryColor = cgGetNamedParameter(p->fprogram, "Texture_SecondaryColor");
+ p->fp_Texture_SecondaryGloss = cgGetNamedParameter(p->fprogram, "Texture_SecondaryGloss");
+ p->fp_Texture_SecondaryGlow = cgGetNamedParameter(p->fprogram, "Texture_SecondaryGlow");
+ p->fp_Texture_Pants = cgGetNamedParameter(p->fprogram, "Texture_Pants");
+ p->fp_Texture_Shirt = cgGetNamedParameter(p->fprogram, "Texture_Shirt");
+ p->fp_Texture_FogMask = cgGetNamedParameter(p->fprogram, "Texture_FogMask");
+ p->fp_Texture_Lightmap = cgGetNamedParameter(p->fprogram, "Texture_Lightmap");
+ p->fp_Texture_Deluxemap = cgGetNamedParameter(p->fprogram, "Texture_Deluxemap");
+ p->fp_Texture_Attenuation = cgGetNamedParameter(p->fprogram, "Texture_Attenuation");
+ p->fp_Texture_Cube = cgGetNamedParameter(p->fprogram, "Texture_Cube");
+ p->fp_Texture_Refraction = cgGetNamedParameter(p->fprogram, "Texture_Refraction");
+ p->fp_Texture_Reflection = cgGetNamedParameter(p->fprogram, "Texture_Reflection");
+ p->fp_Texture_ShadowMapRect = cgGetNamedParameter(p->fprogram, "Texture_ShadowMapRect");
+ p->fp_Texture_ShadowMapCube = cgGetNamedParameter(p->fprogram, "Texture_ShadowMapCube");
+ p->fp_Texture_ShadowMap2D = cgGetNamedParameter(p->fprogram, "Texture_ShadowMap2D");
+ p->fp_Texture_CubeProjection = cgGetNamedParameter(p->fprogram, "Texture_CubeProjection");
+ p->fp_Texture_ScreenDepth = cgGetNamedParameter(p->fprogram, "Texture_ScreenDepth");
+ p->fp_Texture_ScreenNormalMap = cgGetNamedParameter(p->fprogram, "Texture_ScreenNormalMap");
+ p->fp_Texture_ScreenDiffuse = cgGetNamedParameter(p->fprogram, "Texture_ScreenDiffuse");
+ p->fp_Texture_ScreenSpecular = cgGetNamedParameter(p->fprogram, "Texture_ScreenSpecular");
+ p->fp_Alpha = cgGetNamedParameter(p->fprogram, "Alpha");
+ p->fp_BloomBlur_Parameters = cgGetNamedParameter(p->fprogram, "BloomBlur_Parameters");
+ p->fp_ClientTime = cgGetNamedParameter(p->fprogram, "ClientTime");
+ p->fp_Color_Ambient = cgGetNamedParameter(p->fprogram, "Color_Ambient");
+ p->fp_Color_Diffuse = cgGetNamedParameter(p->fprogram, "Color_Diffuse");
+ p->fp_Color_Specular = cgGetNamedParameter(p->fprogram, "Color_Specular");
+ p->fp_Color_Glow = cgGetNamedParameter(p->fprogram, "Color_Glow");
+ p->fp_Color_Pants = cgGetNamedParameter(p->fprogram, "Color_Pants");
+ p->fp_Color_Shirt = cgGetNamedParameter(p->fprogram, "Color_Shirt");
+ p->fp_DeferredColor_Ambient = cgGetNamedParameter(p->fprogram, "DeferredColor_Ambient");
+ p->fp_DeferredColor_Diffuse = cgGetNamedParameter(p->fprogram, "DeferredColor_Diffuse");
+ p->fp_DeferredColor_Specular = cgGetNamedParameter(p->fprogram, "DeferredColor_Specular");
+ p->fp_DeferredMod_Diffuse = cgGetNamedParameter(p->fprogram, "DeferredMod_Diffuse");
+ p->fp_DeferredMod_Specular = cgGetNamedParameter(p->fprogram, "DeferredMod_Specular");
+ p->fp_DistortScaleRefractReflect = cgGetNamedParameter(p->fprogram, "DistortScaleRefractReflect");
+ p->fp_EyePosition = cgGetNamedParameter(p->fprogram, "EyePosition");
+ p->fp_FogColor = cgGetNamedParameter(p->fprogram, "FogColor");
+ p->fp_FogHeightFade = cgGetNamedParameter(p->fprogram, "FogHeightFade");
+ p->fp_FogPlane = cgGetNamedParameter(p->fprogram, "FogPlane");
+ p->fp_FogPlaneViewDist = cgGetNamedParameter(p->fprogram, "FogPlaneViewDist");
+ p->fp_FogRangeRecip = cgGetNamedParameter(p->fprogram, "FogRangeRecip");
+ p->fp_LightColor = cgGetNamedParameter(p->fprogram, "LightColor");
+ p->fp_LightDir = cgGetNamedParameter(p->fprogram, "LightDir");
+ p->fp_LightPosition = cgGetNamedParameter(p->fprogram, "LightPosition");
+ p->fp_OffsetMapping_Scale = cgGetNamedParameter(p->fprogram, "OffsetMapping_Scale");
+ p->fp_PixelSize = cgGetNamedParameter(p->fprogram, "PixelSize");
+ p->fp_ReflectColor = cgGetNamedParameter(p->fprogram, "ReflectColor");
+ p->fp_ReflectFactor = cgGetNamedParameter(p->fprogram, "ReflectFactor");
+ p->fp_ReflectOffset = cgGetNamedParameter(p->fprogram, "ReflectOffset");
+ p->fp_RefractColor = cgGetNamedParameter(p->fprogram, "RefractColor");
+ p->fp_Saturation = cgGetNamedParameter(p->fprogram, "Saturation");
+ p->fp_ScreenCenterRefractReflect = cgGetNamedParameter(p->fprogram, "ScreenCenterRefractReflect");
+ p->fp_ScreenScaleRefractReflect = cgGetNamedParameter(p->fprogram, "ScreenScaleRefractReflect");
+ p->fp_ScreenToDepth = cgGetNamedParameter(p->fprogram, "ScreenToDepth");
+ p->fp_ShadowMap_Parameters = cgGetNamedParameter(p->fprogram, "ShadowMap_Parameters");
+ p->fp_ShadowMap_TextureScale = cgGetNamedParameter(p->fprogram, "ShadowMap_TextureScale");
+ p->fp_SpecularPower = cgGetNamedParameter(p->fprogram, "SpecularPower");
+ p->fp_UserVec1 = cgGetNamedParameter(p->fprogram, "UserVec1");
+ p->fp_UserVec2 = cgGetNamedParameter(p->fprogram, "UserVec2");
+ p->fp_UserVec3 = cgGetNamedParameter(p->fprogram, "UserVec3");
+ p->fp_UserVec4 = cgGetNamedParameter(p->fprogram, "UserVec4");
+ p->fp_ViewTintColor = cgGetNamedParameter(p->fprogram, "ViewTintColor");
+ p->fp_ViewToLight = cgGetNamedParameter(p->fprogram, "ViewToLight");
+ CHECKCGERROR
+ }
+ }
+
+ if ((p->vprogram || !vertstring[0]) && (p->fprogram || !fragstring[0]))
+ Con_DPrintf("^5CG shader %s compiled.\n", permutationname);