Exemple #1
0
        private void glControl1_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Insert:   AngleX += AngleDl; break;

            case Keys.Delete:   AngleX -= AngleDl; break;

            case Keys.Home:     AngleY += AngleDl; break;

            case Keys.End:      AngleY -= AngleDl; break;

            case Keys.Prior:    AngleZ += AngleDl; break;

            case Keys.Next:     AngleZ -= AngleDl; break;


            case Keys.F1: mode = PolygonMode.Fill; break;

            case Keys.F2: mode = PolygonMode.Line; break;

            case Keys.F3: mode = PolygonMode.Point; break;
            }

            glControl1.Invalidate();
        }
Exemple #2
0
 public VideoScene()
 {
     polyFillMode = PolygonMode.Fill;
     fHowManySplits = 2;     // How many sections separate the display screen
     fBlockSize = 8;
     fResolutionChanged = true;
 }
 public PipelineRasterizationStateCreateInfo
 (
     StructureType sType            = StructureType.PipelineRasterizationStateCreateInfo,
     void *pNext                    = default,
     uint flags                     = default,
     Bool32 depthClampEnable        = default,
     Bool32 rasterizerDiscardEnable = default,
     PolygonMode polygonMode        = default,
     CullModeFlags cullMode         = default,
     FrontFace frontFace            = default,
     Bool32 depthBiasEnable         = default,
     float depthBiasConstantFactor  = default,
     float depthBiasClamp           = default,
     float depthBiasSlopeFactor     = default,
     float lineWidth                = default
 )
 {
     SType                   = sType;
     PNext                   = pNext;
     Flags                   = flags;
     DepthClampEnable        = depthClampEnable;
     RasterizerDiscardEnable = rasterizerDiscardEnable;
     PolygonMode             = polygonMode;
     CullMode                = cullMode;
     FrontFace               = frontFace;
     DepthBiasEnable         = depthBiasEnable;
     DepthBiasConstantFactor = depthBiasConstantFactor;
     DepthBiasClamp          = depthBiasClamp;
     DepthBiasSlopeFactor    = depthBiasSlopeFactor;
     LineWidth               = lineWidth;
 }
Exemple #4
0
        public void DrawModel(Model m, mat4 model, Shader sh, PolygonMode mode = PolygonMode.Fill, float lineWidth = 1, bool blend = false)
        {
            sh.use();

            float time = (float)(DateTime.UtcNow - DateTime.Today).TotalSeconds * 3.0f;

            sh.setUniform("time", time);

            sh.setUniform("hlg_model", model);
            sh.setUniform("hlg_mvp", pv * model);
            if (m.HasAlbedo)
            {
                sh.setUniform("hlg_albedo", m.albedo.ptr);
            }

            if (depthEnabled)
            {
                EnableDepth();
            }
            else
            {
                DisableDepth();
            }
            m.Draw(mode, lineWidth, blend);
        }
Exemple #5
0
        /// <summary>
        /// Sets Rasterizer State information
        /// </summary>
        private void BindRasterizerState()
        {
            MaterialFace mf = MaterialFace.Back;
            PolygonMode  pm = PolygonMode.Fill;

            if (RasterizerState != null)
            {
                switch (RasterizerState.FillMode)
                {
                case 0:
                    pm = PolygonMode.Line;
                    break;

                case 1:
                    pm = PolygonMode.Fill;
                    break;
                }
                switch (RasterizerState.CullMode)
                {
                case 1:
                    mf = MaterialFace.Front;
                    break;

                case 2:
                    mf = MaterialFace.FrontAndBack;
                    break;
                }
            }

            GL.PolygonMode(mf, pm);
        }
Exemple #6
0
        void DrawSkeleton()
        {
            if (Device == null)
            {
                return;
            }
            Matrix      P  = Device.ProjectionMatrix;
            PolygonMode PM = Device.PolygonMode;

            Device.PolygonMode = PolygonMode.Line;
            float PW = Device.PenWidth;

            Device.PenWidth = PenWidth;
            Color C = Device.Emission;

            Device.Emission = Color;
            Device.PushMatrix();
            Device.ModelMatrix = Base.ToMatrix();
            bool LE = Device.LightEnabled;

            Device.LightEnabled = false;
            Device.drawRectangle(A, B);
            Device.LightEnabled = LE;
            Device.PopMatrix();
            Device.Emission    = C;
            Device.PenWidth    = PW;
            Device.PolygonMode = PM;

            Device.ProjectionMatrix = P;
        }
        public void Triangulate()
        {
            Simplify();
            var simplifiedPolygonCount = simplifiedPolygons.Count;

            if (simplifiedPolygonCount > 1)
            {
                for (var i = 0; i < simplifiedPolygonCount; i++)
                {
                    var simplifiedPolygon = simplifiedPolygons[i];
                    simplifiedPolygon.Triangulate();
                }
            }
            else
            {
                var triangles = Triangulator.Triangulate(vertices);

                var tr  = transform;
                var pos = tr.position;
                var rot = tr.rotation;

                for (var i = 0; i < triangles.Count; i++)
                {
                    var triangle   = triangles[i];
                    var newPolygon = NewPolygon(triangle, pos, rot, tr, "Triangle " + i);
                    newPolygon.drawVertex      = false;
                    newPolygon.drawVertexIndex = false;
                    newPolygon.Centralize();
                    this.triangles.Add(newPolygon);
                }
            }

            polygonMode = PolygonMode.Triangulated;
        }
Exemple #8
0
        /// <summary>
        /// copies the backcound to the foreground.
        /// </summary>
        public void CopyFromBackGround()
        {
            // Draw the Texture from Backbuffer by a Polygon Rectangle for the full screen

            xyArray    FP = new xyArray(); FP.data = new xy[] { new xy(0, 0), new xy(0, 1), new xy(1, 1), new xy(1, 0) };
            Matrix     P  = ProjectionMatrix;
            GLShader   S  = Shader;
            RenderKind K  = RenderKind;

            RenderKind = RenderKind.Render;
            Shader     = BackGroundShader;
            Texture T = texture;

            texture = BackBuffer.Texture;
            PushMatrix();
            ModelMatrix = Matrix.Translation(new xyz(0, 0, 1));
            PolygonMode PM = PolygonMode;

            PolygonMode      = PolygonMode.Fill;
            ProjectionMatrix = Bias;

            drawPolyLine(FP);
            ProjectionMatrix = P;
            PopMatrix();

            // Save Back
            RenderKind  = K;
            texture     = T;
            this.Shader = S;
            PolygonMode = PM;
        }
Exemple #9
0
      /// <summary>
      /// internal.
      /// </summary>
      /// <param name="Device"></param>
      /// <param name="A"></param>
      public static void drawArrayLined(OpenGlDevice Device, xyArray A)
      {
          if (Entity.Compiling)
          {
              PolygonMode P = Device.PolygonMode;
              MeshCreator.MeshdrawLined(Device, A);
              Device.PolygonMode = P;
              return;
          }
          if (Device.RenderKind == RenderKind.SnapBuffer)
          {
              MeshCreator.MeshdrawLined(Device, A);
              return;
          }


          int MPosition = Device.Shader.Position.handle;

          if (MPosition >= 0)
          {
              GL.EnableVertexAttribArray(MPosition);

              xyf[] Array = (A.ToFloatArray());
              GL.VertexAttribPointer(MPosition, 2, VertexAttribPointerType.Float, false, 0, ref Array[0].x);
              GL.DrawArrays(PrimitiveType.LineStrip, 0, Array.Length);
              GL.DisableVertexAttribArray(MPosition);
          }
      }
 protected AppearanceBase()
 {
     this.m_layer           = 0;
     this.m_lineMode        = (LineMode)null;
     this.m_polygonMode     = (PolygonMode)null;
     this.m_compositingMode = (CompositingMode)null;
 }
Exemple #11
0
        void ShowMarker()
        {
            if (A.dist(B) < 0.0001)
            {
                return;
            }

            Color Save = Device.Emission;

            Device.Emission = MarkerColor;
            double MW = MarkerWidth;

            if (Device.RenderKind == RenderKind.SnapBuffer)
            {
                MW *= 2;
                // To snap it easier
                PolygonMode PM = Device.PolygonMode;
                Device.PolygonMode = PolygonMode.Fill;
                Device.PushTag(Corner.Inside);
                Device.drawRectangle(A, B);
                Device.PopTag();
                Device.PolygonMode = PM;
            }
            Device.Emission = MarkerColor;
            Device.PushTag(Corner.C00);
            if ((Device.SnappItems.Count > 0) && (Device.SnappItems[0].Tag != null) && ((Corner)Device.SnappItems[0].Tag == Corner.C00))
            {
                Device.Emission = HighLightMarker;
            }
            Device.drawPoint(A.toXYZ(), 2 * MW, OpenGlDevice.PointKind.Cube);
            Device.Emission = MarkerColor;
            Device.PopTag();
            Device.PushTag(Corner.C01);
            if ((Device.SnappItems.Count > 0) && (Device.SnappItems[0].Tag != null) && ((Corner)Device.SnappItems[0].Tag == Corner.C01))
            {
                Device.Emission = HighLightMarker;
            }
            Device.drawPoint(new xyz(A.x, B.Y, 0), 2 * MW, OpenGlDevice.PointKind.Cube);
            Device.Emission = MarkerColor;
            Device.PopTag();
            Device.PushTag(Corner.C11);
            if ((Device.SnappItems.Count > 0) && (Device.SnappItems[0].Tag != null) && ((Corner)Device.SnappItems[0].Tag == Corner.C11))
            {
                Device.Emission = HighLightMarker;
            }
            Device.drawPoint(B.toXYZ(), 2 * MW, OpenGlDevice.PointKind.Cube);
            Device.Emission = MarkerColor;
            Device.PopTag();

            Device.PushTag(Corner.C10);
            if ((Device.SnappItems.Count > 0) && (Device.SnappItems[0].Tag != null) && ((Corner)Device.SnappItems[0].Tag == Corner.C10))
            {
                Device.Emission = HighLightMarker;
            }
            Device.drawPoint(new xyz(B.x, A.Y, 0), 2 * MW, OpenGlDevice.PointKind.Cube);
            Device.Emission = MarkerColor;
            Device.PopTag();
            Device.Emission = Save;
        }
