Ejemplo n.º 1
0
 private void Unbind()
 {
     MasterRenderer.EnableCulling();
     Gl.DisableVertexAttribArray(0);
     Gl.DisableVertexAttribArray(1); // UV 매핑 데이터 Slot 비활성
     Gl.DisableVertexAttribArray(2);
     Gl.BindVertexArray(0);
 }
Ejemplo n.º 2
0
        private void OnCreated_GlControl(object sender, GlControlEventArgs e)
        {
            GlControl glControl = (GlControl)sender;

            this.displayManager.CreateDisplay(glControl);

            bool result = WrapSOIL.Initialize();

            if (result == false)
            {
                MessageBox.Show("SOIL: Failed initialize : " + WrapSOIL.GetSoilLastError());
                return;
            }

            this.loader = new Loader();
            //Camera
            this.camera = new Camera(new Vertex3f(0, 10, 0), 20f);

            //Light - Sun
            this.lgihtList = new List <Light>();
            this.sun       = new DirectionalLight(new Vertex3f(-0.5f, -1.5f, 0.5f), new Vertex3f(150, 250, -150), new Vertex3f(0.4f, 0.4f, 0.4f), new Vertex3f(1, 0, 0));
            this.lgihtList.Add(sun);

            //Renderer
            this.renderer    = new MasterRenderer(this.camera, this.loader, this.sun, glControl.ClientSize.Width, glControl.ClientSize.Height);
            this.guiRenderer = new GUIRenderer(this.loader);
            this.inputManager.OnEventMouseWheel += this.camera.OnEventWheel;

            //Water
            this.waterTileList = new List <WaterTile>();
            this.waterTileList.Add(new WaterTile(75, -75, WATER_HEIGHT));

            //Water
            this.waterFrameBuffers = new WaterFrameBuffers();
            this.waterShader       = new WaterShader();
            this.waterRenderer     = new WaterRenderer(loader, waterShader, this.renderer.ProjectionMatrix, this.waterFrameBuffers);


            //Load Resources
            this.entities = new List <Entity>();
            this.terrain  = LoadTerrain(this.loader);
            LoadEntities(this.terrain, this.entities, this.loader);
            LoadPlayer(this.loader, this.entities);

            //Light - Point

            this.lgihtList.Add(new Light(GetHeightPosition(this.terrain, 185, 12.7f, -293), new Vertex3f(2, 0, 0), new Vertex3f(1, 0.01f, 0.002f)));
            this.lgihtList.Add(new Light(GetHeightPosition(this.terrain, 370, 12.7f, -300), new Vertex3f(0, 2, 2), new Vertex3f(1, 0.01f, 0.002f)));
            this.lgihtList.Add(new Light(GetHeightPosition(this.terrain, 293, 12.7f, -305), new Vertex3f(2, 2, 0), new Vertex3f(1, 0.01f, 0.002f)));
            //LoadGUI(this.loader);
            //LoadGUI_Texture(this.loader, this.waterFrameBuffers.RefractionTexture);
            LoadGUI_Texture(this.loader, renderer.DepthMap);

            //MousePicker
            this.mousePicker = new MousePicker(this.camera, this.renderer.ProjectionMatrix, this.terrain);
        }
Ejemplo n.º 3
0
        private void PrepareTextureModel(TextureModel model)
        {
            RawModel rawModel = model.RawModel;

            Gl.BindVertexArray(rawModel.VaoID);
            Gl.EnableVertexAttribArray(0); // Position
            Gl.EnableVertexAttribArray(1); // UV 매핑 데이터 Slot 활성
            Gl.EnableVertexAttribArray(2); // Normal

            ModelTexture texture = model.Texture;

            if (texture.HasTransparency)
            {
                MasterRenderer.DisableCulling();
            }

            this.shader.LoadFakeLighting(texture.UseFakeLigihting);
            this.shader.LoadShineVariables(texture.ShineDamper, texture.Reflectivity);
            Gl.ActiveTexture(TextureUnit.Texture0);
            Gl.BindTexture(TextureTarget.Texture2d, texture.TextureID);
        }