SHARE
TWEET
Untitled
a guest
Dec 18th, 2014
6
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- namespace ConsoleApplication1
- {
- class Program
- {
- static GameWindow Window = new GameWindow(800, 600, GraphicsMode.Default, "OpenTK Window", GameWindowFlags.Default, DisplayDevice.Default);
- static void Main()
- {
- Window.Visible = true;
- int vertextId = GL.CreateShader(ShaderType.VertexShader);
- string vertextShader = "void main() { gl_Position = ftransform(); }";
- GL.ShaderSource(vertextId, vertextShader);
- GL.CompileShader(vertextId);
- int fragmentId = GL.CreateShader(ShaderType.FragmentShader);
- string fragmentShader = "outputColor = vec4(1.0f, 1.0f, 1.0f, 1.0f);";
- GL.ShaderSource(fragmentId, fragmentShader);
- GL.CompileShader(fragmentId);
- int program = GL.CreateProgram();
- GL.AttachShader(program, vertextId);
- GL.AttachShader(program, fragmentId);
- GL.LinkProgram(program);
- int buffer = GL.GenBuffer();
- GL.ClearColor(Color.Black);
- float[] vertices = {
- 0.0f, 0.5f, // Vertex 1 (X, Y)
- 0.5f, -0.5f, // Vertex 2 (X, Y)
- -0.5f, -0.5f // Vertex 3 (X, Y)
- };
- while(true)
- {
- Window.ProcessEvents();
- GL.Clear(ClearBufferMask.ColorBufferBit);
- //GL.UseProgram(program);
- GL.EnableVertexAttribArray(0);
- GL.BindBuffer(BufferTarget.ArrayBuffer, buffer);
- GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);
- GL.BufferData(BufferTarget.ArrayBuffer, new IntPtr(vertices.GetLength(0)), vertices, BufferUsageHint.StaticDraw);
- GL.DrawArrays(PrimitiveType.Triangles, 0, 3);
- GL.DisableVertexAttribArray(0);
- Window.SwapBuffers();
- Console.WriteLine(GL.GetError());
- }
- }
- }
- }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

