protected void setMaterialState() { GL.Enable(EnableCap.ColorMaterial); // turn off per-vertex color GL.Color4(this.MainColor); // setup the base color values... var colorMat = this.colorMaterial ?? _defaultColorMat; SSColorMaterial.applyColorMaterial(colorMat); if (textureMaterial != null) { GL.ActiveTexture(TextureUnit.Texture0); GL.Enable(EnableCap.Texture2D); if (textureMaterial.ambientTex != null || textureMaterial.diffuseTex != null) { // fall back onto the diffuse texture in the absence of ambient SSTexture tex = textureMaterial.diffuseTex ?? textureMaterial.ambientTex; GL.BindTexture(TextureTarget.Texture2D, tex.TextureID); } else { GL.BindTexture(TextureTarget.Texture2D, 0); } } }
private void _renderSetupGLSL(SSRenderConfig renderConfig, SSMainShaderProgram shaderPgm, SSMeshOBJSubsetData subset) { // Step 1: setup GL rendering modes... // GL.Enable(EnableCap.Lighting); // GL.Enable(EnableCap.Blend); // GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); // GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1); // Step 2: setup our material mode and paramaters... if (renderConfig.drawingShadowMap) { // assume SSObject.Render has setup our materials properly for the shadowmap Pass // TODO: find a better way to do this! return; } SSColorMaterial.applyColorMaterial(subset.colorMaterial); if (shaderPgm == null) { SSShaderProgram.DeactivateAll(); // fixed function single-texture if (subset.textureMaterial.diffuseTex != null) { GL.ActiveTexture(TextureUnit.Texture0); GL.Enable(EnableCap.Texture2D); GL.BindTexture(TextureTarget.Texture2D, subset.textureMaterial.diffuseTex.TextureID); } } else { shaderPgm.Activate(); shaderPgm.SetupTextures(subset.textureMaterial); } }