Exemple #1
0
    public Texture TextureFromLump(Lump l)
    {
        int[,] pixelindices = ReadPatchData(l.data);
        int width  = pixelindices.GetLength(0);
        int height = pixelindices.GetLength(1);

        Color[] pixels = new Color[height * width];
        for (int y = 0; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                pixels[y * width + x] = Palette[pixelindices[x, y]];
            }
        }

        Texture2D tex = new Texture2D(width, height);

        tex.SetPixels(pixels);
        if (_overrideParameters.ContainsKey(l.lumpName))
        {
            TextureParameters p = _overrideParameters[l.lumpName];
            tex.wrapModeU  = p.horizontalWrapMode;
            tex.wrapModeV  = p.verticalWrapMode;
            tex.filterMode = p.filterMode;
        }
        else
        {
            tex.wrapMode   = TextureWrapMode.Clamp;
            tex.filterMode = DefaultFilterMode;
        }
        tex.Apply();
        return(tex);
    }
    /**
     *	Generate a new procedural texture
     *  http://catlikecoding.com/unity/tutorials/noise/
     */
    private void generateTexture(Texture2D texture, Transform parent, TextureParameters args)
    {
        int scale      = args.scale;
        int resolution = args.resolution;

        Vector3 point00 = parent.TransformPoint(new Vector3(seed, seed));
        Vector3 point10 = parent.TransformPoint(new Vector3(seed + scale, seed));
        Vector3 point01 = parent.TransformPoint(new Vector3(seed, seed + scale));
        Vector3 point11 = parent.TransformPoint(new Vector3(seed + scale, seed + scale));

        NoiseMethod method   = Noise.methods[(int)type][args.dimensions - 1];
        float       stepSize = 1.0f / resolution;

        for (int y = 0; y < resolution; y++)
        {
            Vector3 point0 = Vector3.Lerp(point00, point01, (y + 0.5f) * stepSize);
            Vector3 point1 = Vector3.Lerp(point10, point11, (y + 0.5f) * stepSize);

            for (int x = 0; x < resolution; x++)
            {
                Vector3 point  = Vector3.Lerp(point0, point1, (x + 0.5f) * stepSize);
                float   sample = Noise.Sum(method, point, args.frequency, args.octaves, args.lacunarity, args.persistence);

                if (type != NoiseMethodType.Value)
                {
                    sample = sample * 0.5f + 0.5f;
                }

                texture.SetPixel(x, y, new Color(sample, sample, sample));
            }
        }

        texture.Apply();
    }
Exemple #3
0
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);
            TextureParameters shadowmapTextureParameters = m_shadowMapTexture.GetTextureParameters();

            info.AddValue("shadowMapTextureParameters", shadowmapTextureParameters, typeof(TextureParameters));
        }
Exemple #4
0
 /// <summary>Registers a texture and returns a handle to the texture.</summary>
 /// <param name="path">The path to the file or folder that contains the texture.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 /// <param name="handle">Receives the handle to the texture.</param>
 /// <param name="loadTexture">Whether the texture is to be pre-loaded</param>
 /// <returns>Whether loading the texture was successful.</returns>
 public override bool RegisterTexture(string path, TextureParameters parameters, out Texture handle, bool loadTexture = false)
 {
     if (File.Exists(path) || Directory.Exists(path))
     {
         Texture data;
         if (Program.Renderer.TextureManager.RegisterTexture(path, parameters, out data))
         {
             handle = data;
             if (loadTexture)
             {
                 OpenBVEGame.RunInRenderThread(() =>
                 {
                     LoadTexture(data, OpenGlTextureWrapMode.ClampClamp);
                 });
             }
             return(true);
         }
     }
     else
     {
         ReportProblem(ProblemType.PathNotFound, path);
     }
     handle = null;
     return(false);
 }
    /**
     *	Generate a new procedural texture
     */
    public Texture2D generateTexture(Transform parent, TextureParameters textureDescription)
    {
        Texture2D texture = createTextureContainer(textureDescription.name, textureDescription.resolution);

        generateTexture(texture, parent, textureDescription);
        return(texture);
    }
