Example #1
0
 /// <summary>
 ///
 /// </summary>
 public override void InitializeComponent()
 {
     this.Config       = PspEmulatorContext.PspConfig;
     this.Memory       = PspEmulatorContext.GetInstance <PspMemory>();
     this.TextureCache = PspEmulatorContext.GetInstance <TextureCache>();
     this.VertexReader = new VertexReader();
 }
Example #2
0
		/// <summary>
		/// 
		/// </summary>
		public override void InitializeComponent()
		{
			base.InitializeComponent();
			this.Config = PspEmulatorContext.PspConfig;
			this.TextureCache = new TextureCacheOpengl(this.Memory, this);
			this.VertexReader = new VertexReader();
			this.TextureCache = new TextureCacheOpengl(Memory, this);
		}
Example #3
0
 /// <summary>
 /// 
 /// </summary>
 public override void InitializeComponent()
 {
     this.Config = PspEmulatorContext.PspConfig;
     this.TextureCache.OpenglGpuImpl = this;
     this.VertexReader = new VertexReader();
 }
Example #4
0
 /// <summary>
 /// 
 /// </summary>
 public override void InitializeComponent()
 {
     this.Config = PspEmulatorContext.PspConfig;
     this.Memory = PspEmulatorContext.GetInstance<PspMemory>();
     this.TextureCache = PspEmulatorContext.GetInstance<TextureCache>();
     this.VertexReader = new VertexReader();
 }
Example #5
0
 void IInjectInitialize.Initialize()
 {
     RenderbufferManager = new RenderbufferManager(this);
     TextureCache        = new TextureCacheOpengl(Memory, this, InjectContext);
     VertexReader        = new VertexReader();
 }
Example #6
0
        /// <summary>
        /// </summary>
        /// <param name="vertexCount"></param>
        public override void Prim(ushort vertexCount)
        {
            VertexType = GpuState.VertexState.Type;

            if (_doPrimStart || (VertexType != _cachedVertexType))
            {
                _cachedVertexType = VertexType;
                _doPrimStart      = false;

                OpenglGpuImplCommon.PrepareStateCommon(GpuState, ScaleViewport);

                if (GpuState.ClearingMode)
                {
                    OpenglGpuImplClear.PrepareStateClear(GpuState);
                }
                else
                {
                    PrepareStateDraw(GpuState);
                }

                OpenglGpuImplMatrix.PrepareStateMatrix(GpuState, out _worldViewProjectionMatrix);
                PrepareDrawStateFirst();
            }

            //if (PrimitiveType == GuPrimitiveType.TriangleStrip) VertexCount++;

            uint morpingVertexCount, totalVerticesWithoutMorphing;

            PreparePrim(GpuState, out totalVerticesWithoutMorphing, vertexCount, out morpingVertexCount);

            var z = 0;

            //for (int n = 0; n < MorpingVertexCount; n++) Console.Write("{0}, ", Morphs[n]); Console.WriteLine("");

            //int VertexInfoFloatCount = (sizeof(Color4F) + sizeof(Vector3F) * 3) / sizeof(float);
            var vertexInfoFloatCount = (sizeof(VertexInfo)) / sizeof(float);

            fixed(VertexInfo *verticesPtr = Vertices)
            {
                if (morpingVertexCount == 1)
                {
                    VertexReader.ReadVertices(0, verticesPtr, (int)totalVerticesWithoutMorphing);
                }
                else
                {
                    VertexInfo tempVertexInfo;
                    var        componentsIn = (float *)&tempVertexInfo;
                    for (var n = 0; n < totalVerticesWithoutMorphing; n++)
                    {
                        var componentsOut = (float *)&verticesPtr[n];
                        for (var cc = 0; cc < vertexInfoFloatCount; cc++)
                        {
                            componentsOut[cc] = 0;
                        }
                        for (var m = 0; m < morpingVertexCount; m++)
                        {
                            VertexReader.ReadVertex(z++, &tempVertexInfo);
                            for (var cc = 0; cc < vertexInfoFloatCount; cc++)
                            {
                                componentsOut[cc] += componentsIn[cc] * GpuState.MorphingState.MorphWeight(m);
                            }
                        }
                        verticesPtr[n].Normal = verticesPtr[n].Normal.Normalize();
                    }
                }
            }

            _CapturePrimitive(_primitiveType, GpuState.GetAddressRelativeToBaseOffset(GpuState.VertexAddress),
                              vertexCount, ref VertexType, () =>
            {
                // Continuation
                if (_indicesList.Length > 0)
                {
                    switch (_primitiveType)
                    {
                    // Degenerate.
                    case GuPrimitiveType.TriangleStrip:
                    case GuPrimitiveType.Sprites:
                        if (vertexCount > 0)
                        {
                            PutVertexIndexRelative(-1);
                            PutVertexIndexRelative(0);
                        }
                        break;

                    // Can't degenerate, flush.
                    default:
                        EndVertex();
                        break;
                    }
                }

                if (_primitiveType == GuPrimitiveType.Sprites)
                {
                    GL.glDisable(GL.GL_CULL_FACE);
                    for (var n = 0; n < vertexCount; n += 2)
                    {
                        VertexInfo v0, v1, v2, v3;

                        readVertex(n + 0, out v0);
                        readVertex(n + 1, out v3);

                        VertexUtils.GenerateTriangleStripFromSpriteVertices(ref v0, out v1, out v2, ref v3);

                        if (n > 0)
                        {
                            PutVertexIndexRelative(-1);
                            PutVertexIndexRelative(0);
                        }

                        PutVertices(v0, v1, v2, v3);
                    }
                }
                else
                {
                    VertexInfo VertexInfo;
                    //Console.Error.WriteLine("{0} : {1} : {2}", BeginMode, VertexCount, VertexType.Index);
                    for (var n = 0; n < vertexCount; n++)
                    {
                        readVertex(n, out VertexInfo);
                        PutVertex(VertexInfo);
                    }
                }
            });
        }