コード例 #1
0
        public OpenGLSceneProcessor(IServiceProvider serviceProvider, IRenderWindow renderWindow, SceneGraph sceneGraph)
        {
            _serviceProvider          = serviceProvider;
            _cancellationTokenManager = _serviceProvider.GetRequiredService <CancellationTokenSource>();
            _logger         = _serviceProvider.GetRequiredService <ILogger <RenderWindow> >();
            _shaderCompiler = _serviceProvider.GetRequiredService <IShaderCompiler>();
            _textureLoader  = _serviceProvider.GetRequiredService <ITextureLoader>();

            _renderWindow   = renderWindow; // This cannot be passed via the service provider otherwise there will be a cycle in the DI graph
            _sceneGraph     = sceneGraph;
            _renderList     = new LinkedList <IRenderCommand>();
            _renderInfo     = new RenderInfo();
            _requestPicking = null;

            GL.LoadBindings(new GLFWBindingsContext());

            // Get human readable log messages during debugging
            if (Debugger.IsAttached)
            {
                GL.Enable(EnableCap.DebugOutput);
                _debugProc = DebugMessageCallback;
                _gcHandle  = GCHandle.Alloc(_debugProc);
                GL.DebugMessageCallback(_debugProc, IntPtr.Zero);
            }

            GL.Enable(EnableCap.DepthTest);

            // Save default frame buffer id for later blitting
            GL.GetInteger(GetPName.FramebufferBinding, out _defaultFrameBufferId);
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, _defaultFrameBufferId);

            InitFrameBuffer(640, 360);
        }
コード例 #2
0
ファイル: TextureShader.cs プロジェクト: Lolik21/AKG
 public TextureShader(IDataProvider dataProvider, IEventAggregator eventAggregator,
                      ITextureLoader textureLoader) : base(eventAggregator)
 {
     _shaderProgramFactory = new ShaderProgramFactory(new ShaderFactory("Texture"));
     _figureResult         = dataProvider.GetVertexPoints("Textures");
     _textureLoader        = textureLoader;
 }
コード例 #3
0
        public TextureFactory(ITextureLoader loader, int capacity = 1024)
        {
            if (loader == null) throw new ArgumentNullException(nameof(loader));

            this.loader = loader;
            this.textures = new Entry[capacity];
        }
コード例 #4
0
ファイル: BufferManager.cs プロジェクト: WCoetser/TRL-3D
        public BufferManager(SceneGraph sceneGraph, ILogger <BufferManager> logger, IShaderCompiler shaderCompiler, ITextureLoader textureLoader)
        {
            _sceneGraph     = sceneGraph;
            _logger         = logger;
            _shaderCompiler = shaderCompiler;
            _textureLoader  = textureLoader;

            _objectToGeometryBuffers = new Dictionary <ObjectIdentityBase, HashSet <ObjectIdentityBase> >();
        }
コード例 #5
0
        protected AbstractTexture(ITextureLoader loader, string characterRace, int width, int height)
        {
            this.textureLoader = loader;
            this.CharacterRace = characterRace;
            this.height        = height;
            this.width         = width;

            loadCallback = (textures, paths) => LoadingTexture(textures, paths);
        }
コード例 #6
0
        /// <summary>
        /// Texture from buffer
        /// </summary>
        /// <param name="index"></param>
        public TextureItem(int index, ITextureLoader textureLoader)
        {
            m_textureIndex  = index;
            m_textureLoader = textureLoader;

            if (m_textureLoader == null)
            {
                throw new Exception("ITextureLoader is null.");
            }
        }
コード例 #7
0
        public TextureFactory(ITextureLoader loader, int capacity = 1024)
        {
            if (loader == null)
            {
                throw new ArgumentNullException(nameof(loader));
            }

            this.loader   = loader;
            this.textures = new Entry[capacity];
        }
