public void Load() { _bitmap = new Bitmap(_voxelRTSWindow.Width, _voxelRTSWindow.Height); _voxelRTSWindow.Resize += (sender, e) => _isDirty = true; GL.GenTextures(1, out _texture); GL.BindTexture(TextureTarget.Texture2D, _texture); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); UpdateTexture(); _shader = new ShaderProgram(); _shader.OnMessage += _shader_OnMessage; using (var sr = new StreamReader("Shaders/TopMenu.Vert")) { _shader.AddShader(ShaderType.VertexShader, sr.ReadToEnd()); } using (var sr = new StreamReader("Shaders/TopMenu.Frag")) { _shader.AddShader(ShaderType.FragmentShader, sr.ReadToEnd()); } _shader.Link(); Loaded = true; }
public void Load() { _squareVertices = new[]{ //Front Face -Size, -Size, Size, Size, -Size, Size, Size, Size, Size, -Size, Size, Size, //Back Face -Size, -Size, -Size, -Size, Size, -Size, Size, Size, -Size, Size, -Size, -Size, //Top Face -Size, Size, -Size, -Size, Size, Size, Size, Size, Size, Size, Size, -Size, //Bottom Face -Size, -Size, -Size, Size, -Size, -Size, Size, -Size, Size, -Size, -Size, Size, //Right Face Size, -Size, -Size, Size, Size, -Size, Size, Size, Size, Size, -Size, Size, //Left Face -Size, -Size, -Size, -Size, -Size, Size, -Size, Size, Size, -Size, Size, -Size }; _shader = new ShaderProgram(); using (var sr = new StreamReader("Shaders/Voxel.Vert")) { _shader.AddShader(ShaderType.VertexShader, sr.ReadToEnd()); } using (var sr = new StreamReader("Shaders/VoxelGreen.Frag")) { _shader.AddShader(ShaderType.FragmentShader, sr.ReadToEnd()); } GL.BindAttribLocation(_shader.Program, 0, "position"); GL.BindAttribLocation(_shader.Program, 1, "instance_position"); GL.BindAttribLocation(_shader.Program, 2, "instance_rotation"); _shader.Link(); GL.GenVertexArrays(1, out _squareVao); GL.GenBuffers(1, out _squareVbo); GL.BindVertexArray(_squareVao); GL.BindBuffer(BufferTarget.ArrayBuffer, _squareVbo); GL.EnableVertexAttribArray(0); GL.EnableVertexAttribArray(1); GL.EnableVertexAttribArray(2); GL.Arb.VertexAttribDivisor(1, 1); GL.Arb.VertexAttribDivisor(2, 1); Loaded = true; }