| 863 | } |
| 864 | |
| 865 | void SimpleOpenGL3App::drawGrid(DrawGridData data) |
| 866 | { |
| 867 | int gridSize = data.gridSize; |
| 868 | float upOffset = data.upOffset; |
| 869 | int upAxis = data.upAxis; |
| 870 | float gridColor[4]; |
| 871 | gridColor[0] = data.gridColor[0]; |
| 872 | gridColor[1] = data.gridColor[1]; |
| 873 | gridColor[2] = data.gridColor[2]; |
| 874 | gridColor[3] = data.gridColor[3]; |
| 875 | |
| 876 | int sideAxis = -1; |
| 877 | int forwardAxis = -1; |
| 878 | |
| 879 | switch (upAxis) |
| 880 | { |
| 881 | case 1: |
| 882 | forwardAxis = 2; |
| 883 | sideAxis = 0; |
| 884 | break; |
| 885 | case 2: |
| 886 | forwardAxis = 1; |
| 887 | sideAxis = 0; |
| 888 | break; |
| 889 | default: |
| 890 | b3Assert(0); |
| 891 | }; |
| 892 | //b3Vector3 gridColor = b3MakeVector3(0.5,0.5,0.5); |
| 893 | |
| 894 | b3AlignedObjectArray<unsigned int> indices; |
| 895 | b3AlignedObjectArray<b3Vector3> vertices; |
| 896 | int lineIndex = 0; |
| 897 | for (int i = -gridSize; i <= gridSize; i++) |
| 898 | { |
| 899 | { |
| 900 | b3Assert(glGetError() == GL_NO_ERROR); |
| 901 | b3Vector3 from = b3MakeVector3(0, 0, 0); |
| 902 | from[sideAxis] = float(i); |
| 903 | from[upAxis] = upOffset; |
| 904 | from[forwardAxis] = float(-gridSize); |
| 905 | b3Vector3 to = b3MakeVector3(0, 0, 0); |
| 906 | to[sideAxis] = float(i); |
| 907 | to[upAxis] = upOffset; |
| 908 | to[forwardAxis] = float(gridSize); |
| 909 | vertices.push_back(from); |
| 910 | indices.push_back(lineIndex++); |
| 911 | vertices.push_back(to); |
| 912 | indices.push_back(lineIndex++); |
| 913 | // m_instancingRenderer->drawLine(from,to,gridColor); |
| 914 | } |
| 915 | |
| 916 | b3Assert(glGetError() == GL_NO_ERROR); |
| 917 | { |
| 918 | b3Assert(glGetError() == GL_NO_ERROR); |
| 919 | b3Vector3 from = b3MakeVector3(0, 0, 0); |
| 920 | from[sideAxis] = float(-gridSize); |
| 921 | from[upAxis] = upOffset; |
| 922 | from[forwardAxis] = float(i); |