예제 #1
0
        public override void Initialize() {
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.Lighting);
            GL.Enable(EnableCap.Light0);

            cameraPlane = new Plane();

            Resize(MainGameWindow.Window.Width, MainGameWindow.Window.Height);

            grid = new Grid(true);
            model = new OBJLoader("Assets/test_object.obj");

            GL.Light(LightName.Light0, LightParameter.Position, new float[] { 0.0f, 0.5f, 0.5f, 0.0f });
            GL.Light(LightName.Light0, LightParameter.Ambient, new float[] { 0f, 1f, 0f, 1f });
            GL.Light(LightName.Light0, LightParameter.Diffuse, new float[] { 0f, 1f, 0f, 1f });
            GL.Light(LightName.Light0, LightParameter.Specular, new float[] { 1f, 1f, 1f, 1f });

            for (int i = 0; i < 6; i++) {
                frustum[i] = new Plane();
            }
            MouseState mouse = OpenTK.Input.Mouse.GetState();
            LastMousePosition = new Vector2(mouse.X, mouse.Y);
            viewMatrix = Move3DCamera(0f);
        }
예제 #2
0
파일: VBO.cs 프로젝트: Mszauer/OpenGL1X
        public override void Initialize() {
            grid = new Grid(true);

            cubeVertices = new float[] { //includes colors
                -1.0f,-1.0f,1.0f,//vertex 1
                1.0f,-1.0f,1.0f,//vertex2
                1.0f,1.0f,1.0f,//vertex3
                -1.0f,1.0f,1.0f,//vertex4
                -1.0f,-1.0f,-1.0f,//vertex5
                1.0f,-1.0f,-1.0f,//vertex6
                1.0f,1.0f,-1.0f,//vertex7
                -1.0f,1.0f,-1.0f,//vertex8
                //colors
                1.0f,0.0f,0.0f,//vertex1
                0.0f,1.0f,0.0f,//vertex2
                0.0f,0.0f,1.0f,//vertex3
                1.0f,1.0f,1.0f,//vertex4
                1.0f,0.0f,0.0f,//vertex5
                0.0f,1.0f,0.0f,//vertex6
                0.0f,0.0f,1.0f,//vertex7
                1.0f,1.0f,1.0f//vertex8
            };
            cubeIndicies = new uint[] {
                //front
                0,1,2,//front triangle1
                2,3,0,//front triangle2
                //top
                1,5,6,//top triangle1
                6,2,1,//top triangle2
                //back
                7,6,5,//back triangle1
                5,4,7,//back triangle2
                //bottom
                4,0,3,//bottom triangle1
                3,7,4,//bottom triangle2
                //left
                4,5,1,//left triangle1
                1,0,4,//left triangle2
                //right
                3,2,6,//right triangle1
                6,7,3//right triangle2
            };

            numIndices = cubeIndicies.Length;

            vertexBuffer = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBuffer);
            GL.BufferData(BufferTarget.ArrayBuffer, new System.IntPtr(cubeVertices.Length * sizeof(float)), cubeVertices, BufferUsageHint.DynamicDraw);

            indexBuffer = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, indexBuffer);
            GL.BufferData(BufferTarget.ElementArrayBuffer, new System.IntPtr(cubeIndicies.Length * sizeof(uint)), cubeIndicies, BufferUsageHint.StaticDraw);

            GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
        }