Exemple #6
0
 public DirectionalLightWithShadow(BaseCamera viewerCamera, TextureParameters ShadowMapSettings, Vector3 Direction,
                                   Vector4 Ambient, Vector4 Diffuse, Vector4 Specular) : base(Direction, Ambient, Diffuse, Specular)
 {
     m_viewerCamera = viewerCamera;
     m_shadowOrthographicProjectionBuilder = new ShadowOrthoBuilder();
     m_shadowMapCache = null;
     InitResources(ShadowMapSettings);
 }
 public TextureSlotParam(TextureTarget target, PixelInternalFormat internalFormat, PixelFormat format, PixelType type, bool mipmaps, params ITextureParameter[] texParams)
 {
     Target         = target;
     InternalFormat = internalFormat;
     Format         = format;
     Type           = type;
     MipMaps        = mipmaps;
     TextureParameters.AddRange(texParams);
 }
Exemple #8
0
    public void LoadSprites()
    {
        bool begin = false;

        foreach (Lump l in WadLoader.lumps)
        {
            if (!begin)
            {
                if (l.lumpName == "S_START")
                {
                    begin = true;
                }

                continue;
            }

            if (l.lumpName == "S_END")
            {
                break;
            }

            int[,] pixelindices = ReadPatchData(l.data);
            int     width  = pixelindices.GetLength(0);
            int     height = pixelindices.GetLength(1);
            Color[] pixels = new Color[height * width];
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    pixels[y * width + x] = Palette[pixelindices[x, y]];
                }
            }

            Texture2D tex = new Texture2D(width, height)
            {
                name = l.lumpName
            };
            tex.SetPixels(pixels);

            if (_overrideParameters.ContainsKey(l.lumpName))
            {
                TextureParameters p = _overrideParameters[l.lumpName];
                tex.wrapModeU  = p.horizontalWrapMode;
                tex.wrapModeV  = p.verticalWrapMode;
                tex.filterMode = p.filterMode;
            }
            else
            {
                tex.wrapMode   = TextureWrapMode.Clamp;
                tex.filterMode = DefaultFilterMode;
            }

            tex.Apply();
            SpriteTextures.Add(l.lumpName, tex);
        }
    }
        private TextureParameters Read_TextureParameters(BinaryReader reader)
        {
            var result = new TextureParameters();

            result.Version = ReadVersion(reader, 1, 0x141223930);
            result.Name    = ReadString(reader);
            result.Texture = ReadUUID(reader);

            return(result);
        }
Exemple #10
0
        /// <summary>Registers a texture and returns a handle to the texture.</summary>
        /// <param name="bitmap">The bitmap that contains the texture.</param>
        /// <param name="parameters">The parameters that specify how to process the texture.</param>
        /// <returns>The handle to the texture.</returns>
        /// <remarks>Be sure not to dispose of the bitmap after calling this function.</remarks>
        public Texture RegisterTexture(Bitmap bitmap, TextureParameters parameters)
        {
            /*
             * Register the texture and return the newly created handle.
             * */
            int idx = GetNextFreeTexture();

            RegisteredTextures[idx] = new Texture(bitmap, parameters);
            RegisteredTexturesCount++;
            return(RegisteredTextures[idx]);
        }
        private void InitFramebuffer(Int32 WidthRezolution, Int32 HeightRezolution)
        {
            var ColorTextureParams        = new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Nearest, TextureMinFilter.Nearest, 0, PixelInternalFormat.Rgb, WidthRezolution, HeightRezolution, PixelFormat.Rgb, PixelType.UnsignedByte, TextureWrapMode.Repeat);
            var DepthStencilTextureParams = new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Nearest, TextureMinFilter.Nearest, 0, PixelInternalFormat.Depth24Stencil8, WidthRezolution, HeightRezolution, PixelFormat.DepthComponent, PixelType.Float, TextureWrapMode.Repeat);

            ColorTexture        = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(ColorTextureParams);
            DepthStencilTexture = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(DepthStencilTextureParams);

            FramebufferDescriptor = GL.GenFramebuffer();
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, FramebufferDescriptor);
            GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, ColorTexture.GetTextureDescriptor(), 0);
            GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthStencilAttachment, TextureTarget.Texture2D, DepthStencilTexture.GetTextureDescriptor(), 0);
            GL.DrawBuffer(DrawBufferMode.ColorAttachment0);
            GL.ReadBuffer(ReadBufferMode.None);
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
        }
        protected override void setTextures()
        {
            var verticalBlurRederTargetParams = new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Linear, TextureMinFilter.Linear,
                                                                      0, PixelInternalFormat.Rgb, EngineStatics.globalSettings.DomainFramebufferRezolution.X / 10,
                                                                      EngineStatics.globalSettings.DomainFramebufferRezolution.Y / 10, PixelFormat.Rgb, PixelType.UnsignedByte, TextureWrapMode.Repeat);

            var horizontalBlurRenderTargetParams = new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Linear, TextureMinFilter.Linear,
                                                                         0, PixelInternalFormat.Rgb, EngineStatics.globalSettings.DomainFramebufferRezolution.X / 10,
                                                                         EngineStatics.globalSettings.DomainFramebufferRezolution.Y / 10, PixelFormat.Rgb, PixelType.UnsignedByte, TextureWrapMode.Repeat);

            var depthOfFieldRenderTargetPrams = new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Nearest, TextureMinFilter.Nearest, 0, PixelInternalFormat.Rgb,
                                                                      EngineStatics.globalSettings.DomainFramebufferRezolution.X, EngineStatics.globalSettings.DomainFramebufferRezolution.Y, PixelFormat.Rgb, PixelType.UnsignedByte, TextureWrapMode.Repeat);

            VerticalBlurTexture       = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(verticalBlurRederTargetParams);
            HorizontalBlurTexture     = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(horizontalBlurRenderTargetParams);
            DepthOfFieldResultTexture = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(depthOfFieldRenderTargetPrams);
        }
