예제 #1
0
        public void Check()
        {
            var flush = new Flush(hand, desk);

            flush.Check();

            if (flush.Probability != 100 || NotInOrder(flush.CardList))
            {
                Probability = (int)GetOddsPercentage(GetOuts().Count());
                var color = GetDominatingColor();
                CardList = tempHand.Where(p => p.Color == color && p.Figure >= CardFigure._10).ToList();
                return;
            }

            if (flush.CardList.Any(x => x.Figure == CardFigure._As))
            {
                Probability = 100;
                var color = GetDominatingColor();
                CardList = GetRFByColor(color);
            }
            else
            {
                var sf = new StraightFlush(hand, desk);
                sf.Check();
                CardList    = sf.CardList;
                Probability = (int)GetOddsPercentage(GetOuts().Count());
            }
        }
예제 #2
0
        public void Constructor_WithMultipleValidFlushSetsInHand_StoresOnlyHighestValueSortedFlushCards()
        {
            List <Card> cards = new List <Card>
            {
                new Card(CardValue.Five, Suit.Club),
                new Card(CardValue.Six, Suit.Club),
                new Card(CardValue.Seven, Suit.Club),
                new Card(CardValue.Nine, Suit.Club),
                new Card(CardValue.Jack, Suit.Club),
                new Card(CardValue.Four, Suit.Heart),
                new Card(CardValue.Six, Suit.Heart),
                new Card(CardValue.Seven, Suit.Heart),
                new Card(CardValue.Nine, Suit.Heart),
                new Card(CardValue.Jack, Suit.Heart)
            };

            Flush hand = new Flush(cards);

            Assert.AreEqual(hand.flushCards.Count, 5);
            Assert.AreEqual(hand.flushCards[0].Value, CardValue.Jack);
            Assert.AreEqual(hand.flushCards[1].Value, CardValue.Nine);
            Assert.AreEqual(hand.flushCards[2].Value, CardValue.Seven);
            Assert.AreEqual(hand.flushCards[3].Value, CardValue.Six);
            Assert.AreEqual(hand.flushCards[4].Value, CardValue.Five);

            foreach (Card card in hand.flushCards)
            {
                Assert.AreEqual(card.Suit, Suit.Club);
            }
        }
예제 #3
0
        public void Test_Flush_CreateInstance(string strCards, bool isValid)
        {
            var cards = Utils.ParseCards(strCards);
            var flush = Flush.CreateInstance(cards);

            CreateInstanceHelper(flush, HandRanks.Flush, cards, isValid);
        }
예제 #4
0
        public void test_scores()
        {
            var highCard = new HighCard();

            Assert.AreEqual(0, highCard.Score);
            var onePair = new OnePair();

            Assert.AreEqual(1, onePair.Score);
            var twoPairs = new TwoPairs();

            Assert.AreEqual(2, twoPairs.Score);
            var set = new Set();

            Assert.AreEqual(3, set.Score);
            var straight = new Straight();

            Assert.AreEqual(4, straight.Score);
            var flush = new Flush();

            Assert.AreEqual(5, flush.Score);
            var fullHouse = new FullHouse();

            Assert.AreEqual(6, fullHouse.Score);
            var quads = new Quads();

            Assert.AreEqual(7, quads.Score);
            var straightFlush = new StraightFlush();

            Assert.AreEqual(8, straightFlush.Score);
            var royalFlush = new RoyalFlush();

            Assert.AreEqual(9, royalFlush.Score);
        }
예제 #5
0
        public bool Calculate(IPokerHand hand)
        {
            var straight = new Straight(hand);
            var flush    = new Flush(hand);

            return(straight.IsHighRank && flush.IsHighRank);
        }
예제 #6
0
        public void Constructor_WithMoreCardsThanNeededCardsForFlush_StoresOnlyHighestValueSortedFlushCards()
        {
            List <Card> cards = new List <Card>
            {
                new Card(CardValue.Two, Suit.Spade),
                new Card(CardValue.Three, Suit.Club),
                new Card(CardValue.Five, Suit.Club),
                new Card(CardValue.Six, Suit.Club),
                new Card(CardValue.Seven, Suit.Club),
                new Card(CardValue.Seven, Suit.Diamond),
                new Card(CardValue.Nine, Suit.Club),
                new Card(CardValue.Jack, Suit.Club),
                new Card(CardValue.Queen, Suit.Heart)
            };
            Flush hand = new Flush(cards);

            Assert.AreEqual(hand.flushCards.Count, 5);
            Assert.AreEqual(hand.flushCards[0].Value, CardValue.Jack);
            Assert.AreEqual(hand.flushCards[1].Value, CardValue.Nine);
            Assert.AreEqual(hand.flushCards[2].Value, CardValue.Seven);
            Assert.AreEqual(hand.flushCards[3].Value, CardValue.Six);
            Assert.AreEqual(hand.flushCards[4].Value, CardValue.Five);

            foreach (Card card in hand.flushCards)
            {
                Assert.AreEqual(card.Suit, Suit.Club);
            }
        }
