Beispiel #1
0
        public override void PrimStart(GlobalGpuState globalGpuState, GpuStateStruct *gpuState,
                                       GuPrimitiveType primitiveType)
        {
            GpuState       = gpuState;
            _primitiveType = primitiveType;
            _doPrimStart   = true;
            ResetVertex();


            if (_shader != null)
            {
                _shader.GetUniform("lopEnabled").Set(gpuState->LogicalOperationState.Enabled);

                if (gpuState->LogicalOperationState.Enabled)
                {
                    if (_logicOpsRenderTarget == null)
                    {
                        _logicOpsRenderTarget = GLRenderTarget.Create(512, 272, RenderTargetLayers.Color);
                    }
                    GLRenderTarget.CopyFromTo(GLRenderTarget.Current, _logicOpsRenderTarget);
                    _shader.GetUniform("backtex").Set(GLTextureUnit.CreateAtIndex(1).SetFiltering(GLScaleFilter.Linear)
                                                      .SetWrap(GLWrap.ClampToEdge).SetTexture(_logicOpsRenderTarget.TextureColor));

                    _shader.GetUniform("lop").Set((int)gpuState->LogicalOperationState.Operation);

                    //new Bitmap(512, 272).SetChannelsDataInterleaved(LogicOpsRenderTarget.ReadPixels(), BitmapChannelList.RGBA).Save(@"c:\temp\test.png");
                }
            }
        }
Beispiel #2
0
        private GLGeometry ConvertGLGeometry(GuPrimitiveType primitiveType)
        {
            switch (primitiveType)
            {
            case GuPrimitiveType.Lines: return(GLGeometry.GL_LINES);

            case GuPrimitiveType.LineStrip: return(GLGeometry.GL_LINE_STRIP);

            case GuPrimitiveType.Triangles: return(GLGeometry.GL_TRIANGLES);

            case GuPrimitiveType.Points: return(GLGeometry.GL_POINTS);

            case GuPrimitiveType.TriangleFan: return(GLGeometry.GL_TRIANGLE_FAN);

            case GuPrimitiveType.TriangleStrip: return(GLGeometry.GL_TRIANGLE_STRIP);

            case GuPrimitiveType.Sprites: return(GLGeometry.GL_TRIANGLE_STRIP);

            default: throw (new NotImplementedException("Not implemented PrimitiveType:'" + primitiveType + "'"));
            }
        }
Beispiel #3
0
 private void _CapturePrimitive(GuPrimitiveType primitiveType, uint vertexAddress, int vetexCount,
                                ref VertexTypeStruct vertexType, Action action)
 {
     if (_pspWavefrontObjWriter != null)
     {
         lock (PspWavefrontObjWriterLock)
             _pspWavefrontObjWriter.StartPrimitive(GpuState, primitiveType, vertexAddress, vetexCount,
                                                   ref vertexType);
         try
         {
             action();
         }
         finally
         {
             lock (PspWavefrontObjWriterLock) _pspWavefrontObjWriter.EndPrimitive();
         }
     }
     else
     {
         action();
     }
 }
