Example #1
0
        private void SetFaceCulling(NUD.Material material)
        {
            bool         enabled      = true;
            CullFaceMode cullFaceMode = CullFaceMode.Back;

            switch (material.cullMode)
            {
            case 0x0000:
                enabled = false;
                break;

            case 0x0404:
                cullFaceMode = CullFaceMode.Front;
                break;

            case 0x0405:
                cullFaceMode = CullFaceMode.Back;
                break;

            default:
                enabled = false;
                break;
            }

            renderSettings.faceCullingSettings = new FaceCullingSettings(enabled, cullFaceMode);
        }
Example #2
0
		public static void CullFace(CullFaceMode mode)
		{
			Debug.Assert(Delegates.pglCullFace != null, "pglCullFace not implemented");
			Delegates.pglCullFace((Int32)mode);
			CallLog("glCullFace({0})", mode);
			DebugCheckErrors();
		}
Example #3
0
        public static void CullFace(CullFaceMode mode)
        {
#if USE_OPENGL
            OpenTK.Graphics.OpenGL.GL.CullFace((OpenTK.Graphics.OpenGL.CullFaceMode)mode);
#else
            OpenTK.Graphics.ES11.GL.CullFace((OpenTK.Graphics.ES11.All)mode);
#endif
        }
        public void CullFaceMode(CullFaceMode cullFaceMode)
        {
            if (mCullFaceMode == cullFaceMode)
            {
                return;
            }

            GL.CullFace(mCullFaceMode = cullFaceMode);
        }
Example #5
0
        internal static CullMode Convert(CullFaceMode cullMode)
        {
            if (!cullModes.ContainsValue(cullMode))
            {
                throw new NotSupportedException("cullMode is not supported");
            }

            return(cullModes.First((f) => f.Value == cullMode).Key);
        }
Example #6
0
        public static void CullFace(CullFaceMode mode)
        {
            GL.CullFace(mode);

            if (enableErrorCheck)
            {
                LogErrors();
            }
        }
Example #7
0
        public static void CullFace(CullFaceMode mode)
        {
#if USE_OPENGL
            if (HardwareAvailable)
            {
                OpenTK.Graphics.OpenGL.GL.CullFace((OpenTK.Graphics.OpenGL.CullFaceMode)mode);
            }
#else
            OpenTK.Graphics.ES11.GL.CullFace((OpenTK.Graphics.ES11.All)mode);
#endif
        }