예제 #7
0
        public void Flush(string documentname, int copies)
        {
            PrinterServiceFunction f = new Flush(this);

            f.AddParameter("documentName", documentname);
            f.AddParameter("copies", copies);
            f.RunFunction();
        }
예제 #8
0
        public void ShouldSayIfAllCardsAreTheSameSuit()
        {
            Hand  theHand = new Hand("7H, 8H, 10H, JH, 4H");
            Flush flush   = new Flush();
            var   result  = flush.IsTypeOf(theHand);

            Assert.That(result, Is.EqualTo(true));
        }
예제 #9
0
        public void GivenHandCardThenCheckIfFlush(string handCard, bool expectedResult)
        {
            var handCardFormatted = Common.ConvertCardStringToList(handCard);

            var isStraightFlush = new Flush().IsThisType(handCardFormatted);

            Assert.True(isStraightFlush == expectedResult);
        }
예제 #10
0
        public void CompareTo_WithIdenticalFlushHands_ReturnsZero()
        {
            List <Card> cards = TestUtil.CreateTestFlushCards(Suit.Club, new int[] { 13, 10, 3, 5, 4 });
            Flush       hand1 = new Flush(cards);
            Flush       hand2 = new Flush(cards);

            Assert.AreEqual(hand1.CompareTo(hand2), 0);
        }
예제 #11
0
        public void CompareTo_WithLargeHands_ThatAreIdentical_ReturnsZero()
        {
            List <Card> cards = TestUtil.CreateTestFlushCards(Suit.Club, new int[] { 13, 12, 11, 9, 8, 6, 5, 4, 2, 1 });
            Flush       hand1 = new Flush(cards);
            Flush       hand2 = new Flush(cards);

            Assert.IsTrue(hand1.CompareTo(hand2) == 0);
        }
예제 #12
0
        public void CompareTo_ComparingAgainstNonFlushHand_ThrowsException()
        {
            List <Card> cards1    = TestUtil.CreateTestFlushCards(Suit.Club, new int[] { 10, 13, 3, 5, 4 });
            Flush       flushHand = new Flush(cards1);
            List <Card> cards2    = TestUtil.CreateDefaultPairCards();
            Pair        pairHand  = new Pair(cards2);

            Assert.ThrowsException <Exception>(() => flushHand.CompareTo(pairHand));
        }
예제 #13
0
        public void CompareTo_WithLargeHands_ThatHaveIdenticalHighestValues_ReturnsZero()
        {
            List <Card> cards1 = TestUtil.CreateTestFlushCards(Suit.Club, new int[] { 13, 12, 11, 9, 8, 6, 5, 4, 2, 1 });
            Flush       hand1  = new Flush(cards1);
            List <Card> cards2 = TestUtil.CreateTestFlushCards(Suit.Heart, new int[] { 13, 12, 11, 9, 8, 7, 5, 4, 3, 1 });
            Flush       hand2  = new Flush(cards2);

            Assert.IsTrue(hand1.CompareTo(hand2) == 0);
        }
예제 #14
0
        public bool IsTypeOf(Hand theHand)
        {
            var straight   = new Straight();
            var flush      = new Flush();
            var isStraight = straight.IsTypeOf(theHand);
            var isFlush    = flush.IsTypeOf(theHand);

            return(isStraight && isFlush);
        }
예제 #15
0
        public void CompareTo_WithEquivalentFlushHands_ReturnsZero()
        {
            List <Card> cards1 = TestUtil.CreateTestFlushCards(Suit.Club, new int[] { 13, 10, 3, 5, 4 });
            Flush       hand1  = new Flush(cards1);

            List <Card> cards2 = TestUtil.CreateTestFlushCards(Suit.Heart, new int[] { 4, 3, 5, 10, 13 });
            Flush       hand2  = new Flush(cards2);

            Assert.AreEqual(hand1.CompareTo(hand2), 0);
        }
