Beispiel #1
0
        /// <summary>
        /// Load contents
        /// </summary>
        public override void LoadContent()
        {
            Display.RenderState.ClearColor = Color.CornflowerBlue;

            // Load the bank
            ResourceManager.AddStorage(new BankStorage("data/data.bnk"));

            // Creates the font
            Font = BitmapFont.CreateFromTTF(@"c:\windows\fonts\verdana.ttf", 14, FontStyle.Regular);

            // Attach the TileSet to the font
            Font.TextTileset = ResourceManager.CreateAsset <TileSet>("TextTileSet");

            SpriteBatch = new SpriteBatch();


            //Text = "Simple text to display. <tile id=\"1\"/><br>This is a text to display";
            Text = @"Lorem ipsum dolor sit amet,   &lt;  &gt; &amp; consectetur adipiscing elit. Duis gravida mattis mi a euismod. " +
                   "Cras et sodales dolor. Nulla iaculis, elit quis mollis tempus, ante dui auctor erat, id aliquet quam sapien in ante. " +
                   "<color r=\"255\" g=\"0\" b=\"0\" a=\"255\">Ut ac mi turpis, vel pellentesque nisi.</color> Duis in eleifend turpis. Aliquam vel <tile id=\"7\" />lorem enim. " +
                   "Vestibulum auctor iaculis mauris, non gravida libero bibendum eu. Cras lacinia augue vel lectus accumsan dictum mattis lorem mollis. " +
                   "Quisque interdum placerat turpis sed vestibulum. Donec luctus pretium metus sit amet gravida. <br /><br />" +
                   "Vivamus neque sapien, faucibus nec vestibulum ac, pharetra tempus odio. Maecenas porta porta eros in cursus.<br /><br />" +
                   "Sed tristique velit id diam varius aliquet. <color r=\"128\" g=\"0\" b=\"200\" a=\"255\">Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. " +
                   "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer eu dui tu</color>rpis, ut porta nibh. " +
                   "Quisque lacinia convallis elit, ac dapibus turpis tristique et. ";
        }
Beispiel #2
0
        /// <summary>
        /// Load contents
        /// </summary>
        public override void LoadContent()
        {
            Display.RenderState.ClearColor = Color.CornflowerBlue;

            SpriteBatch = new Graphic.SpriteBatch();
            Font        = BitmapFont.CreateFromTTF(@"c:\windows\fonts\verdana.ttf", 16, FontStyle.Regular);

            Gamepad.Init(Window);
            CheckDevices();
        }
Beispiel #3
0
        /// <summary>
        /// Called when graphics resources need to be loaded.
        /// </summary>
        public override void LoadContent()
        {
            // Display settings
            Display.RenderState.ClearColor = Color.LightGray;

            // Create a font
            Font = BitmapFont.CreateFromTTF(@"c:\windows\fonts\verdana.ttf", 9, FontStyle.Regular);

            Batch = new SpriteBatch();

            MapSize    = new Size(100, 100);
            BlockSize  = new Size(5, 5);
            PathFinder = new AStar(MapSize);

            ClearMap();
        }
Beispiel #4
0
        /// <summary>
        /// Loads contents
        /// </summary>
        public override void LoadContent()
        {
            Display.RenderState.ClearColor = Color.CornflowerBlue;
            Display.RenderState.DepthTest  = true;



            #region Mesh
            //Mesh = PlyLoader.LoadPly("data/bunny.ply");
            Torus = Mesh.CreateTorus(0.5f, 1.0f, 32, 32);
            Plane = Mesh.CreatePlane(10.0f);
            #endregion


            #region Shader

            SceneShader = Shader.CreateFromFile("shaders/scene.vert", "shaders/scene.frag");
            SceneShader.Compile();

            #endregion


            #region Font

            SpriteBatch = new SpriteBatch();
            Font        = BitmapFont.CreateFromTTF(@"c:\windows\fonts\verdana.ttf", 10, FontStyle.Regular);

            #endregion


            // Frame buffer
            FrameBuffer = new FrameBuffer(new Size(512, 512));


            Camera = new Vector3(-5.0f, 5.0f, 10.0f);
            Light  = new Vector3(0.0f, 0.0f, 10.0f);


            // Matrices
            ModelViewMatrix = Matrix4.LookAt(Camera, Vector3.Zero, Vector3.UnitY);
            float aspectRatio = (float)Display.ViewPort.Width / (float)Display.ViewPort.Height;
            ProjectionMatrix = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(40.0f), aspectRatio, 1.0f, 100.0f);

            // Rotation
            Yaw = 0.0f;
        }