Exemple #12
0
 public void setPolygonMode(PolygonMode sd)
 {
     OgrePINVOKE.Camera_setPolygonMode(swigCPtr, (int)sd);
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public StandardRenderStateData(IStandardRenderState renderState)
 {
     CullFace    = renderState.CullFace;
     PolygonMode = renderState.PolygonMode;
     ZOffset     = renderState.ZOffset;
     PointSize   = renderState.PointSize;
     LineWidth   = renderState.LineWidth;
 }
 /// <summary> Render setup for primitive Triangles from a previous RS and with primitive restart, with optional control over various parameters of the primitive </summary>
 static public GLRenderState Tri(GLRenderState prev, uint primitiverestart, FrontFaceDirection frontface = FrontFaceDirection.Ccw, bool cullface = true,
                                 PolygonMode polygonmode = PolygonMode.Fill, bool polysmooth = false)
 {
     return(new GLRenderState(prev)
     {
         PrimitiveRestart = primitiverestart, FrontFace = frontface, CullFace = cullface, PolygonModeFrontAndBack = polygonmode, PolygonSmooth = polysmooth
     });
 }
 /// <summary> Render setup for primitive Quads from a previous RS, with optional control over various parameters of the primitive </summary>
 static public GLRenderState Quads(GLRenderState prev, FrontFaceDirection frontface = FrontFaceDirection.Ccw, bool cullface = true,
                                   PolygonMode polygonmode = PolygonMode.Fill, bool polysmooth = false)
 {
     return(new GLRenderState(prev)
     {
         FrontFace = frontface, CullFace = cullface, PolygonModeFrontAndBack = polygonmode, PolygonSmooth = polysmooth
     });
 }
 /// <summary> Render setup for primitive Trianges from a previous RS with primitive restart, with optional control over various parameters of the primitive </summary>
 static public GLRenderState Tri(GLRenderState prev, DrawElementsType primitiverestarttype, FrontFaceDirection frontface = FrontFaceDirection.Ccw, bool cullface = true,
                                 PolygonMode polygonmode = PolygonMode.Fill, bool polysmooth = false)
 {
     return(new GLRenderState(prev)
     {
         PrimitiveRestart = GL4Statics.DrawElementsRestartValue(primitiverestarttype), FrontFace = frontface, CullFace = cullface, PolygonModeFrontAndBack = polygonmode, PolygonSmooth = polysmooth
     });
 }
Exemple #17
0
 static void SetPolygonMode(PolygonMode polygonMode)
 {
     if (s_polygonMode != polygonMode)
     {
         s_polygonMode = polygonMode;
         GL.PolygonMode(MaterialFace.FrontAndBack, polygonMode);
     }
 }
Exemple #18
0
        public static void StreamDraw(Mesh m, Shader sh, Texture tx, PolygonMode mode = PolygonMode.Fill)
        {
            Model mv = new Model(m, tx);

            sh.use();
            mv.Draw(mode);
            mv.Destroy();
        }
Exemple #19
0
 public Polygon() : base()
 {
     _points = new List <Point>();
     _bbox   = new BoundingBox3d();
     _center = new Coord3d();
     _polygonOffsetFillEnable = true;
     _polygonMode             = PolygonMode.FRONT_AND_BACK;
 }
Exemple #20
0
        internal static FillMode Convert(PolygonMode fillMode)
        {
            if (!fillModes.ContainsValue(fillMode))
            {
                throw new NotSupportedException("fillMode is not supported");
            }

            return(fillModes.First((f) => f.Value == fillMode).Key);
        }
Exemple #21
0
 public RasterizerState()
 {
     _cullMode            = CullMode.CullClockwiseFace;
     _fillMode            = PolygonMode.Fill;
     _depthBias           = 0;
     _slopeScaleDepthBias = 0;
     _scissorTestEnable   = false;
     _dirty = true;
 }
Exemple #22
0
        public PolygonMode getPolygonMode()
        {
            PolygonMode ret = (PolygonMode)OgrePINVOKE.Camera_getPolygonMode(swigCPtr);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemple #23
0
        /// <summary>
        /// Sets the values before any upcoming draw calls.
        /// </summary>
        /// <param name="program">The program.</param>
        public override void Set(ShaderProgram program)
        {
            if (!m_initialized || FaceMode != m_currentFaceMode)
            {
                m_currentFaceMode = FaceMode;
                m_initialized     = true;

                GL.PolygonMode(MaterialFace.FrontAndBack, m_currentFaceMode);
            }
        }
Exemple #24
0
        public static void ShowWireframe(this StateSet stateSet)
        {
            //StateSet stateSet = new StateSet();
            //src.setStateSet(stateSet);

            PolygonMode polymode = new PolygonMode();

            polymode.setMode(PolygonMode.Face.FRONT_AND_BACK, PolygonMode.Mode.LINE);
            stateSet.setAttributeAndModes(polymode, StateAttribute.Values.OVERRIDE | StateAttribute.Values.ON);
        }
        public void Render(PrimitiveType myRenderMode, PolygonMode myPolygonMode)
        {
            RefreshRenderableData();//essential if data has changed after initial call of ActivateShaders

            this.shader.Use();
            GL.UniformMatrix4(shader.GetUniformAddress("MVP"), false, ref this.mvp);
            switch (myRenderMode)
            {
            case PrimitiveType.Triangles:
            {
                GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
                GL.DrawElements(PrimitiveType.Triangles, this.PointCloud.Indices.Length, DrawElementsType.UnsignedInt, 0);

                break;
            }

            case PrimitiveType.TriangleFan:
            {
                GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
                GL.DrawElements(PrimitiveType.TriangleFan, this.PointCloud.Indices.Length, DrawElementsType.UnsignedInt, 0);

                break;
            }

            case PrimitiveType.TriangleStrip:
            {
                GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
                GL.DrawElements(PrimitiveType.TriangleStrip, this.PointCloud.Indices.Length, DrawElementsType.UnsignedInt, 0);
                //GL.DrawArrays(PrimitiveType.Triangles, 0, this.PointCloudGL.Indices.Length);
                break;
            }
            //case PrimitiveType.Polygon:
            //    {
            //        GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
            //        GL.DrawElements(PrimitiveType.Polygon, this.PointCloudOpenGL.Indices.Length, DrawElementsType.UnsignedInt, 0);
            //        break;
            //    }

            case PrimitiveType.Points:
            {
                GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Point);
                //    GL.PolygonMode(MaterialFace.FrontAndBack, myPolygonMode);
                GL.DrawArrays(myRenderMode, 0, this.PointCloud.Indices.Length);
                break;
            }

            default:
            {
                GL.PolygonMode(MaterialFace.FrontAndBack, myPolygonMode);
                GL.DrawElements(myRenderMode, this.PointCloud.Indices.Length, DrawElementsType.UnsignedInt, 0);
                break;
            }
            }
        }
        private RasterizerState(GraphicsDevice device, RasterizerStateDescription rasterizerStateDescription) : base(device)
        {
            Description = rasterizerStateDescription;

#if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
            polygonMode = Description.FillMode == FillMode.Solid ? PolygonMode.Fill : PolygonMode.Line;
#endif
            
            // TODO: DepthBiasClamp and various other properties are not fully supported yet
            if (Description.DepthBiasClamp != 0.0f) throw new NotSupportedException();
        }
 private void SetPolygonMode(PolygonMode mode)
 {
     if (Mode == PolygonMode.Invalid)
     {
         Mode = mode;
     }
     else if (Mode != mode)
     {
         throw new InvalidGeometricObjectConstructionException();
     }
 }
        protected override void duplicateTo(ref Object3D ret)
        {
            base.duplicateTo(ref ret);
            PolygonMode polygonMode = (PolygonMode)ret;

            polygonMode.setCulling(this.getCulling());
            polygonMode.setWinding(this.getWinding());
            polygonMode.setShading(this.getShading());
            polygonMode.setTwoSidedLightingEnable(this.isTwoSidedLightingEnabled());
            polygonMode.setLocalCameraLightingEnable(this.isLocalCameraLightingEnabled());
            polygonMode.setPerspectiveCorrectionEnable(this.isPerspectiveCorrectionEnabled());
        }
        private RasterizerState(GraphicsDevice device, RasterizerStateDescription rasterizerStateDescription) : base(device)
        {
            Description = rasterizerStateDescription;

#if !SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
            polygonMode = Description.FillMode == FillMode.Solid ? PolygonMode.Fill : PolygonMode.Line;
#endif

            // TODO: DepthBiasClamp and various other properties are not fully supported yet
            if (Description.DepthBiasClamp != 0.0f)
            {
                throw new NotSupportedException();
            }
        }
Exemple #30
0
 public void Draw(PolygonMode mode)
 {
     if (VerticesCount <= 0)
     {
         return;
     }
     if (_vao == null)
     {
         throw new InvalidOperationException("Vao must be created before drawing");
     }
     _vao.Bind();
     GL.PolygonMode(MaterialFace.FrontAndBack, mode);
     GL.DrawArrays(PrimitiveType.Triangles, 0, VerticesCount);
 }
Exemple #31
0
        public void UpdateMesh()
        {
            if (_isDisposed)
            {
                throw new ObjectDisposedException("OpenGLMeshRenderer");
            }
            if (_mesh == null)
            {
                throw new NullReferenceException("Mesh");
            }
            if (_mesh.Vertices == null)
            {
                throw new NullReferenceException("Mesh.Vertices");
            }

            if (_vao != null)
            {
                _shouldUpdateMesh = true;
            }

            _boundSphere = _mesh.Bounds.Sphere;

            _primitiveType = _mesh.Type;
            _frontFace     = _mesh.FrontFace;
            _polygonMode   = _mesh.DrawStyle;

            if (_mesh.Indices == null)
            {
                _verticesCount = (uint)_mesh.Vertices.Length;
                _isIndexed     = false;
            }
            else
            {
                _verticesCount = (uint)_mesh.Indices.Length;
                _isIndexed     = true;
                switch (_mesh.Indices.DataType)
                {
                case VertexAttribPointerType.UnsignedShort:
                    _indexType = DrawElementsType.UnsignedShort;
                    break;

                case VertexAttribPointerType.UnsignedInt:
                    _indexType = DrawElementsType.UnsignedInt;
                    break;

                default:
                    throw new NotSupportedException("Unknown index type: " + _mesh.Indices.DataType);
                }
            }
        }
Exemple #32
0
        public FlagScene()
        {
            fFlagResolution = new Resolution(40, 40);
            fBanner = new FlagSystem(fFlagResolution, timeStep);

            fBanner.size = size;
            fBanner.uTile = 1;
            fBanner.vTile = 1;
            fBanner.WindStrength = windStrength;

            fBanner.ini(timeStep);

            polyFillMode = PolygonMode.Fill;
            bUseTexture = true;
        }
Exemple #33
0
 internal static double ToWebGL(this PolygonMode polygonMode)
 {
     switch (polygonMode)
     {
     //case PolygonMode.Fill:
     //	return GL.FILL;
     //case PolygonMode.Line:
     //	return GL.LINE;
     //case PolygonMode.Point:
     //	return GL.POINT;
     //default:
     //	throw new IllegalValueException(typeof(PolygonMode), polygonMode);
     default:
         throw new CKGLException("glPolygonMode is not available in WebGL.");
     }
 }
Exemple #34
0
		public static D3D9.FillMode ConvertEnum( PolygonMode mode )
		{
			switch ( mode )
			{
				case PolygonMode.Points:
					return D3D9.FillMode.Point;

				case PolygonMode.Wireframe:
					return D3D9.FillMode.Wireframe;

				case PolygonMode.Solid:
					return D3D9.FillMode.Solid;
			}
			;

			return (D3D9.FillMode)0x7fffffff; //D3DFILL_FORCE_DWORD
		}
Exemple #35
0
        public override IntPtr OnKeyboardActivity(object sender, KeyboardActivityArgs kbde)
        {
            if (kbde.AcitivityType == KeyActivityType.KeyDown)
            {
                switch (kbde.VirtualKeyCode)
                {
                    case VirtualKeyCodes.Left:
                    case VirtualKeyCodes.A:
                        angRotY += 1.0f;
                        break;

                    case VirtualKeyCodes.Right:
                    case VirtualKeyCodes.S:
                        angRotY -= 1.0f;
                        break;

                    case VirtualKeyCodes.Up:
                        windStrength += 0.1;
                        break;

                    case VirtualKeyCodes.Down:
                        windStrength -= 0.1;
                        break;
                }
            }

            if (kbde.AcitivityType == KeyActivityType.KeyUp)
            {
                switch (kbde.VirtualKeyCode)
                {
                    case VirtualKeyCodes.F1:
                        flagTexture = fPictureTexture;
                        break;

                    case VirtualKeyCodes.F2:
                        flagTexture = fCamera1;
                        break;

                    case VirtualKeyCodes.F3:
                        flagTexture = fCamera2;
                        break;

                    case VirtualKeyCodes.F:
                        polyFillMode = PolygonMode.Fill;
                        break;
                    case VirtualKeyCodes.L:
                        polyFillMode = PolygonMode.Line;
                        break;
                    case VirtualKeyCodes.W:
                        fBanner.ApplyWind = !fBanner.ApplyWind;
                        break;
                    case VirtualKeyCodes.T:
                        bUseTexture = !bUseTexture;
                        break;
                }
            }

            return IntPtr.Zero;
        }
		public static extern void SetPolygonMode(
			Handle self, 
			PolygonMode value);
Exemple #37
0
		internal static extern void glPolygonMode(MaterialFace face, PolygonMode mode);
Exemple #38
0
 public void SetPolygonMode(PolygonMode polygonMode)
 {
     this.polygonMode = polygonMode;
 }
Exemple #39
0
 public OwnedMesh(object xiOwner, PolygonMode xiMode)
     : base(xiMode)
 {
     this.mOwner = xiOwner;
 }
Exemple #40
0
 /// <summary>
 /// Sets polugon mode for a face
 /// </summary>
 /// <param name="face"></param>
 /// <param name="mode"></param>
 public void SetPolygonMode(CullFace face, PolygonMode mode)
 {
     GL.glPolygonMode((uint)face, (uint)mode);
 }
Exemple #41
0
        private void glControl1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.J)
                x += STEP;
            else if (e.KeyCode == Keys.L)
                x -= STEP;
            else if (e.KeyCode == Keys.K)
                y += STEP;
            else if (e.KeyCode == Keys.I)
                y -= STEP;
            else if (e.KeyCode == Keys.U)
                z += STEP;
            else if (e.KeyCode == Keys.O)
                z -= STEP;
            else if (e.KeyCode == Keys.W)
            {
                if (pm == PolygonMode.Fill)
                    pm = PolygonMode.Line;
                else if (pm == PolygonMode.Line)
                    pm = PolygonMode.Fill;
            }

            glControl1.Invalidate();
        }