예제 #16
0
        public void Test_Flush_ComparableTests(string strInputA, string strInputB, int comp)
        {
            var cardsA = Utils.ParseCards(strInputA);
            var cardsB = Utils.ParseCards(strInputB);

            var flushOne = Flush.CreateInstance(cardsA);
            var flushTwo = Flush.CreateInstance(cardsB);

            ComparableTestsHelper(flushOne, flushTwo, comp);
        }
예제 #17
0
        public void Test_Flush_EqualityOperators(string strInputA, string strInputB, bool areEqual)
        {
            var cardsA = Utils.ParseCards(strInputA);
            var cardsB = Utils.ParseCards(strInputB);

            var flushOne = Flush.CreateInstance(cardsA);
            var flushTwo = Flush.CreateInstance(cardsB);

            EqualityOperatorsHelper(flushOne, flushTwo, areEqual);
        }
예제 #18
0
        /// <summary>
        /// Sends Flush message.
        /// </summary>
        public void Flush()
        {
            byte[] serialized;

            var message = new Flush {
            };
            {
                serialized = message.Serialize(); Writer.Write(serialized.Length); Writer.Write(serialized);
            }
        }
예제 #19
0
        public async Task InsertFlush(Flush flush)
        {   //UPDATE HEALTH AND PERFORMANCE CALCULATION
            flush.Health       = 100;
            flush.Performance  = 100;
            flush.CreationDate = DateTime.Now;

            await _unitOfWork.FlushRepository.Insert(flush);

            await _unitOfWork.SaveChangesAsync();
        }
예제 #20
0
        public void CompareTo_WithDifferentFlushHands_ReturnsNonZero()
        {
            List <Card> cards1 = TestUtil.CreateTestFlushCards(Suit.Club, new int[] { 10, 9, 5, 4, 3 });
            Flush       hand1  = new Flush(cards1);

            List <Card> cards2 = TestUtil.CreateTestFlushCards(Suit.Heart, new int[] { 10, 8, 6, 4, 3 });
            Flush       hand2  = new Flush(cards2);

            Assert.IsTrue(hand1.CompareTo(hand2) > 0);
            Assert.IsTrue(hand2.CompareTo(hand1) < 0);
        }
예제 #21
0
        public void Constructor_WithValidCardsForFlush_StoresSortedFlushCards()
        {
            List <Card> cards = TestUtil.CreateTestFlushCards(Suit.Club, new int[] { 10, 13, 3, 5, 4 });
            Flush       hand  = new Flush(cards);

            Assert.AreEqual(hand.flushCards[0].Value, CardValue.Ace);
            Assert.AreEqual(hand.flushCards[1].Value, CardValue.Jack);
            Assert.AreEqual(hand.flushCards[2].Value, CardValue.Six);
            Assert.AreEqual(hand.flushCards[3].Value, CardValue.Five);
            Assert.AreEqual(hand.flushCards[4].Value, CardValue.Four);
        }
예제 #22
0
            public void Hearths()
            {
                // ARRANGE
                var game = Helper.HearthsFlush();

                // ACT
                var result = new Flush().Evaluate(game);

                // ASSERT
                Assert.IsTrue(result.Success());
                Assert.AreSame(game.Cards, result.UsedCards);
            }
예제 #23
0
            public void Hearths()
            {
                // ARRANGE
                var game = Helper.HearthsFlush();

                // ACT
                var result = new Flush().Evaluate(game);

                // ASSERT
                Assert.IsTrue(result.Success());
                Assert.AreSame(game.Cards, result.UsedCards);
            }
예제 #24
0
 void on_flush(Flush flush_msg)
 {
     if (!string.IsNullOrEmpty(flush_msg.StreamName))
     {
         GetPipeline(flush_msg.StreamName).flush();
     }
     else
     {
         foreach (var kv in pipelines_)
         {
             kv.Value.flush();
         }
     }
 }
예제 #25
0
        public void HandFlushTestDuplicate()
        {
            //Arrange
            List <Card> cards = new List <Card>();

            cards.Add(new Card(Suits.Clubes, "A"));
            cards.Add(new Card(Suits.Clubes, "A"));

            //Act
            Flush hand = new Flush();

            //Assert
            Assert.ThrowsException <InvalidOperationException>(() => hand.IsMatch(cards));
        }
예제 #26
0
        public void Constructor_WithInvalidCardsForFlush_ThrowsException()
        {
            List <Card> cards = new List <Card>
            {
                new Card(CardValue.Five, Suit.Club),
                new Card(CardValue.Seven, Suit.Club),
                new Card(CardValue.Nine, Suit.Club),
                new Card(CardValue.Jack, Suit.Club),
                new Card(CardValue.Queen, Suit.Heart)
            };
            Flush hand;

            Assert.ThrowsException <Exception>(() => { hand = new Flush(cards); });
        }