Exemple #13
0
 /// <summary>Loads a texture and returns the texture data.</summary>
 /// <param name="path">The path to the file or folder that contains the texture.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 /// <param name="texture">Receives the texture.</param>
 /// <returns>Whether loading the texture was successful.</returns>
 public override bool LoadTexture(string path, TextureParameters parameters, out Texture texture)
 {
     if (System.IO.File.Exists(path) || System.IO.Directory.Exists(path))
     {
         for (int i = 0; i < Program.CurrentHost.Plugins.Length; i++)
         {
             if (Program.CurrentHost.Plugins[i].Texture != null)
             {
                 try {
                     if (Program.CurrentHost.Plugins[i].Texture.CanLoadTexture(path))
                     {
                         try {
                             if (Program.CurrentHost.Plugins[i].Texture.LoadTexture(path, out texture))
                             {
                                 texture.CompatibleTransparencyMode = Interface.CurrentOptions.OldTransparencyMode;
                                 texture = texture.ApplyParameters(parameters);
                                 return(true);
                             }
                             Interface.AddMessage(MessageType.Error, false, "Plugin " + Program.CurrentHost.Plugins[i].Title + " returned unsuccessfully at LoadTexture");
                         } catch (Exception ex) {
                             Interface.AddMessage(MessageType.Error, false, "Plugin " + Program.CurrentHost.Plugins[i].Title + " raised the following exception at LoadTexture:" + ex.Message);
                         }
                     }
                 } catch (Exception ex) {
                     Interface.AddMessage(MessageType.Error, false, "Plugin " + Program.CurrentHost.Plugins[i].Title + " raised the following exception at CanLoadTexture:" + ex.Message);
                 }
             }
         }
         FileInfo f = new FileInfo(path);
         if (f.Length == 0)
         {
             Interface.AddMessage(MessageType.Error, false, "Zero-byte texture file encountered at " + path);
         }
         else
         {
             Interface.AddMessage(MessageType.Error, false, "No plugin found that is capable of loading texture " + path);
         }
     }
     else
     {
         ReportProblem(OpenBveApi.Hosts.ProblemType.PathNotFound, path);
     }
     texture = null;
     return(false);
 }
