2
0
Daniele Bartolini 12 жил өмнө
parent
commit
805303b6e8

+ 64 - 65
src/renderers/Renderer.h

@@ -77,147 +77,146 @@ public:
 
 	/// Creates a new vertex buffer optimized for rendering static vertex data.
 	/// @vertices is the array containig @count vertex data elements of the given @format.
-	virtual VertexBufferId	create_vertex_buffer(const void* vertices, size_t count, VertexFormat format) = 0;
+	virtual VertexBufferId	create_vertex_buffer(size_t count, VertexFormat format, const void* vertices) = 0;
 
 	/// Creates a new vertex buffer optimized for rendering dynamic vertex data.
 	/// @vertices is the array containig @count vertex data elements of the given @format.
-	virtual VertexBufferId	create_dynamic_vertex_buffer(const void* vertices, size_t count, VertexFormat format) = 0;
+	virtual VertexBufferId	create_dynamic_vertex_buffer(size_t count, VertexFormat format, const void* vertices) = 0;
 
 	/// Updates the data associated with the given vertex buffer @id.
 	/// @vertices is the array containig @count vertex data elements of the format
 	/// specified at the creation of the buffer.
 	/// @note
 	/// @count and @offset together do not have to exceed the number of elements specified
-	/// at the creation of the buffer.
-	virtual void			update_vertex_buffer(VertexBufferId id, const void* vertices, size_t count, size_t offset) = 0;
+	/// at the creation of the buffer.	
+	virtual void			update_vertex_buffer(VertexBufferId id, size_t offset, size_t count, const void* vertices) = 0;
 
 	/// Destroys the @id vertex buffer.
 	virtual void			destroy_vertex_buffer(VertexBufferId id) = 0;
 
 	/// Creates a new index buffer optimized for rendering static index buffers.
 	/// @indices is the array containing @count index data elements.
-	virtual IndexBufferId	create_index_buffer(const void* indices, size_t count) = 0;
+	virtual IndexBufferId	create_index_buffer(size_t count, const void* indices) = 0;
 
 	/// Destroys the @id index buffer.
 	virtual void			destroy_index_buffer(IndexBufferId id) = 0;
 
-
-	virtual TextureId		create_texture(uint32_t width, uint32_t height, const void* data, PixelFormat format) = 0;
+	virtual TextureId		create_texture(uint32_t width, uint32_t height, PixelFormat format, const void* data) = 0;
 	virtual void			update_texture(TextureId id, uint32_t x, uint32_t y, uint32_t width, uint32_t height, const void* data) = 0;
-	virtual void			destroy_texture(TextureId id) = 0;
+	virtual void			destroy_texture(TextureId id);
 
 	//virtual RenderBufferId	create_render_buffer(uint32_t width, uint32_t height, PixelFormat format) = 0;
 	//virtual void			destroy_render_buffer(RenderBufferId id) = 0;
 
 	///	Tasks to perform before a frame is rendered.
-	virtual void begin_frame() = 0;
+	virtual void			begin_frame() = 0;
 
 	/// Tasks to perform after a frame is rendered.
-	virtual void end_frame() = 0;
+	virtual void			end_frame() = 0;
 
 	/// Sets the clearing color of the framebuffer.
-	virtual void set_clear_color(const Color4& color) = 0;
+	virtual void			set_clear_color(const Color4& color) = 0;
 
-	virtual void set_material_params(const Color4& ambient, const Color4& diffuse, const Color4& specular,
-					const Color4& emission, int32_t shininess) = 0;
+	virtual void			set_material_params(const Color4& ambient, const Color4& diffuse, const Color4& specular,
+												const Color4& emission, int32_t shininess) = 0;
 
 	
 	/// Sets whether lighting is enabled.
-	virtual void set_lighting(bool lighting) = 0;
+	virtual void			set_lighting(bool lighting) = 0;
 
 	/// Sets the global ambient light @color.