Exemple #42
0
 public static void PolygonMode(GLFace face, PolygonMode mode)
 {
     gl.glPolygonMode((int)face, (int)mode);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="mode"></param>
 public PolygonModeState(PolygonMode mode)
 {
     this.Mode = mode;
 }
Exemple #44
0
    public override void OnKeyboardActivity(object sender, KeyboardActivityArgs kbde)
    {
        if (kbde.EventType == KeyEventType.KeyDown)
        {
            switch (kbde.VirtualKeyCode)
            {
                case VirtualKeyCodes.Left:
                case VirtualKeyCodes.A:
                    angRotY += 1.0f;
                    break;

                case VirtualKeyCodes.Right:
                case VirtualKeyCodes.S:
                    angRotY -= 1.0f;
                    break;
            }
        }

        if (kbde.EventType == KeyEventType.KeyUp)
        {
            switch (kbde.VirtualKeyCode)
            {
                //case VirtualKeyCodes.Space:
                //    if (flagTexture == fVideoTexture)
                //        flagTexture = fPictureTexture;
                //    else
                //        flagTexture = fVideoTexture;
                //    break;

                case VirtualKeyCodes.F:
                    polyFillMode = PolygonMode.Fill;
                    break;
                case VirtualKeyCodes.L:
                    polyFillMode = PolygonMode.Line;
                    break;
                case VirtualKeyCodes.W:
                    bandera.bWind = !bandera.bWind;
                    break;
                case VirtualKeyCodes.T:
                    bUseTexture = !bUseTexture;
                    break;
            }
        }
    }
Exemple #45
0
 void btn_wireframe_CheckedChanged(object sender, EventArgs e)
 {
     polygonMode = (btn_wireframe.Checked ? PolygonMode.Line : PolygonMode.Fill);
     gl_frame.Invalidate();
 }
 public static extern void glPolygonMode(PolygonFace face, PolygonMode mode);
Exemple #47
0
 public Mesh(PolygonMode xiMode)
 {
     mPolygonMode = xiMode;
 }
 public static void PolygonMode(PolygonFace face, PolygonMode mode)
 {
     Delegates.glPolygonMode(face, mode);
 }
Exemple #49
0
		/* END STRING MARKER FUNCTIONS */
#endif

		private void LoadGLEntryPoints()
		{
			string baseErrorString;
			if (useES2)
			{
				baseErrorString = "OpenGL ES 2.0";
			}
			else
			{
				baseErrorString = "OpenGL 2.1";
			}
			baseErrorString += " support is required!";

			/* Basic entry points. If you don't have these, you're screwed. */
			try
			{
				INTERNAL_glGetString = (GetString) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glGetString"),
					typeof(GetString)
				);
				glGetIntegerv = (GetIntegerv) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glGetIntegerv"),
					typeof(GetIntegerv)
				);
				glEnable = (Enable) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glEnable"),
					typeof(Enable)
				);
				glDisable = (Disable) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glDisable"),
					typeof(Disable)
				);
				glViewport = (G_Viewport) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glViewport"),
					typeof(G_Viewport)
				);
				glScissor = (Scissor) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glScissor"),
					typeof(Scissor)
				);
				glBlendColor = (BlendColor) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glBlendColor"),
					typeof(BlendColor)
				);
				glBlendFuncSeparate = (BlendFuncSeparate) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glBlendFuncSeparate"),
					typeof(BlendFuncSeparate)
				);
				glBlendEquationSeparate = (BlendEquationSeparate) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glBlendEquationSeparate"),
					typeof(BlendEquationSeparate)
				);
				glColorMask = (ColorMask) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glColorMask"),
					typeof(ColorMask)
				);
				glDepthMask = (DepthMask) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glDepthMask"),
					typeof(DepthMask)
				);
				glDepthFunc = (DepthFunc) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glDepthFunc"),
					typeof(DepthFunc)
				);
				glStencilMask = (StencilMask) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glStencilMask"),
					typeof(StencilMask)
				);
				glStencilFuncSeparate = (StencilFuncSeparate) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glStencilFuncSeparate"),
					typeof(StencilFuncSeparate)
				);
				glStencilOpSeparate = (StencilOpSeparate) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glStencilOpSeparate"),
					typeof(StencilOpSeparate)
				);
				glStencilFunc = (StencilFunc) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glStencilFunc"),
					typeof(StencilFunc)
				);
				glStencilOp = (StencilOp) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glStencilOp"),
					typeof(StencilOp)
				);
				glFrontFace = (FrontFace) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glFrontFace"),
					typeof(FrontFace)
				);
				glPolygonOffset = (PolygonOffset) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glPolygonOffset"),
					typeof(PolygonOffset)
				);
				glGenTextures = (GenTextures) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glGenTextures"),
					typeof(GenTextures)
				);
				glDeleteTextures = (DeleteTextures) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glDeleteTextures"),
					typeof(DeleteTextures)
				);
				glBindTexture = (G_BindTexture) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glBindTexture"),
					typeof(G_BindTexture)
				);
				glTexImage2D = (TexImage2D) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glTexImage2D"),
					typeof(TexImage2D)
				);
				glTexSubImage2D = (TexSubImage2D) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glTexSubImage2D"),
					typeof(TexSubImage2D)
				);
				glCompressedTexImage2D = (CompressedTexImage2D) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glCompressedTexImage2D"),
					typeof(CompressedTexImage2D)
				);
				glCompressedTexSubImage2D = (CompressedTexSubImage2D) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glCompressedTexSubImage2D"),
					typeof(CompressedTexSubImage2D)
				);
				glTexParameteri = (TexParameteri) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glTexParameteri"),
					typeof(TexParameteri)
				);
				glTexParameterf = (TexParameterf) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glTexParameterf"),
					typeof(TexParameterf)
				);
				glActiveTexture = (ActiveTexture) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glActiveTexture"),
					typeof(ActiveTexture)
				);
				glPixelStorei = (PixelStorei) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glPixelStorei"),
					typeof(PixelStorei)
				);
				glGenBuffers = (GenBuffers) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glGenBuffers"),
					typeof(GenBuffers)
				);
				glDeleteBuffers = (DeleteBuffers) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glDeleteBuffers"),
					typeof(DeleteBuffers)
				);
				glBindBuffer = (BindBuffer) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glBindBuffer"),
					typeof(BindBuffer)
				);
				glBufferData = (BufferData) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glBufferData"),
					typeof(BufferData)
				);
				glBufferSubData = (BufferSubData) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glBufferSubData"),
					typeof(BufferSubData)
				);
				glClearColor = (ClearColor) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glClearColor"),
					typeof(ClearColor)
				);
				glClearStencil = (ClearStencil) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glClearStencil"),
					typeof(ClearStencil)
				);
				glClear = (G_Clear) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glClear"),
					typeof(G_Clear)
				);
				glDrawBuffers = (DrawBuffers) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glDrawBuffers"),
					typeof(DrawBuffers)
				);
				glReadPixels = (ReadPixels) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glReadPixels"),
					typeof(ReadPixels)
				);
				glVertexAttribPointer = (VertexAttribPointer) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glVertexAttribPointer"),
					typeof(VertexAttribPointer)
				);
				glEnableVertexAttribArray = (EnableVertexAttribArray) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glEnableVertexAttribArray"),
					typeof(EnableVertexAttribArray)
				);
				glDisableVertexAttribArray = (DisableVertexAttribArray) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glDisableVertexAttribArray"),
					typeof(DisableVertexAttribArray)
				);
				glDrawArrays = (DrawArrays) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glDrawArrays"),
					typeof(DrawArrays)
				);
			}
			catch
			{
				throw new NoSuitableGraphicsDeviceException(baseErrorString);
			}

			/* ARB_draw_elements_base_vertex is ideal! */
			IntPtr ep = SDL.SDL_GL_GetProcAddress("glDrawRangeElementsBaseVertex");
			supportsBaseVertex = ep != IntPtr.Zero;
			if (supportsBaseVertex)
			{
				glDrawRangeElementsBaseVertex = (DrawRangeElementsBaseVertex) Marshal.GetDelegateForFunctionPointer(
					ep,
					typeof(DrawRangeElementsBaseVertex)
				);
				glDrawRangeElements = (DrawRangeElements) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glDrawRangeElements"),
					typeof(DrawRangeElements)
				);
			}
			else
			{
				/* DrawRangeElements is better, but some ES2 targets don't have it. */
				ep = SDL.SDL_GL_GetProcAddress("glDrawRangeElements");
				if (ep != IntPtr.Zero)
				{
					glDrawRangeElements = (DrawRangeElements) Marshal.GetDelegateForFunctionPointer(
						ep,
						typeof(DrawRangeElements)
					);
					glDrawRangeElementsBaseVertex = DrawRangeElementsNoBase;
				}
				else
				{
					ep = SDL.SDL_GL_GetProcAddress("glDrawElements");
					if (ep == IntPtr.Zero)
					{
						throw new NoSuitableGraphicsDeviceException(baseErrorString);
					}
					glDrawElements = (DrawElements) Marshal.GetDelegateForFunctionPointer(
						ep,
						typeof(DrawElements)
					);
					glDrawRangeElements = DrawRangeElementsUnchecked;
					glDrawRangeElementsBaseVertex = DrawRangeElementsNoBaseUnchecked;
				}
			}

			/* These functions are NOT supported in ES.
			 * NVIDIA or desktop ES might, but real scenarios where you need ES
			 * will certainly not have these.
			 * -flibit
			 */
			if (useES2)
			{
				ep = SDL.SDL_GL_GetProcAddress("glPolygonMode");
				if (ep != IntPtr.Zero)
				{
					glPolygonMode = (PolygonMode) Marshal.GetDelegateForFunctionPointer(
						ep,
						typeof(PolygonMode)
					);
				}
				else
				{
					glPolygonMode = PolygonModeESError;
				}
				ep = SDL.SDL_GL_GetProcAddress("glGetTexImage");
				if (ep != IntPtr.Zero)
				{
					glGetTexImage = (GetTexImage) Marshal.GetDelegateForFunctionPointer(
						ep,
						typeof(GetTexImage)
					);
				}
				else
				{
					glGetTexImage = GetTexImageESError;
				}
				ep = SDL.SDL_GL_GetProcAddress("glGetBufferSubData");
				if (ep != IntPtr.Zero)
				{
					glGetBufferSubData = (GetBufferSubData) Marshal.GetDelegateForFunctionPointer(
						ep,
						typeof(GetBufferSubData)
					);
				}
				else
				{
					glGetBufferSubData = GetBufferSubDataESError;
				}
			}
			else
			{
				try
				{
					glPolygonMode = (PolygonMode) Marshal.GetDelegateForFunctionPointer(
						SDL.SDL_GL_GetProcAddress("glPolygonMode"),
						typeof(PolygonMode)
					);
					glGetTexImage = (GetTexImage) Marshal.GetDelegateForFunctionPointer(
						SDL.SDL_GL_GetProcAddress("glGetTexImage"),
						typeof(GetTexImage)
					);
					glGetBufferSubData = (GetBufferSubData) Marshal.GetDelegateForFunctionPointer(
						SDL.SDL_GL_GetProcAddress("glGetBufferSubData"),
						typeof(GetBufferSubData)
					);
				}
				catch
				{
					throw new NoSuitableGraphicsDeviceException(baseErrorString);
				}
			}

			/* We need _some_ form of depth range, ES... */
			IntPtr drPtr = SDL.SDL_GL_GetProcAddress("glDepthRange");
			if (drPtr != IntPtr.Zero)
			{
				glDepthRange = (DepthRange) Marshal.GetDelegateForFunctionPointer(
					drPtr,
					typeof(DepthRange)
				);
			}
			else
			{
				drPtr = SDL.SDL_GL_GetProcAddress("glDepthRangef");
				if (drPtr == IntPtr.Zero)
				{
					throw new NoSuitableGraphicsDeviceException(baseErrorString);
				}
				glDepthRangef = (DepthRangef) Marshal.GetDelegateForFunctionPointer(
					drPtr,
					typeof(DepthRangef)
				);
				glDepthRange = DepthRangeFloat;
			}
			drPtr = SDL.SDL_GL_GetProcAddress("glClearDepth");
			if (drPtr != IntPtr.Zero)
			{
				glClearDepth = (ClearDepth) Marshal.GetDelegateForFunctionPointer(
					drPtr,
					typeof(ClearDepth)
				);
			}
			else
			{
				drPtr = SDL.SDL_GL_GetProcAddress("glClearDepthf");
				if (drPtr == IntPtr.Zero)
				{
					throw new NoSuitableGraphicsDeviceException(baseErrorString);
				}
				glClearDepthf = (ClearDepthf) Marshal.GetDelegateForFunctionPointer(
					drPtr,
					typeof(ClearDepthf)
				);
				glClearDepth = ClearDepthFloat;
			}

			/* Silently fail if using GLES. You didn't need these, right...? >_> */
			try
			{
				glTexImage3D = (TexImage3D) Marshal.GetDelegateForFunctionPointer(
					TryGetEPEXT("glTexImage3D", "OES"),
					typeof(TexImage3D)
				);
				glTexSubImage3D = (TexSubImage3D) Marshal.GetDelegateForFunctionPointer(
					TryGetEPEXT("glTexSubImage3D", "OES"),
					typeof(TexSubImage3D)
				);
				glGenQueries = (GenQueries) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glGenQueries"),
					typeof(GenQueries)
				);
				glDeleteQueries = (DeleteQueries) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glDeleteQueries"),
					typeof(DeleteQueries)
				);
				glBeginQuery = (BeginQuery) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glBeginQuery"),
					typeof(BeginQuery)
				);
				glEndQuery = (EndQuery) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glEndQuery"),
					typeof(EndQuery)
				);
				glGetQueryObjectuiv = (GetQueryObjectuiv) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glGetQueryObjectuiv"),
					typeof(GetQueryObjectuiv)
				);
			}
			catch
			{
				if (useES2)
				{
					FNAPlatform.Log("Some non-ES functions failed to load. Beware...");
				}
				else
				{
					throw new NoSuitableGraphicsDeviceException(baseErrorString);
				}
			}

			/* ARB_framebuffer_object. We're flexible, but not _that_ flexible. */
			try
			{
				glGenFramebuffers = (GenFramebuffers) Marshal.GetDelegateForFunctionPointer(
					TryGetEPEXT("glGenFramebuffers"),
					typeof(GenFramebuffers)
				);
				glDeleteFramebuffers = (DeleteFramebuffers) Marshal.GetDelegateForFunctionPointer(
					TryGetEPEXT("glDeleteFramebuffers"),
					typeof(DeleteFramebuffers)
				);
				glBindFramebuffer = (G_BindFramebuffer) Marshal.GetDelegateForFunctionPointer(
					TryGetEPEXT("glBindFramebuffer"),
					typeof(G_BindFramebuffer)
				);
				glFramebufferTexture2D = (FramebufferTexture2D) Marshal.GetDelegateForFunctionPointer(
					TryGetEPEXT("glFramebufferTexture2D"),
					typeof(FramebufferTexture2D)
				);
				glFramebufferRenderbuffer = (FramebufferRenderbuffer) Marshal.GetDelegateForFunctionPointer(
					TryGetEPEXT("glFramebufferRenderbuffer"),
					typeof(FramebufferRenderbuffer)
				);
				glGenerateMipmap = (GenerateMipmap) Marshal.GetDelegateForFunctionPointer(
					TryGetEPEXT("glGenerateMipmap"),
					typeof(GenerateMipmap)
				);
				glGenRenderbuffers = (GenRenderbuffers) Marshal.GetDelegateForFunctionPointer(
					TryGetEPEXT("glGenRenderbuffers"),
					typeof(GenRenderbuffers)
				);
				glDeleteRenderbuffers = (DeleteRenderbuffers) Marshal.GetDelegateForFunctionPointer(
					TryGetEPEXT("glDeleteRenderbuffers"),
					typeof(DeleteRenderbuffers)
				);
				glBindRenderbuffer = (BindRenderbuffer) Marshal.GetDelegateForFunctionPointer(
					TryGetEPEXT("glBindRenderbuffer"),
					typeof(BindRenderbuffer)
				);
				glRenderbufferStorage = (RenderbufferStorage) Marshal.GetDelegateForFunctionPointer(
					TryGetEPEXT("glRenderbufferStorage"),
					typeof(RenderbufferStorage)
				);
			}
			catch
			{
				throw new NoSuitableGraphicsDeviceException("OpenGL framebuffer support is required!");
			}

			/* EXT_framebuffer_blit (or ARB_framebuffer_object) is needed by the faux-backbuffer. */
			supportsFauxBackbuffer = true;
			try
			{
				glBlitFramebuffer = (BlitFramebuffer) Marshal.GetDelegateForFunctionPointer(
					TryGetEPEXT("glBlitFramebuffer"),
					typeof(BlitFramebuffer)
				);
			}
			catch
			{
				supportsFauxBackbuffer = false;
			}

			/* ARB_instanced_arrays/ARB_draw_instanced are almost optional. */
			SupportsHardwareInstancing = true;
			try
			{
				glVertexAttribDivisor = (VertexAttribDivisor) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glVertexAttribDivisor"),
					typeof(VertexAttribDivisor)
				);
				/* The likelihood of someone having BaseVertex but not Instanced is 0...? */
				if (supportsBaseVertex)
				{
					glDrawElementsInstancedBaseVertex = (DrawElementsInstancedBaseVertex) Marshal.GetDelegateForFunctionPointer(
						SDL.SDL_GL_GetProcAddress("glDrawElementsInstancedBaseVertex"),
						typeof(DrawElementsInstancedBaseVertex)
					);
				}
				else
				{
					glDrawElementsInstanced = (DrawElementsInstanced) Marshal.GetDelegateForFunctionPointer(
						SDL.SDL_GL_GetProcAddress("glDrawElementsInstanced"),
						typeof(DrawElementsInstanced)
					);
					glDrawElementsInstancedBaseVertex = DrawElementsInstancedNoBase;
				}
			}
			catch
			{
				SupportsHardwareInstancing = false;
			}

			/* EXT_draw_buffers2 is probably used by nobody. */
			try
			{
				glColorMaskIndexedEXT = (ColorMaskIndexedEXT) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glColorMaskIndexedEXT"),
					typeof(ColorMaskIndexedEXT)
				);
			}
			catch
			{
				// FIXME: SupportsIndependentWriteMasks? -flibit
			}

			/* EXT_framebuffer_multisample/ARB_texture_multisample is glitter -flibit */
			supportsMultisampling = true;
			try
			{
				glRenderbufferStorageMultisample = (RenderbufferStorageMultisample) Marshal.GetDelegateForFunctionPointer(
					TryGetEPEXT("glRenderbufferStorageMultisample"),
					typeof(RenderbufferStorageMultisample)
				);
				glSampleMaski = (SampleMaski) Marshal.GetDelegateForFunctionPointer(
					SDL.SDL_GL_GetProcAddress("glSampleMaski"),
					typeof(SampleMaski)
				);
			}
			catch
			{
				supportsMultisampling = false;
			}

			if (useCoreProfile)
			{
				try
				{
					INTERNAL_glGetStringi = (GetStringi) Marshal.GetDelegateForFunctionPointer(
						SDL.SDL_GL_GetProcAddress("glGetStringi"),
						typeof(GetStringi)
					);
					glGenVertexArrays = (GenVertexArrays) Marshal.GetDelegateForFunctionPointer(
						SDL.SDL_GL_GetProcAddress("glGenVertexArrays"),
						typeof(GenVertexArrays)
					);
					glDeleteVertexArrays = (DeleteVertexArrays) Marshal.GetDelegateForFunctionPointer(
						SDL.SDL_GL_GetProcAddress("glDeleteVertexArrays"),
						typeof(DeleteVertexArrays)
					);
					glBindVertexArray = (BindVertexArray) Marshal.GetDelegateForFunctionPointer(
						SDL.SDL_GL_GetProcAddress("glBindVertexArray"),
						typeof(BindVertexArray)
					);
				}
				catch
				{
					throw new NoSuitableGraphicsDeviceException("OpenGL 3.2 support is required!");
				}
			}

