public static void Initialize() { var watch = Timer.Start(); initializeGL(); Shaders.Initialize(); ColorManager.Initialize(); watch.StopAndWrite("Configuring GL"); }
public void Initialize() { timah = 0; shader = new Shaders(); currentSceneId = 0; ErrorCode ErrorCheckValue = GL.GetError(); GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL.Enable(EnableCap.DepthTest); ModelMatrix = Matrix4.Identity; ViewMatrix = Matrix4.Identity; ProjectionMatrix = Matrix4.Identity; GL.Enable(EnableCap.DepthTest); GL.DepthFunc(DepthFunction.Less); GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Back); GL.FrontFace(FrontFaceDirection.Ccw); shader.Initialize(); ErrorCheckValue = GL.GetError(); if (ErrorCheckValue != ErrorCode.NoError) Trace.WriteLine("Error at Creating Shaders: " + ErrorCheckValue); //Binding UniformLocations to variables found in shader files modelLocation = GL.GetUniformLocation(shader.ProgramIds[0], "ModelMatrix"); viewLocation = GL.GetUniformLocation(shader.ProgramIds[0], "ViewMatrix"); projectionLocation = GL.GetUniformLocation(shader.ProgramIds[0], "ProjectionMatrix"); timeLocation = GL.GetUniformLocation(shader.ProgramIds[0], "time"); resoLocation = GL.GetUniformLocation(shader.ProgramIds[0], "resolution"); resolution = new Vector2(1280, 720); scenes = new Scene[10]; scenes[0] = new Scene(1000); // Creating a VBO object now, and after it Indexed vb. In otherwords ElementBuffer scenes[0].setBackground(new VBOCube(0, 0, 0, 10.0f, 0, true)); //scenes[0].addNewVBOCube(new VBOCube(0, 0, 0, 10.0f, 0, true)); //scenes[0].addNewVBOCube(new VBOCube(0, 0, 0, 0.5f, 0)); //scenes[0].addNewVBOCube(new VBOCube(0.5f, 0.5f, 0, 0.5f, 0)); //scenes[0].addNewVBOCube(new VBOCube(0, -0.5f, 0, 0.5f, 0)); initializeScene(0); scenes[1] = new Scene(10); scenes[1].setBackground(new VBOCube(0, 0, 0, 10.0f, 1, true)); initializeScene(1); //scenes[5] = new Scene(10000); //scenes[5].setBackground(new VBOCube(0, 0, 0, 10.0f, 2, true)); scenes[2] = new Scene(15); scenes[2].setBackground(new VBOCube(0, 0, 0, 10.0f, 3, true)); scenes[2].addNewVBOCube(new VBOCube(0.7f, 0, 0, 2.0f, 2)); scenes[2].addNewVBOCube(new VBOCube(-0.7f, 0, 0, 2.0f, 2)); initializeScene(2); //JEEB! scenes[3] = new Scene(10); //monta cubea sul on maksimissaan, ei kasva automaattisesti ku lisäät scenes[3].setBackground(new VBOCube(0, 0, 0, ((float)Math.PI * 5), 5, true)); //"5" on sinun shader program //scenes[3].addNewVBOCube(new VBOCube(0.7f, 0, 0.4f, ((float)Math.PI / 3), 2)); // Dunno, liikkuva boksi vai ei initializeScene(3); scenes[4] = new Scene(10); scenes[4].setBackground(new VBOCube(0, 0, 0, 10.0f, 3, true)); scenes[4].addNewVBOCube(new VBOCube(2, 0, 0, 0.5f, 0)); initializeScene(4); scenes[7] = new Scene(10); scenes[7].setBackground(new VBOCube(0, 0, 0, 10.0f, 3, true)); scenes[7].addNewVBOCube(new VBOCube(0.5f, 0, 0, 0.5f, 0)); initializeScene(7); scenes[8] = new Scene(10); scenes[8].setBackground(new VBOCube(0, 0, 0, 10.0f, 3, true)); scenes[8].addNewVBOCube(new VBOCube(-1.0f, -0.2f, -2.0f, 0.5f, 0)); initializeScene(8); scenes[9] = new Scene(10); scenes[9].setBackground(new VBOCube(0, 0, 0, 10.0f, 3, true)); scenes[9].addNewVBOCube(new VBOCube(1.0f, 0.3f, -1.0f, 0.5f, 0)); initializeScene(9); UuNyaaBuilder builder2 = new UuNyaaBuilder(4); scenes[5] = builder2.sceneBuilder(); initializeScene(5); UuNyaaBuilder builder = new UuNyaaBuilder(6); scenes[6] = builder.sceneBuilder(); initializeScene(6); ErrorCheckValue = GL.GetError(); if (ErrorCheckValue != ErrorCode.NoError) Trace.WriteLine("Error at Creating VBO: " + ErrorCheckValue); Matrix4 modelview = Matrix4.CreateTranslation(new Vector3(0, 0, -2)); ViewMatrix = modelview; }