Fixed missing mesh.
This commit is contained in:
parent
a881f1a086
commit
378712283a
@ -1150,12 +1150,13 @@ namespace SlatedGameToolkit.Framework.Graphics.OpenGL
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private delegate void PFNGLBUFFERSUBDATAPROC(BufferTargetARB target, IntPtr offset, IntPtr size, IntPtr data);
|
||||
private delegate void PFNGLBUFFERSUBDATAPROC(BufferTargetARB target, IntPtr offset, UIntPtr size, IntPtr data);
|
||||
private PFNGLBUFFERSUBDATAPROC glBufferSubData;
|
||||
|
||||
public void BufferSubData(BufferTargetARB target, IntPtr offset, IntPtr size, IntPtr data)
|
||||
public void BufferSubData(BufferTargetARB target, IntPtr offset, UIntPtr size, IntPtr data)
|
||||
{
|
||||
glBufferSubData.Invoke(target, offset, size, data);
|
||||
DetectGLError();
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
@ -1165,6 +1166,7 @@ namespace SlatedGameToolkit.Framework.Graphics.OpenGL
|
||||
public void GetBufferSubData(BufferTargetARB target, IntPtr offset, IntPtr size, out IntPtr data)
|
||||
{
|
||||
glGetBufferSubData.Invoke(target, offset, size, out data);
|
||||
DetectGLError();
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
|
@ -11,6 +11,7 @@ using SlatedGameToolkit.Framework.Utilities;
|
||||
namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
{
|
||||
public class MeshBatch : IDisposable {
|
||||
public bool Debug { get; set; }
|
||||
private const int VERTEX_LENGTH = 9;
|
||||
private bool disposed;
|
||||
private float batchDelta;
|
||||
@ -122,10 +123,10 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
}
|
||||
int elementsCount = indices.Length;
|
||||
Array.Copy(indices, 0, this.indices, indicesIndex, elementsCount);
|
||||
indiceOffsets[offsetIndex] = indicesIndex * sizeof(uint);
|
||||
indicesIndex += elementsCount;
|
||||
if (offsetIndex + 1 < verticeOffsets.Length) {
|
||||
verticeOffsets[offsetIndex + 1] = verticeOffsets[offsetIndex] + vertices.Length;
|
||||
indiceOffsets[offsetIndex + 1] = indicesIndex * sizeof(int);
|
||||
}
|
||||
lengths[offsetIndex] = elementsCount;
|
||||
offsetIndex++;
|
||||
@ -153,6 +154,12 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
GLContext.UniformMatrix4fv(modelALoc, 1, false, modelsMatrix.ToColumnMajorArray());
|
||||
if (camera.ViewChanged) GLContext.UniformMatrix4fv(viewALoc, 1, false, camera.ViewMatrix.ToColumnMajorArray());
|
||||
if (camera.ProjectionChanged) GLContext.UniformMatrix4fv(projALoc, 1, false, camera.ProjectionMatrix.ToColumnMajorArray());
|
||||
|
||||
if (Debug) {
|
||||
GLContext.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
|
||||
} else {
|
||||
GLContext.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
|
||||
}
|
||||
GLContext.MultiDrawElementsBaseVertex(PrimitiveType.Triangles, lengths, DrawElementsType.UnsignedInt, indiceOffsets, offsetIndex, verticeOffsets);
|
||||
dataIndex = 0;
|
||||
indicesIndex = 0;
|
||||
|
@ -47,7 +47,7 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
glContext.BufferData(BufferTargetARB.ArrayBuffer, requiredLength, new IntPtr(pointer), dynamic ? OpenGL.BufferUsageARB.DynamicDraw : OpenGL.BufferUsageARB.StaticDraw);
|
||||
vertexBufferLength = requiredLength;
|
||||
} else {
|
||||
glContext.BufferSubData(BufferTargetARB.ArrayBuffer, IntPtr.Zero, new IntPtr(requiredLength), new IntPtr(pointer));
|
||||
glContext.BufferSubData(BufferTargetARB.ArrayBuffer, IntPtr.Zero, new UIntPtr(requiredLength), new IntPtr(pointer));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -60,7 +60,7 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
glContext.BufferData(OpenGL.BufferTargetARB.ElementArrayBuffer, requiredLength, new IntPtr(pointer), dynamic ? OpenGL.BufferUsageARB.DynamicDraw : OpenGL.BufferUsageARB.StaticDraw);
|
||||
indexBufferLength = requiredLength;
|
||||
} else {
|
||||
glContext.BufferSubData(BufferTargetARB.ElementArrayBuffer, IntPtr.Zero, new IntPtr(requiredLength), new IntPtr(pointer));
|
||||
glContext.BufferSubData(BufferTargetARB.ElementArrayBuffer, IntPtr.Zero, new UIntPtr(requiredLength), new IntPtr(pointer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,7 @@ void main()
|
||||
{
|
||||
if (textured) {
|
||||
if (singleChanneled) {
|
||||
float singleVal = texture(texture0, vec2(texCoord.x, 1 - texCoord.y)).r;
|
||||
outputColor = vec4(singleVal);
|
||||
outputColor = vec4(color.xyz, texture(texture0, vec2(texCoord.x, 1 - texCoord.y)).r);
|
||||
} else {
|
||||
outputColor = texture(texture0, vec2(texCoord.x, 1 - texCoord.y)) * color;
|
||||
}
|
||||
|
@ -86,7 +86,8 @@ namespace SlatedGameToolkit.Tools.Utilities.Playground
|
||||
renderer.Draw(logo);
|
||||
renderer.Draw(textureTester);
|
||||
renderer.Draw(untextured);
|
||||
font.Draw(renderer, delta, 0.25f, -0.25f, "123", Color.White);
|
||||
font.Draw(renderer, delta, 0.25f, -0.25f, "1234", Color.White);
|
||||
font.Draw(renderer, delta, 0.25f, -0.35f, "abcd", Color.White);
|
||||
renderer.End();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user