#if DEBUG
			/* ARB_debug_output, for debug contexts */
			IntPtr messageCallback = SDL.SDL_GL_GetProcAddress("glDebugMessageCallbackARB");
			IntPtr messageControl = SDL.SDL_GL_GetProcAddress("glDebugMessageControlARB");
			if (messageCallback == IntPtr.Zero || messageControl == IntPtr.Zero)
			{
				FNAPlatform.Log("ARB_debug_output not supported!");
			}
			else
			{
				glDebugMessageCallbackARB = (DebugMessageCallback) Marshal.GetDelegateForFunctionPointer(
					messageCallback,
					typeof(DebugMessageCallback)
				);
				glDebugMessageControlARB = (DebugMessageControl) Marshal.GetDelegateForFunctionPointer(
					messageControl,
					typeof(DebugMessageControl)
				);
				glDebugMessageControlARB(
					GLenum.GL_DONT_CARE,
					GLenum.GL_DONT_CARE,
					GLenum.GL_DONT_CARE,
					0,
					IntPtr.Zero,
					true
				);
				glDebugMessageControlARB(
					GLenum.GL_DONT_CARE,
					GLenum.GL_DEBUG_TYPE_OTHER_ARB,
					GLenum.GL_DEBUG_SEVERITY_LOW_ARB,
					0,
					IntPtr.Zero,
					false
				);
				glDebugMessageControlARB(
					GLenum.GL_DONT_CARE,
					GLenum.GL_DEBUG_TYPE_OTHER_ARB,
					GLenum.GL_DEBUG_SEVERITY_NOTIFICATION_ARB,
					0,
					IntPtr.Zero,
					false
				);
				glDebugMessageCallbackARB(DebugCall, IntPtr.Zero);
			}

			/* GREMEDY_string_marker, for apitrace */
			IntPtr stringMarkerCallback = SDL.SDL_GL_GetProcAddress("glStringMarkerGREMEDY");
			if (stringMarkerCallback == IntPtr.Zero)
			{
				FNAPlatform.Log("GREMEDY_string_marker not supported!");
			}
			else
			{
				glStringMarkerGREMEDY = (StringMarkerGREMEDY) Marshal.GetDelegateForFunctionPointer(
					stringMarkerCallback,
					typeof(StringMarkerGREMEDY)
				);
			}