Beispiel #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="GpuState"></param>
        private unsafe void _Prim(GpuStateStruct* GpuState, GuPrimitiveType PrimitiveType, ushort VertexCount)
        {
            //if (PrimitiveType == GuPrimitiveType.TriangleStrip) VertexCount++;

            //Console.WriteLine("Prim: {0}, {1}", PrimitiveType, VertexCount);
            this.GpuState = GpuState;

            //Console.WriteLine("--------------------------------------------------------");
            VertexType = GpuState->VertexState.Type;

            ReadVertexDelegate ReadVertex = ReadVertex_Void;
            VertexReader.SetVertexTypeStruct(
                VertexType,
                (byte*)Memory.PspAddressToPointerSafe(GpuState->GetAddressRelativeToBaseOffset(GpuState->VertexAddress), 0)
            );

            #if DEBUG_VERTEX_TYPE
            try
            {
                if (!File.Exists("VertexType_" + VertexType.Value))
                {
                    File.WriteAllBytes(
                        "VertexType_" + VertexType.Value,
                        PointerUtils.PointerToByteArray((byte*)Memory.PspAddressToPointerSafe(GpuState->VertexAddress), 16 * 1024)
                    );
                    File.WriteAllText(
                        "VertexType_" + VertexType.Value + "_str",
                        VertexCount + "," + PrimitiveType + "\n" +
                        VertexType.ToString()
                    );
                    OutputVertexInfoStream = File.OpenWrite("VertexType_" + VertexType.Value + "_list");
                }
            }
            catch
            {
            }
            #endif
            //IndexReader.SetVertexTypeStruct(VertexType, VertexCount, (byte*)Memory.PspAddressToPointerSafe(GpuState->IndexAddress));

            uint TotalVerticesWithoutMorphing = VertexCount;

            //Console.Error.WriteLine("GpuState->IndexAddress: {0:X}", GpuState->IndexAddress);

            // Invalid
            /*
            if (GpuState->IndexAddress == 0xFFFFFFFF)
            {
                //Debug.Fail("Invalid IndexAddress");
                throw (new Exception("Invalid IndexAddress == 0xFFFFFFFF"));
            }
            */

            void* IndexPointer = null;
            if (VertexType.Index != VertexTypeStruct.IndexEnum.Void)
            {
                IndexPointer = Memory.PspAddressToPointerSafe(GpuState->GetAddressRelativeToBaseOffset(GpuState->IndexAddress), 0);
            }

            //Console.Error.WriteLine(VertexType.Index);
            switch (VertexType.Index)
            {
                case VertexTypeStruct.IndexEnum.Void:
                    break;
                case VertexTypeStruct.IndexEnum.Byte:
                    ReadVertex = ReadVertex_Byte;
                    IndexListByte = (byte *)IndexPointer;
                    TotalVerticesWithoutMorphing = 0;
                    for (int n = 0; n < VertexCount; n++)
                    {
                        if (TotalVerticesWithoutMorphing < IndexListByte[n]) TotalVerticesWithoutMorphing = IndexListByte[n];
                    }
                    break;
                case VertexTypeStruct.IndexEnum.Short:
                    ReadVertex = ReadVertex_Short;
                    IndexListShort = (ushort*)IndexPointer;
                    TotalVerticesWithoutMorphing = 0;
                    //VertexCount--;
                    for (int n = 0; n < VertexCount; n++)
                    {
                        //Console.Error.WriteLine(IndexListShort[n]);
                        if (TotalVerticesWithoutMorphing < IndexListShort[n]) TotalVerticesWithoutMorphing = IndexListShort[n];
                    }
                    break;
                default:
                    throw (new NotImplementedException());
            }
            TotalVerticesWithoutMorphing++;

            //Console.WriteLine(TotalVerticesWithoutMorphing);

            int MorpingVertexCount = (int)VertexType.MorphingVertexCount + 1;
            int z = 0;
            VertexInfo TempVertexInfo;

            float* Morphs = &GpuState->MorphingState.MorphWeight0;

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

            //int VertexInfoFloatCount = (sizeof(Color4F) + sizeof(Vector3F) * 3) / sizeof(float);
            int VertexInfoFloatCount = (sizeof(VertexInfo)) / sizeof(float);
            fixed (VertexInfo* VerticesPtr = Vertices)
            {
            #if true
                if (MorpingVertexCount == 1)
                {
                    VertexReader.ReadVertices(0, VerticesPtr, (int)TotalVerticesWithoutMorphing);
                }
                else
                {
                    var ComponentsIn = (float*)&TempVertexInfo;
                    for (int n = 0; n < TotalVerticesWithoutMorphing; n++)
                    {
                        var ComponentsOut = (float*)&VerticesPtr[n];
                        for (int cc = 0; cc < VertexInfoFloatCount; cc++) ComponentsOut[cc] = 0;
                        for (int m = 0; m < MorpingVertexCount; m++)
                        {
                            VertexReader.ReadVertex(z++, &TempVertexInfo);
                            for (int cc = 0; cc < VertexInfoFloatCount; cc++) ComponentsOut[cc] += ComponentsIn[cc] * Morphs[m];
                        }
                        VerticesPtr[n].Normal = VerticesPtr[n].Normal.Normalize();
                    }
                }
            #else
                var ComponentsIn = (float*)&TempVertexInfo;
                for (int n = 0; n < TotalVerticesWithoutMorphing; n++)
                {
                    if (MorpingVertexCount == 1)
                    {
                        VertexReader.ReadVertex(z++, &TempVertexInfo);
                        VerticesPtr[n] = TempVertexInfo;
                        //VertexReader.ReadVertices(0, VerticesPtr, TotalVerticesWithoutMorphing);
                    }
                    else
                    {
                        var ComponentsOut = (float*)&VerticesPtr[n];
                        for (int cc = 0; cc < VertexInfoFloatCount; cc++) ComponentsOut[cc] = 0;
                        for (int m = 0; m < MorpingVertexCount; m++)
                        {
                            VertexReader.ReadVertex(z++, &TempVertexInfo);
                            for (int cc = 0; cc < VertexInfoFloatCount; cc++) ComponentsOut[cc] += ComponentsIn[cc] * Morphs[m];
                        }
                    }
                }
            #endif
            }

            //VertexType.Texture == VertexTypeStruct.TextureEnum.Byte
            //return;
            //PrepareRead(GpuState);

            PrepareStateCommon(GpuState);

            if (GpuState->ClearingMode)
            {
                PrepareStateClear(GpuState);
            }
            else
            {
                PrepareStateDraw(GpuState);
            }

            PrepareStateMatrix(GpuState);

            //GL.Enable(EnableCap.Blend);

            /*
            if (CurrentTexture != null)
            {
                if (CurrentTexture.TextureHash == 0x2202293873)
                {
                    Console.Error.WriteLine(CurrentTexture);
                    Console.Error.WriteLine(VertexCount);
                }
            }
            */

            _CaptureStartPrimitive(PrimitiveType, GpuState->GetAddressRelativeToBaseOffset(GpuState->VertexAddress), VertexCount, ref VertexType);

            // DRAW ACTUALLY
            {
                //uint VertexSize = GpuState->VertexState.Type.GetVertexSize();

                //byte* VertexPtr = (byte*)Memory.PspAddressToPointerSafe(GpuState->VertexAddress);

                //Console.WriteLine(VertexSize);

                var BeginMode = default(BeginMode);

                switch (PrimitiveType)
                {
                    case GuPrimitiveType.Lines: BeginMode = BeginMode.Lines; break;
                    case GuPrimitiveType.LineStrip: BeginMode = BeginMode.LineStrip; break;
                    case GuPrimitiveType.Triangles: BeginMode = BeginMode.Triangles; break;
                    case GuPrimitiveType.Points: BeginMode = BeginMode.Points; break;
                    case GuPrimitiveType.TriangleFan: BeginMode = BeginMode.TriangleFan; break;
                    case GuPrimitiveType.TriangleStrip: BeginMode = BeginMode.TriangleStrip; break;
                    case GuPrimitiveType.Sprites: BeginMode = BeginMode.Quads; break;
                    default: throw (new NotImplementedException("Not implemented PrimitiveType:'" + PrimitiveType + "'"));
                }

                if (PrimitiveType == GuPrimitiveType.Sprites)
                {
                    GL.Disable(EnableCap.CullFace);
                }

                //Console.WriteLine(BeginMode);

                //lock (GpuLock)
                {
                    //Console.Error.WriteLine("GL.Begin : Thread : {0}", Thread.CurrentThread.ManagedThreadId);
                    GL.Begin(BeginMode);
                    {
                        if (PrimitiveType == GuPrimitiveType.Sprites)
                        {
                            GL.Disable(EnableCap.CullFace);
                            for (int n = 0; n < VertexCount; n += 2)
                            {
                                VertexInfo V1, V2, V3, V4;

                                ReadVertex(n + 0, &V1);
                                ReadVertex(n + 1, &V3);
                                {
                                    //if (GpuState->ClearingMode) Console.WriteLine("{0} - {1}", VertexInfoTopLeft, VertexInfoBottomRight);

                                    var Color = V3.Color;
                                    var TZ = V1.Texture.Z;
                                    var PZ = V1.Position.Z;
                                    var NZ = V1.Normal.Z;

                                    V2 = new VertexInfo()
                                    {
                                        Texture = new Vector3F(V3.Texture.X, V1.Texture.Y, TZ),
                                        Position = new Vector3F(V3.Position.X, V1.Position.Y, PZ),
                                        Normal = new Vector3F(V3.Normal.X, V1.Normal.Y, NZ),
                                    };

                                    V4 = new VertexInfo()
                                    {
                                        Texture = new Vector3F(V1.Texture.X, V3.Texture.Y, TZ),
                                        Position = new Vector3(V1.Position.X, V3.Position.Y, PZ),
                                        Normal = new Vector3F(V1.Normal.X, V3.Normal.Y, NZ),
                                    };

                                    V4.Color = V3.Color = V2.Color = V1.Color = Color;
                                    V4.Position.Z = V3.Position.Z = V2.Position.Z = V1.Position.Z = PZ;
                                    V4.Normal.Z = V3.Normal.Z = V2.Normal.Z = V1.Normal.Z = NZ;
                                    V4.Texture.Z = V3.Texture.Z = V2.Texture.Z = V1.Texture.Z = NZ;
                                }
                                PutVertex(ref V1, ref VertexType);
                                PutVertex(ref V2, ref VertexType);
                                PutVertex(ref V3, ref VertexType);
                                PutVertex(ref V4, ref VertexType);
                            }
                        }
                        else
                        {
                            VertexInfo VertexInfo;
                            //Console.Error.WriteLine("{0} : {1} : {2}", BeginMode, VertexCount, VertexType.Index);
                            for (int n = 0; n < VertexCount; n++)
                            {
                                ReadVertex(n, &VertexInfo);
                                PutVertex(ref VertexInfo, ref VertexType);
                            }
                        }
                    }
                    GL.End();
                }
            }

            _CaptureEndPrimitive();

            //Console.WriteLine(VertexCount);

            //PrepareWrite(GpuState);

            #if DEBUG_VERTEX_TYPE
            if (OutputVertexInfoStream != null)
            {
                OutputVertexInfoStream.Close();
                OutputVertexInfoStream = null;
            }
            #endif
        }
