1+ using OpenTK . Windowing . Common ;
2+ using OpenTK . Windowing . Desktop ;
3+ using OpenTK . Graphics . OpenGL4 ;
4+ using System ;
5+ using System . Collections . Generic ;
6+ using System . Linq ;
7+ using System . Text ;
8+ using System . Threading . Tasks ;
9+
10+ namespace FreeFrame
11+ {
12+ class Window : GameWindow
13+ {
14+ int _vertexBuffer ;
15+
16+ public readonly float [ ] _vertices =
17+ {
18+ 0.0f , - 0.5f , 0.0f , // Top
19+ - 0.5f , 0.5f , 0.0f , // Bottom-Left
20+ 0.5f , 0.5f , 0.0f // Bottom-Right
21+ } ;
22+ public Window ( GameWindowSettings gameWindowSettings , NativeWindowSettings nativeWindowSettings ) : base ( gameWindowSettings , nativeWindowSettings ) { }
23+ protected override void OnLoad ( )
24+ {
25+ base . OnLoad ( ) ;
26+ _vertexBuffer = GL . GenBuffer ( ) ;
27+ GL . BindBuffer ( BufferTarget . ArrayBuffer , _vertexBuffer ) ;
28+
29+ GL . BufferData ( BufferTarget . ArrayBuffer , _vertices . Length * sizeof ( float ) , _vertices , BufferUsageHint . StaticDraw ) ;
30+
31+ GL . VertexAttribPointer ( 0 , 3 , VertexAttribPointerType . Float , false , 3 * sizeof ( float ) , 0 ) ;
32+ GL . EnableVertexAttribArray ( 0 ) ;
33+
34+ }
35+ protected override void OnResize ( ResizeEventArgs e )
36+ {
37+ base . OnResize ( e ) ;
38+ // TODO: map the new NDC to the window
39+ }
40+ /// <summary>
41+ /// Triggered at a fixed interval. (Logic, etc.)
42+ /// </summary>
43+ /// <param name="e"></param>
44+ protected override void OnUpdateFrame ( FrameEventArgs e )
45+ {
46+ base . OnUpdateFrame ( e ) ;
47+ }
48+ /// <summary>
49+ /// Triggered as often as possible (fps). (Drawing, etc.)
50+ /// </summary>
51+ /// <param name="e"></param>
52+ protected override void OnRenderFrame ( FrameEventArgs e )
53+ {
54+ base . OnRenderFrame ( e ) ;
55+ GL . DrawArrays ( PrimitiveType . Triangles , 0 , 3 ) ;
56+ }
57+
58+ protected override void OnUnload ( )
59+ {
60+ base . OnUnload ( ) ;
61+ }
62+ }
63+ }
0 commit comments