Esempio n. 1
0
        //
        // FNA3D_VerifySampler
        //

        public static void FNA3D_VerifySampler(IntPtr device, int index, IntPtr texture,
                                               ref FNA3D_SamplerState sampler)
        {
            var samplerCopy = sampler;
            int textureId   = (int)texture;
            var renderer    = Renderer.Get(device);

            renderer.Send(false, () =>
            {
                var state  = (State)renderer.UserData;
                var config = state.TextureConfigs[textureId];

                GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + index);
                GLES20.glBindTexture(config[0], textureId);

                if (index == renderer.TextureUnits - 1)
                {
                    state.TextureOnLastUnit = textureId;
                }

                if (textureId == 0)
                {
                    return;
                }

                GLES20.glTexParameteri(config[0], GLES30.GL_TEXTURE_MAX_LEVEL,
                                       config[2] - 1);
                GLES20.glTexParameteri(config[0], GLES30.GL_TEXTURE_BASE_LEVEL,
                                       samplerCopy.maxMipLevel);

                GLES20.glTexParameteri(config[0], GLES20.GL_TEXTURE_WRAP_S,
                                       TextureWrapMode[(int)samplerCopy.addressU]);
                GLES20.glTexParameteri(config[0], GLES20.GL_TEXTURE_WRAP_T,
                                       TextureWrapMode[(int)samplerCopy.addressV]);
                if (config[0] == GLES30.GL_TEXTURE_3D)
                {
                    GLES20.glTexParameteri(config[0], GLES30.GL_TEXTURE_WRAP_R,
                                           TextureWrapMode[(int)samplerCopy.addressW]);
                }

                int magIndex = (int)samplerCopy.filter * 3;
                int minIndex = magIndex + (config[2] <= 1 ? 1 : 2);

                GLES20.glTexParameteri(config[0], GLES20.GL_TEXTURE_MAG_FILTER,
                                       TextureFilterMode[magIndex]);
                GLES20.glTexParameteri(config[0], GLES20.GL_TEXTURE_MIN_FILTER,
                                       TextureFilterMode[minIndex]);
            });
        }
Esempio n. 2
0
 public static extern void FNA3D_VerifyVertexSampler(
     IntPtr device,
     int index,
     IntPtr texture,             /* FNA3D_Texture* */
     ref FNA3D_SamplerState sampler
     );