-
Notifications
You must be signed in to change notification settings - Fork 0
/
GLHelper.cs
37 lines (27 loc) · 1.04 KB
/
GLHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
namespace drawing;
internal unsafe class GLHelper
{
public static WindowVertexBuffer windowBuffer;
public static void DrawWindowBuffer()
{
if (windowBuffer == null)
InitWindowBuffer();
windowBuffer.BindAndDraw();
}
static void InitWindowBuffer()
{
windowBuffer = new WindowVertexBuffer();
var data = (WindowVertex*)Allocator.Alloc(WindowVertexBuffer.VERTEX_COUNT * Marshal.SizeOf<WindowVertex>());
float pS = -1; // Position Start
float pE = 1; // Position End
float tS = 0; // TexCoord Start
float tE = 1; // TexCoord End
var write = data;
*write++ = new WindowVertex(pS, pE, tS, 1.0f - tE); // Top left ___
*write++ = new WindowVertex(pS, pS, tS, 1.0f - tS); // Bottom left | /|
*write++ = new WindowVertex(pE, pE, tE, 1.0f - tE); // Top right |/_|
*write++ = new WindowVertex(pE, pS, tE, 1.0f - tS); // Bottom right
windowBuffer.BufferData(data);
Allocator.Free(ref data);
}
}