コード例 #8
0
        public static AbstractTexture Create(TextureType type, ITextureLoader loader, string characterRace)
        {
            switch (type)
            {
            case TextureType.Skin:
                return(new Textures.Skin(loader, 0, 0, 1024, 1024, characterRace));

            case TextureType.Eyebrow:
                return(new Textures.Eyebrow(loader, 384, 0, 640, 384, characterRace));

            case TextureType.Scar:
                return(new Textures.Scar(loader, 384, 0, 640, 384, characterRace));

            case TextureType.Beard:
                return(new Textures.Beard(loader, 384, 0, 640, 384, characterRace));

            case TextureType.FaceFeature:
                return(new Textures.FaceFeature(loader, 384, 0, 640, 384, characterRace));

            case TextureType.Hair:
                return(new Textures.Hair(loader, 384, 0, 640, 384, characterRace));

            case TextureType.Eye:
                return(new Textures.Eye(loader, 960, 0, 64, 64, characterRace));

            case TextureType.Head:
                return(new Textures.Head(loader, 384, 0, 640, 384, characterRace));

            case TextureType.Pants:
                return(new Textures.Pants(loader, 0, 0, 512, 576, characterRace));

            case TextureType.Torso:
                return(new Textures.Torso(loader, 0, 512, 1024, 512, characterRace));

            case TextureType.Shoe:
                return(new Textures.Shoes(loader, 0, 0, 384, 448, characterRace));

            case TextureType.Glove:
                return(new Textures.Gloves(loader, 512, 384, 512, 448, characterRace));

            case TextureType.RobeLong:
                return(new Textures.RobeLong(loader, 0, 0, 512, 576, characterRace));

            case TextureType.RobeShort:
                return(new Textures.RobeShort(loader, 0, 0, 512, 576, characterRace));

            case TextureType.Belt:
                return(new Textures.Belt(loader, 0, 512, 512, 256, characterRace));

            case TextureType.Cloak:
                return(new Textures.Cloak(loader, 0, 0, 512, 512, characterRace));
            }

            return(null);
        }
コード例 #9
0
        protected AbstractTexture(ITextureLoader loader, int x, int y, int width, int height, string characterRace, int order, TextureType type = TextureType.Skin) : this(loader, characterRace, width, height)
        {
            this.x = x;
            this.y = y;

            this.MergeOrder = order;
            this.Type       = type;

            textures = textureLoader.ParseTextures(this);
            LoadTexture();
        }
コード例 #10
0
 public static void RegisterLoader(ITextureLoader newLoader)
 {
     if (newLoader != null)
     {
         if (isExistExternalLoader)
         {
             externalLoader.Deinit();
         }
         externalLoader = newLoader;
         initialized    = false;
     }
 }
コード例 #11
0
ファイル: MainLoop.cs プロジェクト: Zulkir/RAVC
 public MainLoop(IPclWorkarounds pclWorkarounds, IClientStatistics statistics, IClientSettings settings, IContext context, IRavcGameWindow gameWindow, IMainThreadBorderStage mainThreadBorderStage, IFinalFrameProvider finalFrameProvider, IClientStatisticsRenderer statisticsRenderer, ITextureLoader textureLoader)
 {
     this.settings = settings;
     this.context = context;
     this.statistics = statistics;
     this.gameWindow = gameWindow;
     this.mainThreadBorderStage = mainThreadBorderStage;
     this.finalFrameProvider = finalFrameProvider;
     this.statisticsRenderer = statisticsRenderer;
     finalRenderer = new FinalRenderer(pclWorkarounds, settings, context);
     cursorRenderer = new CursorRenderer(settings, context, textureLoader);
     stopwatch = new Stopwatch();
 }
コード例 #12
0
ファイル: Atlas.cs プロジェクト: kguner/Components
 /// <summary>
 /// Initializes a new instance of the <see cref="Atlas" /> class.
 /// </summary>
 /// <param name="path">The path.</param>
 /// <param name="textureLoader">The texture loader.</param>
 /// <exception cref="System.Exception">Error reading atlas file:  + path</exception>
 public Atlas(string path, ITextureLoader textureLoader)
 {
     Stream stream = WaveServices.Storage.OpenContentFile(path);
     using (StreamReader reader = new StreamReader(stream))
     {
         try
         {
             this.Load(reader, Path.GetDirectoryName(path), textureLoader);
         }
         catch (Exception ex)
         {
             throw new Exception("Error reading atlas file: " + path, ex);
         }
     }
 }