-	virtual void set_ambient_light(const Color4& color) = 0;
+	virtual void			set_ambient_light(const Color4& color) = 0;
 
 	//! Sets the texture to use in the specified layer
-	virtual void bind_texture(uint32_t layer, TextureId texture) = 0;
+	virtual void			bind_texture(uint32_t layer, TextureId texture) = 0;
 
 	/// Set whether the given texture @unit is enabled.
-	virtual void set_texturing(uint32_t unit, bool texturing) = 0;
+	virtual void			set_texturing(uint32_t unit, bool texturing) = 0;
 
 	/// Sets the texture @mode for the given texture @unit.
-	virtual void set_texture_mode(uint32_t unit, TextureMode mode, const Color4& blendColor) = 0;
+	virtual void			set_texture_mode(uint32_t unit, TextureMode mode, const Color4& blendColor) = 0;
 
 	/// Sets the texture @wrap parameter for the given texture @unit.
-	virtual void set_texture_wrap(uint32_t unit, TextureWrap wrap) = 0;
+	virtual void			set_texture_wrap(uint32_t unit, TextureWrap wrap) = 0;
 
 	/// Sets the @filter for the given texture @unit.
-	virtual void set_texture_filter(uint32_t unit, TextureFilter filter) = 0;
+	virtual void			set_texture_filter(uint32_t unit, TextureFilter filter) = 0;
 
-	virtual void set_light(uint32_t light, bool active) = 0;
-	virtual void set_light_params(uint32_t light, LightType type, const Vec3& position) = 0;
-	virtual void set_light_color(uint32_t light, const Color4& ambient, const Color4& diffuse, const Color4& specular) = 0;
-	virtual void set_light_attenuation(uint32_t light, float constant, float linear, float quadratic) = 0;
+	virtual void			set_light(uint32_t light, bool active) = 0;
+	virtual void			set_light_params(uint32_t light, LightType type, const Vec3& position) = 0;
+	virtual void			set_light_color(uint32_t light, const Color4& ambient, const Color4& diffuse, const Color4& specular) = 0;
+	virtual void			set_light_attenuation(uint32_t light, float constant, float linear, float quadratic) = 0;
 
 	/// Sets whether backface-culling is enabled.
-	virtual void set_backface_culling(bool culling) = 0;
+	virtual void			set_backface_culling(bool culling) = 0;
 
 	/// Sets whether separate specular color is enabled.	
-	virtual void set_separate_specular_color(bool separate) = 0;
+	virtual void			set_separate_specular_color(bool separate) = 0;
 
 	/// Sets whether depth test is enabled.
-	virtual void set_depth_test(bool test) = 0;
+	virtual void			set_depth_test(bool test) = 0;
 
 	/// Sets whether writing to depth buffer is enabled.
-	virtual void set_depth_write(bool write) = 0;
+	virtual void			set_depth_write(bool write) = 0;
 
 	/// Sets the depth function to use when testing depth values.
-	virtual void set_depth_func(CompareFunction func) = 0;
+	virtual void			set_depth_func(CompareFunction func) = 0;
 
 	///	Sets whether normal vectors are scaled after transformations
 	///	and before lighting.
 	/// @note
 	///	If the modelview matrix scales space uniformly, this
 	///	has the effect of restoring the trasformed normal to unit length.
-	virtual void set_rescale_normals(bool rescale) = 0;
+	virtual void			set_rescale_normals(bool rescale) = 0;
 
 	/// Sets whether blending is enabled.
-	virtual void set_blending(bool blending) = 0;
+	virtual void			set_blending(bool blending) = 0;
 
 	///	Specifies blending parameters.
 	/// @note
 	///	This method specifies the blend equation, the blend function
 	///	for source and destination pixel values and a const blend color.