Beispiel #5
0
        /// <summary>
        /// Load contents
        /// </summary>
        public override void LoadContent()
        {
            // Clear color of the screen
            Display.RenderState.ClearColor = Color.CornflowerBlue;

            Batch = new SpriteBatch();

            // Load Verdana font
            Font = BitmapFont.CreateFromTTF(@"c:\windows\fonts\verdana.ttf", 12, FontStyle.Regular);

            // Load a texture
            Smiley = new Texture2D("smiley.png");

            // Texture location on the screen
            Location = new Point(
                Display.ViewPort.Width / 2 - Smiley.Size.Width / 2,
                Display.ViewPort.Height / 2 - Smiley.Size.Height / 2);
        }
Beispiel #6
0
        /// <summary>
        /// Load contents
        /// </summary>
        public override void LoadContent()
        {
            // Clear color of the screen
            Display.RenderState.ClearColor = Color.LightGray;
            //	Mouse.Visible = false;

            if (!PixelCollision.Init())
            {
                MessageBox.Show("GL_ARB_occlusion_query not found !", "Unsupported extension");
                Exit();
            }

            // Textures
            Logo = new Texture2D("data/logo.png");
            Star = new Texture2D("data/star.png");

            // Font
            Sprite = new SpriteBatch();
            Font   = BitmapFont.CreateFromTTF(@"c:\windows\fonts\verdana.ttf", 14, FontStyle.Regular);
        }
Beispiel #7
0
        /// <summary>
        /// Load content
        /// </summary>
        public override void LoadContent()
        {
            Display.RenderState.ClearColor = Color.CornflowerBlue;


            ResourceManager.AddStorage(new BankStorage("data/data.bnk"));


            Manager         = new GuiManager();
            Manager.TileSet = ResourceManager.CreateAsset <TileSet>("Skin");
            Manager.Font    = BitmapFont.CreateFromTTF(@"C:\Windows\Fonts\Verdana.ttf", 12, FontStyle.Regular);


            window          = new Window("Title...");
            window.BgColor  = Color.LightCoral;
            window.Location = new Point(100, 100);
            window.Size     = new Size(320, 240);
            Manager.Add(window);


            CheckBox checkbox1 = new CheckBox();

            checkbox1.Location        = new Point(50, 50);
            checkbox1.Text            = "checkbox 1";
            checkbox1.Font            = BitmapFont.CreateFromTTF(@"C:\Windows\Fonts\Verdana.ttf", 9, FontStyle.Regular);
            checkbox1.CheckedChanged += new EventHandler(checkbox_CheckedChanged);
            window.Add(checkbox1);

            CheckBox checkbox2 = new CheckBox();

            checkbox2.Location        = new Point(50, 65);
            checkbox1.Text            = "checkbox 2";
            checkbox2.Font            = BitmapFont.CreateFromTTF(@"C:\Windows\Fonts\Verdana.ttf", 10, FontStyle.Regular);
            checkbox2.CheckedChanged += new EventHandler(checkbox_CheckedChanged);
            window.Add(checkbox2);



            Font  = BitmapFont.CreateFromTTF(@"C:\Windows\Fonts\Verdana.ttf", 9, FontStyle.Regular);
            Batch = new SpriteBatch();
        }
Beispiel #8
0
        /// <summary>
        /// Load contents
        /// </summary>
        public override void LoadContent()
        {
            Display.RenderState.DepthTest = true;

            // Something to display text
            Font = BitmapFont.CreateFromTTF(@"c:\windows\fonts\verdana.ttf", 11, FontStyle.Regular);


            // Sprite batch
            Batch = new SpriteBatch();


            // Load the texture
            Texture = new Texture2D("data/checkerboard.png");


            // Setup the simple shader
            SimpleShader = new Shader();
            SimpleShader.LoadSource(ShaderType.VertexShader, "data/vertex.txt");
            SimpleShader.LoadSource(ShaderType.FragmentShader, "data/fragment.txt");
            SimpleShader.LoadSource(ShaderType.GeometryShader, "data/geometry.txt");
            SimpleShader.Compile();


            // Create a mesh
            Mesh = Mesh.CreateTorus(0.25f, 0.5f, 32, 32);


            // Matrices
            ModelViewMatrix = Matrix4.LookAt(new Vector3(0.0f, 0.0f, -2.5f), Vector3.Zero, Vector3.UnitY);
            float aspectRatio = (float)Display.ViewPort.Width / (float)Display.ViewPort.Height;

            ProjectionMatrix = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(45.0f), aspectRatio, 0.1f, 20.0f);


            explode_step   = 0.01f;
            explode_factor = 0.0f;
        }