#endif
		}
 public static extern void PolygonMode( MaterialFace face, PolygonMode mode );
Exemple #51
0
        public override IntPtr OnKeyboardActivity(object sender, KeyboardActivityArgs kbde)
        {

            switch (kbde.VirtualKeyCode)
            {
                case VirtualKeyCodes.PageUp:
                    if (fBlockSize > 1)
                    {
                        fBlockSize -= 1;
                        fResolutionChanged = true;
                    }
                    break;

                case VirtualKeyCodes.PageDown:
                    if (fBlockSize <= fVideoTexture.Width / 2)
                    {
                        fBlockSize += 1;
                        fResolutionChanged = true;
                    }
                    break;
            }

            // The following actions are only triggered on KeyUp.
            // This gives us finer control of when they are fired.
            if (kbde.AcitivityType == KeyActivityType.KeyUp)
            {
                switch (kbde.VirtualKeyCode)
                {
                    case VirtualKeyCodes.F:
                        polyFillMode = PolygonMode.Fill;
                        break;
                    case VirtualKeyCodes.L:
                        polyFillMode = PolygonMode.Line;
                        break;
                    
                    case VirtualKeyCodes.Up:
                        if (fBlockSize > 1)
                        {
                            fBlockSize -= 1;
                            fResolutionChanged = true;
                        }
                        break;

                    case VirtualKeyCodes.Down:
                        if (fBlockSize <= fVideoTexture.Width / 2)
                        {
                            fBlockSize += 1;
                            fResolutionChanged = true;
                        }
                        break;
                }
            }

            return base.OnKeyboardActivity(sender, kbde);
        }
 public void PolygonMode(GLFace face, PolygonMode mode)
 {
     gl.glPolygonMode((int)face, (int)mode);
     CheckException();
 }
