JuicyGraphics/src/JuicyGraphics/renderer/graphicalObjects/gridBackground.cs

41 lines
1.2 KiB
C#
Raw Normal View History

using SharpGL.Shaders;
2019-02-15 01:14:17 +01:00
using SharpGL;
2019-02-19 02:30:48 +01:00
using System.Collections.Generic;
using SharpGL.VertexBuffers;
2019-02-14 15:46:16 +01:00
namespace Graphics.Objects {
class gridBackground : iGraphicalObject {
2019-02-19 02:30:48 +01:00
VertexBuffer vbo = new VertexBuffer();
VertexBufferArray vao = new VertexBufferArray();
ShaderProgram gridRender = new ShaderProgram();
public gridBackground(renderCam context) {
vao.Create(context.GL);
vao.Bind(context.GL);
gridRender.Create(context.GL, Shader.FromFile("default.vert"),
Shader.FromFile("background.frag"), new Dictionary<uint, string>()
{ { 0, "position" } });
vbo.Create(context.GL);
vbo.Bind(context.GL);
vbo.SetData(context.GL, 0, new float[] { -1.0f, -1.0f,
1.0f, -1.0f,
1.0f, 1.0f,
-1.0f, 1.0f }, false, 2);
vao.Unbind(context.GL);
}
2019-02-15 01:14:17 +01:00
const double realTileSize = 24.0f;
2019-02-14 15:46:16 +01:00
public void render(renderCam context) {
2019-02-15 01:14:17 +01:00
2019-02-19 02:30:48 +01:00
gridRender.Bind(context.GL);
vao.Bind(context.GL);
context.GL.DrawArrays(OpenGL.GL_QUADS, 0, 8);
vao.Unbind(context.GL);
gridRender.Unbind(context.GL);
2019-02-14 15:46:16 +01:00
}
}
}