blob: f417e143f314005a374193ae679af41d38fee85a (
plain) (
blame)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
using GLFW;
using SharpGL;
using System;
using Unicity.Renderer.Shapes;
using static SharpGL.OpenGL;
namespace Unicity.Renderer
{
public class GraphicsRenderer : IDisposable
{
internal static OpenGL GL = new OpenGL();
public RenderWindow window { get; }
public GraphicsRenderer(RenderWindow window)
{
this.window = window;
}
public void SetClearColor(float red, float green, float blue, float alpha)
{
GL.ClearColor(red, green, blue, alpha);
}
public void ClearScreen()
{
Glfw.MakeContextCurrent(window.window);
GL.Clear(GL_COLOR_BUFFER_BIT);
}
public void RenderShape(Shape shape)
{
shape.Render();
}
bool disposed = false;
protected virtual void Dispose(bool disposing)
{
// Return of already disposed
if (disposed)
{
return;
}
if (disposing)
{
// Free managed objects here
}
// Dispose of any unmanaged resources
window?.Dispose();
// Set disposed flag to true
disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
}
|