示例#1
0
        public void Scissor_IsSmashed_BySpock()
        {
            var    gameMatch = new GameMatch();
            string item      = gameMatch.Decide(Scissor.GetInstance(), Spock.GetInstance());

            Assert.AreEqual("Spock", item);
        }
示例#2
0
        public void Scissor_Decapitate_Lizard()
        {
            var    gameMatch = new GameMatch();
            string item      = gameMatch.Decide(Scissor.GetInstance(), Lizard.GetInstance());

            Assert.AreEqual("Scissor", item);
        }
示例#3
0
        public void Scissor_Cuts_Paper()
        {
            var    gameMatch = new GameMatch();
            string item      = gameMatch.Decide(Scissor.GetInstance(), Paper.GetInstance());

            Assert.AreEqual("Scissor", item);
        }
示例#4
0
        public void Lizard_IsDecapitated_ByScissor()
        {
            var    gameMatch = new GameMatch();
            string item      = gameMatch.Decide(Lizard.GetInstance(), Scissor.GetInstance());

            Assert.AreEqual("Scissor", item);
        }
示例#5
0
        public void Scissors_IsCrushed_ByRock()
        {
            var    gameMatch = new GameMatch();
            string item      = gameMatch.Decide(Scissor.GetInstance(), Rock.GetInstance());

            Assert.AreEqual("Rock", item);
        }
示例#6
0
        public void Paper_IsCut_Scissor()
        {
            var    gameMatch = new GameMatch();
            string item      = gameMatch.Decide(Paper.GetInstance(), Scissor.GetInstance());

            Assert.AreEqual("Scissor", item);
        }
示例#7
0
        public void Scissor_Draws_Scissor()
        {
            var    gameMatch = new GameMatch();
            string item      = gameMatch.Decide(Scissor.GetInstance(), Scissor.GetInstance());

            Assert.AreEqual("Draw", item);
        }
示例#8
0
        public void Rock_Crushes_Scissors()
        {
            var    gameMatch = new GameMatch();
            string item      = gameMatch.Decide(Rock.GetInstance(), Scissor.GetInstance());

            Assert.AreEqual("Rock", item);
        }
示例#9
0
    public static void DoGLScissor(Camera cam, float x, float y, float width, float height)
    {
        Rect r = new Rect();

        r.x      = x / 320.0f;
        r.y      = y / 480.0f;
        r.width  = width / 320.0f;
        r.height = height / 480.0f;

        Scissor.SetScissorRect(cam, r);
    }
示例#10
0
        public void testPaperScissorExpectScissorsCutPaper()
        {
            Mock <IRockPaperScissorUi> mockUI           = new Mock <IRockPaperScissorUi>();
            RockPaperScissor           rockpaperscissor = new RockPaperScissor(mockUI.Object);
            Player paper   = new Paper(rockpaperscissor);
            Player scissor = new Scissor(rockpaperscissor);

            rockpaperscissor.play(paper, scissor);

            mockUI.Verify(m => m.updateUI("Scissors Cut Paper"));
        }
示例#11
0
        public void testRockScissorExpectRockCrushesScissors()
        {
            Mock <IRockPaperScissorUi> mockUI           = new Mock <IRockPaperScissorUi>();
            RockPaperScissor           rockpaperscissor = new RockPaperScissor(mockUI.Object);
            Player rock    = new Rock(rockpaperscissor);
            Player scissor = new Scissor(rockpaperscissor);

            rockpaperscissor.play(rock, scissor);

            mockUI.Verify(m => m.updateUI("Rock Crushes Scissor"));
        }
示例#12
0
        private static IEnumerable <TestCaseData> RockPaperScissorCases()
        {
            var rock    = new Rock(static_rockpaperscissor);
            var paper   = new Paper(static_rockpaperscissor);
            var scissor = new Scissor(static_rockpaperscissor);

            yield return(new TestCaseData(rock, paper, "Paper Covers Rock"));

            yield return(new TestCaseData(rock, scissor, "Rock Crushes Scissor"));

            yield return(new TestCaseData(paper, scissor, "Scissor Cuts Paper"));
        }