예제 #3
0
        public override void Initialize() {
            grid = new Grid(true);

            cubeVertices = new float[] {
                -1.0f,-1.0f,1.0f,//vertex 1
                1.0f,-1.0f,1.0f,//vertex2
                1.0f,1.0f,1.0f,//vertex3
                -1.0f,1.0f,1.0f,//vertex4
                -1.0f,-1.0f,-1.0f,//vertex5
                1.0f,-1.0f,-1.0f,//vertex6
                1.0f,1.0f,-1.0f,//vertex7
                -1.0f,1.0f,-1.0f//vertex8
            };

            cubeColors = new float[] {
                1.0f,0.0f,0.0f,//vertex1
                0.0f,1.0f,0.0f,//vertex2
                0.0f,0.0f,1.0f,//vertex3
                1.0f,1.0f,1.0f,//vertex4
                1.0f,0.0f,0.0f,//vertex5
                0.0f,1.0f,0.0f,//vertex6
                0.0f,0.0f,1.0f,//vertex7
                1.0f,1.0f,1.0f//vertex8
            };
            cubeIndicies = new uint[] {
                //front
                0,1,2,//front triangle1
                2,3,0,//front triangle2
                //top
                1,5,6,//top triangle1
                6,2,1,//top triangle2
                //back
                7,6,5,//back triangle1
                5,4,7,//back triangle2
                //bottom
                4,0,3,//bottom triangle1
                3,7,4,//bottom triangle2
                //left
                4,5,1,//left triangle1
                1,0,4,//left triangle2
                //right
                3,2,6,//right triangle1
                6,7,3//right triangle2
            };
        }
예제 #4
0
        public override void Initialize() {
            models = OBJManager.Instance;
            models.Initialize();
            models.LoadOBJ("Assets/test_object.obj");
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.Lighting);
            GL.Enable(EnableCap.Light0);

            Resize(MainGameWindow.Window.Width, MainGameWindow.Window.Height);

            grid = new Grid(true);
            models = OBJManager.Instance;

            GL.Light(LightName.Light0, LightParameter.Position, new float[] { 0.0f, 0.5f, 0.5f, 0.0f });
            GL.Light(LightName.Light0, LightParameter.Ambient, new float[] { 0f, 1f, 0f, 1f });
            GL.Light(LightName.Light0, LightParameter.Diffuse, new float[] { 0f, 1f, 0f, 1f });
            GL.Light(LightName.Light0, LightParameter.Specular, new float[] { 1f, 1f, 1f, 1f });
        }
예제 #5
0
파일: Program.cs 프로젝트: Mszauer/OpenGL1X
        public static void Main(string[] args) {
            //create new window
            Window = new MainGameWindow();
            Axiis = new Grid();
            TheGame = new CameraExample();
            TheGame.Resize(Window.Width, Window.Height);
            Window.Load += new EventHandler<EventArgs>(Initialize);
            Window.UpdateFrame += new EventHandler<FrameEventArgs>(Update);
            Window.RenderFrame += new EventHandler<FrameEventArgs>(Render);
            Window.Unload += new EventHandler<EventArgs>(Shutdown);

            Window.Title = "Game Name";
            Window.ClientSize = new System.Drawing.Size(800, 600);
            Window.VSync = VSyncMode.On;
            //run 60fps
            Window.Run(60.0f);

            //Dispose at end
            Window.Dispose();
        }
예제 #6
0
 public override void Initialize() {
     grid = new Grid();
 }
예제 #7
0
 public SolarSystem() {
     grid = new Grid();
     GL.Enable(EnableCap.DepthTest);
 }
예제 #8
0
 public Shaded_triangle() {
     grid = new Grid();
 }
예제 #9
0
 public override void Initialize() {
     grid = new Grid(true);
     GL.Enable(EnableCap.DepthTest);
     GL.Enable(EnableCap.CullFace);
     Resize(MainGameWindow.Window.Width, MainGameWindow.Window.Height);
 }
예제 #10
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();
            }
        }
예제 #11
0
 public override void Initialize() {
     base.Initialize();
     grid = new Grid();
 }
예제 #12
0
 public GLSolarSystem() {
     grid = new Grid();
     GL.Enable(EnableCap.DepthTest);
     Resize(MainGameWindow.Window.Width, MainGameWindow.Window.Height);
 }
예제 #13
0
 public override void Initialize() {
     grid = new Grid();
     GL.Enable(EnableCap.DepthTest);
 }