Exemplo n.º 1
0
        public override void DrawSequentialPolyMultiTexture(BaseTexture texture, BaseTexture lightMapTexture, byte[] lightMapData, GLPoly p, int lightMapNumber)
        {
            GL.Enable(EnableCap.Texture2D);
            // Binds world to texture env 0
            texture.Bind( );
            GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, ( int )TextureEnvMode.Replace);

            // Binds lightmap to texenv 1
            this.Device.EnableMultitexture( ); // Same as SelectTexture (TEXTURE1).
            lightMapTexture.BindLightmap((( GLTextureDesc )lightMapTexture.Desc).TextureNumber + lightMapNumber);
            var i = lightMapNumber;

            if (lightMapTexture.LightMapModified[i])
            {
                lightMapTexture.CommitLightmap(lightMapData, i);
            }

            GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, ( int )TextureEnvMode.Blend);
            GL.Begin(PrimitiveType.Polygon);
            for (i = 0; i < p.numverts; i++)
            {
                var v = p.verts[i];
                GL.MultiTexCoord2(TextureUnit.Texture0, v[3], v[4]);
                GL.MultiTexCoord2(TextureUnit.Texture1, v[5], v[6]);
                GL.Vertex3(v);
            }
            GL.End( );
            GL.Disable(EnableCap.Texture2D);
        }
Exemplo n.º 2
0
        public override void DrawWaterPolyMultiTexture(byte[] lightMapData, BaseTexture texture, BaseTexture lightMapTexture, int lightMapTextureNumber, GLPoly p, double time)
        {
            GL.Enable(EnableCap.Texture2D);

            texture.Bind( );

            GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, ( int )TextureEnvMode.Replace);

            this.Device.EnableMultitexture( );

            lightMapTexture.BindLightmap((( GLTextureDesc )lightMapTexture.Desc).TextureNumber + lightMapTextureNumber);
            var i = lightMapTextureNumber;

            if (lightMapTexture.LightMapModified[i])
            {
                lightMapTexture.CommitLightmap(lightMapData, i);
            }

            GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, ( int )TextureEnvMode.Blend);
            GL.Begin(PrimitiveType.TriangleFan);

            var nv = new float[3];

            for (i = 0; i < p.numverts; i++)
            {
                var v = p.verts[i];
                GL.MultiTexCoord2(TextureUnit.Texture0, v[3], v[4]);
                GL.MultiTexCoord2(TextureUnit.Texture1, v[5], v[6]);

                nv[0] = ( float )(v[0] + 8 * Math.Sin(v[1] * 0.05 + time) * Math.Sin(v[2] * 0.05 + time));
                nv[1] = ( float )(v[1] + 8 * Math.Sin(v[0] * 0.05 + time) * Math.Sin(v[2] * 0.05 + time));
                nv[2] = v[2];

                GL.Vertex3(nv);
            }
            GL.End( );

            GL.Disable(EnableCap.Texture2D);
        }