Beispiel #1
0
        public Resources.Texture CreateTexture(string name, int width, int height, PixelFormat pixelFormat, PixelInternalFormat interalFormat, PixelType pixelType, byte[] data, bool mipmap)
        {
            var handle = RenderSystem.CreateTexture(width, height, data, pixelFormat, interalFormat, pixelType, mipmap, null);

            var texture = new Resources.Texture(name, "");
            texture.Handle = handle;
            texture.Width = width;
            texture.Height = height;
            texture.PixelInternalFormat = interalFormat;
            texture.PixelFormat = pixelFormat;

            ResourceManager.Manage(texture);

            return texture;
        }
Beispiel #2
0
 public void Init(Resources.Texture texture, Vector2 position, Vector2 size, Vector2 uvPosition, Vector2 uvSize, Vector4 color, bool alphaBlend, bool srgb)
 {
     Texture = texture;
     Position = position;
     Size = size;
     UvPositon = uvPosition;
     UvSize = uvSize;
     Color = color;
     AlphaBlend = alphaBlend;
     SRGB = srgb;
 }
Beispiel #3
0
        public RenderTarget CreateRenderTarget(string name, Renderer.RenderTargets.Definition definition)
        {
            if (string.IsNullOrWhiteSpace(name))
                throw new ArgumentNullException("name");
            if (definition == null)
                throw new ArgumentNullException("definition");

            int[] textureHandles;

            var renderTarget = new RenderTarget(definition.Width, definition.Height);

            renderTarget.Handle = RenderSystem.CreateRenderTarget(definition, out textureHandles, (handle, success, errors) =>
            {
                renderTarget.IsReady = true;
            });

            var textures = new Resources.Texture[textureHandles.Length];
            for (var i = 0; i < textureHandles.Length; i++)
            {
                var texture = new Resources.Texture("_sys/render_targets/" + name + "_" + StringConverter.ToString(i), "");
                texture.Handle = textureHandles[i];
                texture.Width = definition.Width;
                texture.Height = definition.Height;

                ResourceManager.Manage(texture);

                textures[i] = texture;
            }

            renderTarget.Textures = textures;

            return renderTarget;
        }