| 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 25 * POSSIBILITY OF SUCH DAMAGE. |
25 * POSSIBILITY OF SUCH DAMAGE. |
| 26 */ |
26 */ |
| 27 |
27 |
| |
28 #include "ascension/context.h" |
| 28 #include "ascension/error.h" |
29 #include "ascension/error.h" |
| 29 #include "ascension/mesh.h" |
30 #include "ascension/mesh.h" |
| 30 |
31 |
| 31 #include <cx/allocator.h> |
32 #include <cx/allocator.h> |
| 32 |
33 |
| 63 glDeleteVertexArrays(count, arrays); |
64 glDeleteVertexArrays(count, arrays); |
| 64 asc_error_catch_gl("Deleting mesh buffers"); |
65 asc_error_catch_gl("Deleting mesh buffers"); |
| 65 } |
66 } |
| 66 |
67 |
| 67 void asc_mesh_draw_triangle_strip(const AscMesh *mesh) { |
68 void asc_mesh_draw_triangle_strip(const AscMesh *mesh) { |
| |
69 AscGLCounters *counters = &asc_active_glctx->ctr; |
| |
70 counters->draw_calls++; |
| |
71 counters->vertices_rendered += mesh->vtx_count; |
| |
72 counters->triangles_rendered += mesh->vtx_count - 2; |
| 68 glBindVertexArray(mesh->vao); |
73 glBindVertexArray(mesh->vao); |
| 69 glDrawArrays(GL_TRIANGLE_STRIP, 0, mesh->vtx_count); |
74 glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei) mesh->vtx_count); |
| 70 asc_error_catch_gl("Drawing mesh"); |
75 asc_error_catch_gl("Drawing mesh"); |
| 71 #ifndef NDEBUG |
76 #ifndef NDEBUG |
| 72 // only unbind in debug mode to detect accidental re-use of the wrong VAO |
77 // only unbind in debug mode to detect accidental re-use of the wrong VAO |
| 73 glBindVertexArray(0); |
78 glBindVertexArray(0); |
| 74 #endif |
79 #endif |