Beispiel #9
0
        /// <summary>
        /// Loads the form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TileSetForm_Load(object sender, EventArgs e)
        {
            GLTileControl.MakeCurrent();
            Display.RenderState.Blending = true;
            Display.BlendingFunction(BlendingFactorSource.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            GLTextureControl.MakeCurrent();
            Display.RenderState.Blending = true;
            Display.BlendingFunction(BlendingFactorSource.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);


            Batch = new SpriteBatch();

            CheckerBoard = new Texture2D(ResourceManager.GetInternalResource("ArcEngine.Resources.checkerboard.png"));
            CheckerBoard.HorizontalWrap = TextureWrapFilter.Repeat;
            CheckerBoard.VerticalWrap   = TextureWrapFilter.Repeat;

            TileSet.Load(Node);

            TextureNameBox.Text = TileSet.TextureName;

            BMFont = BitmapFont.CreateFromTTF(@"c:\windows\fonts\verdana.ttf", 12, FontStyle.Bold);
        }
Beispiel #10
0
        /// <summary>
        /// Loads contents
        /// </summary>
        public override void LoadContent()
        {
            Display.RenderState.ClearColor = Color.CornflowerBlue;
            Display.RenderState.DepthTest  = true;

            // Matrices
            ModelViewMatrix = Matrix4.LookAt(new Vector3(0.0f, 0.0f, -2.5f), Vector3.Zero, Vector3.UnitY);
            float aspectRatio = (float)Display.ViewPort.Width / (float)Display.ViewPort.Height;

            ProjectionMatrix = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(45.0f), aspectRatio, 0.1f, 20.0f);


            #region Shader

            #region Vertex Shader
            string vshader = @"
				#version 130

				uniform mat4 modelview;
				uniform vec3 DiffuseMaterial;

				in vec3 in_position;
				in vec3 in_normal;

				out vec3 EyespaceNormal;
				out vec3 Diffuse;

				void main(void)
				{
					gl_Position = modelview * vec4(in_position, 1.0);

					Diffuse = DiffuseMaterial;

					mat3 NormalMatrix = mat3(modelview);
					EyespaceNormal = NormalMatrix * in_normal;
				}"                ;
            #endregion

            #region Fragment Shader
            string fshader = @"
				#version 130

				uniform vec3 LightPosition;
				uniform vec3 AmbientMaterial;
				uniform vec3 SpecularMaterial;
				uniform float Shininess;

				in vec3 EyespaceNormal;
				in vec3 Diffuse;

				out vec4 frag_color;


				float stepmix(float edge0, float edge1, float E, float x)
				{
					 float T = clamp(0.5 * (x - edge0 + E) / E, 0.0, 1.0);
					 return mix(edge0, edge1, T);
				}


				void main(void)
				{
					vec3 N = normalize(EyespaceNormal);
					vec3 L = normalize(LightPosition);
					vec3 Eye = vec3(0, 0, 1);
					vec3 H = normalize(L + Eye);
    
					float df = max(0.0, dot(N, L));				// Diffuse factor
					float sf = max(0.0, dot(N, H));				// Specular factor
					sf = pow(sf, Shininess);

					const float A = 0.1;			// gradient regions
					const float B = 0.3;		
					const float C = 0.6;		
					const float D = 1.0;		
					float E = fwidth(df);		// Epsilon to smooth edges

					if      (df > A - E && df < A + E) df = stepmix(A, B, E, df);
					else if (df > B - E && df < B + E) df = stepmix(B, C, E, df);
					else if (df > C - E && df < C + E) df = stepmix(C, D, E, df);
					else if (df < A) df = 0.0;
					else if (df < B) df = B;
					else if (df < C) df = C;
					else		df = D;

					E = fwidth(sf);
					if (sf > 0.5 - E && sf < 0.5 + E)
					{
						sf = smoothstep(0.5 - E, 0.5 + E, sf);
					}
					else
					{
						sf = step(0.5, sf);
					}

					vec3 color = AmbientMaterial + df * Diffuse + sf * SpecularMaterial;
					frag_color = vec4(color, 1.0);
				}"                ;
            #endregion

            Shader = new Shader();
            Shader.SetSource(ShaderType.VertexShader, vshader);
            Shader.SetSource(ShaderType.FragmentShader, fshader);
            Shader.Compile();
            Display.Shader = Shader;
            #endregion


            #region Mesh

            Trefoil = Mesh.CreateTrefoil(128, 32);
            //Torus = Mesh.CreateTorus(0.25f, 0.5f, 32, 32);
            Torus = Mesh.CreateDisk(0.25f, 1.0f, 32, 32);

            #endregion


            #region Font

            Sprite = new SpriteBatch();
            Font   = BitmapFont.CreateFromTTF("c:\\windows\\fonts\\verdana.ttf", 16, FontStyle.Regular);

            #endregion
        }
