Explorar o código

Implement draw_lines() for GLESRenderer

Daniele Bartolini %!s(int64=12) %!d(string=hai) anos
pai
achega
fe0bc2781a
Modificáronse 2 ficheiros con 19 adicións e 0 borrados
  1. 18 0
      src/renderers/gles/GLESRenderer.cpp
  2. 1 0
      src/renderers/gles/GLESRenderer.h

+ 18 - 0
src/renderers/gles/GLESRenderer.cpp

@@ -692,6 +692,24 @@ void GLESRenderer::set_light_attenuation(uint32_t light, float constant, float l
 	glLightf(GL_LIGHT0 + light, GL_QUADRATIC_ATTENUATION, quadratic);
 	glLightf(GL_LIGHT0 + light, GL_QUADRATIC_ATTENUATION, quadratic);
 }
 }
 
 
+//-----------------------------------------------------------------------------
+void GLESRenderer::draw_lines(const float* vertices, const float* colors, uint32_t count)
+{
+	glBindBuffer(GL_ARRAY_BUFFER, 0);
+	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+
+	glEnableClientState(GL_VERTEX_ARRAY);
+	glEnableClientState(GL_COLOR_ARRAY);
+
+	glVertexPointer(3, GL_FLOAT, 0, vertices);
+	glColorPointer(4, GL_FLOAT, 0, colors);
+
+	glDrawArrays(GL_LINES, 0, count);
+
+	glDisableClientState(GL_COLOR_ARRAY);
+	glDisableClientState(GL_VERTEX_ARRAY);
+}
+
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 void GLESRenderer::render_triangles(const float* vertices, const float* normals, const float* uvs, const uint16_t* indices, uint32_t count)
 void GLESRenderer::render_triangles(const float* vertices, const float* normals, const float* uvs, const uint16_t* indices, uint32_t count)
 {
 {

+ 1 - 0
src/renderers/gles/GLESRenderer.h

@@ -115,6 +115,7 @@ public:
 	void				render_vertex_index_buffer(const VertexBuffer* vertices, const IndexBuffer* indices);
 	void				render_vertex_index_buffer(const VertexBuffer* vertices, const IndexBuffer* indices);
 	void				render_point_buffer(const VertexBuffer* buffer);
 	void				render_point_buffer(const VertexBuffer* buffer);
 
 
+	void				draw_lines(const float* vertices, const float* colors, uint32_t count);
 	void				render_triangles(const float* vertices, const float* normals, const float* uvs, const uint16_t* indices, uint32_t count);
 	void				render_triangles(const float* vertices, const float* normals, const float* uvs, const uint16_t* indices, uint32_t count);
 
 
 	TextureId			load_texture(TextureResource* texture);
 	TextureId			load_texture(TextureResource* texture);