示例#13
0
    public static void Main(string[] args)
    {
        var paper   = new Paper();
        var rock    = new Rock();
        var scissor = new Scissor();

        Console.WriteLine("paper.Beats(paper) = " + paper.Beats(paper));
        Console.WriteLine("paper.Beats(scissor) = " + paper.Beats(scissor));
        Console.WriteLine("paper.Beats(rock) = " + paper.Beats(rock));
        Console.WriteLine("scissor.Beats(paper) = " + scissor.Beats(paper));
        Console.WriteLine("scissor.Beats(scissor) = " + scissor.Beats(scissor));
        Console.WriteLine("scissor.Beats(rock) = " + scissor.Beats(rock));
        Console.WriteLine("rock.Beats(paper) = " + rock.Beats(paper));
        Console.WriteLine("rock.Beats(scissor) = " + rock.Beats(scissor));
        Console.WriteLine("rock.Beats(rock) = " + rock.Beats(rock));
    }
示例#14
0
        public void Reset()
        {
            Fill               = new Paint(Colour.White);
            Stroke             = new Paint(Colour.Black);
            CompositeOperation = new CompositeOperationState(Blending.CompositeOperation.SourceOver);
            ShapeAntiAlias     = true;
            StrokeWidth        = 1.0f;
            MiterLimit         = 10.0f;
            LineCap            = LineCap.Butt;
            LineJoin           = LineCap.Miter;
            Alpha              = 1.0f;
            Transform          = Matrix3X2 <float> .Identity;

            Scissor = new Scissor(new Vector2D <float>(-1.0f));

            FontSize      = 16.0f;
            LetterSpacing = 0.0f;
            LineHeight    = 1.0f;
            FontBlur      = 0.0f;
            TextAlign     = Align.Left | Align.Baseline;
            FontId        = 0;
        }
示例#15
0
        private static Hand GetPlayerVote(Player player)
        {
            Console.WriteLine($"{player.Name} vote: ");
            var  input = Console.ReadLine();
            Hand vote  = null;
            var  value = int.Parse(input);

            if (value == 1)
            {
                vote = new Rock();
            }
            else if (value == 2)
            {
                vote = new Paper();
            }
            else if (value == 3)
            {
                vote = new Scissor();
            }

            return(vote);
        }
示例#16
0
    void Update()
    {
        if (ready)
        {
            ready = false;
            while (mode == p_mode)
            {
                mode = Random.Range(0, patternCount);
            }
            p_mode = mode;
            // mode = 4;
            Debug.Log(mode);
            switch (mode)
            {
            case 0:
                StartCoroutine(Circle.circle(bullet[mode], this.transform.position));
                break;

            case 1:
                StartCoroutine(MvCircle.mvCircle(bullet[mode], this.transform.position));
                break;

            case 2:
                StartCoroutine(Snipe.mvCircle(bullet[mode], this.transform.position));
                break;

            case 3:
                StartCoroutine(MvCircleR.mvCircleR(bullet[mode], this.transform.position));
                break;

            case 4:
                StartCoroutine(Scissor.scissor(bullet[mode], this.transform.position));
                break;
            }
        }
    }
示例#17
0
    public void SetStudyMaterialVisiblity(StudyMaterial studyMaterial, bool visibleOrNot)
    {
        switch (studyMaterial)
        {
        case StudyMaterial.BoxFilled:
            BoxFilled.SetActive(visibleOrNot);
            break;

        case StudyMaterial.YellowPaper:
            YellowPaper.SetActive(visibleOrNot);
            break;

        case StudyMaterial.BluePaper:
            BluePaper.SetActive(visibleOrNot);
            break;

        case StudyMaterial.WorkSheet:
            WorkSheet.SetActive(visibleOrNot);
            break;

        case StudyMaterial.Book:
            Book.SetActive(visibleOrNot);
            break;

        case StudyMaterial.Tablet:
            Tablet.SetActive(visibleOrNot);
            break;

        case StudyMaterial.NoteBook:
            NoteBook.SetActive(visibleOrNot);
            break;

        case StudyMaterial.OpenBook:
            OpenBook.SetActive(visibleOrNot);
            break;

        case StudyMaterial.PencilBox:
            PencilBox.SetActive(visibleOrNot);
            break;

        case StudyMaterial.Pencil:
            Pencil.SetActive(visibleOrNot);
            break;

        case StudyMaterial.Pen:
            Pen.SetActive(visibleOrNot);
            break;

        case StudyMaterial.LunchBox:
            LunchBox.SetActive(visibleOrNot);
            break;

        case StudyMaterial.MilkBottle:
            MilkBottle.SetActive(visibleOrNot);
            break;

        case StudyMaterial.Bag:
            Bag.SetActive(visibleOrNot);
            break;

        case StudyMaterial.Ruler:
            Ruler.SetActive(visibleOrNot);
            break;

        case StudyMaterial.Eraser:
            Eraser.SetActive(visibleOrNot);
            break;

        case StudyMaterial.Glue:
            Glue.SetActive(visibleOrNot);
            break;

        case StudyMaterial.Scissor:
            Scissor.SetActive(visibleOrNot);
            break;

        case StudyMaterial.RippedPaper:
            RippedPaper.SetActive(visibleOrNot);
            break;

        case StudyMaterial.Apple:
            Apple.SetActive(visibleOrNot);
            break;

        case StudyMaterial.WeeklyPlan:
            WeeklyPlan.SetActive(visibleOrNot);
            break;

        default:
            BluePaper.SetActive(visibleOrNot);
            break;
        }
    }