Exemple #53
0
        private void LoadGLEntryPoints()
        {
            /* Basic entry points. If you don't have these, you're screwed. */
            try
            {
                INTERNAL_glGetString = (GetString) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGetString"),
                    typeof(GetString)
                );
                glGetIntegerv = (GetIntegerv) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGetIntegerv"),
                    typeof(GetIntegerv)
                );
                glEnable = (Enable) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glEnable"),
                    typeof(Enable)
                );
                glDisable = (Disable) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDisable"),
                    typeof(Disable)
                );
                glViewport = (G_Viewport) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glViewport"),
                    typeof(G_Viewport)
                );
                glDepthRange = (DepthRange) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDepthRange"),
                    typeof(DepthRange)
                );
                glScissor = (Scissor) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glScissor"),
                    typeof(Scissor)
                );
                glBlendColor = (BlendColor) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glBlendColor"),
                    typeof(BlendColor)
                );
                glBlendFuncSeparate = (BlendFuncSeparate) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glBlendFuncSeparate"),
                    typeof(BlendFuncSeparate)
                );
                glBlendEquationSeparate = (BlendEquationSeparate) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glBlendEquationSeparate"),
                    typeof(BlendEquationSeparate)
                );
                glColorMask = (ColorMask) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glColorMask"),
                    typeof(ColorMask)
                );
                glDepthMask = (DepthMask) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDepthMask"),
                    typeof(DepthMask)
                );
                glDepthFunc = (DepthFunc) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDepthFunc"),
                    typeof(DepthFunc)
                );
                glStencilMask = (StencilMask) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glStencilMask"),
                    typeof(StencilMask)
                );
                glStencilFuncSeparate = (StencilFuncSeparate) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glStencilFuncSeparate"),
                    typeof(StencilFuncSeparate)
                );
                glStencilOpSeparate = (StencilOpSeparate) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glStencilOpSeparate"),
                    typeof(StencilOpSeparate)
                );
                glStencilFunc = (StencilFunc) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glStencilFunc"),
                    typeof(StencilFunc)
                );
                glStencilOp = (StencilOp) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glStencilOp"),
                    typeof(StencilOp)
                );
                glCullFace = (CullFace) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glCullFace"),
                    typeof(CullFace)
                );
                glFrontFace = (FrontFace) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glFrontFace"),
                    typeof(FrontFace)
                );
                glPolygonMode = (PolygonMode) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glPolygonMode"),
                    typeof(PolygonMode)
                );
                glPolygonOffset = (PolygonOffset) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glPolygonOffset"),
                    typeof(PolygonOffset)
                );
                glGenTextures = (GenTextures) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGenTextures"),
                    typeof(GenTextures)
                );
                glDeleteTextures = (DeleteTextures) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDeleteTextures"),
                    typeof(DeleteTextures)
                );
                glBindTexture = (G_BindTexture) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glBindTexture"),
                    typeof(G_BindTexture)
                );
                glTexImage2D = (TexImage2D) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glTexImage2D"),
                    typeof(TexImage2D)
                );
                glTexSubImage2D = (TexSubImage2D) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glTexSubImage2D"),
                    typeof(TexSubImage2D)
                );
                glCompressedTexImage2D = (CompressedTexImage2D) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glCompressedTexImage2D"),
                    typeof(CompressedTexImage2D)
                );
                glCompressedTexSubImage2D = (CompressedTexSubImage2D) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glCompressedTexSubImage2D"),
                    typeof(CompressedTexSubImage2D)
                );
                glTexImage3D = (TexImage3D) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glTexImage3D"),
                    typeof(TexImage3D)
                );
                glTexSubImage3D = (TexSubImage3D) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glTexSubImage3D"),
                    typeof(TexSubImage3D)
                );
                glGetTexImage = (GetTexImage) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGetTexImage"),
                    typeof(GetTexImage)
                );
                glTexParameteri = (TexParameteri) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glTexParameteri"),
                    typeof(TexParameteri)
                );
                glTexParameterf = (TexParameterf) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glTexParameterf"),
                    typeof(TexParameterf)
                );
                glActiveTexture = (ActiveTexture) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glActiveTexture"),
                    typeof(ActiveTexture)
                );
                glPixelStorei = (PixelStorei) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glPixelStorei"),
                    typeof(PixelStorei)
                );
                glGenBuffers = (GenBuffers) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGenBuffers"),
                    typeof(GenBuffers)
                );
                glDeleteBuffers = (DeleteBuffers) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDeleteBuffers"),
                    typeof(DeleteBuffers)
                );
                glBindBuffer = (BindBuffer) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glBindBuffer"),
                    typeof(BindBuffer)
                );
                glBufferData = (BufferData) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glBufferData"),
                    typeof(BufferData)
                );
                glBufferSubData = (BufferSubData) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glBufferSubData"),
                    typeof(BufferSubData)
                );
                glMapBuffer = (MapBuffer) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glMapBuffer"),
                    typeof(MapBuffer)
                );
                glUnmapBuffer = (UnmapBuffer) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glUnmapBuffer"),
                    typeof(UnmapBuffer)
                );
                glClearColor = (ClearColor) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glClearColor"),
                    typeof(ClearColor)
                );
                glClearDepth = (ClearDepth) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glClearDepth"),
                    typeof(ClearDepth)
                );
                glClearStencil = (ClearStencil) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glClearStencil"),
                    typeof(ClearStencil)
                );
                glClear = (G_Clear) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glClear"),
                    typeof(G_Clear)
                );
                glDrawBuffers = (DrawBuffers) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDrawBuffers"),
                    typeof(DrawBuffers)
                );
                glReadPixels = (ReadPixels) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glReadPixels"),
                    typeof(ReadPixels)
                );
                glVertexAttribPointer = (VertexAttribPointer) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glVertexAttribPointer"),
                    typeof(VertexAttribPointer)
                );
                glEnableVertexAttribArray = (EnableVertexAttribArray) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glEnableVertexAttribArray"),
                    typeof(EnableVertexAttribArray)
                );
                glDisableVertexAttribArray = (DisableVertexAttribArray) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDisableVertexAttribArray"),
                    typeof(DisableVertexAttribArray)
                );
                glDrawRangeElements = (DrawRangeElements) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDrawRangeElements"),
                    typeof(DrawRangeElements)
                );
                glDrawArrays = (DrawArrays) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDrawArrays"),
                    typeof(DrawArrays)
                );
                glGenQueries = (GenQueries) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGenQueries"),
                    typeof(GenQueries)
                );
                glDeleteQueries = (DeleteQueries) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDeleteQueries"),
                    typeof(DeleteQueries)
                );
                glBeginQuery = (BeginQuery) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glBeginQuery"),
                    typeof(BeginQuery)
                );
                glEndQuery = (EndQuery) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glEndQuery"),
                    typeof(EndQuery)
                );
                glGetQueryObjectiv = (GetQueryObjectiv) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGetQueryObjectiv"),
                    typeof(GetQueryObjectiv)
                );
            }
            catch
            {
                throw new NoSuitableGraphicsDeviceException("OpenGL 2.1 support is required!");
            }

            /* ARB_framebuffer_object. We're flexible, but not _that_ flexible. */
            try
            {
                glGenFramebuffers = (GenFramebuffers) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glGenFramebuffers"),
                    typeof(GenFramebuffers)
                );
                glDeleteFramebuffers = (DeleteFramebuffers) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glDeleteFramebuffers"),
                    typeof(DeleteFramebuffers)
                );
                glBindFramebuffer = (G_BindFramebuffer) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glBindFramebuffer"),
                    typeof(G_BindFramebuffer)
                );
                glFramebufferTexture2D = (FramebufferTexture2D) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glFramebufferTexture2D"),
                    typeof(FramebufferTexture2D)
                );
                glFramebufferRenderbuffer = (FramebufferRenderbuffer) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glFramebufferRenderbuffer"),
                    typeof(FramebufferRenderbuffer)
                );
                glGenerateMipmap = (GenerateMipmap) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glGenerateMipmap"),
                    typeof(GenerateMipmap)
                );
            #if !DISABLE_FAUXBACKBUFFER
                glBlitFramebuffer = (BlitFramebuffer) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glBlitFramebuffer"),
                    typeof(BlitFramebuffer)
                );
            #endif
                glGenRenderbuffers = (GenRenderbuffers) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glGenRenderbuffers"),
                    typeof(GenRenderbuffers)
                );
                glDeleteRenderbuffers = (DeleteRenderbuffers) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glDeleteRenderbuffers"),
                    typeof(DeleteRenderbuffers)
                );
                glBindRenderbuffer = (BindRenderbuffer) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glBindRenderbuffer"),
                    typeof(BindRenderbuffer)
                );
                glRenderbufferStorage = (RenderbufferStorage) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glRenderbufferStorage"),
                    typeof(RenderbufferStorage)
                );
            }
            catch
            {
                throw new NoSuitableGraphicsDeviceException("OpenGL framebuffer support is required!");
            }

            /* ARB_instanced_arrays/ARB_draw_instanced are almost optional. */
            SupportsHardwareInstancing = true;
            try
            {
                glVertexAttribDivisor = (VertexAttribDivisor) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glVertexAttribDivisor"),
                    typeof(VertexAttribDivisor)
                );
                glDrawElementsInstanced = (DrawElementsInstanced) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDrawElementsInstanced"),
                    typeof(DrawElementsInstanced)
                );
            }
            catch
            {
                SupportsHardwareInstancing = false;
            }

            /* EXT_draw_buffers2 is probably used by nobody. */
            try
            {
                glColorMaskIndexedEXT = (ColorMaskIndexedEXT) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glColorMaskIndexedEXT"),
                    typeof(ColorMaskIndexedEXT)
                );
            }
            catch
            {
                // FIXME: SupportsIndependentWriteMasks? -flibit
            }

            /* EXT_framebuffer_multisample/ARB_texture_multisample is glitter -flibit */
            supportsMultisampling = true;
            try
            {
                glRenderbufferStorageMultisample = (RenderbufferStorageMultisample) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glRenderbufferStorageMultisample"),
                    typeof(RenderbufferStorageMultisample)
                );
                glSampleMaski = (SampleMaski) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glSampleMaski"),
                    typeof(SampleMaski)
                );
            }
            catch
            {
                supportsMultisampling = false;
            }

            if (useCoreProfile)
            {
                try
                {
                    INTERNAL_glGetStringi = (GetStringi) Marshal.GetDelegateForFunctionPointer(
                        SDL.SDL_GL_GetProcAddress("glGetStringi"),
                        typeof(GetStringi)
                    );
                    glGenVertexArrays = (GenVertexArrays) Marshal.GetDelegateForFunctionPointer(
                        SDL.SDL_GL_GetProcAddress("glGenVertexArrays"),
                        typeof(GenVertexArrays)
                    );
                    glDeleteVertexArrays = (DeleteVertexArrays) Marshal.GetDelegateForFunctionPointer(
                        SDL.SDL_GL_GetProcAddress("glDeleteVertexArrays"),
                        typeof(DeleteVertexArrays)
                    );
                    glBindVertexArray = (BindVertexArray) Marshal.GetDelegateForFunctionPointer(
                        SDL.SDL_GL_GetProcAddress("glBindVertexArray"),
                        typeof(BindVertexArray)
                    );
                }
                catch
                {
                    throw new NoSuitableGraphicsDeviceException("OpenGL 3.2 support is required!");
                }
            }

            #if DEBUG
            /* ARB_debug_output, for debug contexts */
            IntPtr messageCallback = SDL.SDL_GL_GetProcAddress("glDebugMessageCallbackARB");
            IntPtr messageControl = SDL.SDL_GL_GetProcAddress("glDebugMessageControlARB");
            if (messageCallback == IntPtr.Zero || messageControl == IntPtr.Zero)
            {
                System.Console.WriteLine("ARB_debug_output not supported!");
            }
            else
            {
                glDebugMessageCallbackARB = (DebugMessageCallback) Marshal.GetDelegateForFunctionPointer(
                    messageCallback,
                    typeof(DebugMessageCallback)
                );
                glDebugMessageControlARB = (DebugMessageControl) Marshal.GetDelegateForFunctionPointer(
                    messageControl,
                    typeof(DebugMessageControl)
                );
                glDebugMessageControlARB(
                    GLenum.GL_DONT_CARE,
                    GLenum.GL_DONT_CARE,
                    GLenum.GL_DONT_CARE,
                    0,
                    IntPtr.Zero,
                    true
                );
                glDebugMessageControlARB(
                    GLenum.GL_DONT_CARE,
                    GLenum.GL_DEBUG_TYPE_OTHER_ARB,
                    GLenum.GL_DEBUG_SEVERITY_LOW_ARB,
                    0,
                    IntPtr.Zero,
                    false
                );
                glDebugMessageControlARB(
                    GLenum.GL_DONT_CARE,
                    GLenum.GL_DEBUG_TYPE_OTHER_ARB,
                    GLenum.GL_DEBUG_SEVERITY_NOTIFICATION_ARB,
                    0,
                    IntPtr.Zero,
                    false
                );
                glDebugMessageCallbackARB(DebugCall, IntPtr.Zero);
            }

            /* GREMEDY_string_marker, for apitrace */
            IntPtr stringMarkerCallback = SDL.SDL_GL_GetProcAddress("glStringMarkerGREMEDY");
            if (stringMarkerCallback == IntPtr.Zero)
            {
                System.Console.WriteLine("GREMEDY_string_marker not supported!");
            }
            else
            {
                glStringMarkerGREMEDY = (StringMarkerGREMEDY) Marshal.GetDelegateForFunctionPointer(
                    stringMarkerCallback,
                    typeof(StringMarkerGREMEDY)
                );
            }
            #endif
        }
