bool loadGLTextures () { bool status = false; texture [0] = new Texture2DFont (NSBundle.MainBundle.PathForResource ("Font", "bmp")); texture [1] = new Texture2D (NSBundle.MainBundle.PathForResource ("Bumps", "bmp")); if (texture [0].TextureName > 0 && texture [1].TextureName > 0) { status = true; } return status; }
bool loadGLTextures() { bool status = false; texture [0] = new Texture2DFont(NSBundle.MainBundle.PathForResource("Font", "bmp")); texture [1] = new Texture2D(NSBundle.MainBundle.PathForResource("Bumps", "bmp")); if (texture [0].TextureName > 0 && texture [1].TextureName > 0) { status = true; } return(status); }
// This method renders our scene and where all of your drawing code will go. // The main thing to note is that we've factored the drawing code out of the NSView subclass so that // the full-screen and non-fullscreen views share the same states for rendering public bool DrawGLScene() { // Clear The Screen And The Depth Buffer GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); // Reset The Current Modelview Matrix GL.LoadIdentity(); // Select second texture GL.BindTexture(TextureTarget.Texture2D, texture [1].TextureName); //GL.BindTexture (TextureTarget.Texture2D, texture[1]); // Move into screen 5 units GL.Translate(0.0f, 0.0f, -5.0f); // Rotate around Z axis (clockwise) GL.Rotate(45.0f, 0.0f, 0.0f, 1.0f); // Rotate on X and Y axis by cnt1 (left and right ) GL.Rotate(cnt1 * 30.0f, 1.0f, 1.0f, 0.0f); // Disable blending before drawing in 3D GL.Disable(EnableCap.Blend); // Bright white GL.Color3(1.0f, 1.0f, 1.0f); GL.Begin(BeginMode.Quads); GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(-1.0f, 1.0f); GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(1.0f, 1.0f); GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(1.0f, -1.0f); GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(-1.0f, -1.0f); GL.End(); // Rotate on the X and Y axis by 90 degrees (left to right ) GL.Rotate(90.0f, 1.0f, 1.0f, 0.0f); GL.Begin(BeginMode.Quads); GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(-1.0f, 1.0f); GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(1.0f, 1.0f); GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(1.0f, -1.0f); GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(-1.0f, -1.0f); GL.End(); GL.Enable(EnableCap.Blend); GL.LoadIdentity(); // Reset the view // Pulsing colors based on text position GL.Color3(Math.Cos(cnt1), Math.Sin(cnt2), 1.0f - 0.5f * Math.Cos(cnt1 + cnt2)); // Print GL text to the screen Texture2DFont font = (Texture2DFont)texture[0]; font.RenderText(280 + (int)(250 * Math.Cos(cnt1)), 235 + (int)(200 * Math.Sin(cnt2)), "NeHe", 0); GL.Color3(1.0f * (float)Math.Sin(cnt2), 1.0f - 0.5f * (float)Math.Cos(cnt1 + cnt2), 1.0f * (float)Math.Cos(cnt1)); font.RenderText((int)(280 + 230 * Math.Cos(cnt2)), (int)(235 + 200 * Math.Sin(cnt1)), "OpenGL", 1); // Set Color To Blue GL.Color3(Color.Blue); font.RenderText((int)(240 + 200 * Math.Cos((cnt2 + cnt1) / 5)), 3, "Giuseppe D'Agata", 0); GL.Color3(Color.White); font.RenderText((int)(243 + 200 * Math.Cos((cnt2 + cnt1) / 5)), 2, "Giuseppe D'Agata", 0); // Increase first counter cnt1 += 0.01f; // Increase second counter cnt2 += 0.0081f; return(true); }