Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Draw()
- {
- if (TitleScreen == true)
- {
- GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- GL.glBindTexture(GL.GL_TEXTURE_2D, m_TextureIDs[0]);
- DrawClouds();
- //System.Threading.Thread.Sleep(1000);
- DrawString(100, 575, "PROTECT THE PIE!", 0);
- DrawString(500, 575, "Press 'P' to Play", 0);
- DrawString(1000, 575, "Press 'E' to Exit", 0);
- }
- if (GamePlay == true)
- {
- GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- DrawPicnicMat();
- DrawPieMask();
- DrawPie();
- DrawFly();
- DrawString(520, 825, "Protect The Pie!", 0);
- DrawString(75, 65, "Score:", 0);
- DrawString(900, 65, "Flies Killed:", 0);
- }
- }
- public void DrawString(int x, int y, string str, int charSet)
- {
- GL.glEnable(GL.GL_BLEND);
- GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE);
- //GL.glEnable(GL.GL_TEXTURE_2D);
- if (charSet > 1) { charSet = 1; }
- GL.glBindTexture(GL.GL_TEXTURE_2D, m_TextureIDs[1]);// Select Our Font Texture
- GL.glDisable(GL.GL_DEPTH_TEST);// Disables Depth Testing
- GL.glMatrixMode(GL.GL_PROJECTION);// Select The Projection Matrix
- GL.glPushMatrix();// Store The Projection Matrix
- GL.glLoadIdentity();// Reset The Projection Matrix
- GL.glOrtho(0, m_ScreenWidth, 0, m_ScreenHeight, 0, 10);// Set Up An Ortho
- // Screen with the same dimensions as the screen
- GL.glMatrixMode(GL.GL_MODELVIEW);// Select The Modelview Matrix
- GL.glPushMatrix();// Store The Modelview Matrix
- GL.glLoadIdentity();// Reset The Modelview Matrix
- GL.glTranslated(x, y, 0);// Position The Text (0,0 - Bottom Left)
- // Choose The Font Set (0 or 1)
- GL.glListBase((uint)(BaseList - 32 + (128 * charSet)));
- object[] t = new object[str.Length];// Convert string to an array of objects
- for (int i = 0; i < str.Length; i++)
- {
- t[i] = str[i];
- }
- GL.glEnable(GL.GL_BLEND);
- // Write The Text To The Screen
- GL.glCallLists(str.Length * 4, GL.GL_UNSIGNED_int, t);
- GL.glDisable(GL.GL_BLEND);
- GL.glMatrixMode(GL.GL_PROJECTION);// Select The Projection Matrix
- GL.glPopMatrix();// Restore The Old Projection Matrix
- GL.glMatrixMode(GL.GL_MODELVIEW);// Select The Modelview Matrix
- GL.glPopMatrix();// Restore The Old Projection Matrix
- GL.glEnable(GL.GL_DEPTH_TEST);// Enables Depth Testing
- }
- public void TextInitialise()
- {
- float cx, cy;
- BaseList = GL.glGenLists(256);
- GL.glBindTexture(GL.GL_TEXTURE_2D, this.m_TextureIDs[1]);
- //Select font Texture\\
- Bitmap image = new Bitmap("C:\\Users\\Emma Challis\\Desktop\\Project12\\Project1\\font.bmp");
- image.RotateFlip(RotateFlipType.RotateNoneFlipY);
- System.Drawing.Imaging.BitmapData bitmapdata;
- Rectangle rect = new Rectangle(0, 0, image.Width, image.Height);
- bitmapdata = image.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly,
- System.Drawing.Imaging.PixelFormat.Format24bppRgb);
- GL.glBindTexture(GL.GL_TEXTURE_2D, m_TextureIDs[1]);
- GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, (int)GL.GL_RGB8, image.Width,
- image.Height, 0, GL.GL_BGR_EXT,
- GL.GL_UNSIGNED_byte, bitmapdata.Scan0);
- GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, (int)GL.GL_LINEAR);
- GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, (int)GL.GL_LINEAR);
- image.UnlockBits(bitmapdata);
- image.Dispose();
- for (float row = 0; row < 16; row++)
- {
- for (float col = 0; col < 16; col++)
- {
- cx = (float)row / 16.0f; // X Tex Coord Of Current Character
- cy = (float)col / 16.0f; // Y Tex Coord Of Current Character
- GL.glNewList((uint)(this.BaseList + col * 16 + row), GL.GL_COMPILE);
- // Start Building A List
- GL.glBegin(GL.GL_QUADS); // Use A Quad For Each Character
- GL.glTexCoord2f(cx, 1 - cy - 1f / 16f); //Texture Coord (Bottom Left)
- GL.glVertex2i(0, 0); // Vertex Coord (Bottom Left)
- GL.glTexCoord2f(cx + 1f / 16f, 1 - cy - 1f / 16f);// Texture Coord (Bottom Right)
- GL.glVertex2i(16, 0); // Vertex Coord (Bottom Right)
- GL.glTexCoord2f(cx + 1f / 16f, 1 - cy); // Texture Coord (Top Right)
- GL.glVertex2i(16, 16); // Vertex Coord (Top Right)
- GL.glTexCoord2f(cx, 1 - cy); // Texture Coord (Top Left)
- GL.glVertex2i(0, 16); // Vertex Coord (Top Left)
- GL.glEnd(); // Done Building Our Quad (Character)
- GL.glTranslated(10, 0, 0); // Move To The Right Of The Character Ready to
- // So That We’re Ready To Draw Another Character If We Need To
- GL.glEndList();// Done Building The Display List
- }
- }
- }
Add Comment
Please, Sign In to add comment