コード例 #13
0
        public LightningShader(IDataProvider dataProvider, IEventAggregator eventAggregator,
                               ITextureLoader textureLoader) : base(eventAggregator)
        {
            _shaderProgramFactory      = new ShaderProgramFactory(new ShaderFactory("Lightning"));
            _lampShaderProgramFactory  = new ShaderProgramFactory(new ShaderFactory("LightningLamp"));
            _worldMapProgramFactory    = new ShaderProgramFactory(new ShaderFactory("WorldMap"));
            _figureResult              = dataProvider.GetVertexPoints("Lightning");
            _worldMapResult            = dataProvider.GetVertexPoints("WorldMap");
            _textureLoader             = textureLoader;
            eventAggregator.OnKeyDown += OnOnKeyDown;


            Timer timer = new Timer();

            timer.Tick    += TimerOnTick;
            timer.Interval = 10;
            timer.Enabled  = true;
        }
コード例 #14
0
        public static bool Register(ImageFormat format, ITextureLoader loader)
        {
            try
            {
                var verified = loader.Verify();
                if (verified)
                {
                    Loaders[format] = loader;
                    return(true);
                }
            }
            catch (Exception e)
            {
                XuaLogger.AutoTranslator.Warn(e, "An image loader could not be registered.");
            }

            return(false);
        }
コード例 #15
0
ファイル: TriangleBuffer.cs プロジェクト: WCoetser/TRL-3D
        /// <summary>
        /// Builds a buffer based on the given triangles for the given scene graph
        /// </summary>
        /// <param name="sceneGraph">The scene graph for the entire world model.</param>
        /// <param name="triangleAssertionsToRender">The triangles for which a buffer needs to be constructed.</param>
        public TriangleBuffer(SceneGraph sceneGraph,
                              BufferManager bufferManager,
                              IEnumerable <Core.Scene.Triangle> triangleAssertionsToRender,
                              ILogger logger,
                              IShaderCompiler shaderCompiler,
                              ITextureLoader textureLoader) : base()
        {
            _logger         = logger;
            _shaderCompiler = shaderCompiler;
            _textureLoader  = textureLoader;
            _sceneGraph     = sceneGraph;
            _bufferManager  = bufferManager;

            _triangleAssertionsToRender = triangleAssertionsToRender.ToArray();

            _vertexBuffer      = new Lazy <float[]>(() => new float[_triangleAssertionsToRender.Length * VerticesPerTriangle * ComponentsPerVertex]);
            _vertexIndexBuffer = new Lazy <uint[]>(() => new uint[_triangleAssertionsToRender.Length * VerticesPerTriangle]);

            _textureObjectIdToShaderIndex = new EqualityComparerMapper <ulong>(EqualityComparer <ulong> .Default);

            BuildBuffer();
        }
コード例 #16
0
ファイル: CursorRenderer.cs プロジェクト: Zulkir/RAVC
        public CursorRenderer(IClientSettings settings, IContext context, ITextureLoader textureLoader)
        {
            var header = settings.IsEs ? EsHeader : DesktopHeader;
            var vertexShader = context.Create.VertexShader(header + VertexShaderText);
            var fragmentShader = context.Create.FragmentShader(header + FragmentShaderText);
            program = context.Create.Program(new ShaderProgramDescription
            {
                VertexShaders = new[] { vertexShader },
                FragmentShaders = new[] { fragmentShader },
                VertexAttributeNames = new[] { "in_position", "in_tex_coord" },
                SamplerNames = new[] { "DiffTexture" }
            });

            var vertexBuffer = context.Create.Buffer(BufferTarget.ArrayBuffer, 4 * Vertex.Size, BufferUsageHint.StaticDraw, new[]
            {
                new Vertex(-1f, 1f, 0f, 0f),
                new Vertex(1f, 1f, 1f, 0f),
                new Vertex(1f, -1f, 1f, 1f),
                new Vertex(-1f, -1f, 0f, 1f)
            });

            var indexBuffer = context.Create.Buffer(BufferTarget.ElementArrayBuffer, 6 * sizeof(ushort), BufferUsageHint.StaticDraw, new ushort[]
            {
                0, 1, 2, 0, 2, 3
            });

            vertexArray = context.Create.VertexArray();
            vertexArray.SetVertexAttributeF(0, vertexBuffer, VertexAttributeDimension.Two, VertexAttribPointerType.Float, false, Vertex.Size, 0);
            vertexArray.SetVertexAttributeF(1, vertexBuffer, VertexAttributeDimension.Two, VertexAttribPointerType.Float, false, Vertex.Size, 2 * sizeof(float));
            vertexArray.SetElementArrayBuffer(indexBuffer);

            texture = textureLoader.LoadTexture(context, "Cursor.png");
            sampler = context.Create.Sampler();
            sampler.SetMagFilter(TextureMagFilter.Nearest);
        }
