Kaynağa Gözat

Delete sprite

Daniele Bartolini 10 yıl önce
ebeveyn
işleme
22ce8c6abc
2 değiştirilmiş dosya ile 0 ekleme ve 108 silme
  1. 0 65
      engine/renderers/sprite.cpp
  2. 0 43
      engine/renderers/sprite.h

+ 0 - 65
engine/renderers/sprite.cpp

@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2012-2015 Daniele Bartolini and individual contributors.
- * License: https://github.com/taylor001/crown/blob/master/LICENSE
- */
-
-#include "sprite.h"
-#include "vector3.h"
-#include "quaternion.h"
-#include "sprite_resource.h"
-#include "allocator.h"
-#include "scene_graph.h"
-#include "unit.h"
-#include "material.h"
-#include "render_world.h"
-#include "device.h"
-#include "material_manager.h"
-
-namespace crown
-{
-
-Sprite::Sprite(RenderWorld& render_world, SceneGraph& sg, UnitId id, const SpriteResource* sr)
-	: m_render_world(render_world)
-	, m_scene_graph(sg)
-	, m_resource(sr)
-	, m_frame(0)
-	, _depth(0)
-	, _unit_id(id)
-{
-}
-
-void Sprite::set_material(MaterialId id)
-{
-	m_material = id;
-}
-
-void Sprite::set_frame(uint32_t i)
-{
-	m_frame = i;
-}
-
-void Sprite::set_depth(int32_t z)
-{
-	_depth = z;
-}
-
-void Sprite::render()
-{
-	if (m_material.id != INVALID_ID)
-		material_manager::get()->lookup_material(m_material)->bind();
-
-	bgfx::setState(BGFX_STATE_RGB_WRITE
-		| BGFX_STATE_ALPHA_WRITE
-		| BGFX_STATE_DEPTH_TEST_LEQUAL
-		| BGFX_STATE_DEPTH_WRITE
-		| BGFX_STATE_CULL_CW
-		| BGFX_STATE_MSAA
-		| BGFX_STATE_BLEND_ALPHA);
-	bgfx::setVertexBuffer(m_resource->vb);
-	bgfx::setIndexBuffer(m_resource->ib, m_frame * 6, 6);
-	TransformInstance ti = m_scene_graph.get(_unit_id);
-	bgfx::setTransform(matrix4x4::to_float_ptr(m_scene_graph.world_pose(ti)));
-	bgfx::submit(0, _depth);
-}
-
-} // namespace crown

+ 0 - 43
engine/renderers/sprite.h

@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2012-2015 Daniele Bartolini and individual contributors.
- * License: https://github.com/taylor001/crown/blob/master/LICENSE
- */
-
-#pragma once
-
-#include "render_world_types.h"
-#include "vector3.h"
-#include "matrix4x4.h"
-#include "quaternion.h"
-#include "sprite_resource.h"
-#include "material.h"
-#include "world_types.h"
-#include <bgfx.h>
-
-namespace crown
-{
-
-struct Sprite
-{
-	Sprite(RenderWorld& render_world, SceneGraph& sg, UnitId id, const SpriteResource* sr);
-
-	void set_material(MaterialId id);
-
-	void set_frame(uint32_t i);
-
-	void set_depth(int32_t z);
-
-	void render();
-
-public:
-
-	RenderWorld& m_render_world;
-	SceneGraph& m_scene_graph;
-	const SpriteResource* m_resource;
-	MaterialId m_material;
-	uint32_t m_frame;
-	int32_t _depth;
-	UnitId _unit_id;
-};
-
-} // namespace crown