示例#18
0
    public bool SetStudyMaterialVisiblityAndRetrun(StudyMaterial studyMaterial, bool visibleOrNot)
    {
        switch (studyMaterial)
        {
        case StudyMaterial.BoxFilled:

            if (BoxFilled != null)
            {
                BoxFilled.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.YellowPaper:
            if (YellowPaper != null)
            {
                YellowPaper.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.BluePaper:
            if (BluePaper != null)
            {
                BluePaper.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.WorkSheet:
            if (WorkSheet != null)
            {
                WorkSheet.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.Book:
            if (Book != null)
            {
                Book.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.Tablet:
            if (Tablet != null)
            {
                Tablet.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.NoteBook:
            if (NoteBook != null)
            {
                NoteBook.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.OpenBook:
            if (OpenBook != null)
            {
                OpenBook.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.PencilBox:
            if (PencilBox != null)
            {
                PencilBox.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.Pencil:
            if (Pencil != null)
            {
                Pencil.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.Pen:
            if (Pen != null)
            {
                Pen.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.LunchBox:
            if (LunchBox != null)
            {
                LunchBox.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.MilkBottle:
            if (MilkBottle != null)
            {
                MilkBottle.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.Bag:
            if (Bag != null)
            {
                Bag.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.Ruler:
            if (Ruler != null)
            {
                Ruler.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.Eraser:
            if (Eraser != null)
            {
                Eraser.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.Glue:
            if (Glue != null)
            {
                Glue.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.Scissor:
            if (Scissor != null)
            {
                Scissor.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.RippedPaper:
            if (RippedPaper != null)
            {
                RippedPaper.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        case StudyMaterial.Apple:
            if (Apple != null)
            {
                Apple.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;

        default:
            if (BluePaper != null)
            {
                BluePaper.SetActive(visibleOrNot);
            }
            else
            {
                return(false);
            }
            break;
        }
        return(true);
    }
示例#19
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
		}
示例#20
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
        }
示例#21
0
        public FragUniforms(Paint paint, Scissor scissor, float width, float fringe, float strokeThr, VulkanRenderer renderer)
        {
            Matrix3X2 <float> invtransform;

            _innerCol = paint.InnerColour.Premult();
            _outerCol = paint.OuterColour.Premult();

            if (scissor.Extent.X < -0.5f || scissor.Extent.Y < -0.5f)
            {
                _scissorMat   = new Matrix3X4 <float>();
                _scissorExt   = new Vector2D <float>(1.0f);
                _scissorScale = new Vector2D <float>(1.0f);
            }
            else
            {
                _             = Matrix3X2.Invert(scissor.Transform, out invtransform);
                _scissorMat   = new Matrix3X4 <float>(invtransform);
                _scissorExt   = scissor.Extent;
                _scissorScale = new Vector2D <float>(
                    MathF.Sqrt(scissor.Transform.M11 * scissor.Transform.M11 + scissor.Transform.M21 * scissor.Transform.M21) / fringe,
                    MathF.Sqrt(scissor.Transform.M21 * scissor.Transform.M21 + scissor.Transform.M22 * scissor.Transform.M22) / fringe
                    );
            }

            _extent     = paint.Extent;
            _strokeMult = (width * 0.5f + fringe * 0.5f) / fringe;
            _strokeThr  = strokeThr;

            if (paint.Image != 0)
            {
                ref var tex = ref renderer.TextureManager.FindTexture(paint.Image);
                if (tex.Id == 0)
                {
                    _type    = (int)ShaderType.Fillgrad;
                    _radius  = paint.Radius;
                    _feather = paint.Feather;
                    _texType = 0;

                    _ = Matrix3X2.Invert(paint.Transform, out invtransform);
                }
                else
                {
                    if (tex.HasFlag(ImageFlags.FlipY))
                    {
                        Matrix3X2 <float> m1, m2;
                        m1 = Matrix3X2.CreateTranslation(new Vector2D <float>(0.0f, _extent.Y * 0.5f));
                        m1 = Transforms.NvgTransforms.Multiply(m1, paint.Transform);
                        m2 = Matrix3X2.CreateScale(new Vector2D <float>(1.0f, -1.0f));
                        m2 = Transforms.NvgTransforms.Multiply(m2, m1);
                        m1 = Matrix3X2.CreateTranslation(new Vector2D <float>(0.0f, -_extent.Y * 0.5f));
                        m1 = Transforms.NvgTransforms.Multiply(m1, m2);
                        _  = Matrix3X2.Invert(m1, out invtransform);
                    }
                    else
                    {
                        _ = Matrix3X2.Invert(paint.Transform, out invtransform);
                    }
                    _type = (int)ShaderType.FillImg;

                    if (tex.TextureType == Texture.Rgba)
                    {
                        _texType = tex.HasFlag(ImageFlags.Premultiplied) ? 0 : 1;
                    }
                    else
                    {
                        _texType = 2;
                    }

                    _radius = _feather = 0.0f;
                }
            }
示例#22
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
        }
示例#23
0
 public Outcome GetOutcome(Scissor scissor)
 {
     return(Outcome.TIE);
 }
示例#24
0
        /* END STRING MARKER FUNCTIONS */
#endif

        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)
                    );
                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.
             * While we do not directly call glVertexAttribDivisor ourselves,
             * we still need to check for ARB_instanced_arrays support.
             * -flibit
             */
            SupportsHardwareInstancing = SDL.SDL_GL_GetProcAddress("glVertexAttribDivisor") != IntPtr.Zero;
            try
            {
                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 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
        }
示例#25
0
    public void HideByDefaultStudyMaterials()
    {
        if (BoxFilled != null)
        {
            BoxFilled.SetActive(false);
        }
        if (YellowPaper != null)
        {
            YellowPaper.SetActive(false);
        }
        if (BluePaper != null)
        {
            BluePaper.SetActive(false);
        }
        if (WorkSheet != null)
        {
            WorkSheet.SetActive(false);
        }
        if (NoteBook != null)
        {
            NoteBook.SetActive(false);
        }
        if (Tablet != null)
        {
            Tablet.SetActive(false);
        }
        if (Book != null)
        {
            Book.SetActive(false);
        }
        if (OpenBook != null)
        {
            OpenBook.SetActive(false);
        }
        if (PencilBox != null)
        {
            PencilBox.SetActive(false);
        }
        if (Pencil != null)
        {
            Pencil.SetActive(false);
        }
        if (Pen != null)
        {
            Pen.SetActive(false);
        }
        if (LunchBox != null)
        {
            LunchBox.SetActive(false);
        }
        if (MilkBottle != null)
        {
            MilkBottle.SetActive(false);
        }
        if (Bag != null)
        {
            Bag.SetActive(false);
        }
        if (Ruler != null)
        {
            Ruler.SetActive(false);
        }
        if (Eraser != null)
        {
            Eraser.SetActive(false);
        }
        if (Glue != null)
        {
            Glue.SetActive(false);
        }
        if (Scissor != null)
        {
            Scissor.SetActive(false);
        }
        if (RippedPaper != null)
        {
            RippedPaper.SetActive(false);
        }
        if (Apple != null)
        {
            Apple.SetActive(false);
        }

        if (WeeklyPlan != null)
        {
            WeeklyPlan.SetActive(false);
        }
    }
示例#26
0
    public void RandomlyShowOrHideStudyMaterialsOnDesk()
    {
        int yesOrNo;

        if (BoxFilled != null)
        {
            yesOrNo = Random.Range(0, 11) % 2;
            if (yesOrNo == 1)
            {
                BoxFilled.SetActive(true);
            }
            else
            {
                BoxFilled.SetActive(false);
            }
        }
        if (NoteBook != null)
        {
            yesOrNo = Random.Range(0, 11) % 2;
            if (yesOrNo == 1)
            {
                NoteBook.SetActive(true);
            }
            else
            {
                NoteBook.SetActive(false);
            }
        }
        if (Tablet != null)
        {
            yesOrNo = Random.Range(0, 11) % 2;
            if (yesOrNo == 1)
            {
                Tablet.SetActive(true);
            }
            else
            {
                Tablet.SetActive(false);
            }
        }
        if (Book != null)
        {
            yesOrNo = Random.Range(0, 11) % 2;
            if (yesOrNo == 1)
            {
                Book.SetActive(true);
            }
            else
            {
                Book.SetActive(false);
            }
        }
        if (PencilBox != null)
        {
            yesOrNo = Random.Range(0, 11) % 2;
            if (yesOrNo == 1)
            {
                PencilBox.SetActive(true);
            }
            else
            {
                PencilBox.SetActive(false);
            }
        }
        if (Pencil != null)
        {
            yesOrNo = Random.Range(0, 11) % 2;
            if (yesOrNo == 1)
            {
                Pencil.SetActive(true);
            }
            else
            {
                Pencil.SetActive(false);
            }
        }
        if (Pen != null)
        {
            yesOrNo = Random.Range(0, 11) % 2;
            if (yesOrNo == 1)
            {
                Pen.SetActive(true);
            }
            else
            {
                Pen.SetActive(false);
            }
        }
        if (LunchBox != null)
        {
            yesOrNo = Random.Range(0, 11) % 2;
            if (yesOrNo == 1)
            {
                LunchBox.SetActive(true);
            }
            else
            {
                LunchBox.SetActive(false);
            }
        }
        if (MilkBottle != null)
        {
            yesOrNo = Random.Range(0, 11) % 2;
            if (yesOrNo == 1)
            {
                MilkBottle.SetActive(true);
            }
            else
            {
                MilkBottle.SetActive(false);
            }
        }
        if (Ruler != null)
        {
            yesOrNo = Random.Range(0, 11) % 2;
            if (yesOrNo == 1)
            {
                Ruler.SetActive(true);
            }
            else
            {
                Ruler.SetActive(false);
            }
        }
        if (Eraser != null)
        {
            yesOrNo = Random.Range(0, 11) % 2;
            if (yesOrNo == 1)
            {
                Eraser.SetActive(true);
            }
            else
            {
                Eraser.SetActive(false);
            }
        }
        if (Glue != null)
        {
            yesOrNo = Random.Range(0, 11) % 2;
            if (yesOrNo == 1)
            {
                Glue.SetActive(true);
            }
            else
            {
                Glue.SetActive(false);
            }
        }
        if (Scissor != null)
        {
            yesOrNo = Random.Range(0, 11) % 2;
            if (yesOrNo == 1)
            {
                Scissor.SetActive(true);
            }
            else
            {
                Scissor.SetActive(false);
            }
        }
        if (Apple != null)
        {
            yesOrNo = Random.Range(0, 11) % 2;
            if (yesOrNo == 1)
            {
                Apple.SetActive(true);
            }
            else
            {
                Apple.SetActive(false);
            }
        }
    }
示例#27
0
文件: BFLYT.cs 项目: xnqdev/Lyzon
        public void ReadSections(ref BinaryStream s)
        {
            SectionHeader section = new SectionHeader(ref s);

            currentSection = section;

            s.BaseStream.Position -= 8;

            switch (section.signature)
            {
            case "lyt1":
                layoutSettings = new LayoutSettings(ref s);

                System.Windows.Forms.MessageBox.Show($"Read Layout Settings [{section.signature}]");

                layoutSettings.sectionHeader = section;
                break;

            case "txl1":
                textureList = new TextureList(ref s);

                System.Windows.Forms.MessageBox.Show($"Read Texture List [{section.signature}]");

                layoutSettings.sectionHeader = section;
                break;

            case "fnl1":
                fontList = new FontList(ref s);

                System.Windows.Forms.MessageBox.Show($"Read Font List [{section.signature}]");

                layoutSettings.sectionHeader = section;
                break;

            case "mat1":
                materialList = new MaterialList(ref s);

                System.Windows.Forms.MessageBox.Show($"Read Material List [{section.signature}]");

                layoutSettings.sectionHeader = section;
                break;

            case "pan1":
                Pane pane = new Pane(ref s);

                if (rootPane == null)
                {
                    rootPane = pane;
                }

                if (parentPane != null)
                {
                    if (parentPane.children == null)
                    {
                        parentPane.children = new List <dynamic>();
                    }

                    parentPane.children.Add(pane);

                    pane.parent = parentPane;
                }

                lastPane = pane;

                System.Windows.Forms.MessageBox.Show($"Read Pane [{section.signature}]");

                lastPane.sectionHeader = section;
                break;

            case "pic1":
                Picture pic = new Picture(ref s);

                if (parentPane != null)
                {
                    if (parentPane.children == null)
                    {
                        parentPane.children = new List <dynamic>();
                    }

                    parentPane.children.Add(pic);

                    pic.parent = parentPane;
                }

                lastPane = pic;

                System.Windows.Forms.MessageBox.Show($"Read Picture Pane [{section.signature}]");

                lastPane.sectionHeader = section;
                break;

            case "txt1":
                TextBox txt = new TextBox(ref s);

                if (parentPane != null)
                {
                    if (parentPane.children == null)
                    {
                        parentPane.children = new List <dynamic>();
                    }

                    parentPane.children.Add(txt);

                    txt.parent = parentPane;
                }

                lastPane = txt;

                System.Windows.Forms.MessageBox.Show($"Read TextBox Pane [{section.signature}]");

                lastPane.sectionHeader = section;
                break;

            case "wnd1":
                Window wnd = new Window(ref s);

                if (parentPane != null)
                {
                    if (parentPane.children == null)
                    {
                        parentPane.children = new List <dynamic>();
                    }

                    parentPane.children.Add(wnd);

                    wnd.parent = parentPane;
                }

                lastPane = wnd;

                System.Windows.Forms.MessageBox.Show($"Read Window Pane [{section.signature}]");

                lastPane.sectionHeader = section;
                break;

            case "bnd1":
                Bounding bnd = new Bounding(ref s);

                if (parentPane != null)
                {
                    if (parentPane.children == null)
                    {
                        parentPane.children = new List <dynamic>();
                    }

                    parentPane.children.Add(bnd);

                    bnd.parent = parentPane;
                }

                lastPane = bnd;

                System.Windows.Forms.MessageBox.Show($"Read Bounding Pane [{section.signature}]");

                lastPane.sectionHeader = section;
                break;

            case "cpt1":
                Capture cpt = new Capture(ref s);

                if (parentPane != null)
                {
                    if (parentPane.children == null)
                    {
                        parentPane.children = new List <dynamic>();
                    }

                    parentPane.children.Add(cpt);

                    cpt.parent = parentPane;
                }

                lastPane = cpt;

                System.Windows.Forms.MessageBox.Show($"Read Capture Pane [{section.signature}]");

                lastPane.sectionHeader = section;
                break;

            case "prt1":
                s.ReadBytes(section.size);
                break;

            case "ali1":
                Alignment ali = new Alignment(ref s);     // Read Alignment Pane later

                if (parentPane != null)
                {
                    if (parentPane.children == null)
                    {
                        parentPane.children = new List <dynamic>();
                    }

                    parentPane.children.Add(ali);

                    ali.parent = parentPane;
                }

                lastPane = ali;

                System.Windows.Forms.MessageBox.Show($"Read Alignment Pane [{section.signature}]");

                lastPane.sectionHeader = section;
                break;

            case "scr1":
                Scissor scr = new Scissor(ref s);

                if (parentPane != null)
                {
                    if (parentPane.children == null)
                    {
                        parentPane.children = new List <dynamic>();
                    }

                    parentPane.children.Add(scr);

                    scr.parent = parentPane;
                }

                lastPane = scr;

                System.Windows.Forms.MessageBox.Show($"Read Scissor Pane [{section.signature}]");

                lastPane.sectionHeader = section;
                break;

            case "pas1":
                if (lastPane != null)
                {
                    parentPane = lastPane;
                }

                s.ReadBytes(8);
                break;

            case "pae1":
                lastPane   = parentPane;
                parentPane = lastPane != null ? lastPane.parent : null;

                s.ReadBytes(8);
                break;

            case "grp1":
                Group group = new Group(ref s);

                if (rootGroup == null)
                {
                    rootGroup = group;
                }

                if (parentGroup != null)
                {
                    if (parentGroup.children == null)
                    {
                        parentGroup.children = new List <Group>();
                    }

                    parentGroup.children.Add(group);

                    group.parent = parentGroup;
                }

                lastGroup = group;

                System.Windows.Forms.MessageBox.Show($"Read Group [{section.signature}]");

                lastGroup.sectionHeader = section;
                break;

            case "grs1":
                if (lastGroup != null)
                {
                    parentGroup = lastGroup;
                }

                s.ReadBytes(8);
                break;

            case "gre1":
                lastGroup   = parentGroup;
                parentGroup = lastGroup != null ? lastGroup.parent : null;

                s.ReadBytes(8);
                break;

            case "usd1":     // Temporary
                s.ReadBytes(section.size);
                break;

            case "cnt1":     // Temporary
                s.ReadBytes(section.size);
                break;
            }
        }