コード例 #17
0
ファイル: Atlas.cs プロジェクト: kguner/Components
 /// <summary>
 /// Initializes a new instance of the <see cref="Atlas" /> class.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <param name="dir">The dir.</param>
 /// <param name="textureLoader">The texture loader.</param>
 public Atlas(TextReader reader, string dir, ITextureLoader textureLoader)
 {
     this.Load(reader, dir, textureLoader);
 }
コード例 #18
0
 public TextureResourceManager(ITextureLoader textureLoader, IConfiguration configuration, ILogger logger)
 {
     _textureLoader = textureLoader;
     _configuration = configuration;
     _logger        = logger;
 }
コード例 #19
0
 public Skin(ITextureLoader loader, int x, int y, int width, int height,
             string characterRace) :
     base(loader, x, y, width, height, characterRace, 0, TextureType.Skin)
 {
 }
コード例 #20
0
 public DXTextureFactory(ITextureLoader loader, int capacity = 1024)
     : base(loader, capacity)
 {
 }
コード例 #21
0
 public Pants(ITextureLoader loader, int x, int y, int width, int height,
              string characterRace) :
     base(loader, x, y, width, height, characterRace, 21, TextureType.Pants)
 {
 }
コード例 #22
0
 public Eye(ITextureLoader loader, int x, int y, int width, int height,
            string characterRace) :
     base(loader, x, y, width, height, characterRace, 7, TextureType.Eye)
 {
 }
コード例 #23
0
 public Torso(ITextureLoader loader, int x, int y, int width, int height,
              string characterRace) :
     base(loader, x, y, width, height, characterRace, 22, TextureType.Torso)
 {
 }
コード例 #24
0
 public DXTextureFactory(DXGraphicsHost host, ITextureLoader loader, int capacity = 1024)
     : base(loader, capacity)
 {
     this.graphicsHost = host;
 }
コード例 #25
0
 public Shoes(ITextureLoader loader, int x, int y, int width, int height,
              string characterRace) :
     base(loader, x, y, width, height, characterRace, 23, TextureType.Shoe)
 {
 }
コード例 #26
0
 public MeshTexture(ITextureLoader loader, string characterRace, string[][] texturePaths) : base(loader, characterRace, 512, 512, texturePaths)
 {
     folderPath = null;
 }
コード例 #27
0
 public FaceFeature(ITextureLoader loader, int x, int y, int width, int height,
                    string characterRace) :
     base(loader, x, y, width, height, characterRace, 3, TextureType.FaceFeature)
 {
 }
コード例 #28
0
 public void RegisterTextureLoader(ITextureLoader loader)
 {
     Loaders.Add(loader);
 }
コード例 #29
0
 public RobeShort(ITextureLoader loader, int x, int y, int width, int height,
                  string characterRace) :
     base(loader, x, y, width, height, characterRace, 27, TextureType.RobeShort)
 {
 }
コード例 #30
0
 public Cloak(ITextureLoader loader, int x, int y, int width, int height,
              string characterRace) :
     base(loader, x, y, width, height, characterRace, 24, TextureType.Cloak)
 {
 }
コード例 #31
0
 protected AbstractTexture(ITextureLoader loader, string characterRace, int width, int height, string path) : this(loader, characterRace, width, height)
 {
     textures = loader.ParseTextures(this, path);
     LoadTexture();
 }
