summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/IndexGenerator.h
blob: 8d2a5e870060c4aa33ccb41aacff30e699fb31a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

// This is currently only used by the DX backend, but it may make sense to
// use it in the GL backend or a future DX10 backend too.

#pragma once

#include "Common/CommonTypes.h"

class IndexGenerator
{
public:
  // Init
  static void Init();
  static void Start(u16* Indexptr);

  static void AddIndices(int primitive, u32 numVertices);

  // returns numprimitives
  static u32 GetNumVerts() { return base_index; }
  static u32 GetIndexLen() { return (u32)(index_buffer_current - BASEIptr); }
  static u32 GetRemainingIndices();

private:
  // Triangles
  template <bool pr>
  static u16* AddList(u16* Iptr, u32 numVerts, u32 index);
  template <bool pr>
  static u16* AddStrip(u16* Iptr, u32 numVerts, u32 index);
  template <bool pr>
  static u16* AddFan(u16* Iptr, u32 numVerts, u32 index);
  template <bool pr>
  static u16* AddQuads(u16* Iptr, u32 numVerts, u32 index);
  template <bool pr>
  static u16* AddQuads_nonstandard(u16* Iptr, u32 numVerts, u32 index);

  // Lines
  static u16* AddLineList(u16* Iptr, u32 numVerts, u32 index);
  static u16* AddLineStrip(u16* Iptr, u32 numVerts, u32 index);

  // Points
  static u16* AddPoints(u16* Iptr, u32 numVerts, u32 index);

  template <bool pr>
  static u16* WriteTriangle(u16* Iptr, u32 index1, u32 index2, u32 index3);

  static u16* index_buffer_current;
  static u16* BASEIptr;
  static u32 base_index;
};