Beispiel #5
0
 private void _CaptureStartPrimitive(GuPrimitiveType PrimitiveType, uint VertexAddress, int VetexCount, ref VertexTypeStruct VertexType)
 {
     if (PspWavefrontObjWriter != null)
     {
         lock (PspWavefrontObjWriterLock)
         {
             if (PspWavefrontObjWriter != null) PspWavefrontObjWriter.StartPrimitive(GpuState, PrimitiveType, VertexAddress, VetexCount, ref VertexType);
         }
     }
 }
Beispiel #6
0
 public unsafe override void Prim(GpuStateStruct* GpuState, GuPrimitiveType PrimitiveType, ushort VertexCount)
 {
     //Console.WriteLine("VertexCount: {0}", VertexCount);
     var Start = DateTime.UtcNow;
     {
         _Prim(GpuState, PrimitiveType, VertexCount);
     }
     var End = DateTime.UtcNow;
     //Console.Error.WriteLine("Prim: {0}", End - Start);
 }
Beispiel #7
0
 public override void Prim(GlobalGpuState GlobalGpuState, GpuStateStruct* GpuState, GuPrimitiveType PrimitiveType, ushort VertexCount)
 {
 }
Beispiel #8
0
 public abstract void Prim(GlobalGpuState GlobalGpuState, GpuStateStruct* GpuState, GuPrimitiveType PrimitiveType, ushort VertexCount);