Exemple #54
0
        public void LoadGLEntryPoints()
        {
            /* Basic entry points. If you don't have these, you're screwed. */
            try
            {
                INTERNAL_glGetString = (GetString) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGetString"),
                    typeof(GetString)
                );
                glGetIntegerv = (GetIntegerv) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGetIntegerv"),
                    typeof(GetIntegerv)
                );
                glEnable = (Enable) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glEnable"),
                    typeof(Enable)
                );
                glDisable = (Disable) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDisable"),
                    typeof(Disable)
                );
                glViewport = (G_Viewport) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glViewport"),
                    typeof(G_Viewport)
                );
                glDepthRange = (DepthRange) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDepthRange"),
                    typeof(DepthRange)
                );
                glScissor = (Scissor) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glScissor"),
                    typeof(Scissor)
                );
                glBlendColor = (BlendColor) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glBlendColor"),
                    typeof(BlendColor)
                );
                glBlendFuncSeparate = (BlendFuncSeparate) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glBlendFuncSeparate"),
                    typeof(BlendFuncSeparate)
                );
                glBlendEquationSeparate = (BlendEquationSeparate) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glBlendEquationSeparate"),
                    typeof(BlendEquationSeparate)
                );
                glColorMask = (ColorMask) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glColorMask"),
                    typeof(ColorMask)
                );
                glDepthMask = (DepthMask) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDepthMask"),
                    typeof(DepthMask)
                );
                glDepthFunc = (DepthFunc) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDepthFunc"),
                    typeof(DepthFunc)
                );
                glStencilMask = (StencilMask) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glStencilMask"),
                    typeof(StencilMask)
                );
                glStencilFuncSeparate = (StencilFuncSeparate) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glStencilFuncSeparate"),
                    typeof(StencilFuncSeparate)
                );
                glStencilOpSeparate = (StencilOpSeparate) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glStencilOpSeparate"),
                    typeof(StencilOpSeparate)
                );
                glStencilFunc = (StencilFunc) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glStencilFunc"),
                    typeof(StencilFunc)
                );
                glStencilOp = (StencilOp) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glStencilOp"),
                    typeof(StencilOp)
                );
                glCullFace = (CullFace) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glCullFace"),
                    typeof(CullFace)
                );
                glFrontFace = (FrontFace) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glFrontFace"),
                    typeof(FrontFace)
                );
                glPolygonMode = (PolygonMode) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glPolygonMode"),
                    typeof(PolygonMode)
                );
                glPolygonOffset = (PolygonOffset) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glPolygonOffset"),
                    typeof(PolygonOffset)
                );
                glGenTextures = (GenTextures) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGenTextures"),
                    typeof(GenTextures)
                );
                glDeleteTextures = (DeleteTextures) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDeleteTextures"),
                    typeof(DeleteTextures)
                );
                glBindTexture = (G_BindTexture) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glBindTexture"),
                    typeof(G_BindTexture)
                );
                glTexImage2D = (TexImage2D) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glTexImage2D"),
                    typeof(TexImage2D)
                );
                glTexSubImage2D = (TexSubImage2D) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glTexSubImage2D"),
                    typeof(TexSubImage2D)
                );
                glCompressedTexImage2D = (CompressedTexImage2D) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glCompressedTexImage2D"),
                    typeof(CompressedTexImage2D)
                );
                glCompressedTexSubImage2D = (CompressedTexSubImage2D) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glCompressedTexSubImage2D"),
                    typeof(CompressedTexSubImage2D)
                );
                glTexImage3D = (TexImage3D) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glTexImage3D"),
                    typeof(TexImage3D)
                );
                glTexSubImage3D = (TexSubImage3D) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glTexSubImage3D"),
                    typeof(TexSubImage3D)
                );
                glGetTexImage = (GetTexImage) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGetTexImage"),
                    typeof(GetTexImage)
                );
                glTexParameteri = (TexParameteri) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glTexParameteri"),
                    typeof(TexParameteri)
                );
                glTexParameterf = (TexParameterf) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glTexParameterf"),
                    typeof(TexParameterf)
                );
                glActiveTexture = (ActiveTexture) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glActiveTexture"),
                    typeof(ActiveTexture)
                );
                glGetTexLevelParameteriv = (GetTexLevelParameteriv) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGetTexLevelParameteriv"),
                    typeof(GetTexLevelParameteriv)
                );
                glPixelStorei = (PixelStorei) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glPixelStorei"),
                    typeof(PixelStorei)
                );
                glGenBuffers = (GenBuffers) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGenBuffers"),
                    typeof(GenBuffers)
                );
                glDeleteBuffers = (DeleteBuffers) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDeleteBuffers"),
                    typeof(DeleteBuffers)
                );
                glBindBuffer = (BindBuffer) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glBindBuffer"),
                    typeof(BindBuffer)
                );
                glBufferData = (BufferData) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glBufferData"),
                    typeof(BufferData)
                );
                glBufferSubData = (BufferSubData) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glBufferSubData"),
                    typeof(BufferSubData)
                );
                glMapBuffer = (MapBuffer) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glMapBuffer"),
                    typeof(MapBuffer)
                );
                glUnmapBuffer = (UnmapBuffer) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glUnmapBuffer"),
                    typeof(UnmapBuffer)
                );
                glEnableVertexAttribArray = (EnableVertexAttribArray) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glEnableVertexAttribArray"),
                    typeof(EnableVertexAttribArray)
                );
                glDisableVertexAttribArray = (DisableVertexAttribArray) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDisableVertexAttribArray"),
                    typeof(DisableVertexAttribArray)
                );
                glVertexAttribPointer = (G_VertexAttribPointer) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glVertexAttribPointer"),
                    typeof(G_VertexAttribPointer)
                );
                glClearColor = (ClearColor) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glClearColor"),
                    typeof(ClearColor)
                );
                glClearDepth = (ClearDepth) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glClearDepth"),
                    typeof(ClearDepth)
                );
                glClearStencil = (ClearStencil) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glClearStencil"),
                    typeof(ClearStencil)
                );
                glClear = (G_Clear) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glClear"),
                    typeof(G_Clear)
                );
                glDrawBuffers = (DrawBuffers) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDrawBuffers"),
                    typeof(DrawBuffers)
                );
                glReadPixels = (ReadPixels) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glReadPixels"),
                    typeof(ReadPixels)
                );
                glDrawRangeElements = (DrawRangeElements) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDrawRangeElements"),
                    typeof(DrawRangeElements)
                );
                glDrawArrays = (DrawArrays) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDrawArrays"),
                    typeof(DrawArrays)
                );
                glGenQueries = (GenQueries) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGenQueries"),
                    typeof(GenQueries)
                );
                glDeleteQueries = (DeleteQueries) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDeleteQueries"),
                    typeof(DeleteQueries)
                );
                glBeginQuery = (BeginQuery) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glBeginQuery"),
                    typeof(BeginQuery)
                );
                glEndQuery = (EndQuery) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glEndQuery"),
                    typeof(EndQuery)
                );
                glGetQueryObjectiv = (GetQueryObjectiv) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGetQueryObjectiv"),
                    typeof(GetQueryObjectiv)
                );
                glCreateShader = (CreateShader) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glCreateShader"),
                    typeof(CreateShader)
                );
                glDeleteShader = (DeleteShader) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDeleteShader"),
                    typeof(DeleteShader)
                );
                glShaderSource = (ShaderSource) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glShaderSource"),
                    typeof(ShaderSource)
                );
                glCompileShader = (CompileShader) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glCompileShader"),
                    typeof(CompileShader)
                );
                glCreateProgram = (CreateProgram) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glCreateProgram"),
                    typeof(CreateProgram)
                );
                glDeleteProgram = (DeleteProgram) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDeleteProgram"),
                    typeof(DeleteProgram)
                );
                glAttachShader = (AttachShader) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glAttachShader"),
                    typeof(AttachShader)
                );
                glDetachShader = (DetachShader) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDetachShader"),
                    typeof(DetachShader)
                );
                glLinkProgram = (LinkProgram) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glLinkProgram"),
                    typeof(LinkProgram)
                );
                glUseProgram = (UseProgram) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glUseProgram"),
                    typeof(UseProgram)
                );
                glUniform1i = (Uniform1i) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glUniform1i"),
                    typeof(Uniform1i)
                );
                glUniform4fv = (Uniform4fv) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glUniform4fv"),
                    typeof(Uniform4fv)
                );
                glGetShaderiv = (GetShaderiv) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGetShaderiv"),
                    typeof(GetShaderiv)
                );
                glGetProgramiv = (GetProgramiv) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGetProgramiv"),
                    typeof(GetProgramiv)
                );
                glGetUniformLocation = (GetUniformLocation) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGetUniformLocation"),
                    typeof(GetUniformLocation)
                );
                glGetAttribLocation = (GetAttribLocation) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGetAttribLocation"),
                    typeof(GetAttribLocation)
                );
                glBindAttribLocation = (BindAttribLocation) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glBindAttribLocation"),
                    typeof(BindAttribLocation)
                );
                glIsShader = (IsShader) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glIsShader"),
                    typeof(IsShader)
                );
                glIsProgram = (IsProgram) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glIsProgram"),
                    typeof(IsProgram)
                );
                glGetShaderInfoLog = (GetShaderInfoLog) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGetShaderInfoLog"),
                    typeof(GetShaderInfoLog)
                );
                glGetProgramInfoLog = (GetProgramInfoLog) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glGetProgramInfoLog"),
                    typeof(GetProgramInfoLog)
                );
                glFlush = (Flush) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glFlush"),
                    typeof(Flush)
                );
            }
            catch
            {
                throw new NoSuitableGraphicsDeviceException("OpenGL 2.1 support is required!");
            }

            /* ARB_framebuffer_object. We're flexible, but not _that_ flexible. */
            try
            {
                glGenFramebuffers = (GenFramebuffers) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glGenFramebuffers"),
                    typeof(GenFramebuffers)
                );
                glDeleteFramebuffers = (DeleteFramebuffers) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glDeleteFramebuffers"),
                    typeof(DeleteFramebuffers)
                );
                glBindFramebuffer = (G_BindFramebuffer) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glBindFramebuffer"),
                    typeof(G_BindFramebuffer)
                );
                glFramebufferTexture2D = (FramebufferTexture2D) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glFramebufferTexture2D"),
                    typeof(FramebufferTexture2D)
                );
                glFramebufferRenderbuffer = (FramebufferRenderbuffer) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glFramebufferRenderbuffer"),
                    typeof(FramebufferRenderbuffer)
                );
            #if !DISABLE_FAUXBACKBUFFER
                glBlitFramebuffer = (BlitFramebuffer) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glBlitFramebuffer"),
                    typeof(BlitFramebuffer)
                );
            #endif
                glGenRenderbuffers = (GenRenderbuffers) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glGenRenderbuffers"),
                    typeof(GenRenderbuffers)
                );
                glDeleteRenderbuffers = (DeleteRenderbuffers) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glDeleteRenderbuffers"),
                    typeof(DeleteRenderbuffers)
                );
                glBindRenderbuffer = (BindRenderbuffer) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glBindRenderbuffer"),
                    typeof(BindRenderbuffer)
                );
                glRenderbufferStorage = (RenderbufferStorage) Marshal.GetDelegateForFunctionPointer(
                    TryGetFramebufferEP("glRenderbufferStorage"),
                    typeof(RenderbufferStorage)
                );
            }
            catch
            {
                throw new NoSuitableGraphicsDeviceException("OpenGL framebuffer support is required!");
            }

            /* ARB_instanced_arrays/ARB_draw_instanced are almost optional. */
            SupportsHardwareInstancing = true;
            try
            {
                glVertexAttribDivisor = (VertexAttribDivisor) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glVertexAttribDivisor"),
                    typeof(VertexAttribDivisor)
                );
                glDrawElementsInstanced = (DrawElementsInstanced) Marshal.GetDelegateForFunctionPointer(
                    SDL.SDL_GL_GetProcAddress("glDrawElementsInstanced"),
                    typeof(DrawElementsInstanced)
                );
            }
            catch
            {
                SupportsHardwareInstancing = false;
            }

            #if DEBUG
            /* ARB_debug_output, for debug contexts */
            IntPtr messageCallback = SDL.SDL_GL_GetProcAddress("glDebugMessageCallbackARB");
            IntPtr messageControl = SDL.SDL_GL_GetProcAddress("glDebugMessageControlARB");
            if (messageCallback == IntPtr.Zero || messageControl == IntPtr.Zero)
            {
                System.Console.WriteLine("ARB_debug_output not supported!");
            }
            else
            {
                glDebugMessageCallbackARB = (DebugMessageCallback) Marshal.GetDelegateForFunctionPointer(
                    messageCallback,
                    typeof(DebugMessageCallback)
                );
                glDebugMessageControlARB = (DebugMessageControl) Marshal.GetDelegateForFunctionPointer(
                    messageControl,
                    typeof(DebugMessageControl)
                );
                glDebugMessageCallbackARB(DebugCall, IntPtr.Zero);
                glDebugMessageControlARB(
                    GLenum.GL_DONT_CARE,
                    GLenum.GL_DONT_CARE,
                    GLenum.GL_DONT_CARE,
                    0,
                    IntPtr.Zero,
                    true
                );
                glDebugMessageControlARB(
                    GLenum.GL_DONT_CARE,
                    GLenum.GL_DEBUG_TYPE_OTHER_ARB,
                    GLenum.GL_DEBUG_SEVERITY_LOW_ARB,
                    0,
                    IntPtr.Zero,
                    false
                );
            }

            /* GREMEDY_string_marker, for apitrace */
            IntPtr stringMarkerCallback = SDL.SDL_GL_GetProcAddress("glStringMarkerGREMEDY");
            if (stringMarkerCallback == IntPtr.Zero)
            {
                System.Console.WriteLine("GREMEDY_string_marker not supported!");
            }
            else
            {
                glStringMarkerGREMEDY = (StringMarkerGREMEDY) Marshal.GetDelegateForFunctionPointer(
                    stringMarkerCallback,
                    typeof(StringMarkerGREMEDY)
                );
            }
            #endif
        }