コード例 #32
0
ファイル: Atlas.cs プロジェクト: kguner/Components
        /// <summary>
        /// Loads the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="imagesDir">The images dir.</param>
        /// <param name="textureLoader">The texture loader.</param>
        /// <exception cref="System.ArgumentNullException">textureLoader cannot be null.</exception>
        private void Load(TextReader reader, string imagesDir, ITextureLoader textureLoader)
        {
            if (textureLoader == null)
            {
                throw new ArgumentNullException("textureLoader cannot be null.");
            }

            this.textureLoader = textureLoader;

            string[] tuple = new string[4];
            AtlasPage page = null;

            while (true)
            {
                string line = reader.ReadLine();

                if (line == null)
                {
                    break;
                }

                if (line.Trim().Length == 0)
                {
                    page = null;
                }
                else if (page == null)
                {
                    page = new AtlasPage();
                    page.Name = line;

                    page.Format = (Format)Enum.Parse(typeof(Format), this.ReadValue(reader), false);

                    this.ReadTuple(reader, tuple);

                    page.MinFilter = (TextureFilter)Enum.Parse(typeof(TextureFilter), tuple[0], true);
                    page.MagFilter = (TextureFilter)Enum.Parse(typeof(TextureFilter), tuple[1], true);

                    string direction = this.ReadValue(reader);
                    page.UWrap = TextureWrap.ClampToEdge;
                    page.VWrap = TextureWrap.ClampToEdge;
                    if (direction == "x")
                    {
                        page.UWrap = TextureWrap.Repeat;
                    }
                    else if (direction == "y")
                    {
                        page.VWrap = TextureWrap.Repeat;
                    }
                    else if (direction == "xy")
                    {
                        page.UWrap = page.VWrap = TextureWrap.Repeat;
                    }

                    textureLoader.Load(page, Path.Combine(imagesDir, line));

                    this.Pages.Add(page);
                }
                else
                {
                    AtlasRegion region = new AtlasRegion();
                    region.Name = line;
                    region.Page = page;

                    region.Rotate = bool.Parse(this.ReadValue(reader));

                    this.ReadTuple(reader, tuple);
                    int x = int.Parse(tuple[0]);
                    int y = int.Parse(tuple[1]);

                    this.ReadTuple(reader, tuple);
                    int width = int.Parse(tuple[0]);
                    int height = int.Parse(tuple[1]);

                    region.U = x / (float)page.Width;
                    region.V = y / (float)page.Height;

                    if (region.Rotate)
                    {
                        region.U2 = (x + height) / (float)page.Width;
                        region.V2 = (y + width) / (float)page.Height;
                    }
                    else
                    {
                        region.U2 = (x + width) / (float)page.Width;
                        region.V2 = (y + height) / (float)page.Height;
                    }

                    region.X = x;
                    region.Y = y;
                    region.Width = Math.Abs(width);
                    region.Height = Math.Abs(height);

                    if (this.ReadTuple(reader, tuple) == 4)
                    { // split is optional
                        region.Splits = new int[] { int.Parse(tuple[0]), int.Parse(tuple[1]), int.Parse(tuple[2]), int.Parse(tuple[3]) };

                        if (this.ReadTuple(reader, tuple) == 4)
                        { // pad is optional, but only present with splits
                            region.Pads = new int[] { int.Parse(tuple[0]), int.Parse(tuple[1]), int.Parse(tuple[2]), int.Parse(tuple[3]) };

                            this.ReadTuple(reader, tuple);
                        }
                    }

                    region.OriginalWidth = int.Parse(tuple[0]);
                    region.OriginalHeight = int.Parse(tuple[1]);

                    this.ReadTuple(reader, tuple);
                    region.OffsetX = int.Parse(tuple[0]);
                    region.OffsetY = int.Parse(tuple[1]);

                    region.Index = int.Parse(this.ReadValue(reader));

                    this.regions.Add(region);
                }
            }
        }
コード例 #33
0
 public Head(ITextureLoader loader, int x, int y, int width, int height,
             string characterRace) :
     base(loader, x, y, width, height, characterRace, 20, TextureType.Head)
 {
 }
コード例 #34
0
 public Belt(ITextureLoader loader, int x, int y, int width, int height,
             string characterRace) :
     base(loader, x, y, width, height, characterRace, 28, TextureType.Belt)
 {
 }
コード例 #35
0
 public TextureProvider(TextureSearcher textureSearcher, ITextureLoader <TBitmap> loader, SceneContext sceneContext)
 {
     _textureSearcher = textureSearcher;
     _loader          = loader;
     _sceneContext    = sceneContext;
 }
コード例 #36
0
 /// <param name="textureLoader"></param>
 /// <param name="addressFormat">"Should have parrameter 0 - width, parameter 1 - height"</param>
 public RandomTextureLoader([NotNull] ITextureLoader textureLoader, [NotNull] string addressFormat)
 {
     this.textureLoader = textureLoader ?? throw new ArgumentNullException(nameof(textureLoader));
     this.addressFormat = addressFormat ?? throw new ArgumentNullException(nameof(addressFormat));
 }
コード例 #37
0
 protected AbstractTexture(ITextureLoader loader, string characterRace, int width, int height, string[][] texturePaths) : this(loader, characterRace, width, height)
 {
     textures = texturePaths;
     LoadTexture();
 }