private void DrawBlock(VertexArray block, ClipmapLevel level, ClipmapLevel coarserLevel, int overallWest, int overallSouth, int blockWest, int blockSouth, Context context, SceneState sceneState) { int textureWest = blockWest - overallWest; int textureSouth = blockSouth - overallSouth; _patchOriginInClippedLevel.Value = new Vector2F(textureWest, textureSouth); DrawState drawState = new DrawState(_renderState, _shaderProgram, block); context.Draw(_primitiveType, drawState, sceneState); }
public void RenderInterleavedVertexBuffer() { string vs = @"#version 330 layout(location = og_positionVertexLocation) in vec4 position; layout(location = og_colorVertexLocation) in vec4 color; out vec4 fsColor; void main() { gl_Position = position; fsColor = color; }"; string fs = @"#version 330 in vec4 fsColor; out vec4 FragColor; void main() { FragColor = fsColor; }"; InterleavedVertex[] vertices = new InterleavedVertex[] { new InterleavedVertex() { Position = new Vector4F(0, 0, 0, 1), Color = new BlittableRGBA(Color.Red) }, new InterleavedVertex() { Position = new Vector4F(0, 0, 0, 1), Color = new BlittableRGBA(Color.FromArgb(255, 0, 255, 0)) } }; GraphicsWindow window = Device.CreateWindow(1, 1); Framebuffer framebuffer = TestUtility.CreateFramebuffer(window.Context); ShaderProgram sp = Device.CreateShaderProgram(vs, fs); VertexBuffer vertexBuffer = Device.CreateVertexBuffer(BufferHint.StaticDraw, ArraySizeInBytes.Size(vertices)); VertexArray va = window.Context.CreateVertexArray(); { int colorOffset = SizeInBytes <Vector4F> .Value; vertexBuffer.CopyFromSystemMemory(vertices); va.Attributes[sp.VertexAttributes["position"].Location] = new VertexBufferAttribute(vertexBuffer, ComponentDatatype.Float, 4, false, 0, SizeInBytes <InterleavedVertex> .Value); va.Attributes[sp.VertexAttributes["color"].Location] = new VertexBufferAttribute(vertexBuffer, ComponentDatatype.UnsignedByte, 4, true, colorOffset, SizeInBytes <InterleavedVertex> .Value); window.Context.Framebuffer = framebuffer; window.Context.Draw(PrimitiveType.Points, 0, 1, new DrawState(TestUtility.CreateRenderStateWithoutDepthTest(), sp, va), new SceneState()); TestUtility.ValidateColor(framebuffer.ColorAttachments[0], 255, 0, 0); window.Context.Draw(PrimitiveType.Points, 1, 1, new DrawState(TestUtility.CreateRenderStateWithoutDepthTest(), sp, va), new SceneState()); TestUtility.ValidateColor(framebuffer.ColorAttachments[0], 0, 255, 0); } }