Beispiel #11
0
        /// <summary>
        /// Loads contents
        /// </summary>
        public override void  LoadContent()
        {
            CreateGameWindow(new Size(1024, 768));
            Window.Text = "Frame Buffer example";

            // Matrices
            ModelViewMatrix = Matrix4.LookAt(new Vector3(0.0f, 0.0f, -2.5f), Vector3.Zero, Vector3.UnitY);
            float aspectRatio = (float)Display.ViewPort.Width / (float)Display.ViewPort.Height;

            ProjectionMatrix = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4.0f, aspectRatio, 0.1f, 20.0f);


            #region Shader


            #region Vertex Shader
            string vshader = @"
				#version 130

				uniform mat4 modelview_matrix;
				uniform mat4 projection_matrix;
				uniform mat4 mvp_matrix;

				in vec3 in_position;
				in vec3 in_normal;
				in vec3 in_tangent;
				in vec2 in_texcoord;

				out vec4 out_color;

				void main(void)
				{
					gl_Position = mvp_matrix * vec4(in_position, 1.0);
					
					out_color = modelview_matrix * vec4(in_normal, 1.0);
				}"                ;
            #endregion

            #region Fragment Shader
            string fshader = @"
				#version 130

				in vec4 out_color;

				out vec4 frag_color;

				void main(void)
				{
					frag_color = out_color;
				}"                ;
            #endregion

            Shader = new Shader();
            Shader.SetSource(ShaderType.VertexShader, vshader);
            Shader.SetSource(ShaderType.FragmentShader, fshader);
            Shader.Compile();
            Display.Shader = Shader;
            #endregion


            // Enable depth test writting
            Display.RenderState.DepthTest = true;

            // Frame buffer
            Buffer = new FrameBuffer(new Size(512, 512));

            // Texture to display
            Texture = new Texture2D("data/test.png");

            // Mesh
            Mesh = Mesh.CreateTrefoil(128, 32);


            #region Font

            SpriteBatch = new SpriteBatch();
            Font        = BitmapFont.CreateFromTTF(@"c:\windows\fonts\verdana.ttf", 12, FontStyle.Regular);

            #endregion
        }
Beispiel #12
0
        /// <summary>
        /// Load contents
        /// </summary>
        public override void LoadContent()
        {
            Display.RenderState.ClearColor = Color.Black;
            Display.RenderState.DepthTest  = true;
            Display.RenderState.Culling    = true;


            #region Audio

            AudioManager.Create();
            Stream = new AudioStream();
            Stream.LoadOgg("data/Hydrate-Kenny_Beltrey.ogg");
            Stream.Play();

            #endregion


            #region Matrices

            CameraPostion = new Vector3(0.0f, 0.1f, 3.0f);

            float aspectRatio = (float)Display.ViewPort.Width / (float)Display.ViewPort.Height;
            ProjectionMatrix = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(45.0f), aspectRatio, 0.1f, 100.0f);

            #endregion


            #region Shader

            Shader = new Shader();
            Shader.LoadSource(ShaderType.VertexShader, "data/shader.vert");
            Shader.LoadSource(ShaderType.FragmentShader, "data/shader.frag");
            Shader.Compile();
            Display.Shader = Shader;

            #endregion


            #region Textures

            Texture2D.DefaultMagFilter            = TextureMagFilter.Linear;
            Texture2D.DefaultMinFilter            = TextureMinFilter.Linear;
            Texture2D.DefaultHorizontalWrapFilter = TextureWrapFilter.Repeat;
            Texture2D.DefaultVerticalWrapFilter   = TextureWrapFilter.Repeat;

            Marble                = new Texture2D("data/Marble.png");
            Marble.MinFilter      = TextureMinFilter.Linear;
            Marble.MagFilter      = TextureMagFilter.Linear;
            Marble.HorizontalWrap = TextureWrapFilter.Repeat;
            Marble.VerticalWrap   = TextureWrapFilter.Repeat;

            Moon           = new Texture2D("data/Moon.png");
            Moon.MinFilter = TextureMinFilter.Linear;
            Moon.MagFilter = TextureMagFilter.Linear;

            Mars           = new Texture2D("data/Mars.png");
            Mars.MinFilter = TextureMinFilter.Linear;
            Mars.MagFilter = TextureMagFilter.Linear;

            #endregion


            #region Mesh
            Torus = Mesh.CreateTorus(0.15f, 0.50f, 40, 20);

            Sphere          = Mesh.CreateSphere(0.1f, 26);
            Sphere.Position = new Vector3(1.0f, 0.4f, 0.0f);

            float[] data = new float[]
            {
                // Vertex					Texture
                -10.0f, 0.0f, 20.0f, 0.0f, 0.0f,
                10.0f, 0.0f, 20.0f, 20.0f, 0.0f,
                10.0f, 0.0f, -20.0f, 20.0f, 20.0f,
                -10.0f, 0.0f, -20.0f, 0.0f, 20.0f,
            };
            Floor = new Mesh();
            Floor.SetVertices(data);
            Floor.SetIndices(new uint[] { 0, 1, 2, 3 });
            Floor.Buffer.AddDeclaration("in_position", 3);
            Floor.Buffer.AddDeclaration("in_texcoord", 2);
            Floor.PrimitiveType = PrimitiveType.TriangleFan;
            Floor.Position      = new Vector3(0.0f, -1.0f, 0.0f);

            #endregion


            Batch = new Graphic.SpriteBatch();
            Font  = BitmapFont.CreateFromTTF(@"c:\windows\fonts\verdana.ttf", 10, FontStyle.Regular);
        }
