mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-23 20:57:12 -04:00
Remove DrawMode/DrawVb/DrawIndexedVb, just provide DrawVb_Lines and DrawVb_IndexedTris
This commit is contained in:
parent
7f81de5ca6
commit
bf846b80c0
@ -100,7 +100,7 @@ namespace ClassicalSharp {
|
||||
public void EndBatch() {
|
||||
if (index > 0) {
|
||||
if (texIndex != lastIndex) game.Graphics.BindTexture(atlas.TexIds[texIndex]);
|
||||
game.Graphics.UpdateDynamicIndexedVb(DrawMode.Triangles, vb, vertices, index);
|
||||
game.Graphics.UpdateDynamicVb_IndexedTris(vb, vertices, index);
|
||||
index = 0;
|
||||
lastIndex = -1;
|
||||
}
|
||||
@ -165,7 +165,7 @@ namespace ClassicalSharp {
|
||||
int lastIndex, texIndex;
|
||||
void Flush() {
|
||||
if (lastIndex != -1) {
|
||||
game.Graphics.UpdateDynamicIndexedVb(DrawMode.Triangles, vb, vertices, index);
|
||||
game.Graphics.UpdateDynamicVb_IndexedTris(vb, vertices, index);
|
||||
index = 0;
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
|
||||
ModelCache cache = game.ModelCache;
|
||||
gfx.SetBatchFormat(VertexFormat.P3fT2fC4b);
|
||||
gfx.UpdateDynamicIndexedVb(DrawMode.Triangles, cache.vb, cache.vertices, index);
|
||||
gfx.UpdateDynamicVb_IndexedTris(cache.vb, cache.vertices, index);
|
||||
index = 0;
|
||||
}
|
||||
}
|
||||
|
@ -141,8 +141,7 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
posAtlas.Add(14, vertices, ref index);
|
||||
|
||||
gfx.BindTexture(posAtlas.tex.ID);
|
||||
gfx.UpdateDynamicIndexedVb(DrawMode.Triangles,
|
||||
game.ModelCache.vb, game.ModelCache.vertices, index);
|
||||
gfx.UpdateDynamicVb_IndexedTris(game.ModelCache.vb, game.ModelCache.vertices, index);
|
||||
}
|
||||
|
||||
bool speeding, halfSpeeding, noclip, fly;
|
||||
|
@ -54,8 +54,7 @@ namespace ClassicalSharp.Gui.Widgets {
|
||||
}
|
||||
|
||||
gfx.BindTexture(posAtlas.tex.ID);
|
||||
gfx.UpdateDynamicIndexedVb(DrawMode.Triangles,
|
||||
game.ModelCache.vb, game.ModelCache.vertices, index);
|
||||
gfx.UpdateDynamicVb_IndexedTris(game.ModelCache.vb, game.ModelCache.vertices, index);
|
||||
}
|
||||
|
||||
void DrawHearts() {
|
||||
@ -81,7 +80,7 @@ namespace ClassicalSharp.Gui.Widgets {
|
||||
}
|
||||
|
||||
gfx.BindTexture(game.Gui.IconsTex);
|
||||
gfx.UpdateDynamicIndexedVb(DrawMode.Triangles, cache.vb, cache.vertices, index);
|
||||
gfx.UpdateDynamicVb_IndexedTris(cache.vb, cache.vertices, index);
|
||||
}
|
||||
|
||||
static TextureRec backRec = new TextureRec(16 / 256f, 0 / 256f, 9 / 256f, 9 / 256f);
|
||||
|
@ -76,7 +76,7 @@ namespace ClassicalSharp.Entities {
|
||||
game.Graphics.BindTexture(shadowTex);
|
||||
boundShadowTex = true;
|
||||
}
|
||||
game.Graphics.UpdateDynamicIndexedVb(DrawMode.Triangles, vb, verts, index);
|
||||
game.Graphics.UpdateDynamicVb_IndexedTris(vb, verts, index);
|
||||
}
|
||||
|
||||
const byte c = 255; // avoids 'ambiguous match' compile errors.
|
||||
|
@ -143,8 +143,8 @@ namespace ClassicalSharp.Model {
|
||||
/// <summary> Sends the updated vertex data to the GPU. </summary>
|
||||
protected void UpdateVB() {
|
||||
ModelCache cache = game.ModelCache;
|
||||
game.Graphics.UpdateDynamicIndexedVb(
|
||||
DrawMode.Triangles, cache.vb, cache.vertices, index);
|
||||
game.Graphics.UpdateDynamicVb_IndexedTris(
|
||||
cache.vb, cache.vertices, index);
|
||||
index = 0;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ namespace ClassicalSharp.Entities {
|
||||
gfx.texVerts[3] = new VertexP3fT2fC4b(ref p212, nameTex.U2, nameTex.V2, col);
|
||||
|
||||
gfx.SetBatchFormat(VertexFormat.P3fT2fC4b);
|
||||
gfx.UpdateDynamicIndexedVb(DrawMode.Triangles, gfx.texVb, gfx.texVerts, 4);
|
||||
gfx.UpdateDynamicVb_IndexedTris(gfx.texVb, gfx.texVerts, 4);
|
||||
}
|
||||
|
||||
protected void CheckSkin() {
|
||||
|
@ -284,13 +284,13 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
device.SetIndices(iBuffers[ib]);
|
||||
}
|
||||
|
||||
public override void DrawVb(DrawMode mode, int startVertex, int verticesCount) {
|
||||
device.DrawPrimitives(modeMappings[(int)mode], startVertex, NumPrimitives(verticesCount, mode));
|
||||
public override void DrawVb_Lines(int startVertex, int verticesCount) {
|
||||
device.DrawPrimitives(PrimitiveType.LineList, startVertex, verticesCount / 2);
|
||||
}
|
||||
|
||||
public override void DrawIndexedVb(DrawMode mode, int indicesCount, int startIndex) {
|
||||
device.DrawIndexedPrimitives(modeMappings[(int)mode], 0, startIndex / 6 * 4,
|
||||
indicesCount / 6 * 4, startIndex, NumPrimitives(indicesCount, mode));
|
||||
public override void DrawVb_IndexedTris(int indicesCount, int startIndex) {
|
||||
device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, startIndex / 6 * 4,
|
||||
indicesCount / 6 * 4, startIndex, indicesCount / 3);
|
||||
}
|
||||
|
||||
internal override void DrawIndexedVb_TrisT2fC4b(int indicesCount, int startIndex) {
|
||||
@ -509,10 +509,6 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
id = -1;
|
||||
}
|
||||
|
||||
static int NumPrimitives(int vertices, DrawMode mode) {
|
||||
return mode == DrawMode.Triangles ? vertices / 3 : vertices / 2;
|
||||
}
|
||||
|
||||
protected unsafe override void LoadOrthoMatrix(float width, float height) {
|
||||
Matrix4 matrix = Matrix4.CreateOrthographicOffCenter(0, width, height, 0, -10000, 10000);
|
||||
const float zN = -10000, zF = 10000;
|
||||
|
@ -36,16 +36,16 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
|
||||
/// <summary> Binds and draws the specified subset of the vertices in the current dynamic vertex buffer<br/>
|
||||
/// This method also replaces the dynamic vertex buffer's data first with the given vertices before drawing. </summary>
|
||||
public void UpdateDynamicVb<T>(DrawMode mode, int vb, T[] vertices, int vCount) where T : struct {
|
||||
public void UpdateDynamicVb_Lines<T>(int vb, T[] vertices, int vCount) where T : struct {
|
||||
SetDynamicVbData(vb, vertices, vCount);
|
||||
DrawVb(mode, 0, vCount);
|
||||
DrawVb_Lines(0, vCount);
|
||||
}
|
||||
|
||||
/// <summary> Binds and draws the specified subset of the vertices in the current dynamic vertex buffer<br/>
|
||||
/// This method also replaces the dynamic vertex buffer's data first with the given vertices before drawing. </summary>
|
||||
public void UpdateDynamicIndexedVb<T>(DrawMode mode, int vb, T[] vertices, int vCount) where T : struct {
|
||||
public void UpdateDynamicVb_IndexedTris<T>(int vb, T[] vertices, int vCount) where T : struct {
|
||||
SetDynamicVbData(vb, vertices, vCount);
|
||||
DrawIndexedVb(mode, vCount * 6 / 4, 0);
|
||||
DrawVb_IndexedTris(vCount * 6 / 4, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
quadVerts[2] = new VertexP3fC4b(x + width, y + height, 0, c);
|
||||
quadVerts[3] = new VertexP3fC4b(x, y + height, 0, c);
|
||||
SetBatchFormat(VertexFormat.P3fC4b);
|
||||
UpdateDynamicIndexedVb(DrawMode.Triangles, quadVb, quadVerts, 4);
|
||||
UpdateDynamicVb_IndexedTris(quadVb, quadVerts, 4);
|
||||
}
|
||||
|
||||
public virtual void Draw2DQuad(float x, float y, float width, float height,
|
||||
@ -71,7 +71,7 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
quadVerts[2] = new VertexP3fC4b(x + width, y + height, 0, c);
|
||||
quadVerts[3] = new VertexP3fC4b(x, y + height, 0, c);
|
||||
SetBatchFormat(VertexFormat.P3fC4b);
|
||||
UpdateDynamicIndexedVb(DrawMode.Triangles, quadVb, quadVerts, 4);
|
||||
UpdateDynamicVb_IndexedTris(quadVb, quadVerts, 4);
|
||||
}
|
||||
|
||||
internal VertexP3fT2fC4b[] texVerts = new VertexP3fT2fC4b[4];
|
||||
@ -80,7 +80,7 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
int index = 0;
|
||||
Make2DQuad(ref tex, col.Pack(), texVerts, ref index);
|
||||
SetBatchFormat(VertexFormat.P3fT2fC4b);
|
||||
UpdateDynamicIndexedVb(DrawMode.Triangles, texVb, texVerts, 4);
|
||||
UpdateDynamicVb_IndexedTris(texVb, texVerts, 4);
|
||||
}
|
||||
|
||||
public static void Make2DQuad(ref Texture tex, int col,
|
||||
@ -152,10 +152,6 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
P3fC4b = 0, P3fT2fC4b = 1,
|
||||
}
|
||||
|
||||
public enum DrawMode {
|
||||
Triangles = 0, Lines = 1,
|
||||
}
|
||||
|
||||
public enum CompareFunc {
|
||||
Always = 0,
|
||||
NotEqual = 1,
|
||||
|
@ -170,11 +170,11 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
/// This method also replaces the dynamic vertex buffer's data first with the given vertices before drawing. </summary>
|
||||
public abstract void SetDynamicVbData<T>(int vb, T[] vertices, int vCount) where T : struct;
|
||||
|
||||
/// <summary> Draws the specified subset of the vertices in the current vertex buffer. </summary>
|
||||
public abstract void DrawVb(DrawMode mode, int startVertex, int vCount);
|
||||
/// <summary> Draws the specified subset of the vertices in the current vertex buffer as lines. </summary>
|
||||
public abstract void DrawVb_Lines(int startVertex, int vCount);
|
||||
|
||||
/// <summary> Draws the specified subset of the vertices in the current vertex buffer. </summary>
|
||||
public abstract void DrawIndexedVb(DrawMode mode, int indicesCount, int startIndex);
|
||||
/// <summary> Draws the specified subset of the vertices in the current vertex buffer as triangles. </summary>
|
||||
public abstract void DrawVb_IndexedTris(int indicesCount, int startIndex);
|
||||
|
||||
/// <summary> Optimised version of DrawIndexedVb for VertexFormat.Pos3fTex2fCol4b </summary>
|
||||
internal abstract void DrawIndexedVb_TrisT2fC4b(int indicesCount, int offsetVertex, int startIndex);
|
||||
|
@ -14,7 +14,6 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
/// or 1.2 with the GL_ARB_vertex_buffer_object extension. </summary>
|
||||
public unsafe class OpenGLApi : IGraphicsApi {
|
||||
|
||||
BeginMode[] modeMappings;
|
||||
bool glLists = false;
|
||||
int activeList = -1;
|
||||
const int dynamicListId = 1234567891;
|
||||
@ -306,14 +305,14 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
}
|
||||
|
||||
const DrawElementsType indexType = DrawElementsType.UnsignedShort;
|
||||
public override void DrawVb(DrawMode mode, int startVertex, int verticesCount) {
|
||||
public override void DrawVb_Lines(int startVertex, int verticesCount) {
|
||||
if (glLists) { DrawDynamicLines(verticesCount, startVertex); return; }
|
||||
|
||||
setupBatchFunc();
|
||||
GL.DrawArrays(modeMappings[(int)mode], startVertex, verticesCount);
|
||||
GL.DrawArrays(BeginMode.Lines, startVertex, verticesCount);
|
||||
}
|
||||
|
||||
public override void DrawIndexedVb(DrawMode mode, int indicesCount, int startIndex) {
|
||||
public override void DrawVb_IndexedTris(int indicesCount, int startIndex) {
|
||||
if (glLists) {
|
||||
if (activeList != dynamicListId) { GL.CallList(activeList); }
|
||||
else { DrawDynamicTriangles(indicesCount, startIndex); }
|
||||
@ -321,7 +320,7 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
}
|
||||
|
||||
setupBatchFunc();
|
||||
GL.DrawElements(modeMappings[(int)mode], indicesCount, indexType, new IntPtr(startIndex * 2));
|
||||
GL.DrawElements(BeginMode.Triangles, indicesCount, indexType, new IntPtr(startIndex * 2));
|
||||
}
|
||||
|
||||
void DrawDynamicLines(int verticesCount, int startVertex) {
|
||||
@ -498,9 +497,7 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
compareFuncs[2] = Compare.Never; compareFuncs[3] = Compare.Less;
|
||||
compareFuncs[4] = Compare.Lequal; compareFuncs[5] = Compare.Equal;
|
||||
compareFuncs[6] = Compare.Gequal; compareFuncs[7] = Compare.Greater;
|
||||
|
||||
modeMappings = new BeginMode[2];
|
||||
modeMappings[0] = BeginMode.Triangles; modeMappings[1] = BeginMode.Lines;
|
||||
|
||||
fogModes = new FogMode[3];
|
||||
fogModes[0] = FogMode.Linear; fogModes[1] = FogMode.Exp;
|
||||
fogModes[2] = FogMode.Exp2;
|
||||
|
@ -12,7 +12,6 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
/// <summary> Implements IGraphicsAPI using OpenGL ES 1.1 </summary>
|
||||
public unsafe class OpenGLESApi : IGraphicsApi {
|
||||
|
||||
All[] modeMappings;
|
||||
public OpenGLESApi() {
|
||||
InitFields();
|
||||
int texDims;
|
||||
@ -226,14 +225,14 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
}
|
||||
|
||||
const All indexType = All.UnsignedShort;
|
||||
public override void DrawVb(DrawMode mode, int startVertex, int verticesCount) {
|
||||
public override void DrawVb_Lines(int startVertex, int verticesCount) {
|
||||
setupBatchFunc();
|
||||
GL.DrawArrays(modeMappings[(int)mode], startVertex, verticesCount);
|
||||
GL.DrawArrays(All.Lines, startVertex, verticesCount);
|
||||
}
|
||||
|
||||
public override void DrawIndexedVb(DrawMode mode, int indicesCount, int startIndex) {
|
||||
public override void DrawVb_IndexedTris(int indicesCount, int startIndex) {
|
||||
setupBatchFunc();
|
||||
GL.DrawElements(modeMappings[(int)mode], indicesCount, indexType, new IntPtr(startIndex * 2));
|
||||
GL.DrawElements(All.Triangles, indicesCount, indexType, new IntPtr(startIndex * 2));
|
||||
}
|
||||
|
||||
internal override void DrawIndexedVb_TrisT2fC4b(int indicesCount, int startIndex) {
|
||||
@ -361,8 +360,6 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
}
|
||||
|
||||
void InitFields() {
|
||||
modeMappings = new All[2];
|
||||
modeMappings[0] = All.Triangles; modeMappings[1] = All.Lines;
|
||||
blendFuncs = new All[6];
|
||||
blendFuncs[0] = All.Zero; blendFuncs[1] = All.One;
|
||||
blendFuncs[2] = All.SrcAlpha; blendFuncs[3] = All.OneMinusSrcAlpha;
|
||||
|
@ -81,7 +81,7 @@ namespace ClassicalSharp.Particles {
|
||||
if (partCount == 0) continue;
|
||||
|
||||
gfx.BindTexture(game.TerrainAtlas1D.TexIds[i]);
|
||||
gfx.DrawIndexedVb(DrawMode.Triangles, partCount * 6 / 4, offset * 6 / 4);
|
||||
gfx.DrawVb_IndexedTris(partCount * 6 / 4, offset * 6 / 4);
|
||||
offset += partCount;
|
||||
}
|
||||
}
|
||||
@ -111,7 +111,7 @@ namespace ClassicalSharp.Particles {
|
||||
int drawCount = Math.Min(count, maxParticles * 4);
|
||||
if (drawCount == 0) return;
|
||||
gfx.BindTexture(ParticlesTexId);
|
||||
gfx.UpdateDynamicIndexedVb(DrawMode.Triangles, vb, vertices, drawCount);
|
||||
gfx.UpdateDynamicVb_IndexedTris(vb, vertices, drawCount);
|
||||
}
|
||||
|
||||
public void Tick(ScheduledTask task) {
|
||||
|
@ -54,7 +54,7 @@ namespace ClassicalSharp.Renderers {
|
||||
gfx.BindTexture(sideTexId);
|
||||
gfx.SetBatchFormat(VertexFormat.P3fT2fC4b);
|
||||
gfx.BindVb(sidesVb);
|
||||
gfx.DrawIndexedVb(DrawMode.Triangles, sidesVertices * 6 / 4, 0);
|
||||
gfx.DrawVb_IndexedTris(sidesVertices * 6 / 4, 0);
|
||||
|
||||
gfx.RestoreAlphaState(game.BlockInfo.Draw[block]);
|
||||
gfx.Texturing = false;
|
||||
@ -75,7 +75,7 @@ namespace ClassicalSharp.Renderers {
|
||||
// Fixes some 'depth bleeding through' issues with 16 bit depth buffers on large maps.
|
||||
float yVisible = Math.Min(0, map.Env.SidesHeight);
|
||||
if (camPos.Y >= yVisible)
|
||||
gfx.DrawIndexedVb(DrawMode.Triangles, edgesVertices * 6 / 4, 0);
|
||||
gfx.DrawVb_IndexedTris(edgesVertices * 6 / 4, 0);
|
||||
|
||||
gfx.RestoreAlphaState(game.BlockInfo.Draw[block]);
|
||||
gfx.Texturing = false;
|
||||
|
@ -73,7 +73,7 @@ namespace ClassicalSharp.Renderers {
|
||||
game.Graphics.LoadMatrix(ref m);
|
||||
|
||||
game.Graphics.BindVb(vb);
|
||||
game.Graphics.DrawIndexedVb(DrawMode.Triangles, count * 6 / 4, 0);
|
||||
game.Graphics.DrawVb_IndexedTris(count * 6 / 4, 0);
|
||||
|
||||
game.Graphics.Texturing = false;
|
||||
game.Graphics.LoadMatrix(ref game.View);
|
||||
|
@ -37,14 +37,14 @@ namespace ClassicalSharp.Renderers {
|
||||
gfx.SetBatchFormat(VertexFormat.P3fC4b);
|
||||
gfx.BindVb(skyVb);
|
||||
if (skyY == normalY) {
|
||||
gfx.DrawIndexedVb(DrawMode.Triangles, skyVertices * 6 / 4, 0);
|
||||
gfx.DrawVb_IndexedTris(skyVertices * 6 / 4, 0);
|
||||
} else {
|
||||
Matrix4 m = Matrix4.Identity;
|
||||
m.Row3.Y = skyY - normalY; // Y translation matrix
|
||||
|
||||
gfx.PushMatrix();
|
||||
gfx.MultiplyMatrix(ref m);
|
||||
gfx.DrawIndexedVb(DrawMode.Triangles, skyVertices * 6 / 4, 0);
|
||||
gfx.DrawVb_IndexedTris(skyVertices * 6 / 4, 0);
|
||||
gfx.PopMatrix();
|
||||
}
|
||||
RenderClouds(deltaTime);
|
||||
@ -114,7 +114,7 @@ namespace ClassicalSharp.Renderers {
|
||||
gfx.BindTexture(game.CloudsTex);
|
||||
gfx.SetBatchFormat(VertexFormat.P3fT2fC4b);
|
||||
gfx.BindVb(cloudsVb);
|
||||
gfx.DrawIndexedVb(DrawMode.Triangles, cloudVertices * 6 / 4, 0);
|
||||
gfx.DrawVb_IndexedTris(cloudVertices * 6 / 4, 0);
|
||||
gfx.AlphaTest = false;
|
||||
gfx.Texturing = false;
|
||||
|
||||
|
@ -108,7 +108,7 @@ namespace ClassicalSharp.Renderers {
|
||||
gfx.AlphaArgBlend = true;
|
||||
|
||||
gfx.SetBatchFormat(VertexFormat.P3fT2fC4b);
|
||||
gfx.UpdateDynamicIndexedVb(DrawMode.Triangles, vb, vertices, index);
|
||||
gfx.UpdateDynamicVb_IndexedTris(vb, vertices, index);
|
||||
|
||||
gfx.AlphaArgBlend = false;
|
||||
gfx.AlphaTest = true;
|
||||
|
@ -49,7 +49,7 @@ namespace ClassicalSharp.Selections {
|
||||
}
|
||||
|
||||
game.Graphics.SetBatchFormat(VertexFormat.P3fC4b);
|
||||
game.Graphics.UpdateDynamicIndexedVb(DrawMode.Triangles, vb, vertices, index);
|
||||
game.Graphics.UpdateDynamicVb_IndexedTris(vb, vertices, index);
|
||||
}
|
||||
|
||||
void ContextLost() { game.Graphics.DeleteVb(ref vb); }
|
||||
|
@ -64,7 +64,7 @@ namespace ClassicalSharp.Renderers {
|
||||
gfx.AlphaBlending = true;
|
||||
gfx.DepthWrite = false;
|
||||
gfx.SetBatchFormat(VertexFormat.P3fC4b);
|
||||
gfx.UpdateDynamicIndexedVb(DrawMode.Triangles, vb, vertices, index);
|
||||
gfx.UpdateDynamicVb_IndexedTris(vb, vertices, index);
|
||||
gfx.DepthWrite = true;
|
||||
gfx.AlphaBlending = false;
|
||||
}
|
||||
|
@ -67,12 +67,12 @@ namespace ClassicalSharp.Selections {
|
||||
}
|
||||
|
||||
gfx.SetBatchFormat(VertexFormat.P3fC4b);
|
||||
gfx.UpdateDynamicVb(DrawMode.Lines, lineVb, lineVertices,
|
||||
gfx.UpdateDynamicVb_Lines(lineVb, lineVertices,
|
||||
selections.Count * LineVerticesCount);
|
||||
|
||||
gfx.DepthWrite = false;
|
||||
gfx.AlphaBlending = true;
|
||||
gfx.UpdateDynamicIndexedVb(DrawMode.Triangles, vb, vertices,
|
||||
gfx.UpdateDynamicVb_IndexedTris(vb, vertices,
|
||||
selections.Count * VerticesCount);
|
||||
gfx.DepthWrite = true;
|
||||
gfx.AlphaBlending = false;
|
||||
|
@ -48,7 +48,7 @@ void AxisLinesRenderer_Render(Real64 delta) {
|
||||
}
|
||||
|
||||
Gfx_SetBatchFormat(VertexFormat_P3fC4b);
|
||||
GfxCommon_UpdateDynamicIndexedVb(DrawMode_Triangles, axisLines_vb, vertices, axisLines_numVertices);
|
||||
GfxCommon_UpdateDynamicVb_IndexedTris(axisLines_vb, vertices, axisLines_numVertices);
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,7 +55,7 @@ Gfx_SetTexturing(false);
|
||||
void BordersRenderer_RenderSides(Real64 delta) {
|
||||
BlockID block = WorldEnv_SidesBlock;
|
||||
BordersRenderer_SetupState(block, borders_sideTexId, borders_sidesVb)
|
||||
Gfx_DrawIndexedVb(DrawMode_Triangles, borders_sidesVertices * 6 / 4, 0);
|
||||
Gfx_DrawVb_IndexedTris(borders_sidesVertices * 6 / 4, 0);
|
||||
BordersRenderer_ResetState(block);
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ void BordersRenderer_RenderEdges(Real64 delta) {
|
||||
Vector3 camPos = Game_CurrentCameraPos;
|
||||
Int32 yVisible = min(0, WorldEnv_SidesHeight);
|
||||
if (camPos.Y >= yVisible) {
|
||||
Gfx_DrawIndexedVb(DrawMode_Triangles, borders_edgesVertices * 6 / 4, 0);
|
||||
Gfx_DrawVb_IndexedTris(borders_edgesVertices * 6 / 4, 0);
|
||||
}
|
||||
BordersRenderer_ResetState(block);
|
||||
}
|
||||
|
@ -26,8 +26,6 @@ String_AppendConstant(&logMsg, msg);\
|
||||
String_AppendInt32(&logMsg, i);\
|
||||
Platform_Log(logMsg);
|
||||
|
||||
#define D3D9_NumPrimitives(mode, vertices) (mode == DrawMode_Triangles ? vertices / 3 : vertices / 2)
|
||||
|
||||
|
||||
/* We only ever create a single index buffer internally. */
|
||||
#define d3d9_iBuffersExpSize 2
|
||||
@ -350,11 +348,10 @@ void Gfx_SetBatchFormat(VertexFormat vertexFormat) {
|
||||
d3d9_batchStride = Gfx_strideSizes[vertexFormat];
|
||||
}
|
||||
|
||||
void Gfx_DrawVb(DrawMode drawMode, Int32 startVertex, Int32 vCount) {
|
||||
Int32 numPrims = D3D9_NumPrimitives(drawMode, vCount);
|
||||
ReturnCode hresult = IDirect3DDevice9_DrawPrimitive(device, d3d9_modeMappings[drawMode],
|
||||
startVertex, numPrims);
|
||||
ErrorHandler_CheckOrFail(hresult, "D3D9_DrawVb");
|
||||
void Gfx_DrawVb_Lines(Int32 startVertex, Int32 vCount) {
|
||||
ReturnCode hresult = IDirect3DDevice9_DrawPrimitive(device, D3DPT_LINELIST,
|
||||
startVertex, vCount / 2);
|
||||
ErrorHandler_CheckOrFail(hresult, "D3D9_DrawVb_Lines");
|
||||
}
|
||||
|
||||
void Gfx_SetDynamicVbData(GfxResourceID vb, void* vertices, Int32 vCount) {
|
||||
@ -366,11 +363,10 @@ void Gfx_SetDynamicVbData(GfxResourceID vb, void* vertices, Int32 vCount) {
|
||||
ErrorHandler_CheckOrFail(hresult, "D3D9_SetDynamicVbData - Bind");
|
||||
}
|
||||
|
||||
void Gfx_DrawIndexedVb(DrawMode drawMode, Int32 indicesCount, Int32 startIndex) {
|
||||
Int32 numPrims = D3D9_NumPrimitives(drawMode, indicesCount);
|
||||
ReturnCode hresult = IDirect3DDevice9_DrawIndexedPrimitive(device, d3d9_modeMappings[drawMode], 0,
|
||||
VCOUNT(startIndex), VCOUNT(indicesCount), startIndex, numPrims);
|
||||
ErrorHandler_CheckOrFail(hresult, "D3D9_DrawIndexedVb");
|
||||
void Gfx_DrawVb_IndexedTris(Int32 indicesCount, Int32 startIndex) {
|
||||
ReturnCode hresult = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0,
|
||||
VCOUNT(startIndex), VCOUNT(indicesCount), startIndex, indicesCount / 3);
|
||||
ErrorHandler_CheckOrFail(hresult, "D3D9_DrawVb_IndexedTris");
|
||||
}
|
||||
|
||||
void Gfx_DrawIndexedVb_TrisT2fC4b_Range(Int32 indicesCount, Int32 offsetVertex, Int32 startIndex) {
|
||||
|
@ -25,7 +25,6 @@ typedef struct MatrixStack {
|
||||
} MatrixStack;
|
||||
|
||||
|
||||
D3DPRIMITIVETYPE d3d9_modeMappings[2] = { D3DPT_TRIANGLELIST, D3DPT_LINELIST };
|
||||
D3DFORMAT d3d9_depthFormats[6] = { D3DFMT_D32, D3DFMT_D24X8, D3DFMT_D24S8, D3DFMT_D24X4S4, D3DFMT_D16, D3DFMT_D15S1 };
|
||||
D3DFORMAT d3d9_viewFormats[4] = { D3DFMT_X8R8G8B8, D3DFMT_R8G8B8, D3DFMT_R5G6B5, D3DFMT_X1R5G5B5 };
|
||||
D3DBLEND d3d9_blendFuncs[6] = { D3DBLEND_ZERO, D3DBLEND_ONE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA, D3DBLEND_DESTALPHA, D3DBLEND_INVDESTALPHA };
|
||||
|
@ -76,7 +76,7 @@ void EnvRenderer_RenderClouds(Real64 delta) {
|
||||
Gfx_BindTexture(env_cloudsTex);
|
||||
Gfx_SetBatchFormat(VertexFormat_P3fT2fC4b);
|
||||
Gfx_BindVb(env_cloudsVb);
|
||||
Gfx_DrawIndexedVb(DrawMode_Triangles, env_cloudVertices * 6 / 4, 0);
|
||||
Gfx_DrawVb_IndexedTris(env_cloudVertices * 6 / 4, 0);
|
||||
Gfx_SetAlphaTest(false);
|
||||
Gfx_SetTexturing(false);
|
||||
|
||||
|
@ -158,11 +158,11 @@ void Gfx_SetBatchFormat(VertexFormat vertexFormat);
|
||||
This method also replaces the dynamic vertex buffer's data first with the given vertices before drawing. */
|
||||
void Gfx_SetDynamicVbData(GfxResourceID vb, void* vertices, Int32 vCount);
|
||||
|
||||
/* Draws the specified subset of the vertices in the current vertex buffer. */
|
||||
void Gfx_DrawVb(DrawMode drawMode, Int32 startVertex, Int32 vCount);
|
||||
/* Draws the specified subset of the vertices in the current vertex buffer as lines. */
|
||||
void Gfx_DrawVb_Lines(Int32 startVertex, Int32 vCount);
|
||||
|
||||
/* Draws the specified subset of the vertices in the current vertex buffer. */
|
||||
void Gfx_DrawIndexedVb(DrawMode drawMode, Int32 indicesCount, Int32 startIndex);
|
||||
/* Draws the specified subset of the vertices in the current vertex buffer as triangles. */
|
||||
void Gfx_DrawVb_IndexedTris(Int32 indicesCount, Int32 startIndex);
|
||||
|
||||
/* Optimised version of DrawIndexedVb for VertexFormat_Pos3fTex2fCol4b */
|
||||
void Gfx_DrawIndexedVb_TrisT2fC4b_Range(Int32 indicesCount, Int32 offsetVertex, Int32 startIndex);
|
||||
|
@ -32,14 +32,14 @@ void GfxCommon_RecreateContext(void) {
|
||||
}
|
||||
|
||||
|
||||
void GfxCommon_UpdateDynamicVb(Int32 drawMode, Int32 vb, void* vertices, Int32 vCount) {
|
||||
void GfxCommon_UpdateDynamicVb_Lines(Int32 vb, void* vertices, Int32 vCount) {
|
||||
Gfx_SetDynamicVbData(vb, vertices, vCount);
|
||||
Gfx_DrawVb(drawMode, 0, vCount);
|
||||
Gfx_DrawVb_Lines(0, vCount);
|
||||
}
|
||||
|
||||
void GfxCommon_UpdateDynamicIndexedVb(Int32 drawMode, Int32 vb, void* vertices, Int32 vCount) {
|
||||
void GfxCommon_UpdateDynamicVb_IndexedTris(Int32 vb, void* vertices, Int32 vCount) {
|
||||
Gfx_SetDynamicVbData(vb, vertices, vCount);
|
||||
Gfx_DrawIndexedVb(drawMode, vCount * 6 / 4, 0);
|
||||
Gfx_DrawVb_IndexedTris(vCount * 6 / 4, 0);
|
||||
}
|
||||
|
||||
void GfxCommon_Draw2DFlat(Real32 x, Real32 y, Real32 width, Real32 height,
|
||||
@ -51,7 +51,7 @@ void GfxCommon_Draw2DFlat(Real32 x, Real32 y, Real32 width, Real32 height,
|
||||
VertexP3fC4b_Set(&quadVerts[3], x, y + height, 0, col);
|
||||
|
||||
Gfx_SetBatchFormat(VertexFormat_P3fC4b);
|
||||
GfxCommon_UpdateDynamicIndexedVb(DrawMode_Triangles, GfxCommon_quadVb, quadVerts, 4);
|
||||
GfxCommon_UpdateDynamicVb_IndexedTris(GfxCommon_quadVb, quadVerts, 4);
|
||||
}
|
||||
|
||||
void GfxCommon_Draw2DGradient(Real32 x, Real32 y, Real32 width, Real32 height,
|
||||
@ -63,7 +63,7 @@ void GfxCommon_Draw2DGradient(Real32 x, Real32 y, Real32 width, Real32 height,
|
||||
VertexP3fC4b_Set(&quadVerts[3], x, y + height, 0, bottomCol);
|
||||
|
||||
Gfx_SetBatchFormat(VertexFormat_P3fC4b);
|
||||
GfxCommon_UpdateDynamicIndexedVb(DrawMode_Triangles, GfxCommon_quadVb, quadVerts, 4);
|
||||
GfxCommon_UpdateDynamicVb_IndexedTris(GfxCommon_quadVb, quadVerts, 4);
|
||||
}
|
||||
|
||||
void GfxCommon_Draw2DTexture(Texture* tex, PackedCol col) {
|
||||
@ -71,7 +71,7 @@ void GfxCommon_Draw2DTexture(Texture* tex, PackedCol col) {
|
||||
VertexP3fT2fC4b* ptr = texVerts;
|
||||
GfxCommon_Make2DQuad(tex, col, &ptr);
|
||||
Gfx_SetBatchFormat(VertexFormat_P3fT2fC4b);
|
||||
GfxCommon_UpdateDynamicIndexedVb(DrawMode_Triangles, GfxCommon_texVb, texVerts, 4);
|
||||
GfxCommon_UpdateDynamicVb_IndexedTris(GfxCommon_texVb, texVerts, 4);
|
||||
}
|
||||
|
||||
void GfxCommon_Make2DQuad(Texture* tex, PackedCol col, VertexP3fT2fC4b** vertices) {
|
||||
|
@ -26,11 +26,11 @@ void GfxCommon_RecreateContext(void);
|
||||
|
||||
/* Binds and draws the specified subset of the vertices in the current dynamic vertex buffer
|
||||
This method also replaces the dynamic vertex buffer's data first with the given vertices before drawing. */
|
||||
void GfxCommon_UpdateDynamicVb(Int32 drawMode, Int32 vb, void* vertices, Int32 vCount);
|
||||
void GfxCommon_UpdateDynamicVb_Lines(Int32 vb, void* vertices, Int32 vCount);
|
||||
|
||||
/*Binds and draws the specified subset of the vertices in the current dynamic vertex buffer
|
||||
This method also replaces the dynamic vertex buffer's data first with the given vertices before drawing. */
|
||||
void GfxCommon_UpdateDynamicIndexedVb(Int32 drawMode, Int32 vb, void* vertices, Int32 vCount);
|
||||
void GfxCommon_UpdateDynamicVb_IndexedTris(Int32 vb, void* vertices, Int32 vCount);
|
||||
|
||||
|
||||
GfxResourceID GfxCommon_quadVb;
|
||||
|
@ -9,12 +9,6 @@ typedef Int32 VertexFormat;
|
||||
#define VertexFormat_P3fT2fC4b 1
|
||||
|
||||
|
||||
/* 3D vertex drawing types*/
|
||||
typedef Int32 DrawMode;
|
||||
#define DrawMode_Triangles 0
|
||||
#define DrawMode_Lines 1
|
||||
|
||||
|
||||
/* 3D graphics pixel comparison functions */
|
||||
typedef Int32 CompareFunc;
|
||||
#define CompareFunc_Always 0
|
||||
|
@ -66,8 +66,7 @@ static Real32 IModel_MinDist(Real32 dist, Real32 extent) {
|
||||
|
||||
void IModel_UpdateVB(void) {
|
||||
IModel* model = IModel_ActiveModel;
|
||||
GfxCommon_UpdateDynamicIndexedVb(
|
||||
DrawMode_Triangles, ModelCache_Vb, ModelCache_Vertices, model->index);
|
||||
GfxCommon_UpdateDynamicVb_IndexedTris(ModelCache_Vb, ModelCache_Vertices, model->index);
|
||||
model->index = 0;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ void IsometricDrawer_DrawBatch(BlockID block, Real32 size, Real32 x, Real32 y) {
|
||||
void IsometricDrawer_EndBatch(void) {
|
||||
if (iso_count > 0) {
|
||||
if (iso_1DIndex != iso_last1DIndex) Gfx_BindTexture(Atlas1D_TexIds[iso_1DIndex]);
|
||||
GfxCommon_UpdateDynamicIndexedVb(DrawMode_Triangles, iso_vb, iso_vertices, iso_count);
|
||||
GfxCommon_UpdateDynamicVb_IndexedTris(iso_vb, iso_vertices, iso_count);
|
||||
|
||||
iso_count = 0;
|
||||
iso_last1DIndex = -1;
|
||||
@ -169,7 +169,7 @@ void IsometricDrawer_SpriteXQuad(BlockID block, bool firstPart) {
|
||||
|
||||
void IsometricDrawer_Flush(void) {
|
||||
if (iso_last1DIndex != -1) {
|
||||
GfxCommon_UpdateDynamicIndexedVb(DrawMode_Triangles, iso_vb, iso_vertices, iso_count);
|
||||
GfxCommon_UpdateDynamicVb_IndexedTris(iso_vb, iso_vertices, iso_count);
|
||||
iso_count = 0;
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,7 @@ void PickedPosRenderer_Render(Real64 delta) {
|
||||
Gfx_SetDepthWrite(false);
|
||||
Gfx_SetBatchFormat(VertexFormat_P3fC4b);
|
||||
|
||||
GfxCommon_UpdateDynamicIndexedVb(DrawMode_Triangles, pickedPos_vb,
|
||||
pickedPos_vertices, pickedPos_numVertices);
|
||||
GfxCommon_UpdateDynamicVb_IndexedTris(pickedPos_vb, pickedPos_vertices, pickedPos_numVertices);
|
||||
Gfx_SetDepthWrite(true);
|
||||
Gfx_SetAlphaBlending(false);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ void SkyboxRenderer_Render(Real64 deltaTime) {
|
||||
Gfx_LoadMatrix(&m);
|
||||
|
||||
Gfx_BindVb(skybox_vb);
|
||||
Gfx_DrawIndexedVb(DrawMode_Triangles, skybox_count * 6 / 4, 0);
|
||||
Gfx_DrawVb_IndexedTris(skybox_count * 6 / 4, 0);
|
||||
|
||||
Gfx_SetTexturing(false);
|
||||
Gfx_LoadMatrix(&Game_View);
|
||||
|
@ -124,7 +124,7 @@ void WeatherRenderer_Render(Real64 deltaTime) {
|
||||
Gfx_SetAlphaArgBlend(true);
|
||||
|
||||
Gfx_SetBatchFormat(VertexFormat_P3fT2fC4b);
|
||||
GfxCommon_UpdateDynamicIndexedVb(DrawMode_Triangles, weather_vb, weather_vertices, index);
|
||||
GfxCommon_UpdateDynamicVb_IndexedTris(weather_vb, weather_vertices, index);
|
||||
|
||||
Gfx_SetAlphaArgBlend(false);
|
||||
Gfx_SetDepthWrite(false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user