SHARE
TWEET

Untitled

a guest Dec 18th, 2014 6 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace ConsoleApplication1
  2. {
  3.     class Program
  4.     {
  5.         static GameWindow Window = new GameWindow(800, 600, GraphicsMode.Default, "OpenTK Window", GameWindowFlags.Default, DisplayDevice.Default);
  6.  
  7.         static void Main()
  8.         {
  9.             Window.Visible = true;
  10.  
  11.             int vertextId = GL.CreateShader(ShaderType.VertexShader);
  12.             string vertextShader = "void main() { gl_Position = ftransform(); }";
  13.             GL.ShaderSource(vertextId, vertextShader);
  14.             GL.CompileShader(vertextId);
  15.  
  16.             int fragmentId = GL.CreateShader(ShaderType.FragmentShader);
  17.             string fragmentShader = "outputColor = vec4(1.0f, 1.0f, 1.0f, 1.0f);";
  18.             GL.ShaderSource(fragmentId, fragmentShader);
  19.             GL.CompileShader(fragmentId);
  20.  
  21.             int program = GL.CreateProgram();
  22.             GL.AttachShader(program, vertextId);
  23.             GL.AttachShader(program, fragmentId);
  24.             GL.LinkProgram(program);
  25.  
  26.             int buffer = GL.GenBuffer();
  27.  
  28.             GL.ClearColor(Color.Black);
  29.  
  30.             float[] vertices = {
  31.                     0.0f,  0.5f, // Vertex 1 (X, Y)
  32.                     0.5f, -0.5f, // Vertex 2 (X, Y)
  33.                     -0.5f, -0.5f  // Vertex 3 (X, Y)
  34.                 };
  35.  
  36.             while(true)
  37.             {
  38.                 Window.ProcessEvents();
  39.                
  40.                 GL.Clear(ClearBufferMask.ColorBufferBit);
  41.  
  42.                 //GL.UseProgram(program);
  43.  
  44.                 GL.EnableVertexAttribArray(0);
  45.  
  46.                 GL.BindBuffer(BufferTarget.ArrayBuffer, buffer);
  47.  
  48.                 GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);
  49.  
  50.                 GL.BufferData(BufferTarget.ArrayBuffer, new IntPtr(vertices.GetLength(0)), vertices, BufferUsageHint.StaticDraw);
  51.  
  52.                 GL.DrawArrays(PrimitiveType.Triangles, 0, 3);
  53.  
  54.                 GL.DisableVertexAttribArray(0);
  55.  
  56.                 Window.SwapBuffers();
  57.  
  58.                 Console.WriteLine(GL.GetError());
  59.             }
  60.         }
  61.     }
  62. }
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. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top