Beispiel #13
0
        /// <summary>
        /// Loads contents
        /// </summary>
        public override void LoadContent()
        {
            Display.RenderState.ClearColor = Color.CornflowerBlue;



            // Shader
            Shader         = Shader.CreateTextureShader();
            Display.Shader = Shader;


            #region Texture

            // Loads a texture and binds it to TUI 2
            Texture = new Texture2D("data/texture.png");
            Texture.HorizontalWrap = TextureWrapFilter.Repeat;
            Texture.VerticalWrap   = TextureWrapFilter.Repeat;
            Display.TextureUnit    = 2;
            Display.Texture        = Texture;

            #endregion

            // Matrices
            ModelViewMatrix  = Matrix4.LookAt(new Vector3(0, 0, 1), new Vector3(0, 0, 0), new Vector3(0, 1, 0));;
            ProjectionMatrix = Matrix4.CreateOrthographicOffCenter(0, Display.ViewPort.Width, Display.ViewPort.Height, 0, -1.0f, 1.0f);
            TextureMatrix    = Matrix4.Scale(1.0f / Texture.Size.Width, 1.0f / Texture.Size.Height, 1.0f);

            #region Buffer


            // Indices
            uint[] indices = new uint[]
            {
                0, 1, 2,
                1, 2, 3
            };

            Index = new IndexBuffer();
            Index.Update(indices);


            // Creates a position, color, texture buffer
            Buffer = BatchBuffer.CreatePositionColorTextureBuffer();


            // Vertex elements
            float[] vertices = new float[]
            {
                // Coord						Color							Texture
                100.0f, 100.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
                500.0f, 100.0f, 0.0f, 1.0f, 0.0f, 1.0f, 256.0f, 0.0f,
                100.0f, 500.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 256.0f,
                500.0f, 500.0f, 1.0f, 1.0f, 1.0f, 1.0f, 256.0f, 256.0f
            };
            Buffer.SetVertices(vertices);


            // Or set data one by one
            Buffer.AddPoint(new Point(100, 100), Color.FromArgb(255, 0, 0), new Point(0, 0));
            Buffer.AddPoint(new Point(500, 100), Color.FromArgb(0, 255, 0), new Point(256, 0));
            Buffer.AddPoint(new Point(100, 500), Color.FromArgb(0, 0, 255), new Point(0, 256));
            Buffer.AddPoint(new Point(500, 500), Color.FromArgb(255, 255, 255), new Point(256, 256));
            Buffer.Update();


            #region VAO

            //Batch = new BatchBuffer();


            //VertexBuffer.Bind(0, 2);
            //Shader.BindAttrib(0, "in_position");

            //ColorBuffer.Bind(1, 4);
            //Shader.BindAttrib(1, "in_color");


            //GL.BindVertexArray(0);

            #endregion

            #endregion


            #region Font

            SpriteBatch = new Graphic.SpriteBatch();
            Font        = BitmapFont.CreateFromTTF("c:\\windows\\fonts\\verdana.ttf", 16, FontStyle.Regular);

            #endregion
        }