Sfoglia il codice sorgente

Remove some aimlessness from renderers and rename render_* to draw_*

Daniele Bartolini 12 anni fa
parent
commit
e7a641dcea

+ 1 - 1
src/Terrain.cpp

@@ -278,7 +278,7 @@ void Terrain::Render()
 {
 	Renderer* renderer = device()->renderer();
 
-	renderer->render_triangles(
+	renderer->draw_triangles(
 				mVertices[0].to_float_ptr(),
 				mNormals[0].to_float_ptr(),
 				mTexCoords[0].to_float_ptr(),

+ 3 - 12
src/renderers/Renderer.h

@@ -67,13 +67,8 @@ enum DrawMode
 
 class Renderer
 {
-
 public:
 
-	static Renderer* CreateRenderer();
-	static void	DestroyRenderer(Renderer* renderer);
-
-
 	Renderer() {}
 	virtual ~Renderer() {}
 
@@ -183,15 +178,11 @@ public:
 	//! Loads the current matrix
 	virtual void set_matrix(MatrixType type, const Mat4& matrix) = 0;
 
-	//! Selects the active matrix
-	virtual void select_matrix(MatrixType type) = 0;
-
-	virtual void render_vertex_index_buffer(const VertexBuffer* vertices, const IndexBuffer* indices) = 0;
-
-	virtual void render_point_buffer(const VertexBuffer* buffer) = 0;
+	virtual void draw_vertex_index_buffer(const VertexBuffer* vertices, const IndexBuffer* indices) = 0;
+	virtual void draw_point_buffer(const VertexBuffer* buffer) = 0;
 
 	virtual void draw_lines(const float* vertices, const float* colors, uint32_t count) = 0;
-	virtual void render_triangles(const float* vertices, const float* normals, const float* uvs, const uint16_t* indices, uint32_t count) = 0;
+	virtual void draw_triangles(const float* vertices, const float* normals, const float* uvs, const uint16_t* indices, uint32_t count) = 0;
 
 	// FIXME
 	virtual TextureId	load_texture(TextureResource* texture) = 0;

+ 3 - 26
src/renderers/gl/GLRenderer.cpp

@@ -614,30 +614,7 @@ void GLRenderer::set_matrix(MatrixType type, const Mat4& matrix)
 }
 
 //-----------------------------------------------------------------------------
-void GLRenderer::select_matrix(MatrixType type)
-{
-	switch (type)
-	{
-		case MT_VIEW:
-		case MT_MODEL:
-			glMatrixMode(GL_MODELVIEW);
-			break;
-		case MT_PROJECTION:
-			glMatrixMode(GL_PROJECTION);
-			break;
-		case MT_TEXTURE:
-			glMatrixMode(GL_TEXTURE);
-			break;
-		case MT_COLOR:
-			glMatrixMode(GL_COLOR);
-			break;
-		default:
-			break;
-	}
-}
-
-//-----------------------------------------------------------------------------
-void GLRenderer::render_vertex_index_buffer(const VertexBuffer* vertices, const IndexBuffer* indices)
+void GLRenderer::draw_vertex_index_buffer(const VertexBuffer* vertices, const IndexBuffer* indices)
 {
 	assert(vertices != NULL);
 	assert(indices != NULL);
@@ -659,7 +636,7 @@ void GLRenderer::render_vertex_index_buffer(const VertexBuffer* vertices, const
 }
 
 //-----------------------------------------------------------------------------
-void GLRenderer::render_point_buffer(const VertexBuffer* buffer)
+void GLRenderer::draw_point_buffer(const VertexBuffer* buffer)
 {
 	if (buffer == NULL)
 		return;
@@ -763,7 +740,7 @@ void GLRenderer::draw_lines(const float* vertices, const float* colors, uint32_t
 }
 
 //-----------------------------------------------------------------------------
-void GLRenderer::render_triangles(const float* vertices, const float* normals, const float* uvs, const uint16_t* indices, uint32_t count)
+void GLRenderer::draw_triangles(const float* vertices, const float* normals, const float* uvs, const uint16_t* indices, uint32_t count)
 {
 	glBindBuffer(GL_ARRAY_BUFFER, 0);
 	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

+ 3 - 5
src/renderers/gl/GLRenderer.h

@@ -111,13 +111,11 @@ public:
 	Mat4				get_matrix(MatrixType type) const;
 	void				set_matrix(MatrixType type, const Mat4& matrix);
 
-	void				select_matrix(MatrixType type);
-
-	void				render_vertex_index_buffer(const VertexBuffer* vertices, const IndexBuffer* indices);
-	void				render_point_buffer(const VertexBuffer* buffer);
+	void				draw_vertex_index_buffer(const VertexBuffer* vertices, const IndexBuffer* indices);
+	void				draw_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				draw_triangles(const float* vertices, const float* normals, const float* uvs, const uint16_t* indices, uint32_t count);
 
 	TextureId			load_texture(TextureResource* texture);
 	void				unload_texture(TextureResource* texture);

+ 3 - 26
src/renderers/gles/GLESRenderer.cpp

@@ -565,30 +565,7 @@ void GLESRenderer::set_matrix(MatrixType type, const Mat4& matrix)
 }
 
 //-----------------------------------------------------------------------------
-void GLESRenderer::select_matrix(MatrixType type)
-{
-	switch (type)
-	{
-		case MT_VIEW:
-		case MT_MODEL:
-			glMatrixMode(GL_MODELVIEW);
-			break;
-		case MT_PROJECTION:
-			glMatrixMode(GL_PROJECTION);
-			break;
-		case MT_TEXTURE:
-			glMatrixMode(GL_TEXTURE);
-			break;
-		case MT_COLOR:
-			//glMatrixMode(GL_COLOR);
-			break;
-		default:
-			break;
-	}
-}
-
-//-----------------------------------------------------------------------------
-void GLESRenderer::render_vertex_index_buffer(const VertexBuffer* vertices, const IndexBuffer* indices)
+void GLESRenderer::draw_vertex_index_buffer(const VertexBuffer* vertices, const IndexBuffer* indices)
 {
 	assert(vertices != NULL);
 	assert(indices != NULL);
@@ -610,7 +587,7 @@ void GLESRenderer::render_vertex_index_buffer(const VertexBuffer* vertices, cons
 }
 
 //-----------------------------------------------------------------------------
-void GLESRenderer::render_point_buffer(const VertexBuffer* buffer)
+void GLESRenderer::draw_point_buffer(const VertexBuffer* buffer)
 {
 	if (buffer == NULL)
 		return;
@@ -711,7 +688,7 @@ void GLESRenderer::draw_lines(const float* vertices, const float* colors, uint32
 }
 
 //-----------------------------------------------------------------------------
-void GLESRenderer::render_triangles(const float* vertices, const float* normals, const float* uvs, const uint16_t* indices, uint32_t count)
+void GLESRenderer::draw_triangles(const float* vertices, const float* normals, const float* uvs, const uint16_t* indices, uint32_t count)
 {
 	glBindBuffer(GL_ARRAY_BUFFER, 0);
 	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

+ 3 - 5
src/renderers/gles/GLESRenderer.h

@@ -110,13 +110,11 @@ public:
 	Mat4				get_matrix(MatrixType type) const;
 	void				set_matrix(MatrixType type, const Mat4& matrix);
 
-	void				select_matrix(MatrixType type);
-
-	void				render_vertex_index_buffer(const VertexBuffer* vertices, const IndexBuffer* indices);
-	void				render_point_buffer(const VertexBuffer* buffer);
+	void				draw_vertex_index_buffer(const VertexBuffer* vertices, const IndexBuffer* indices);
+	void				draw_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				draw_triangles(const float* vertices, const float* normals, const float* uvs, const uint16_t* indices, uint32_t count);
 
 	TextureId			load_texture(TextureResource* texture);
 	void				unload_texture(TextureResource* texture);