Beispiel #9
0
		public override void Prim(GlobalGpuState GlobalGpuState, GpuStateStruct* GpuState, GuPrimitiveType PrimitiveType, ushort VertexCount)
		{
			VertexType = GpuState->VertexState.Type;
			var TextureState = &GpuState->TextureMappingState.TextureState;

			VertexReader.SetVertexTypeStruct(
				VertexType,
				(byte*)Memory.PspAddressToPointerSafe(GlobalGpuState.GetAddressRelativeToBaseOffset(GpuState->VertexAddress), 0)
			);

			// Set Matrices
			this.ShaderProgram.Use();

			PrepareStateCommon(GpuState);

			if (GpuState->ClearingMode)
			{
				PrepareStateClear(GpuState);
			}
			else
			{
				PrepareStateDraw(GpuState);
			}

			PrepareStateMatrix(GpuState);

			fixed (VertexInfo* VertexInfoBufferPtr = VertexInfoBuffer)
			{
				switch (PrimitiveType)
				{
					case GuPrimitiveType.Sprites:
						int m = 0;
						for (int n = 0; n < VertexCount; n += 2)
						{
							VertexInfo TopLeft, _TopRight, BottomRight, _BottomLeft;

							VertexReader.ReadVertex(n + 0, &TopLeft);
							VertexReader.ReadVertex(n + 1, &BottomRight);
							TopLeft.Color.W = 1.0f;
							BottomRight.Color.W = 1.0f;

							//Console.WriteLine("--------------");
							//Console.WriteLine("({0},{1}) ({2},{3})", TopLeft.Position.X, TopLeft.Position.Y, TopLeft.Texture.X, TopLeft.Texture.Y);
							//Console.WriteLine("({0},{1}) ({2},{3})", BottomRight.Position.X, BottomRight.Position.Y, BottomRight.Texture.X, BottomRight.Texture.Y);

							{
								//if (GpuState->ClearingMode) Console.WriteLine("{0} - {1}", VertexInfoTopLeft, VertexInfoBottomRight);

								var Color = BottomRight.Color;
								var TZ = TopLeft.Texture.Z;
								var PZ = TopLeft.Position.Z;
								var NZ = TopLeft.Normal.Z;

								_TopRight = new VertexInfo()
								{
									Texture = new Vector4f(BottomRight.Texture.X, TopLeft.Texture.Y, TZ, 0),
									Position = new Vector4f(BottomRight.Position.X, TopLeft.Position.Y, PZ, 0),
									Normal = new Vector4f(BottomRight.Normal.X, TopLeft.Normal.Y, NZ, 0),
								};

								_BottomLeft = new VertexInfo()
								{
									Texture = new Vector4f(TopLeft.Texture.X, BottomRight.Texture.Y, TZ, 0),
									Position = new Vector4f(TopLeft.Position.X, BottomRight.Position.Y, PZ, 0),
									Normal = new Vector4f(TopLeft.Normal.X, BottomRight.Normal.Y, NZ, 0),
								};

								_BottomLeft.Color = BottomRight.Color = _TopRight.Color = TopLeft.Color = Color;
								_BottomLeft.Position.Z = BottomRight.Position.Z = _TopRight.Position.Z = TopLeft.Position.Z = PZ;
								_BottomLeft.Normal.Z = BottomRight.Normal.Z = _TopRight.Normal.Z = TopLeft.Normal.Z = NZ;
								_BottomLeft.Texture.Z = BottomRight.Texture.Z = _TopRight.Texture.Z = TopLeft.Texture.Z = NZ;
							}

							//VertexInfoBufferPtr[m++] = _TopRight;
							//VertexInfoBufferPtr[m++] = BottomRight;
							//VertexInfoBufferPtr[m++] = TopLeft;
							//VertexInfoBufferPtr[m++] = _BottomLeft;

							VertexInfoBufferPtr[m++] = _TopRight;
							VertexInfoBufferPtr[m++] = TopLeft;
							VertexInfoBufferPtr[m++] = BottomRight;
							VertexInfoBufferPtr[m++] = _BottomLeft;

							//Console.WriteLine("-----");
							//Console.WriteLine("({0},{1}) ({2},{3})", _TopRight.Position.X, _TopRight.Position.Y, _TopRight.Texture.X, _TopRight.Texture.Y);
							//Console.WriteLine("({0},{1}) ({2},{3})", TopLeft.Position.X, TopLeft.Position.Y, TopLeft.Texture.X, TopLeft.Texture.Y);
							//Console.WriteLine("({0},{1}) ({2},{3})", BottomRight.Position.X, BottomRight.Position.Y, BottomRight.Texture.X, BottomRight.Texture.Y);
							//Console.WriteLine("({0},{1}) ({2},{3})", _BottomLeft.Position.X, _BottomLeft.Position.Y, _BottomLeft.Texture.X, _BottomLeft.Texture.Y);

							//VertexInfoBufferPtr[m++] = _BottomLeft;
							//VertexInfoBufferPtr[m++] = BottomRight;
							//VertexInfoBufferPtr[m++] = _TopRight;
							//VertexInfoBufferPtr[m++] = TopLeft;

							//VertexInfoBufferPtr[m++] = _BottomLeft;
							//VertexInfoBufferPtr[m++] = TopLeft;
							//VertexInfoBufferPtr[m++] = BottomRight;
							//VertexInfoBufferPtr[m++] = _TopRight;

							//VertexInfoBufferPtr[m++] = _BottomLeft;
							//VertexInfoBufferPtr[m++] = TopLeft;
							//VertexInfoBufferPtr[m++] = BottomRight;
							//VertexInfoBufferPtr[m++] = _TopRight;
						}
						VertexCount = (ushort)m;
						break;
					default:
						VertexReader.ReadVertices(0, VertexInfoBufferPtr, VertexCount);
						break;
				}

				//if (PrimitiveType == GuPrimitiveType.LineStrip)
				{
					aPositionLocation.Pointer(3, GL.GL_FLOAT, false, sizeof(VertexInfo), ((byte*)VertexInfoBufferPtr) + (int)Marshal.OffsetOf(typeof(VertexInfo), "Position"));
					aPositionLocation.Enable();

					if (VertexType.ColorSize != 0)
					{
						aColorLocation.Pointer(4, GL.GL_FLOAT, false, sizeof(VertexInfo), ((byte*)VertexInfoBufferPtr) + (int)Marshal.OffsetOf(typeof(VertexInfo), "Color"));
						aColorLocation.Enable();
						u_has_vertex_color.SetBool(true);
					}
					else
					{
						aColorLocation.Disable();
						u_has_vertex_color.SetBool(false);
					}

					u_transform_2d.SetBool(VertexType.Transform2D);

					if (GpuState->TextureMappingState.Enabled)
					{
						aTexCoord.Pointer(3, GL.GL_FLOAT, false, sizeof(VertexInfo), ((byte*)VertexInfoBufferPtr) + (int)Marshal.OffsetOf(typeof(VertexInfo), "Texture"));
						aTexCoord.Enable();
						u_has_texture.SetBool(true);
						u_texture.SetInt(0);
						u_texture_effect.SetInt((int)TextureState->Effect);
					}
					else
					{
						aTexCoord.Disable();
						u_has_texture.SetBool(false);
					}

					GL.glDrawArrays(PrimitiveTypeTranslate[(int)PrimitiveType], 0, VertexCount);
				}

				//TestingRender();
			}
		}
		private void PrepareStateDraw(GpuStateStruct* GpuState, GuPrimitiveType PrimitiveType)
		{
			var VertexType = GpuState->VertexState.Type;
			var TextureState = &GpuState->TextureMappingState.TextureState;

			if (PrimitiveType == GuPrimitiveType.Sprites)
			{
				GL.glDisable(GL.GL_CULL_FACE);
			}
			else
			{
				PrepareState_Blend(GpuState);
				GL.glDisable(GL.GL_CULL_FACE);
				//if (GL.glEnableDisable(GL.GL_CULL_FACE, GpuState->BackfaceCullingState.Enabled))
				//{
				//	GL.glCullFace((GpuState->BackfaceCullingState.FrontFaceDirection == FrontFaceDirectionEnum.ClockWise) ? GL.GL_CW : GL.GL_CCW);
				//}

				//GL.glEnableDisable(GL.GL_CULL_FACE, true);
				//GL.glCullFace(GL.GL_CCW);

				//this.fColor.SetVec4(1, 0, 0, 1);
				if (VertexType.Color == VertexTypeStruct.ColorEnum.Void)
				{
					this.fColor.SetVec4(&GpuState->LightingState.AmbientModelColor.Red);
					//this.fColor.SetVec4(VertexInfo.Color.X, VertexInfo.Color.Y, VertexInfo.Color.Z, VertexInfo.Color.W);
				}
			}

			if (GlEnableDisable(GL.GL_TEXTURE_2D, GpuState->TextureMappingState.Enabled))
			{
				GL.glActiveTexture(GL.GL_TEXTURE0);
				CurrentTexture = TextureCache.Get(GpuState);
				CurrentTexture.Bind();
				//CurrentTexture.Save("c:/temp/" + CurrentTexture.TextureHash + ".png");

				GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, (TextureState->FilterMinification == TextureFilter.Linear) ? GL.GL_LINEAR : GL.GL_NEAREST);
				GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, (TextureState->FilterMagnification == TextureFilter.Linear) ? GL.GL_LINEAR : GL.GL_NEAREST);

				GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, (TextureState->WrapU == WrapMode.Repeat) ? GL.GL_REPEAT : GL.GL_CLAMP_TO_EDGE);
				GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, (TextureState->WrapV == WrapMode.Repeat) ? GL.GL_REPEAT : GL.GL_CLAMP_TO_EDGE);

				//Console.WriteLine("{0}", TextureState->Effect);
				//GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvModeTranslate[(int)TextureState->Effect]);
			}
		}
