Example #1
0
        public override void Initialize()
        {
            base.Initialize();
            base.Initialize();
            grid = new Grid(true);
            snow = new SnowParticleSystem(5000, new Vector3(0f, 0f, 0f), new Vector3(10f, 10f, 10f));
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.Blend);

            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            crazyTexture = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, crazyTexture);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat);
            {
                //load bmp texture
                Bitmap bmp = new Bitmap("Assets/crazy_taxi.png");
                //get the data about bmp
                BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                //upload data to gpu
                GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp_data.Width, bmp_data.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0);
                //mark cpu memory for disposal
                bmp.UnlockBits(bmp_data);
                bmp.Dispose();
            }

            houseTexture = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, houseTexture);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            {
                Bitmap     bmp      = new Bitmap("Assets/houses.png");
                BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                house1_uv_bottom = 326.0f / (float)bmp.Height;
                house1_uv_right  = 186.0f / (float)bmp.Width;

                house2_uv_left   = 332.0f / (float)bmp.Width;
                house2_uv_right  = (332.0f + 180.0f) / (float)bmp.Width;
                house2_uv_bottom = 336.0f / (float)bmp.Height;

                GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp_data.Width, bmp_data.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0);
                bmp.UnlockBits(bmp_data);
                bmp.Dispose();
            }
            uiTexture = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, uiTexture);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            {
                //load bmp texture
                Bitmap bmp = new Bitmap("Assets/ui_atlas.png");
                //get the data about bmp
                BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                uiTextureSize = new Size(bmp.Width, bmp.Height);
                //upload data to gpu
                GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp_data.Width, bmp_data.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0);
                //mark cpu memory for disposal
                bmp.UnlockBits(bmp_data);
                bmp.Dispose();
            }
        }
Example #2
0
        public override void Initialize() {
            base.Initialize();
            base.Initialize();
            grid = new Grid(true);
            snow = new SnowParticleSystem(5000, new Vector3(0f, 0f, 0f), new Vector3(10f, 10f, 10f));
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.Blend);

            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            crazyTexture = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, crazyTexture);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat);
            {
                //load bmp texture
                Bitmap bmp = new Bitmap("Assets/crazy_taxi.png");
                //get the data about bmp
                BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                //upload data to gpu
                GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp_data.Width, bmp_data.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0);
                //mark cpu memory for disposal
                bmp.UnlockBits(bmp_data);
                bmp.Dispose();
            }

            houseTexture = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, houseTexture);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            {
                Bitmap bmp = new Bitmap("Assets/houses.png");
                BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                house1_uv_bottom = 326.0f/(float)bmp.Height;
                house1_uv_right = 186.0f / (float)bmp.Width;

                house2_uv_left = 332.0f / (float)bmp.Width;
                house2_uv_right = (332.0f + 180.0f) / (float)bmp.Width;
                house2_uv_bottom = 336.0f / (float)bmp.Height;

                GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp_data.Width, bmp_data.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0);
                bmp.UnlockBits(bmp_data);
                bmp.Dispose();
            }
            uiTexture = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, uiTexture);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            {
                //load bmp texture
                Bitmap bmp = new Bitmap("Assets/ui_atlas.png");
                //get the data about bmp
                BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                uiTextureSize = new Size(bmp.Width, bmp.Height);
                //upload data to gpu
                GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp_data.Width, bmp_data.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0);
                //mark cpu memory for disposal
                bmp.UnlockBits(bmp_data);
                bmp.Dispose();
            }
        }