fna-workbench

fna-workbench Commit Details


Date:2016-03-18 11:57:52 (8 years 9 months ago)
Author:Ethan Lee
Branch:master
Commit:453dd6a2658c634ce511599c520a4b7e3c98eb3c
Parents: 1c26d09cbc32d7c3325c9cbfd67ce2dd8a7596d0
Message:XNAToGL-ify IndexElementSize

Changes:

File differences

src/Graphics/OpenGLDevice.cs
11201120
11211121
11221122
1123
1124
1125
11261123
11271124
11281125
......
11321129
11331130
11341131
1135
1136
1137
1138
1132
1133
11391134
11401135
11411136
......
11551150
11561151
11571152
1158
1159
1160
11611153
11621154
11631155
11641156
1165
1166
1167
1168
1157
1158
11691159
11701160
11711161
......
11971187
11981188
11991189
1200
1201
1202
12031190
12041191
12051192
12061193
12071194
12081195
1209
1210
1211
1196
12121197
12131198
1214
1199
12151200
12161201
12171202
......
21462131
21472132
21482133
2149
2134
21502135
21512136
21522137
......
41564141
41574142
41584143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
41594156
41604157
41614158
int primitiveCount,
IndexBuffer indices
) {
// Unsigned short or unsigned int?
bool shortIndices = indices.IndexElementSize == IndexElementSize.SixteenBits;
// Bind the index buffer
BindIndexBuffer(indices.buffer);
minVertexIndex,
minVertexIndex + numVertices - 1,
XNAToGL.PrimitiveVerts(primitiveType, primitiveCount),
shortIndices ?
GLenum.GL_UNSIGNED_SHORT :
GLenum.GL_UNSIGNED_INT,
(IntPtr) (startIndex * (shortIndices ? 2 : 4)),
XNAToGL.IndexType[(int) indices.IndexElementSize],
(IntPtr) (startIndex * XNAToGL.IndexSize[(int) indices.IndexElementSize]),
baseVertex
);
}
// Bind the index buffer
BindIndexBuffer(indices.buffer);
// Unsigned short or unsigned int?
bool shortIndices = indices.IndexElementSize == IndexElementSize.SixteenBits;
// Draw!
glDrawElementsInstancedBaseVertex(
XNAToGL.Primitive[(int) primitiveType],
XNAToGL.PrimitiveVerts(primitiveType, primitiveCount),
shortIndices ?
GLenum.GL_UNSIGNED_SHORT :
GLenum.GL_UNSIGNED_INT,
(IntPtr) (startIndex * (shortIndices ? 2 : 4)),
XNAToGL.IndexType[(int) indices.IndexElementSize],
(IntPtr) (startIndex * XNAToGL.IndexSize[(int) indices.IndexElementSize]),
instanceCount,
baseVertex
);
// Unbind current index buffer.
BindIndexBuffer(OpenGLBuffer.NullBuffer);
// Unsigned short or unsigned int?
bool shortIndices = indexElementSize == IndexElementSize.SixteenBits;
// Draw!
glDrawRangeElements(
XNAToGL.Primitive[(int) primitiveType],
0,
numVertices - 1,
XNAToGL.PrimitiveVerts(primitiveType, primitiveCount),
shortIndices ?
GLenum.GL_UNSIGNED_SHORT :
GLenum.GL_UNSIGNED_INT,
XNAToGL.IndexType[(int) indexElementSize],
(IntPtr) (
indexData.ToInt64() +
(indexOffset * (shortIndices ? 2 : 4))
(indexOffset * XNAToGL.IndexSize[(int) indexElementSize])
)
);
}
result = new OpenGLBuffer(
handle,
(IntPtr) (indexCount * (indexElementSize == IndexElementSize.SixteenBits ? 2 : 4)),
(IntPtr) (indexCount * XNAToGL.IndexSize[(int) indexElementSize]),
dynamic ? GLenum.GL_STREAM_DRAW : GLenum.GL_STATIC_DRAW
);
element.VertexElementFormat == VertexElementFormat.NormalizedShort4);
}
public static readonly GLenum[] IndexType = new GLenum[]
{
GLenum.GL_UNSIGNED_SHORT,// IndexElementSize.SixteenBits
GLenum.GL_UNSIGNED_INT// IndexElementSize.ThirtyTwoBits
};
public static readonly int[] IndexSize = new int[]
{
2,// IndexElementSize.SixteenBits
4// IndexElementSize.ThirtyTwoBits
};
public static readonly GLenum[] Primitive = new GLenum[]
{
GLenum.GL_TRIANGLES,// PrimitiveType.TriangleList

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.06085s using 13 queries.