Exemple #55
0
		/// <summary>
		///		Internal utility method for rendering a single object.
		/// </summary>
		/// <param name="renderable">The renderable to issue to the pipeline.</param>
		/// <param name="pass">The pass which is being used.</param>
		/// <param name="doLightIteration">If true, this method will issue the renderable to
		/// the pipeline possibly multiple times, if the pass indicates it should be
		/// done once per light.</param>
		/// <param name="manualLightList">Only applicable if 'doLightIteration' is false, this
		/// method allows you to pass in a previously determined set of lights
		/// which will be used for a single render of this object.</param>
		protected virtual void RenderSingleObject( IRenderable renderable,
												   Pass pass,
												   bool doLightIteration,
												   LightList manualLightList )
		{
			ushort numMatrices = 0;

			// grab the current scene detail level
			PolygonMode camPolyMode = this.cameraInProgress.PolygonMode;

			// get the world matrices and the count
			renderable.GetWorldTransforms( this.xform );
			numMatrices = renderable.NumWorldTransforms;

			// set the world matrices in the render system
			if ( numMatrices > 1 )
			{
				this.targetRenderSystem.SetWorldMatrices( this.xform, numMatrices );
			}
			else
			{
				this.targetRenderSystem.WorldMatrix = this.xform[ 0 ];
			}

			// issue view/projection changes (if any)
			this.UseRenderableViewProjection( renderable );

			if ( !this.suppressRenderStateChanges )
			{
				bool passSurfaceAndLightParams = true;
				if ( pass.IsProgrammable )
				{
					// Tell auto params object about the renderable change
					this.autoParamDataSource.Renderable = renderable;
					pass.UpdateAutoParamsNoLights( this.autoParamDataSource );
					if ( pass.HasVertexProgram )
					{
						passSurfaceAndLightParams = pass.VertexProgram.PassSurfaceAndLightStates;
					}
				}

				// issue texture units that depend on updated view matrix
				// reflective env mapping is one case
				for ( int i = 0; i < pass.TextureUnitStageCount; i++ )
				{
					TextureUnitState texUnit = pass.GetTextureUnitState( i );

					if ( texUnit.HasViewRelativeTexCoordGen )
					{
					    targetRenderSystem.SetTextureUnitSettings( i, texUnit );
					    //this.targetRenderSystem.SetTextureUnit( i, texUnit, !pass.HasFragmentProgram );
					}
				}

				// Normalize normals
				bool thisNormalize = renderable.NormalizeNormals;

				if ( thisNormalize != normalizeNormals )
				{
					this.targetRenderSystem.NormalizeNormals = thisNormalize;
					normalizeNormals = thisNormalize;
				}

				// Set up the solid / wireframe override
				PolygonMode requestedMode = pass.PolygonMode;
				if ( renderable.PolygonModeOverrideable == true )
				{
					// check camera detial only when render detail is overridable
					if ( requestedMode > camPolyMode )
					{
						// only downgrade detail; if cam says wireframe we don't go up to solid
						requestedMode = camPolyMode;
					}
				}

				if ( requestedMode != this.lastPolyMode )
				{
					this.targetRenderSystem.PolygonMode = requestedMode;
					this.lastPolyMode = requestedMode;
				}

				// TODO: Add ClipPlanes to RenderSystem.cs
				// This is removed in OGRE 1.6.0... no need to port - J. Price
				//targetRenderSystem.ClipPlanes = renderable.ClipPlanes;

				// get the renderables render operation
				op = renderable.RenderOperation;
				// TODO: Add srcRenderable to RenderOperation.cs
				//op.srcRenderable = renderable;

				if ( doLightIteration )
				{
					// Here's where we issue the rendering operation to the render system
					// Note that we may do this once per light, therefore it's in a loop
					// and the light parameters are updated once per traversal through the
					// loop
					LightList rendLightList = renderable.Lights;
					bool iteratePerLight = pass.IteratePerLight;
					int numIterations = iteratePerLight ? rendLightList.Count : 1;
					LightList lightListToUse = null;

					for ( int i = 0; i < numIterations; i++ )
					{
						// determine light list to use
						if ( iteratePerLight )
						{
							localLightList.Clear();

							// check whether we need to filter this one out
							if ( pass.RunOnlyOncePerLightType && pass.OnlyLightType != rendLightList[ i ].Type )
							{
								// skip this one
								continue;
							}

							localLightList.Add( rendLightList[ i ] );
							lightListToUse = localLightList;
						}
						else
						{
							// use complete light list
							lightListToUse = rendLightList;
						}

						if ( pass.IsProgrammable )
						{
							// Update any automatic gpu params for lights
							// Other bits of information will have to be looked up
							this.autoParamDataSource.SetCurrentLightList( lightListToUse );
							pass.UpdateAutoParamsLightsOnly( this.autoParamDataSource );

						    UpdateGpuProgramParameters( pass );
						}

						// Do we need to update light states?
						// Only do this if fixed-function vertex lighting applies
						if ( pass.LightingEnabled && passSurfaceAndLightParams )
						{
							this.targetRenderSystem.UseLights( lightListToUse, pass.MaxSimultaneousLights );
						}
                        this.targetRenderSystem.CurrentPassIterationCount = pass.IterationCount;
						// issue the render op
						this.targetRenderSystem.Render( op );
					} // iterate per light
				}
				else
				{
					// do we need to update GPU program parameters?
					if ( pass.IsProgrammable )
					{
						// do we have a manual light list
						if ( manualLightList != null )
						{
							// Update any automatic gpu params for lights
							// Other bits of information will have to be looked up
							this.autoParamDataSource.SetCurrentLightList( manualLightList );
							pass.UpdateAutoParamsLightsOnly( this.autoParamDataSource );
						}

					    UpdateGpuProgramParameters( pass );
					}

					// Use manual lights if present, and not using vertex programs
					if ( manualLightList != null && pass.LightingEnabled && passSurfaceAndLightParams )
					{
						this.targetRenderSystem.UseLights( manualLightList, pass.MaxSimultaneousLights );
					}
                    this.targetRenderSystem.CurrentPassIterationCount = pass.IterationCount;
					// issue the render op
					this.targetRenderSystem.Render( op );
				}
			}
			else
			{
				// suppressRenderStateChanges
				// Just render
                this.targetRenderSystem.CurrentPassIterationCount = 1;
				this.targetRenderSystem.Render( op );
			}

			// Reset view / projection changes if any
			this.ResetViewProjectionMode();
		}
Exemple #56
0
 public void RenderMode(PolygonMode _mode)
 {
     camera.PolygonMode = _mode;
 }
Exemple #57
0
 public static void SetPolygonMode(Face face, PolygonMode mode)
 {
     Gl.PolygonMode((uint)face, (uint)mode);
     Gl.GetError();
 }
Exemple #58
0
 public static D3D.FillMode ConvertEnum(PolygonMode mode)
 {
     switch (mode)
     {
         case PolygonMode.Points:
             return D3D.FillMode.Point;
         case PolygonMode.Wireframe:
             return D3D.FillMode.Wireframe;
         case PolygonMode.Solid:
             return D3D.FillMode.Solid;
         default:
             throw new NotImplementedException();
     }
 }
Exemple #59
0
		public static void PolygonMode(MaterialFace face, PolygonMode mode)
		{
			Debug.Assert(Delegates.pglPolygonMode != null, "pglPolygonMode not implemented");
			Delegates.pglPolygonMode((Int32)face, (Int32)mode);
			CallLog("glPolygonMode({0}, {1})", face, mode);
			DebugCheckErrors();
		}
Exemple #60
0
 public FlagScene()
 {
     polyFillMode = PolygonMode.Fill;
     bUseTexture = true;
 }