-	virtual void set_blending_params(BlendEquation equation, BlendFunction src, BlendFunction dst, const Color4& color) = 0;
+	virtual void			set_blending_params(BlendEquation equation, BlendFunction src, BlendFunction dst, const Color4& color) = 0;
 
 	/// Sets whether writing to color buffer is enabled.
-	virtual void set_color_write(bool write) = 0;
+	virtual void			set_color_write(bool write) = 0;
 
 	/// Sets whether fog is enabled.
-	virtual void set_fog(bool fog) = 0;
+	virtual void			set_fog(bool fog) = 0;
 
 	/// Specifies fog parameters.
-	virtual void set_fog_params(FogMode mode, float density, float start, float end, const Color4& color) = 0;
-
-	virtual void set_alpha_test(bool test) = 0;
-
-	virtual void set_alpha_params(CompareFunction func, float ref) = 0;
-
-	virtual void set_shading_type(ShadingType type) = 0;
-
-	virtual void set_polygon_mode(PolygonMode mode) = 0;
-
-	virtual void set_front_face(FrontFace face) = 0;
-
-	virtual void set_viewport_params(int32_t x, int32_t y, int32_t width, int32_t height) = 0;
-	virtual void get_viewport_params(int32_t& x, int32_t& y, int32_t& width, int32_t& height) = 0;
-
-	virtual void set_scissor(bool scissor) = 0;
-	virtual void set_scissor_params(int32_t x, int32_t y, int32_t width, int32_t height) = 0;
-	virtual void get_scissor_params(int32_t& x, int32_t& y, int32_t& width, int32_t& height) = 0;
-
-	virtual void set_point_sprite(bool sprite) = 0;
-	virtual void set_point_size(float size) = 0;
-	virtual void set_point_params(float min, float max) = 0;
-
-	virtual Mat4 get_matrix(MatrixType type) const = 0;
-	virtual void set_matrix(MatrixType type, const Mat4& matrix) = 0;
-
-	virtual void bind_vertex_buffer(VertexBufferId vb) const = 0;
+	virtual void			set_fog_params(FogMode mode, float density, float start, float end, const Color4& color) = 0;
+
+	virtual void			set_alpha_test(bool test) = 0;
+
+	virtual void			set_alpha_params(CompareFunction func, float ref) = 0;
+
+	virtual void			set_shading_type(ShadingType type) = 0;
+
+	virtual void 			set_polygon_mode(PolygonMode mode) = 0;
+				
+	virtual void 			set_front_face(FrontFace face) = 0;
+				
+	virtual void 			set_viewport_params(int32_t x, int32_t y, int32_t width, int32_t height) = 0;
+	virtual void 			get_viewport_params(int32_t& x, int32_t& y, int32_t& width, int32_t& height) = 0;
+				
+	virtual void 			set_scissor(bool scissor) = 0;
+	virtual void 			set_scissor_params(int32_t x, int32_t y, int32_t width, int32_t height) = 0;
+	virtual void 			get_scissor_params(int32_t& x, int32_t& y, int32_t& width, int32_t& height) = 0;
+				
+	virtual void 			set_point_sprite(bool sprite) = 0;
+	virtual void 			set_point_size(float size) = 0;
+	virtual void 			set_point_params(float min, float max) = 0;
+				
+	virtual Mat4 			get_matrix(MatrixType type) const = 0;
+	virtual void 			set_matrix(MatrixType type, const Mat4& matrix) = 0;
+				
+	virtual void 			bind_vertex_buffer(VertexBufferId vb) const = 0;
 	//virtual void bind_render_buffer(RenderBufferId id) const = 0;
-
-	virtual void draw_triangles(IndexBufferId id) const = 0;
-
-	virtual void draw_lines(const float* vertices, const float* colors, uint32_t count) = 0;
+				
+	virtual void 			draw_triangles(IndexBufferId id) const = 0;
+				
+	virtual void 			draw_lines(const float* vertices, const float* colors, uint32_t count) = 0;
 };
 
 } // namespace crown

