protected override void OnLoad(EventArgs e) { Debug.WriteLine("OnLoad"); VSync = VSyncMode.Off; CreateProjection(); _solidProgram = new ShaderProgram(); _solidProgram.AddShader(ShaderType.VertexShader, @"Components\Shaders\1Vert\simplePipeVert.c"); _solidProgram.AddShader(ShaderType.FragmentShader, @"Components\Shaders\5Frag\simplePipeFrag.c"); _solidProgram.Link(); _texturedProgram = new ShaderProgram(); _texturedProgram.AddShader(ShaderType.VertexShader, @"Components\Shaders\1Vert\simplePipeTexVert.c"); _texturedProgram.AddShader(ShaderType.FragmentShader, @"Components\Shaders\5Frag\simplePipeTexFrag.c"); _texturedProgram.Link(); var models = new Dictionary <string, ARenderable>(); models.Add("Wooden", new TexturedRenderObject(RenderObjectFactory.CreateTexturedCube(1, 256, 256), _texturedProgram.Id, @"Components\Textures\wooden.png")); models.Add("Golden", new TexturedRenderObject(RenderObjectFactory.CreateTexturedCube(1, 256, 256), _texturedProgram.Id, @"Components\Textures\wooden.png")); models.Add("Asteroid", new TexturedRenderObject(RenderObjectFactory.CreateTexturedCube(1, 1536, 256), _texturedProgram.Id, @"Components\Textures\asteroid.bmp")); models.Add("Spacecraft", new TexturedRenderObject(RenderObjectFactory.CreateTexturedCube6(1, 1536, 256), _texturedProgram.Id, @"Components\Textures\spacecraft.png")); models.Add("Gameover", new TexturedRenderObject(RenderObjectFactory.CreateTexturedCube6(1, 1, 1), _texturedProgram.Id, @"Components\Textures\gameover.png")); models.Add("Bullet", new ColoredRenderObject(RenderObjectFactory.CreateSolidCube(1, Color4.HotPink), _solidProgram.Id)); models.Add("TestObject", new TexturedRenderObject(RenderObjectFactory.CreateTexturedCube(1, 1, 1), _texturedProgram.Id, @"Components\Textures\asteroid texture one side.jpg")); models.Add("TestObjectGen", new MipMapGeneratedRenderObject(RenderObjectFactory.CreateTexturedCube(1, 1, 1), _texturedProgram.Id, @"Components\Textures\asteroid texture one side.jpg", 8)); models.Add("TestObjectPreGen", new MipMapManualRenderObject(RenderObjectFactory.CreateTexturedCube(1, 1, 1), _texturedProgram.Id, @"Components\Textures\asteroid texture one side mipmap levels 0 to 8.bmp", 9)); _gameObjectFactory = new GameObjectFactory(models); _gameObjects.Add(_gameObjectFactory.CreateTestObject("TestObject")); _gameObjects.Last().SetPosition(new Vector4(-0.65f, 0, -2.7f, 0)); _gameObjects.Add(_gameObjectFactory.CreateTestObject("TestObjectGen")); _gameObjects.Last().SetPosition(new Vector4(0.65f, -0.65f, -2.7f, 0)); _gameObjects.Add(_gameObjectFactory.CreateTestObject("TestObjectPreGen")); _gameObjects.Last().SetPosition(new Vector4(0.65f, 0.65f, -2.7f, 0)); //_player = _gameObjectFactory.CreateSpacecraft(); //_gameObjects.Add(_player); //_gameObjects.Add(_gameObjectFactory.CreateAsteroid()); //_gameObjects.Add(_gameObjectFactory.CreateGoldenAsteroid()); //_gameObjects.Add(_gameObjectFactory.CreateWoodenAsteroid()); CursorVisible = true; GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); GL.PatchParameter(PatchParameterInt.PatchVertices, 3); GL.PointSize(3); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.CullFace); Closed += OnClosed; Debug.WriteLine("OnLoad .. done"); }
protected override void OnLoad(EventArgs e) { Debug.WriteLine("OnLoad"); VSync = VSyncMode.Off; CreateProjection(); _textProgram = new ShaderProgram(); _textProgram.AddShader(ShaderType.VertexShader, @"Components\Shaders\1Vert\textVert.c"); _textProgram.AddShader(ShaderType.FragmentShader, @"Components\Shaders\5Frag\textFrag.c"); _textProgram.Link(); _solidProgram = new ShaderProgram(); _solidProgram.AddShader(ShaderType.VertexShader, @"Components\Shaders\1Vert\simplePipeVert.c"); _solidProgram.AddShader(ShaderType.FragmentShader, @"Components\Shaders\5Frag\simplePipeFrag.c"); _solidProgram.Link(); _solidProgram = new ShaderProgram(); _solidProgram.AddShader(ShaderType.VertexShader, @"Components\Shaders\1Vert\gouraudPipeSolidVert.c"); _solidProgram.AddShader(ShaderType.FragmentShader, @"Components\Shaders\5Frag\gouraudPipeFrag.c"); _solidProgram.Link(); //_solidProgram = new ShaderProgram(); //_solidProgram.AddShader(ShaderType.VertexShader, @"Components\Shaders\1Vert\phongPipeSolidVert.c"); //_solidProgram.AddShader(ShaderType.FragmentShader, @"Components\Shaders\5Frag\phongPipeFrag.c"); //_solidProgram.Link(); _texturedProgram = new ShaderProgram(); _texturedProgram.AddShader(ShaderType.VertexShader, @"Components\Shaders\1Vert\simplePipeTexVert.c"); _texturedProgram.AddShader(ShaderType.FragmentShader, @"Components\Shaders\5Frag\simplePipeTexFrag.c"); _texturedProgram.Link(); _models = new Dictionary <string, ARenderable>(); var textModel = new TexturedRenderObject(RenderObjectFactory.CreateTexturedCharacter(), _textProgram.Id, @"Components\Textures\font singleline.bmp"); //textModel.SetFiltering(All.Nearest); _models.Add("Quad", textModel); _models.Add("Wooden", new MipMapGeneratedRenderObject(new IcoSphereFactory().Create(3), _texturedProgram.Id, @"Components\Textures\wooden.png", 8)); _models.Add("Golden", new MipMapGeneratedRenderObject(new IcoSphereFactory().Create(3), _texturedProgram.Id, @"Components\Textures\golden.bmp", 8)); _models.Add("Asteroid", new MipMapGeneratedRenderObject(new IcoSphereFactory().Create(3), _texturedProgram.Id, @"Components\Textures\moonmap1k.jpg", 8)); _models.Add("Spacecraft", new MipMapGeneratedRenderObject(RenderObjectFactory.CreateTexturedCube6(1, 1, 1), _texturedProgram.Id, @"Components\Textures\spacecraft.png", 8)); _models.Add("Gameover", new MipMapGeneratedRenderObject(RenderObjectFactory.CreateTexturedCube6(1, 1, 1), _texturedProgram.Id, @"Components\Textures\gameover.png", 8)); _models.Add("Bullet", new MipMapGeneratedRenderObject(new IcoSphereFactory().Create(3), _texturedProgram.Id, @"Components\Textures\dotted.png", 8)); //models.Add("TestObject", new TexturedRenderObject(RenderObjectFactory.CreateTexturedCube(1, 1, 1), _texturedProgram.Id, @"Components\Textures\asteroid texture one side.jpg")); //models.Add("TestObjectGen", new MipMapGeneratedRenderObject(RenderObjectFactory.CreateTexturedCube(1, 1, 1), _texturedProgram.Id, @"Components\Textures\asteroid texture one side.jpg", 8)); //models.Add("TestObjectPreGen", new MipMapManualRenderObject(RenderObjectFactory.CreateTexturedCube(1, 1, 1), _texturedProgram.Id, @"Components\Textures\asteroid texture one side mipmap levels 0 to 8.bmp", 9)); _gameObjectFactory = new GameObjectFactory(_models); _player = _gameObjectFactory.CreateSpacecraft(); //_gameObjects.Add(_player); //_gameObjects.Add(_gameObjectFactory.CreateAsteroid()); //_gameObjects.Add(_gameObjectFactory.CreateGoldenAsteroid()); //_gameObjects.Add(_gameObjectFactory.CreateWoodenAsteroid()); var maxX = 2.5f; var maxY = 1.5f; for (float x = -maxX; x < maxX; x += 0.5f) { for (float y = -maxY; y < maxY; y += 0.5f) { _gameObjects.Add(_gameObjectFactory.CreateSelectableSphere(new Vector4(x, y, -5f, 0))); } } for (float x = -maxX; x < maxX; x += 0.65f) { for (float y = -maxY; y < maxY; y += 0.65f) { _gameObjects.Add(_gameObjectFactory.CreateSelectableSphereSecondary(new Vector4(x, y, -6f, 0))); } } _text = new RenderText(_models["Quad"], new Vector4(-0.2f, 0.1f, -0.4f, 1), Color4.Red, "Score"); _camera = new StaticCamera(); CursorVisible = true; GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); GL.PatchParameter(PatchParameterInt.PatchVertices, 3); GL.PointSize(3); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.CullFace); MouseUp += OnMouseUp; Closed += OnClosed; Debug.WriteLine("OnLoad .. done"); }