private void Window_Load(object sender, EventArgs e) { GL.ClearColor(Color.FromArgb(0, 0, 0, 0)); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.Texture2D); player = new Player(100f); shaderProgram = new ShaderProgram(); shaderProgram.CreateVertexShader(Utils.LoadShaderCode("vertex.glsl")); shaderProgram.CreateFragmentShader(Utils.LoadShaderCode("fragment.glsl")); shaderProgram.Link(); shaderProgram.CreateUniform("viewMatrix"); shaderProgram.CreateUniform("worldMatrix"); shaderProgram.CreateUniform("projectionMatrix"); shaderProgram.CreateUniform("lightViewMatrix"); shaderProgram.CreateUniform("lightProjectionMatrix"); shaderProgram.CreateUniform("viewPos"); shaderProgram.CreateUniform("light.color"); shaderProgram.CreateUniform("light.direction"); shaderProgram.CreateUniform("light.ambientStrength"); shaderProgram.CreateUniform("light.position"); shaderProgram.CreateUniform("material.color"); shaderProgram.CreateUniform("material.specularStrength"); shaderProgram.CreateUniform("material.shininess"); shaderProgram.CreateUniform("shadowMap"); depthFbo = new ShadowMapFbo(shadowMapWidth, shadowMapHeight); depthShaderProgram = new ShaderProgram(); depthShaderProgram.CreateVertexShader(Utils.LoadShaderCode("depth_shadowmap_vertex.glsl")); depthShaderProgram.CreateFragmentShader(Utils.LoadShaderCode("depth_shadowmap_fragment.glsl")); depthShaderProgram.Link(); depthShaderProgram.CreateUniform("lightViewMatrix"); depthShaderProgram.CreateUniform("lightProjectionMatrix"); depthShaderProgram.CreateUniform("worldMatrix"); light = new Light(); light.SetDirection(new Vector3(-1f, -1f, -1f)); light.SetPosition(new Vector3(ncRooms / 2f * (rmWidth + gap), rmHeight + 2 * player.GetRadius() + lightHeightOffset, nrRooms / 2f * (rmWidth + gap))); light.InitiateBeam(100000f); player.SetPosition(light.GetPosition() - 1.2f * light.GetRadius() * Vector3.One); ico = new IcoSphere(100f, 5); ico.SetPosition(light.GetPosition() + 1000 * light.GetDirection()); stack = new Stack <int>(); rooms = new Room[nrRooms * ncRooms]; for (var i = 0; i < nrRooms; ++i) { for (var j = 0; j < ncRooms; ++j) { var offset = new Vector3(j * (rmWidth + gap), 0.0f, i * (rmWidth + gap)); rooms[GetFlatteredIndex(i, j)] = new Room(offset, rmWidth, rmHeight); } } plane = new Quad(Vector3.Zero, ncRooms * (rmWidth + gap), nrRooms * (rmWidth + gap), Vector3.UnitZ, Vector4.One); plane.UpdateRotation(MathHelper.DegreesToRadians(-90f), 0.0f, 0.0f); plane.UpdatePosition(Vector3.UnitZ * nrRooms * (rmWidth + gap)); curInd = GetFlatteredIndex(0, 0); rooms[curInd].Visit(); }