Exemple #14
0
 /// <summary>Registers a texture and returns a handle to the texture.</summary>
 /// <param name="path">The path to the file or folder that contains the texture.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 /// <param name="handle">Receives the handle to the texture.</param>
 /// <returns>Whether loading the texture was successful.</returns>
 public override bool RegisterTexture(string path, TextureParameters parameters, out Texture handle)
 {
     if (System.IO.File.Exists(path) || System.IO.Directory.Exists(path))
     {
         Texture data;
         if (Program.Renderer.TextureManager.RegisterTexture(path, parameters, out data))
         {
             handle = data;
             return(true);
         }
     }
     else
     {
         ReportProblem(OpenBveApi.Hosts.ProblemType.PathNotFound, path);
     }
     handle = null;
     return(false);
 }
Exemple #15
0
 /// <summary>Loads a texture and returns the texture data.</summary>
 /// <param name="path">The path to the file or folder that contains the texture.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 /// <param name="texture">Receives the texture.</param>
 /// <returns>Whether loading the texture was successful.</returns>
 public override bool LoadTexture(string path, TextureParameters parameters, out Texture texture)
 {
     if (System.IO.File.Exists(path) || System.IO.Directory.Exists(path))
     {
         for (int i = 0; i < Plugins.LoadedPlugins.Length; i++)
         {
             if (Plugins.LoadedPlugins[i].Texture != null)
             {
                 try {
                     if (Plugins.LoadedPlugins[i].Texture.CanLoadTexture(path))
                     {
                         try {
                             if (Plugins.LoadedPlugins[i].Texture.LoadTexture(path, out texture))
                             {
                                 texture.CompatibleTransparencyMode = false;
                                 texture = texture.ApplyParameters(parameters);
                                 return(true);
                             }
                             Interface.AddMessage(MessageType.Error, false, "Plugin " + Plugins.LoadedPlugins[i].Title + " returned unsuccessfully at LoadTexture");
                         } catch (Exception ex) {
                             Interface.AddMessage(MessageType.Error, false, "Plugin " + Plugins.LoadedPlugins[i].Title + " raised the following exception at LoadTexture:" + ex.Message);
                         }
                     }
                 } catch (Exception ex) {
                     Interface.AddMessage(MessageType.Error, false, "Plugin " + Plugins.LoadedPlugins[i].Title + " raised the following exception at CanLoadTexture:" + ex.Message);
                 }
             }
         }
         Interface.AddMessage(MessageType.Error, false, "No plugin found that is capable of loading texture " + path);
     }
     else
     {
         ReportProblem(ProblemType.PathNotFound, path);
     }
     texture = null;
     return(false);
 }
Exemple #16
0
 /// <summary>Registers a texture and returns a handle to the texture.</summary>
 /// <param name="texture">The texture data.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 /// <param name="handle">Receives the handle to the texture.</param>
 /// <returns>Whether loading the texture was successful.</returns>
 public override bool RegisterTexture(Texture texture, TextureParameters parameters, out Texture handle)
 {
     texture = texture.ApplyParameters(parameters);
     handle  = Textures.RegisterTexture(texture);
     return(true);
 }
 /// <summary>
 /// Sets an integer parameter on a integer texture.
 /// </summary>
 /// <param name="TextureID">Id of texture</param>
 /// <param name="target">Target of texture id.</param>
 /// <param name="pname"></param>
 /// <param name="data"></param>
 public static void TextureParameterIuivEXT(uint TextureID, TextureTarget target, TextureParameters pname, uint data)
 {
     Delegates.glTextureParameterIuivEXT(TextureID, target, pname, ref data);
 }
 public static void GetTextureParameterivEXT(uint TextureID, TextureTarget target, TextureParameters pname, int[] @params)
 {
     Delegates.glGetTextureParameterivEXT(TextureID, target, pname, ref @params[0]);
 }
Exemple #19
0
 /// <summary>Registers a texture and returns a handle to the texture.</summary>
 /// <param name="path">The path to the file or folder that contains the texture.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 /// <param name="handle">Receives the handle to the texture.</param>
 /// <returns>Whether loading the texture was successful.</returns>
 public virtual bool RegisterTexture(Path.PathReference path, TextureParameters parameters, out TextureHandle handle)
 {
     handle = null;
     return(false);
 }
 public static float GetTextureParameterfvEXT(uint TextureID, TextureTarget target, TextureParameters pname)
 {
     float tmp = 0.0f;
     Delegates.glGetTextureParameterfvEXT(TextureID, target, pname, ref tmp);
     return tmp;
 }
 /// <summary>
 /// Sets a integer parameter.
 /// </summary>
 /// <param name="target"></param>
 /// <param name="pname"></param>
 /// <param name="data"></param>
 public static void TexParameterIiv(TextureTarget target, TextureParameters pname, int[] data)
 {
     Delegates.glTexParameterIiv(target, pname, ref data[0]);
 }