Beispiel #11
0
        public unsafe override void Prim(GlobalGpuState GlobalGpuState, GpuStateStruct* GpuState, GuPrimitiveType PrimitiveType, ushort VertexCount)
        {
            #if SLOW_SIMPLE_RENDER_TARGET
            PrepareRead(GpuState);
            #endif

            //Console.WriteLine("VertexCount: {0}", VertexCount);
            var Start = DateTime.UtcNow;
            {
                _Prim(GlobalGpuState, GpuState, PrimitiveType, VertexCount);
            }
            var End = DateTime.UtcNow;

            #if SLOW_SIMPLE_RENDER_TARGET
            PrepareWrite(GpuState);
            #endif

            //Console.Error.WriteLine("Prim: {0}", End - Start);

            if (!GpuState->ClearingMode)
            {
                //Console.WriteLine("{0}", (*GpuState).ToStringDefault());
            }

            #if false
            if (GpuState->ClearingMode)
            {
                ResetState();
                GL.Begin(BeginMode.Quads);
                {
                    GL.Vertex2(0, 0);
                    GL.Vertex2(100, 0);
                    GL.Vertex2(100, 100);
                    GL.Vertex2(0, 100);
                }
                GL.End();
                SaveFrameBuffer(GpuState, "frameBuffer.png");
            }
            #endif
        }
Beispiel #12
0
 public virtual void PrimStart(GlobalGpuState GlobalGpuState, GpuStateStruct* GpuState, GuPrimitiveType PrimitiveType)
 {
 }