+ 5 - 5
src/renderers/gl/GLRenderer.cpp

@@ -188,7 +188,7 @@ GLRenderer::~GLRenderer()
 }
 
 //-----------------------------------------------------------------------------
-VertexBufferId GLRenderer::create_vertex_buffer(const void* vertices, size_t count, VertexFormat format)
+VertexBufferId GLRenderer::create_vertex_buffer(size_t count, VertexFormat format, const void* vertices)
 {
 	const VertexBufferId id = m_vertex_buffers_id_table.create();
 
@@ -206,7 +206,7 @@ VertexBufferId GLRenderer::create_vertex_buffer(const void* vertices, size_t cou
 }
 
 //-----------------------------------------------------------------------------
-VertexBufferId GLRenderer::create_dynamic_vertex_buffer(const void* vertices, size_t count, VertexFormat format)
+VertexBufferId GLRenderer::create_dynamic_vertex_buffer(size_t count, VertexFormat format, const void* vertices)
 {
 	const VertexBufferId id = m_vertex_buffers_id_table.create();
 
@@ -224,7 +224,7 @@ VertexBufferId GLRenderer::create_dynamic_vertex_buffer(const void* vertices, si
 }
 
 //-----------------------------------------------------------------------------
-void GLRenderer::update_vertex_buffer(VertexBufferId id, const void* vertices, size_t count, size_t offset)
+void GLRenderer::update_vertex_buffer(VertexBufferId id, size_t offset, size_t count, const void* vertices)
 {
 	assert(m_vertex_buffers_id_table.has(id));
 
@@ -248,7 +248,7 @@ void GLRenderer::destroy_vertex_buffer(VertexBufferId id)
 }
 
 //-----------------------------------------------------------------------------
-IndexBufferId GLRenderer::create_index_buffer(const void* indices, size_t count)
+IndexBufferId GLRenderer::create_index_buffer(size_t count, const void* indices)
 {
 	const IndexBufferId id = m_index_buffers_id_table.create();
 
@@ -277,7 +277,7 @@ void GLRenderer::destroy_index_buffer(IndexBufferId id)
 }
 
 //-----------------------------------------------------------------------------
-TextureId GLRenderer::create_texture(uint32_t width, uint32_t height, const void* data, PixelFormat format)
+TextureId GLRenderer::create_texture(uint32_t width, uint32_t height, PixelFormat format, const void* data)
 {
 	const TextureId id = m_textures_id_table.create();
 

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

@@ -79,15 +79,15 @@ public:
 						GLRenderer();
 						~GLRenderer();
 
-	VertexBufferId		create_vertex_buffer(const void* vertices, size_t count, VertexFormat format);
-	VertexBufferId		create_dynamic_vertex_buffer(const void* vertices, size_t count, VertexFormat format);
-	void				update_vertex_buffer(VertexBufferId id, const void* vertices, size_t count, size_t offset);
+	VertexBufferId		create_vertex_buffer(size_t count, VertexFormat format, const void* vertices);
+	VertexBufferId		create_dynamic_vertex_buffer(size_t count, VertexFormat format, const void* vertices);
+	void				update_vertex_buffer(VertexBufferId id, size_t offset, size_t count, const void* vertices);
 	void				destroy_vertex_buffer(VertexBufferId id);
 
-	IndexBufferId		create_index_buffer(const void* indices, size_t count);
+	IndexBufferId		create_index_buffer(size_t count, const void* indices);
 	void				destroy_index_buffer(IndexBufferId id);
 
-	TextureId			create_texture(uint32_t width, uint32_t height, const void* data, PixelFormat format);
+	TextureId			create_texture(uint32_t width, uint32_t height, PixelFormat format, const void* data);
 	void				update_texture(TextureId id, uint32_t x, uint32_t y, uint32_t width, uint32_t height, const void* data);
 	void				destroy_texture(TextureId id);