예제 #27
0
        public override int GetHashCode()
        {
            var result = Flush.GetHashCode();

            result = result
                     ^ (Mode.GetHashCode() ^ 1); // power of two for every other field(^1, ^2, ^4, ^8, ^16, ...)

            if (SelectedItem != null)
            {
                result ^= SelectedItem.GetHashCode();
            }

            return(result);
        }
예제 #28
0
파일: Test.cs 프로젝트: PChiesa/Poker
        public void IsFlush()
        {
            _cardHand = new List <Card> {
                new Card(CardRank.Eight, CardSuit.Spades),
                new Card(CardRank.Two, CardSuit.Spades),
                new Card(CardRank.Ten, CardSuit.Spades),
                new Card(CardRank.Ace, CardSuit.Spades),
                new Card(CardRank.Three, CardSuit.Spades)
            };

            var hand = new Flush();

            Assert.IsTrue(hand.HasHand(_cardHand));
        }
예제 #29
0
        public void Test_Flush_EqualityOperators_ForNull()
        {
            var cards = Utils.ParseCards("3D 5D 7D 9D JD");
            var flush = Flush.CreateInstance(cards);

            Assert.False(flush.Equals(null));

            Assert.True((Flush)null == (Flush)null);
            Assert.False((Flush)null == flush);
            Assert.False(flush == (Flush)null);

            Assert.False((Flush)null != (Flush)null);
            Assert.True((Flush)null != flush);
            Assert.True(flush != (Flush)null);
        }
예제 #30
0
        public void flush_no2()
        {
            var set   = new Flush();
            var cards = new List <Card>
            {
                new Card(Suit.Clubs, Rank.Eight),
                new Card(Suit.Diamonds, Rank.Eight),
                new Card(Suit.Hearts, Rank.Eight),
                new Card(Suit.Spades, Rank.Seven)
            };

            set.SetCards(cards);
            var result = set.IsPresent();

            Assert.IsFalse(result);
        }
예제 #31
0
        public void flush_no()
        {
            var set   = new Flush();
            var cards = new List <Card>
            {
                new Card(Suit.Clubs, Rank.Ace),
                new Card(Suit.Clubs, Rank.Seven),
                new Card(Suit.Clubs, Rank.King),
                new Card(Suit.Clubs, Rank.Ten),
                new Card(Suit.Spades, Rank.Seven)
            };

            set.SetCards(cards);
            var result = set.IsPresent();

            Assert.IsFalse(result);
        }
예제 #32
0
            public void NoHearthsFlushByOneCard()
            {
                // ARRANGE
                var cards = Helper.HearthsFlush().Cards.ToArray();

                var game = new Game(
                    cards[0],
                    cards[1],
                    cards[2],
                    cards[3],
                    new Card(cards[4].Rank, Suit.CLUBS));

                // ACT
                var result = new Flush().Evaluate(game);

                // ASSERT
                Assert.IsFalse(result.Success());
            }
예제 #33
0
 public static unsafe CompressStatus Compress2(CompressionHandle state, byte[] inBuf, ref int inBufSize, int inBufOffset, byte[] outBuf, ref int outBufSize, int outBufOffset, Flush flushType)
 {
     if (inBufOffset + inBufSize > inBuf.Length)
     {
         throw new ArgumentException("Offset plus count is larger than the length of array", nameof(inBuf));
     }
     if (outBufOffset + outBufSize > outBuf.Length)
     {
         throw new ArgumentException("Offset plus count is larger than the length of array", nameof(outBuf));
     }
     fixed (byte* inBytes = inBuf)
     fixed (byte* outBytes = outBuf)
     {
         IntPtr inSize = new IntPtr(inBufSize);
         IntPtr outSize = new IntPtr(outBufSize);
         CompressStatus result = (CompressStatus)lzham_compress2(state, inBytes+inBufOffset, ref inSize, outBytes+outBufOffset, ref outSize, flushType);
         inBufSize = inSize.ToInt32();
         outBufSize = outSize.ToInt32();
         return result;
     }
 }
예제 #34
0
 private static extern unsafe int lzham_compress2(CompressionHandle state, byte* inBuf, ref IntPtr inBufSize, byte* outBuf,
     ref IntPtr outBufSize, Flush flushType);
예제 #35
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
        }