Exemple #22
0
    public void BuildWallTextures()
    {
        foreach (MapTexture t in MapTextures)
        {
            Color[] pixels = new Color[t.width * t.height];

            //set the base pixels clear
            for (int y = 0; y < t.height; y++)
            {
                for (int x = 0; x < t.width; x++)
                {
                    pixels[y * t.width + x] = Palette[256];
                }
            }

            foreach (MapPatch p in t.patches)
            {
                if (p.number >= PatchNames.Count)
                {
                    Debug.LogError("TextureLoader: BuildTextures: Patch number out of range, in texture \"" + t.textureName + "\"");
                    continue;
                }

                string patchName = PatchNames[p.number];
                if (!Patches.ContainsKey(patchName))
                {
                    Debug.LogError("TextureLoader: BuildTextures: Could not find patch \"" + patchName + "\"");
                    continue;
                }

                int[,] patch = Patches[patchName];

                int pheight = patch.GetLength(1);
                for (int y = 0; y < pheight; y++)
                {
                    for (int x = 0; x < patch.GetLength(0); x++)
                    {
                        int py = pheight - y - 1;

                        if (patch[x, py] == 256)
                        {
                            continue;
                        }

                        int oy = p.originy + y;
                        int ox = p.originx + x;

                        if (ox >= 0 && ox < t.width && oy >= 0 && oy < t.height)
                        {
                            pixels[(t.height - oy - 1) * t.width + ox] = Palette[patch[x, py]];
                        }
                    }
                }
            }

            bool alphaCut = false;
            for (int y = 0; y < t.height; y++)
            {
                for (int x = 0; x < t.width; x++)
                {
                    if (pixels[y * t.width + x].a < 1f)
                    {
                        alphaCut = true;
                    }
                }
            }

            Texture2D tex = new Texture2D(t.width, t.height)
            {
                name = t.textureName
            };
            tex.SetPixels(pixels);

            if (_overrideParameters.ContainsKey(t.textureName))
            {
                TextureParameters p = _overrideParameters[t.textureName];
                tex.wrapModeU  = p.horizontalWrapMode;
                tex.wrapModeV  = p.verticalWrapMode;
                tex.filterMode = p.filterMode;
            }
            else
            {
                tex.wrapMode   = TextureWrapMode.Repeat;
                tex.filterMode = DefaultFilterMode;
            }

            tex.Apply();
            WallTextures.Add(t.textureName, tex);

            if (alphaCut)
            {
                NeedsAlphacut.Add(t.textureName, true);
            }
        }
    }
Exemple #23
0
 /// <summary>Loads a texture and returns the texture data.</summary>
 /// <param name="path">The path to the file or folder that contains the texture.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 /// <param name="texture">Receives the texture.</param>
 /// <returns>Whether loading the texture was successful.</returns>
 public virtual bool LoadTexture(string path, TextureParameters parameters, out Textures.Texture texture)
 {
     texture = null;
     return(false);
 }
Exemple #24
0
 /// <summary>Registers a texture and returns a handle to the texture.</summary>
 /// <param name="texture">The texture data.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 /// <param name="handle">Receives the handle to the texture.</param>
 /// <returns>Whether loading the texture was successful.</returns>
 public override bool RegisterTexture(Texture texture, TextureParameters parameters, out Texture handle)
 {
     texture = texture.ApplyParameters(parameters);
     handle  = Program.Renderer.TextureManager.RegisterTexture(texture);
     return(true);
 }
 public static extern void glGetTexParameterfv(TextureTarget target, TextureParameters pname, ref float @params);
Exemple #26
0
 /// <summary>
 /// Sets an integer parameter on a integer texture.
 /// </summary>
 /// <param name="TextureID">Id of texture</param>
 /// <param name="target">Target of texture id.</param>
 /// <param name="pname"></param>
 /// <param name="data"></param>
 public static void TextureParameterIuivEXT(uint TextureID, TextureTarget target, TextureParameters pname, uint data)
 {
     Delegates.glTextureParameterIuivEXT(TextureID, target, pname, ref data);
 }