Example #8
0
 public GLState(CullFaceMode cullFaceMode, DepthFunction depthFunction, BlendingFactorSrc blendingFactorSrc,
                BlendingFactorDest blendingFactorDest, params EnableCap[] enableCaps)
 {
     CullFaceMode       = cullFaceMode;
     DepthFunction      = depthFunction;
     BlendingFactorSrc  = blendingFactorSrc;
     BlendingFactorDest = blendingFactorDest;
     EnableCaps         = enableCaps;
     _fullHash          = "{" + CullFaceMode + "}{" + DepthFunction + "}{" + BlendingFactorSrc + "}{" + BlendingFactorDest +
                          "}{" + EnableCaps.Aggregate("", (left, cap) => left + cap.ToString()) + "}";
 }
        public MeshRender(Transform transformParent, Mesh mesh, Shader shader, Texture texture)
        {
            _cullType = CullFaceMode.Front;

            transform = transformParent;

            _mesh    = mesh;
            _shader  = shader;
            _texture = texture;

            /*if (_shader != null)
             * {
             *  _shader.Use();
             * }*/

            IBO = GL.GenBuffer();
            VAO = GL.GenVertexArray();

            vbo = GL.GenBuffer();
            dbo = GL.GenBuffer();
            tbo = GL.GenBuffer();
            nbo = GL.GenBuffer();

            GL.BindBuffer(BufferTarget.ElementArrayBuffer, IBO);
            GL.BufferData(BufferTarget.ElementArrayBuffer, _mesh._indices.Length * sizeof(int), _mesh._indices, BufferUsageHint.StaticDraw);

            GL.BindVertexArray(VAO);

            GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);
            GL.BufferData(BufferTarget.ArrayBuffer, _mesh._vertices.Length * Vector3.SizeInBytes, _mesh._vertices, BufferUsageHint.StaticDraw);
            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(0);

            //Colors
            GL.BindBuffer(BufferTarget.ArrayBuffer, dbo);
            GL.BufferData(BufferTarget.ArrayBuffer, _mesh._Colors.Length * sizeof(float), _mesh._Colors, BufferUsageHint.StaticDraw);
            GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(1);

            //Texture
            GL.BindBuffer(BufferTarget.ArrayBuffer, tbo);
            GL.BufferData(BufferTarget.ArrayBuffer, _mesh._texCoords.Length * Vector2.SizeInBytes, _mesh._texCoords, BufferUsageHint.StaticDraw);
            GL.VertexAttribPointer(2, 2, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(2);

            GL.BindBuffer(BufferTarget.ArrayBuffer, nbo);
            GL.BufferData(BufferTarget.ArrayBuffer, _mesh._Normals.Length * Vector3.SizeInBytes, _mesh._Normals, BufferUsageHint.StaticDraw);
            GL.VertexAttribPointer(3, 3, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(3);

            TickSystem.AddRenderItemT(this);
        }
Example #10
0
 public void setCullFace(CullFaceMode face)
 {
     if (face != cullFace)
     {
         cullFace = face;
         if ((face == CullFaceMode.Front) || (face == CullFaceMode.Back) || (face == CullFaceMode.FrontAndBack))
         {
             GL.Enable(EnableCap.CullFace);
             GL.CullFace(face);
         }
         else
         {
             GL.Disable(EnableCap.CullFace);
         }
     }
 }
        public ChunkCloudRender(Transform transformParent)
        {
            isReady   = false;
            _cullType = CullFaceMode.Front;

            transform          = new Transform();
            transform.Position = new Vector3(transformParent.Position.X, 50, transformParent.Position.Z);
            transform.Rotation = new Quaternion(MathHelper.DegreesToRadians(90), 0, 0, 1);
            transform.Size     = new Vector3(10, 10, 1);

            C_shader  = AssetsManager.GetShader("Cloud");
            C_texture = AssetsManager.GetTexture("Cloud");

            CreteCloudMesh();

            if (mesh != null)
            {
                if (C_shader != null)
                {
                    C_shader.Use();
                }

                C_VAO = GL.GenVertexArray();
                C_IBO = GL.GenBuffer();
                C_vbo = GL.GenBuffer();
                C_tbo = GL.GenBuffer();

                GL.BindBuffer(BufferTarget.ElementArrayBuffer, C_IBO);
                GL.BufferData(BufferTarget.ElementArrayBuffer, mesh._indices.Length * sizeof(int), mesh._indices, BufferUsageHint.StaticDraw);

                GL.BindVertexArray(C_VAO);
                GL.BindBuffer(BufferTarget.ArrayBuffer, C_vbo);
                GL.BufferData(BufferTarget.ArrayBuffer, mesh._vertices.Length * Vector3.SizeInBytes, mesh._vertices, BufferUsageHint.StaticDraw);
                GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(0);

                //Texture
                GL.BindBuffer(BufferTarget.ArrayBuffer, C_tbo);
                GL.BufferData(BufferTarget.ArrayBuffer, mesh._texCoords.Length * Vector2.SizeInBytes, mesh._texCoords, BufferUsageHint.StaticDraw);
                GL.VertexAttribPointer(1, 2, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(1);

                TickSystem.AddRenderItem(this);

                isReady = true;
            }
        }
Example #12
0
        public DemoMesh(Demo demo)
        {
            this.demo = demo;

            Render = new RenderMeshDeferredPNT();

            meshVertexBuffer = -1;
            meshIndexBuffer  = -1;
            meshVertices     = null;
            meshIndices16Bit = null;
            meshIndices32Bit = null;
            meshIndicesType  = 0;
            meshCullMode     = CullFaceMode.Back;
            dynamic          = false;
            scaleNormals     = false;

            SetTexture(null);
        }
Example #13
0
        /// <summary>
        /// Merge this state with another one.
        /// </summary>
        /// <param name="state">
        /// A <see cref="IGraphicsState"/> having the same <see cref="StateIdentifier"/> of this state.
        /// </param>
        public override void Merge(IGraphicsState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }

            CullFaceState otherState = state as CullFaceState;

            if (otherState == null)
            {
                throw new ArgumentException("not a CullFaceState", "state");
            }

            _FrontFaceMode = otherState._FrontFaceMode;
            _Enabled       = otherState._Enabled;
            _CulledFace    = otherState._CulledFace;
        }
Example #14
0
        public RenderState(Framebuffer fbuf,
                           ShaderProgram prog,
                           StorageBuffer[] ssboBindings,
                           UniformBuffer[] uboBindings,
                           bool dWrite,
                           bool colorWrite,
                           DepthFunc dTest,
                           float far,
                           float near,
                           BlendFactor src,
                           BlendFactor dst,
                           Vector4 ClearColor,
                           float ClearDepth,
                           CullFaceMode cullMode,
                           IndexBuffer iBuffer = null,
                           Vector4[] viewports = null)
        {
            Framebuffer                 = fbuf;
            ShaderProgram               = prog;
            DepthWrite                  = dWrite;
            ColorWrite                  = colorWrite;
            DepthTest                   = dTest;
            FarPlane                    = far;
            NearPlane                   = near;
            Src                         = src;
            Dst                         = dst;
            this.ClearColor             = ClearColor;
            this.ClearDepth             = ClearDepth;
            CullMode                    = cullMode;
            ShaderStorageBufferBindings = ssboBindings;
            UniformBufferBindings       = uboBindings;
            IndexBuffer                 = iBuffer;

            if (viewports == null)
            {
                Viewports = new Vector4[] { new Vector4(0, 0, Framebuffer == null ? 0 : Framebuffer.Width, Framebuffer == null ? 0 : Framebuffer.Height) }
            }
            ;
            else
            {
                Viewports = viewports;
            }
        }
        private void SetUpGL()
        {
            _cullType = CullFaceMode.Front;

            IBO = GL.GenBuffer();
            VAO = GL.GenVertexArray();

            vbo = GL.GenBuffer();
            dbo = GL.GenBuffer();
            tbo = GL.GenBuffer();
            nbo = GL.GenBuffer();

            GL.BindBuffer(BufferTarget.ElementArrayBuffer, IBO);
            GL.BufferData(BufferTarget.ElementArrayBuffer, AssetsManager.GetMesh(_mesh)._indices.Length *sizeof(int), AssetsManager.GetMesh(_mesh)._indices, BufferUsageHint.StaticDraw);

            GL.BindVertexArray(VAO);

            GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);
            GL.BufferData(BufferTarget.ArrayBuffer, AssetsManager.GetMesh(_mesh)._vertices.Length *Vector3.SizeInBytes, AssetsManager.GetMesh(_mesh)._vertices, BufferUsageHint.StaticDraw);
            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(0);

            //Colors
            GL.BindBuffer(BufferTarget.ArrayBuffer, dbo);
            GL.BufferData(BufferTarget.ArrayBuffer, AssetsManager.GetMesh(_mesh)._Colors.Length *sizeof(float), AssetsManager.GetMesh(_mesh)._Colors, BufferUsageHint.StaticDraw);
            GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(1);

            //Texture
            GL.BindBuffer(BufferTarget.ArrayBuffer, tbo);
            GL.BufferData(BufferTarget.ArrayBuffer, AssetsManager.GetMesh(_mesh)._texCoords.Length *Vector2.SizeInBytes, AssetsManager.GetMesh(_mesh)._texCoords, BufferUsageHint.StaticDraw);
            GL.VertexAttribPointer(2, 2, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(2);

            GL.BindBuffer(BufferTarget.ArrayBuffer, nbo);
            GL.BufferData(BufferTarget.ArrayBuffer, AssetsManager.GetMesh(_mesh)._Normals.Length *Vector3.SizeInBytes, AssetsManager.GetMesh(_mesh)._Normals, BufferUsageHint.StaticDraw);
            GL.VertexAttribPointer(3, 3, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(3);

            TickSystem.AddRenderItem(this);
        }
Example #16
0
 public void SetCullFace(CullFaceMode mode, CullFaceDirection direction)
 {
     OpenTK.Graphics.ES20.CullFaceMode       mode_  = 0;
     OpenTK.Graphics.ES20.FrontFaceDirection mode2_ = 0;
     switch (mode)
     {
     case CullFaceMode.Back:
         mode_ = OpenTK.Graphics.ES20.CullFaceMode.Back;
         break;
     }
     switch (direction)
     {
     case CullFaceDirection.Ccw:
         mode2_ = OpenTK.Graphics.ES20.FrontFaceDirection.Ccw;
         break;
     }
     GL.CullFace(mode_);
     GL.FrontFace(mode2_);
     //Debug.Assert(false);
     __curCullFace = new CullFace(mode, direction);
 }
Example #17
0
        public RasterizerStateDesc(RasterizerStateTypes type)
        {
            switch (type)
            {
            case RasterizerStateTypes.Solid_CullNone:
                cullMode = CullFaceMode.None;
                break;

            case RasterizerStateTypes.Solid_CullCW:
                cullMode = CullFaceMode.Back;
                break;

            case RasterizerStateTypes.Solid_CullCCW:
                cullMode = CullFaceMode.Front;
                break;

            default:
                Debug.ThrowError("RasterizerStateDesc", "Unsuported RasterizerStateType");
                break;
            }
        }
        public RasterizerStateDesc(RasterizerStateTypes type)
        {
            switch (type)
            {
                case RasterizerStateTypes.Solid_CullNone:
                    cullMode = CullFaceMode.None;
                    break;

                case RasterizerStateTypes.Solid_CullCW:
                    cullMode = CullFaceMode.Back;
                    break;

                case RasterizerStateTypes.Solid_CullCCW:
                    cullMode = CullFaceMode.Front;
                    break;

                default:
                    Debug.ThrowError("RasterizerStateDesc", "Unsuported RasterizerStateType");
                    break;
            }
        }
Example #19
0
        public static void FaceCulling(bool enable = true, CullFaceMode cullFaceMode = CullFaceMode.Back, FrontFaceDirection frontFace = FrontFaceDirection.Ccw)
        {
            if (enable)
            {
                if (!_faceCullingEnabled)
                {
                    GL.Enable(EnableCap.CullFace);
                }
                GL.CullFace(cullFaceMode);
                GL.FrontFace(frontFace);

                _faceCullingMode = cullFaceMode;
                _faceCullingFrontFaceDirection = frontFace;
            }
            else if (_faceCullingEnabled)
            {
                GL.Disable(EnableCap.CullFace);
            }

            _faceCullingEnabled = enable;
        }
Example #20
0
        public GraphicsContext(GraphicsDevice Device, Box Viewport)
        {
            this.CoreNum = 6;

            this.Device     = Device;
            this.Viewport   = Viewport;
            this.FrameCount = 0;

            this.ColorBuffer = null;
            this.ZBuffer     = new float[Viewport.Width * Viewport.Height];

            this.Vertices  = new ListCore <Vertex>(this.CoreNum);
            this.Fragments = new ListCore <Fragment>(this.CoreNum);
            this.Indices   = null;

            this.ClearColor         = Colorf.Black;
            this.FillModeState      = FillMode.Solid;
            this.CullFaceModeState  = CullFaceMode.Back;
            this.FrontFaceModeState = FrontFaceMode.CCW;
            this.Shader             = null;
            this.VertexBuffer       = null;
            this.IndexBuffer        = null;
        }
Example #21
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mode"></param>
 /// <param name="enableCapacity">Enable() or Disable() this capacity?</param>
 public CullFaceSwitch(CullFaceMode mode, bool enableCapacity)
     : base(OpenGL.GL_CULL_FACE, enableCapacity)
 {
     this.Init(mode);
 }
Example #22
0
 public CullFaceSwitch(CullFaceMode mode)
     : base(OpenGL.GL_CULL_FACE, true)
 {
     this.Init(mode);
 }
Example #23
0
 public static Reaction <T> Culling <T> (this Reaction <T> render, CullFaceMode mode = CullFaceMode.Back,
                                         FrontFaceDirection frontFace = FrontFaceDirection.Cw)
 {
     return(render.Culling(i => Tuple.Create(mode, frontFace)));
 }
Example #24
0
		public static void SetCullMode(CullFaceMode cull)
		{
			GL.Enable(EnableCap.CullFace);
			GL.CullFace(cull);
		}
Example #25
0
 /// <summary>
 /// Construct a CullFaceState, specifying front face and enabling culling of the specified faces.
 /// </summary>
 /// <param name="frontFace">
 /// A <see cref="FrontFaceDirection"/> that specify how front faces are determined.
 /// </param>
 /// <param name="culledFace">
 /// A <see cref="CullFaceMode"/> that specify which faces are culled.
 /// </param>
 public CullFaceState(FrontFaceDirection frontFace, CullFaceMode culledFace)
 {
     _FrontFaceMode = frontFace;
     _Enabled       = true;
     _CulledFace    = culledFace;
 }
Example #26
0
        public DemoMesh(Demo demo, TriangleMesh triangleMesh, DemoTexture texture, Vector2 textureScale, bool indices, bool indices16Bit, bool flipTriangles, bool flipNormals, bool smoothNormals, CullFaceMode cullMode, bool dynamic, bool scaleNormals)
        {
            this.demo = demo;

            Render = new RenderMeshDeferredPNT();

            meshVertexBuffer  = -1;
            meshIndexBuffer   = -1;
            meshVertices      = null;
            meshIndices16Bit  = null;
            meshIndices32Bit  = null;
            meshIndicesType   = 0;
            this.dynamic      = dynamic;
            this.scaleNormals = scaleNormals;

            SetCullMode(cullMode);
            SetTexture(texture);

            if (indices)
            {
                triangleMesh.GetMeshVertices(flipNormals, smoothNormals, out meshVertices);
                CreateVertexBuffer(meshVertices, dynamic);

                if (indices16Bit)
                {
                    triangleMesh.GetMesh16BitIndices(flipTriangles, out meshIndices16Bit);
                    CreateIndexBuffer(meshIndices16Bit, false);
                }
                else
                {
                    triangleMesh.GetMesh32BitIndices(flipTriangles, out meshIndices32Bit);
                    CreateIndexBuffer(meshIndices32Bit, false);
                }
            }
            else
            {
                triangleMesh.GetMesh(textureScale, flipTriangles, flipNormals, smoothNormals, out meshVertices);
                CreateVertexBuffer(meshVertices, dynamic);
            }
        }
Example #27
0
		/// <summary>
		/// Merge this state with another one.
		/// </summary>
		/// <param name="state">
		/// A <see cref="IGraphicsState"/> having the same <see cref="StateIdentifier"/> of this state.
		/// </param>
		public override void Merge(IGraphicsState state)
		{
			if (state == null)
				throw new ArgumentNullException("state");

			CullFaceState otherState = state as CullFaceState;

			if (otherState == null)
				throw new ArgumentException("not a CullFaceState", "state");

			_FrontFaceMode = otherState._FrontFaceMode;
			_Enabled = otherState._Enabled;
			_CulledFace = otherState._CulledFace;
		}
 /// <summary>
 /// Push a FaceCull flag on the engine's stack.
 /// </summary>
 /// <param name="mode">FaceCull flag.</param>
 public void PushCullFaceMode(CullFaceMode mode)
 {
   UnsafeNativeMethods.CRhinoDisplayPipeline_PushCullFaceMode(m_ptr, (int)mode);
 }
Example #29
0
		/// <summary>
		/// Construct a CullFaceState, enabling front/back face culling (front face is defaulted to CCW).
		/// </summary>
		/// <param name="culledFace">
		/// A <see cref="CullFaceMode"/> that specify which faces are culled.
		/// </param>
		public CullFaceState(CullFaceMode culledFace)
			: this(FrontFaceDirection.Ccw, culledFace)
		{
			
		}
Example #30
0
		/// <summary>
		/// Construct a CullFaceState, specifying front face and enabling culling of the specified faces.
		/// </summary>
		/// <param name="frontFace">
		/// A <see cref="FrontFaceDirection"/> that specify how front faces are determined.
		/// </param>
		/// <param name="culledFace">
		/// A <see cref="CullFaceMode"/> that specify which faces are culled.
		/// </param>
		public CullFaceState(FrontFaceDirection frontFace, CullFaceMode culledFace)
		{
			_FrontFaceMode = frontFace;
			_Enabled = true;
			_CulledFace = culledFace;
		}
Example #31
0
		public static void CullFace(CullFaceMode mode)
		{
#if USE_OPENGL
			if (openGlHardwareAvailable)
			{
				OpenTK.Graphics.OpenGL.GL.CullFace((OpenTK.Graphics.OpenGL.CullFaceMode)mode);
			}
#else
			OpenTK.Graphics.ES11.GL.CullFace((OpenTK.Graphics.ES11.All)mode);
#endif
		}
Example #32
0
 public static void CullMode(CullFaceMode mode)
 {
     GL.Enable(EnableCap.CullFace);
     GL.CullFace(mode);
 }
Example #33
0
 private void Init(CullFaceMode mode)
 {
     this.Mode = mode;
 }
 public static extern void CullFace( CullFaceMode mode );
Example #35
0
 public static void glCullFace(CullFaceMode mode)
 {
     i_OpenGL1_0.glCullFace(mode);
 }
Example #36
0
 /// <summary>
 /// Construct a CullFaceState, enabling front/back face culling (front face is defaulted to CCW).
 /// </summary>
 /// <param name="culledFace">
 /// A <see cref="CullFaceMode"/> that specify which faces are culled.
 /// </param>
 public CullFaceState(CullFaceMode culledFace)
     : this(FrontFaceDirection.Ccw, culledFace)
 {
 }
Example #37
0
 public void SetCullMode(CullFaceMode cullMode)
 {
     meshCullMode = cullMode;
 }
Example #38
0
 public int CreateRenderState(bool enableAlphaBlend = false, bool enableDepthWrite = true, bool enableDepthTest = true, BlendingFactorSrc src = BlendingFactorSrc.Zero, BlendingFactorDest dest = BlendingFactorDest.One, CullFaceMode cullFaceMode = CullFaceMode.Back, bool enableCullFace = true, DepthFunction depthFunction = DepthFunction.Less)
 {
     return RenderSystem.CreateRenderState(enableAlphaBlend, enableDepthWrite, enableDepthTest, src, dest, cullFaceMode, enableCullFace, depthFunction);
 }
Example #39
0
        public DemoMesh(Demo demo, Shape shape, DemoTexture texture, Vector2 textureScale, bool indices, bool indices16Bit, bool flipTriangles, bool flipNormals, bool smoothNormals, CullFaceMode cullMode, bool dynamic, bool scaleNormals)
        {
            this.demo = demo;

            Render = new RenderMeshDeferredPNT();

            meshVertexBuffer  = -1;
            meshIndexBuffer   = -1;
            meshVertices      = null;
            meshIndices16Bit  = null;
            meshIndices32Bit  = null;
            meshIndicesType   = 0;
            this.dynamic      = dynamic;
            this.scaleNormals = scaleNormals;

            SetCullMode(cullMode);
            SetTexture(texture);

            if (indices)
            {
                meshVertices = new VertexPositionNormalTexture[shape.VertexCount];
                shape.GetMeshVertices(textureScale.X, textureScale.Y, flipNormals, smoothNormals, meshVertices);
                CreateVertexBuffer(meshVertices, dynamic);

                if (indices16Bit)
                {
                    meshIndices16Bit = new ushort[shape.IndexCount];
                    shape.GetMesh16BitIndices(flipTriangles, meshIndices16Bit);
                    CreateIndexBuffer(meshIndices16Bit, false);
                }
                else
                {
                    meshIndices32Bit = new int[shape.IndexCount];
                    shape.GetMesh32BitIndices(flipTriangles, meshIndices32Bit);
                    CreateIndexBuffer(meshIndices32Bit, false);
                }
            }
            else
            {
                meshVertices = new VertexPositionNormalTexture[shape.TriangleVertexCount];
                shape.GetMesh(textureScale.X, textureScale.Y, flipTriangles, flipNormals, smoothNormals, meshVertices);
                CreateVertexBuffer(meshVertices, dynamic);
            }
        }
Example #40
0
 private void Init(CullFaceMode mode)
 {
     this.Mode = mode;
 }
        public ChunkMeshRender(Transform transformParent, Mesh mesh, Shader shader, Texture texture)
        {
            isReady   = false;
            _cullType = CullFaceMode.Front;

            transform = transformParent;

            _Mesh = new Mesh(mesh);

            if (_Mesh != null)
            {
                _shader  = shader;
                _texture = texture;

                shader.SetInt("texture0", 0);

                /*if (_shader != null)
                 * {
                 *  _shader.Use();
                 * }*/

                IndiceLength = _Mesh._indices.Length;

                IBO = GL.GenBuffer();
                VAO = GL.GenVertexArray();

                vbo = GL.GenBuffer();
                dbo = GL.GenBuffer();
                tbo = GL.GenBuffer();
                nbo = GL.GenBuffer();

                GL.BindBuffer(BufferTarget.ElementArrayBuffer, IBO);
                GL.BufferData(BufferTarget.ElementArrayBuffer, _Mesh._indices.Length * sizeof(int), _Mesh._indices, BufferUsageHint.StreamDraw);

                GL.BindVertexArray(VAO);

                //Vertices(Vector3)
                GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);
                GL.BufferData(BufferTarget.ArrayBuffer, _Mesh._vertices.Length * Vector3.SizeInBytes, _Mesh._vertices, BufferUsageHint.StreamDraw);
                GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(0);

                //Colors(Vectro4|Color)
                GL.BindBuffer(BufferTarget.ArrayBuffer, dbo);
                GL.BufferData(BufferTarget.ArrayBuffer, _Mesh._Colors.Length * Vector4.SizeInBytes, _Mesh._Colors, BufferUsageHint.StreamDraw);
                GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(1);

                //Texture(Vector2)
                GL.BindBuffer(BufferTarget.ArrayBuffer, tbo);
                GL.BufferData(BufferTarget.ArrayBuffer, _Mesh._texCoords.Length * Vector2.SizeInBytes, _Mesh._texCoords, BufferUsageHint.StreamDraw);
                GL.VertexAttribPointer(2, 2, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(2);

                //Mesh Normals(Vector3)
                GL.BindBuffer(BufferTarget.ArrayBuffer, nbo);
                GL.BufferData(BufferTarget.ArrayBuffer, _Mesh._Normals.Length * Vector3.SizeInBytes, _Mesh._Normals, BufferUsageHint.StreamDraw);
                GL.VertexAttribPointer(3, 3, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(3);

                isReady = true;

                TickSystem.AddRenderItem(this);
            }
        }
Example #42
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mode"></param>
 public CullFaceState(CullFaceMode mode)
     : base(OpenGL.GL_CULL_FACE, true)
 {
     this.Init(mode);
 }
Example #43
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mode"></param>
 /// <param name="enableCapacity">Enable() or Disable() this capacity?</param>
 public CullFaceState(CullFaceMode mode, bool enableCapacity)
     : base(OpenGL.GL_CULL_FACE, enableCapacity)
 {
     this.Init(mode);
 }
Example #44
0
		internal static extern void glCullFace(CullFaceMode mode);
Example #45
0
 public static void CullFace(CullFaceMode mode)
 {
     Instance?.CullFace(mode);
 }
Example #46
0
		public static void CullFace(CullFaceMode mode)
		{
			glCullFace deleg = BaseGraphicsContext.Current.Loader.Get<glCullFace>();
			if (deleg != null)
				deleg(mode);
		}