Exemple #27
0
        /// <summary>
        /// Gets an integer parameter from a integer texture.
        /// </summary>
        /// <param name="TextureID">Id of texture</param>
        /// <param name="target">Target of texture id.</param>
        /// <param name="pname"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static uint GetTextureParameterIuivEXT(uint TextureID, TextureTarget target, TextureParameters pname)
        {
            uint tmp = 0;

            Delegates.glGetTextureParameterIuivEXT(TextureID, target, pname, ref tmp);
            return(tmp);
        }
Exemple #28
0
 /// <summary>
 /// Gets an integer parameter from a integer texture.
 /// </summary>
 /// <param name="TextureID">Id of texture</param>
 /// <param name="target">Target of texture id.</param>
 /// <param name="pname"></param>
 /// <param name="data"></param>
 public static void GetTextureParameterIivEXT(uint TextureID, TextureTarget target, TextureParameters pname, int[] data)
 {
     Delegates.glGetTextureParameterIivEXT(TextureID, target, pname, ref data[0]);
 }
 /// <summary>
 /// Gets an integer parameter from a integer texture.
 /// </summary>
 /// <param name="TextureID">Id of texture</param>
 /// <param name="target">Target of texture id.</param>
 /// <param name="pname"></param>
 /// <param name="data"></param>
 public static void GetTextureParameterIivEXT(uint TextureID, TextureTarget target, TextureParameters pname, int[] data)
 {
     Delegates.glGetTextureParameterIivEXT(TextureID, target, pname, ref data[0]);
 }
 /// <summary>
 /// Sets a integer parameter.
 /// </summary>
 /// <param name="target"></param>
 /// <param name="pname"></param>
 /// <param name="data"></param>
 public static void TexParameterIuiv(TextureTarget target, TextureParameters pname, ref uint data)
 {
     Delegates.glTexParameterIuiv(target, pname, ref data);
 }
 public static void TextureParameterfvEXT(uint TextureID, TextureTarget target, TextureParameters pname, float[] param)
 {
     Delegates.glTextureParameterfvEXT(TextureID, target, pname, param);
 }
 // --- constructors ---
 /// <summary>Creates a new path origin.</summary>
 /// <param name="path">The path to the texture.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 /// <param name="Host">The callback function to the host application</param>
 public PathOrigin(string path, TextureParameters parameters, Hosts.HostInterface Host)
 {
     this.Path        = path;
     this.Parameters  = parameters;
     this.currentHost = Host;
 }
 public static void GetTexParameterfv(TextureTarget target, TextureParameters pname, float[] @params)
 {
     Delegates.glGetTexParameterfv(target, pname, ref @params[0]);
 }
Exemple #34
0
        /// <summary>Registeres a texture and returns a handle to the texture.</summary>
        /// <param name="path">The path to the texture.</param>
        /// <param name="parameters">The parameters that specify how to process the texture.</param>
        /// <param name="handle">Receives a handle to the texture.</param>
        /// <returns>Whether registering the texture was successful.</returns>
        public bool RegisterTexture(string path, TextureParameters parameters, out Texture handle)
        {
            /* BUG:
             * Attempt to delete null texture handles from the end of the array
             * These sometimes seem to end up there
             *
             * Have also seen a registered textures count of 72 and an array length of 64
             * Is it possible for a texture to fail to register, but still increment the registered textures count?
             *
             * There appears to be a timing issue somewhere whilst loading, as this only happens intermittantly
             */
            if (RegisteredTexturesCount > RegisteredTextures.Length)
            {
                /* BUG:
                 * The registered textures count very occasional becomes greater than the array length (Texture loader crashses possibly?)
                 * This then crashes when we attempt to itinerate the array, so reset it...
                 */
                RegisteredTexturesCount = RegisteredTextures.Length;
            }

            if (RegisteredTexturesCount != 0)
            {
                try
                {
                    for (int i = RegisteredTexturesCount - 1; i > 0; i--)
                    {
                        if (RegisteredTextures[i] != null)
                        {
                            break;
                        }

                        Array.Resize(ref RegisteredTextures, RegisteredTextures.Length - 1);
                    }
                }
                catch
                {
                    // ignored
                }
            }

            /*
             * Check if the texture is already registered.
             * If so, return the existing handle.
             * */
            for (int i = 0; i < RegisteredTexturesCount; i++)
            {
                if (RegisteredTextures[i] != null)
                {
                    try
                    {
                        //The only exceptions thrown were these when it barfed
                        PathOrigin source = RegisteredTextures[i].Origin as PathOrigin;

                        if (source != null && source.Path == path && source.Parameters == parameters)
                        {
                            handle = RegisteredTextures[i];
                            return(true);
                        }
                    }
                    catch
                    {
                        // ignored
                    }
                }
            }

            /*
             * Register the texture and return the newly created handle.
             * */
            int idx = GetNextFreeTexture();

            RegisteredTextures[idx] = new Texture(path, parameters, currentHost);
            RegisteredTexturesCount++;
            handle = RegisteredTextures[idx];
            return(true);
        }
 public static void TexParameteri(TextureTarget target, TextureParameters pname, int param)
 {
     Delegates.glTexParameteri(target, pname, param);
 }
Exemple #36
0
 /// <summary>Loads a texture and returns the texture data.</summary>
 /// <param name="path">The path to the file or folder that contains the texture.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 /// <param name="texture">Receives the texture.</param>
 /// <returns>Whether loading the texture was successful.</returns>
 public virtual bool LoadTexture(Path.PathReference path, TextureParameters parameters, out Texture texture)
 {
     texture = null;
     return(false);
 }
 public static void TexParameterfv(TextureTarget target, TextureParameters pname, float[] param)
 {
     Delegates.glTexParameterfv(target, pname, @param);
 }
Exemple #38
0
 /// <summary>Registers a texture and returns a handle to the texture.</summary>
 /// <param name="path">The path to the file or folder that contains the texture.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 /// <param name="handle">Receives the handle to the texture.</param>
 /// <param name="loadTexture">Whether the texture should also be pre-loaded</param>
 /// <returns>Whether loading the texture was successful.</returns>
 public virtual bool RegisterTexture(string path, TextureParameters parameters, out Textures.Texture handle, bool loadTexture = false)
 {
     handle = null;
     return(false);
 }
 /// <summary>
 /// Gets an integer parameter from a integer texture.
 /// </summary>
 /// <param name="TextureID">Id of texture</param>
 /// <param name="target">Target of texture id.</param>
 /// <param name="pname"></param>
 /// <param name="data"></param>
 /// <returns></returns>
 public static uint GetTextureParameterIuivEXT(uint TextureID, TextureTarget target, TextureParameters pname)
 {
     uint tmp = 0;
     Delegates.glGetTextureParameterIuivEXT(TextureID, target, pname, ref tmp);
     return tmp;
 }
 public static extern void glTexParameteri(TextureTarget target, TextureParameters pname, int param);
Exemple #41
0
 public override bool RegisterTexture(string path, TextureParameters parameters, out Texture handle)
 {
     handle = new Texture(path, parameters, this);
     return(true);
     // return base.RegisterTexture(path, parameters, out handle);
 }
Exemple #42
0
 public override bool RegisterTexture(Bitmap texture, TextureParameters parameters, out OpenBveApi.Textures.Texture handle)
 {
     handle = new Texture(texture, parameters);
     return(true);
 }
 public static extern void glTexParameterfv(TextureTarget target, TextureParameters pname, float[] param);
Exemple #44
0
 /// <summary>Registers a texture and returns a handle to the texture.</summary>
 /// <param name="texture">The texture data.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 /// <param name="handle">Receives the handle to the texture.</param>
 /// <returns>Whether loading the texture was successful.</returns>
 public virtual bool RegisterTexture(Textures.Texture texture, TextureParameters parameters, out Textures.Texture handle)
 {
     handle = null;
     return(false);
 }
 public static int GetTexParameteriv(TextureTarget target, TextureParameters pname)
 {
     int tmp = 0;
     Delegates.glGetTexParameteriv(target, pname, ref tmp);
     return tmp;
 }