SoundSource_Imp::SoundSource_Imp(Sound* manager, osm::Sound* sound)
	{
		m_manager = manager;
		m_sound = sound;

		SafeAddRef(m_manager);
		SafeAddRef(m_sound);
	}
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	void CoreLayer2D_Imp::AddObject(ObjectPtr object)
	{
		if (object->GetObjectType() == Object2DType::Camera)
		{
			auto camera = (CoreCameraObject2D_Imp*)object;
			m_cameras.push_back(camera);
			SafeAddRef(camera);
		}
		else
		{
			m_objects.push_back(object);
			SafeAddRef(object);
		}

		object->SetLayer(this);

		{
			auto o = CoreObject2DToImp(object);
			o->OnAdded(m_renderer);

#if __CULLING_2D__
			if (object->GetObjectType() == Object2DType::Map)
			{
				auto map = (CoreMapObject2D_Imp*)o;
				map->RegisterObjectToCulling();
				map->SetFirstSortedKey(world->GetNextFirstSortedKey());
				world->IncNextFirstSortedKey();
			}
			else if (object->GetObjectType() != Object2DType::Camera)
			{
				auto userData = new Culling2DUserData(object);

				auto cObj = culling2d::Object::Create(userData, world);

				cObj->SetFirstSortedKey(world->GetNextFirstSortedKey());
				world->IncNextFirstSortedKey();

				o->SetCullingObject(cObj);


				AddTransformedObject(cObj);
				o->SetAlreadyCullingUpdated(true);


				world->AddObject(cObj);
			}
#endif
		}


	}
	Asset* AssetManager::findAsset(int type, const String& name, intptr_t arg) {
		SCOPE_LOCK;

		checkType(__func__, type);

		Data* d = m_datas[type];

		AssetDict::iterator it =d->assetDict.find(d->factory->generateKey(name, arg));
		if ( it != d->assetDict.end()) {
			it->second->addref();
			return it->second;
		}

		Asset* a = d->factory->create();
		if (a->init(name, arg)) {
			a->m_key = a->getKey();
			AX_ASSERT(!a->m_key.empty());
			d->assetDict[a->m_key] = a;

			return a;
		}

		d->factory->destroy(a);
		SafeAddRef(d->defaulted);
		return d->defaulted;
	}
Beispiel #4
0
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	Material3DCommand::Material3DCommand(Shader3D_Imp* shader, std::shared_ptr<MaterialPropertyBlock>& values)
		: MaterialCommand(shader->GetNativeShader().get(), values)
		, m_shader(shader)
		, m_target(nullptr)
	{
		SafeAddRef(m_shader);
	}
Beispiel #5
0
	std::shared_ptr<AnimationClip> ModelObject3D::GetAnimationClip(const achar* name)
	{
		auto anim = m_coreObject->GetAnimationClip(name);
		if (anim == nullptr) return nullptr;
		SafeAddRef(anim);
		return CreateSharedPtrWithReleaseDLL(anim);
	}
	void CoreLayer2D_Imp::DrawRotatedRectangleAdditionally(RectF drawingArea, Color color, Vector2DF rotationCenter, float angle, RectF uv, Texture2D* texture, AlphaBlendMode alphaBlend, int32_t priority)
	{
		Sprite sprite;

		std::array<Color, 4> col = { color, color, color, color };

		SafeAddRef(texture);

		auto vertexes = drawingArea.GetVertexes();

		auto globalCenter = vertexes[0] + rotationCenter;

		for (auto& vert : vertexes)
		{
			vert -= globalCenter;
			auto deg = vert.GetDegree();
			deg += angle;
			vert.SetDegree(deg);
			vert += globalCenter;
		}


		sprite.pos = vertexes;
		sprite.col = col;
		sprite.uv = uv.GetVertexes();
		sprite.Texture_ = CreateSharedPtrWithReleaseDLL(texture);
		sprite.AlphaBlend_ = alphaBlend;
		sprite.Priority = priority;

		sprites.push_back(sprite);
	}
Beispiel #7
0
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	DeviceObject::DeviceObject(Graphics* graphics)
		: m_graphics(graphics)
	{
		assert(m_graphics != nullptr);
		SafeAddRef(m_graphics);
		((Graphics_Imp*) graphics)->AddDeviceObject(this);
	}
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	ObjectSystemFactory_Imp::ObjectSystemFactory_Imp(Core_Imp* core, Graphics_Imp* graphics, Log_Imp* logger, Vector2DI windowSize)
		: core(core)
		, m_graphics(graphics)
		, m_logger(logger)
		, m_windowSize(windowSize)
	{
		SafeAddRef(m_graphics);
	}
Beispiel #9
0
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	MaterialCommand::MaterialCommand(NativeShader_Imp* shader, std::shared_ptr<MaterialPropertyBlock>& block)
		: shader(shader)
	{
		SafeAddRef(shader);

		auto b = (MaterialPropertyBlock_Imp*) block.get();

		b->AddValuesTo(shader, constantValues);
	}
Beispiel #10
0
	bool Grid::AddObject(Object* object)
	{
		bool inserted = objects.insert(object).second;
		if (inserted)
		{
			SafeAddRef(object);
		}
		return inserted;
	}
	CoreObject2D_Imp::CoreObject2D_Imp(Graphics_Imp* graphics)
		: m_graphics(graphics)
		, m_objectInfo(ObjectInfo2D())
		, m_transform(TransformInfo2D())
		, cullingObject(nullptr)
	{
		SafeAddRef(m_graphics);
		alreadyCullingUpdated = false;
	}
Beispiel #12
0
	StreamFile_Imp::StreamFile_Imp(File_Imp* file, const astring& cacheKey, std::shared_ptr<BaseFile>& baseFile)
		: file(file)
		, cacheKey(cacheKey)
		, baseFile(baseFile)
	{
		fileOffset = 0;
		fileSize = baseFile->GetSize();
		current = 0;

		SafeAddRef(file);
	}
Beispiel #13
0
	StaticFile_Imp::StaticFile_Imp(File_Imp* file, const astring& cacheKey, std::shared_ptr<BaseFile>& baseFile)
		: file(file)
		, cacheKey(cacheKey)
	{
		baseFile->ReadAllBytes(m_buffer);

		m_path = baseFile->GetFullPath();

		SafeAddRef(file);

		isInPackage = false;
	}
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	PostEffectRenderer::PostEffectRenderer(
		Graphics* graphics,
		std::shared_ptr<VertexBuffer_Imp> vertexBuffer,
		std::shared_ptr<IndexBuffer_Imp> indexBuffer)
		: m_graphics(nullptr)
	{
		m_graphics = (Graphics_Imp*)graphics;
		m_vertexBuffer = vertexBuffer;
		m_indexBuffer = indexBuffer;

		SafeAddRef(m_graphics);
	}
Beispiel #15
0
	StreamFile_Imp::StreamFile_Imp(File_Imp* file, const astring& cacheKey, const std::shared_ptr<BaseFile>& baseFile, PackFileInternalHeader& internalHeader, std::shared_ptr<Decryptor> decryptor)
		: file(file)
		, cacheKey(cacheKey)
		, baseFile(baseFile)
		, decryptor(decryptor)
	{
		fileOffset = internalHeader.GetOffset();
		fileSize = internalHeader.GetSize();
		current = 0;

		SafeAddRef(file);
	}
Beispiel #16
0
COAHolder::COAHolder()
{
	VDATEHEAP();

	// set reference count to 1
	SafeAddRef();

	// no sink pointers yet
	m_iSize = 0;
	m_ppIAS = NULL;

	GET_A5();
}
Beispiel #17
0
	StaticFile_Imp::StaticFile_Imp(File_Imp* file, const astring& cacheKey, const std::shared_ptr<BaseFile>& packedFile, PackFileInternalHeader& internalHeader, std::shared_ptr<Decryptor> decryptor)
		: file(file)
		, cacheKey(cacheKey)
	{
		packedFile->Seek(internalHeader.GetOffset());
		packedFile->ReadBytes(m_buffer, internalHeader.GetSize(), decryptor.get(), internalHeader.GetOffset());

		m_path = packedFile->GetFullPath() + ToAString("?") + internalHeader.GetFileName();

		SafeAddRef(file);

		isInPackage = true;
	}
	void AnimationSource_Imp::AddAnimation(KeyframeAnimation* keyframeAnimation)
	{
		if (m_animations.find(keyframeAnimation) == m_animations.end())
		{
			SafeAddRef(keyframeAnimation);
			m_animations.insert(keyframeAnimation);

			auto kf = (KeyframeAnimation_Imp*) keyframeAnimation;
			if (length < kf->GetLength())
			{
				length = kf->GetLength();
			}
		}
	}
Beispiel #19
0
Font* Graphics_Imp::CreateDynamicFont_(const achar* font, int32_t fontSize, Color color, int32_t outlineSize, Color outlineColor)
{
	auto extFont = FontContainer->Get(font);
	if (extFont != nullptr)
	{
		SafeAddRef(extFont);
		return extFont;
	}

	auto font_ = Font_Imp::Create(this, font, fontSize, color, outlineSize, outlineColor);

	FontContainer->Register(font, font_);

	return font_;
}
Beispiel #20
0
	void CoreLayer2D_Imp::DrawTextAdditionally(Vector2DF pos, Color color, Font* font, const achar* text, WritingDirection writingDirection, AlphaBlendMode alphaBlend, int32_t priority)
	{
		SafeAddRef(font);

		Text text_;
		text_.Position_ = pos;
		text_.Color_ = color;
		text_.Font_ = CreateSharedPtrWithReleaseDLL(font);
		text_.Text_ = text;
		text_.WritingDirection_ = writingDirection;
		text_.AlphaBlend_ = alphaBlend;
		text_.Priority_ = priority;

		texts.push_back(text_);
	}
	void SpriteRenderer3D::AddSprite(Vector3DF positions[4], Color colors[4], Vector2DF uv[4], Texture2D* texture, AlphaBlendMode alphaBlend, bool depthWrite, bool depthTest)
	{
		Sprite s;
		s.TexturePtr = texture;
		SafeAddRef(s.TexturePtr);
		s.AlphaBlendState = alphaBlend;
		s.DepthWrite = depthWrite;
		s.DepthTest = depthTest;

		memcpy(s.Positions, positions, sizeof(asd::Vector3DF) * 4);
		memcpy(s.Colors, colors, sizeof(asd::Color) * 4);
		memcpy(s.UV, uv, sizeof(asd::Vector2DF) * 4);

		sprites.push_back(s);
	}
Beispiel #22
0
	void CoreLayer2D_Imp::DrawRectangleAdditionally(RectF drawingArea, Color color, RectF uv, Texture2D* texture, AlphaBlendMode alphaBlend, int32_t priority)
	{
		Sprite sprite;

		std::array<Color, 4> col = { color, color, color, color };

		SafeAddRef(texture);

		sprite.pos = drawingArea.GetVertexes();
		sprite.col = col;
		sprite.uv = uv.GetVertexes();
		sprite.Texture_ = CreateSharedPtrWithReleaseDLL(texture);
		sprite.AlphaBlend_ = alphaBlend;
		sprite.Priority = priority;

		sprites.push_back(sprite);
	}
Beispiel #23
0
STDMETHODIMP_(ULONG) COAHolder::AddRef()
{
	ULONG	cRefs;

	VDATEHEAP();

	M_PROLOG(this);

	LEDebugOut((DEB_ITRACE, "%p _IN COAHolder::AddRef (  )\n", this));

	cRefs = SafeAddRef();

	LEDebugOut((DEB_ITRACE, "%p OUT	COAHolder::AddRef ( %lu )\n", this,
		cRefs));

	return cRefs;
}
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	ProfilerViewer_Imp::ProfilerViewer_Imp(
		Graphics_Imp* graphics,
		Log* log,
		Profiler_Imp* profiler,
		LayerProfiler_Imp* layerProfiler,
		Core* core,
		Vector2DI windowSize)
		: m_profiler(profiler)
		, m_layerProfiler(layerProfiler)
		, m_renderer(nullptr)
		, m_windowSize(windowSize)
		, m_graphics(graphics)
		, m_core(core)
		, m_materTexture(nullptr)
		, log(log)
	{
		SafeAddRef(m_profiler);
	}
Beispiel #25
0
	void CoreLayer2D_Imp::DrawTriangleAdditionally(Vector2DF position1, Vector2DF position2, Vector2DF position3, Color color, Vector2DF uv1, Vector2DF uv2, Vector2DF uv3, Texture2D* texture, AlphaBlendMode alphaBlend, int32_t priority)
	{
		Sprite sprite;

		std::array<Vector2DF, 4> vertexes = { position1, position2, position3, position3 };
		std::array<Vector2DF, 4> uvs = { uv1, uv2, uv3, uv3 };

		std::array<Color, 4> col = { color, color, color, color };

		SafeAddRef(texture);

		sprite.pos = vertexes;
		sprite.col = col;
		sprite.uv = uvs;
		sprite.Texture_ = CreateSharedPtrWithReleaseDLL(texture);
		sprite.AlphaBlend_ = alphaBlend;
		sprite.Priority = priority;

		sprites.push_back(sprite);
	}
Beispiel #26
0
	void CoreLayer2D_Imp::DrawSpriteAdditionally(Vector2DF upperLeftPos, Vector2DF upperRightPos, Vector2DF lowerRightPos, Vector2DF lowerLeftPos,
		Color upperLeftCol, Color upperRightCol, Color lowerRightCol, Color lowerLeftCol,
		Vector2DF upperLeftUV, Vector2DF upperRightUV, Vector2DF lowerRightUV, Vector2DF lowerLeftUV,
		Texture2D* texture, AlphaBlendMode alphaBlend, int32_t priority)
	{
		Sprite sprite;
		std::array<Vector2DF, 4> pos = { upperLeftPos, upperRightPos, lowerRightPos, lowerLeftPos };
		std::array<Color, 4> col = { upperLeftCol, upperRightCol, lowerRightCol, lowerLeftCol };
		std::array<Vector2DF, 4> uv = { upperLeftUV, upperRightUV, lowerRightUV, lowerLeftUV };

		SafeAddRef(texture);

		sprite.pos = pos;
		sprite.col = col;
		sprite.uv = uv;
		sprite.Texture_ = CreateSharedPtrWithReleaseDLL(texture);
		sprite.AlphaBlend_ = alphaBlend;
		sprite.Priority = priority;

		sprites.push_back(sprite);
	}
Beispiel #27
0
	std::shared_ptr<NativeShader_Imp> ShaderCache::CreateFromBinary(
		const achar* key,
		const uint8_t* vertexShader,
		int32_t vertexShaderSize,
		const uint8_t* pixelShader,
		int32_t pixelShaderSize,
		std::vector <VertexLayout>& layout)
	{
		NativeShader_Imp* shader = nullptr;

		auto it = m_shaders.find(key);
		if (it != m_shaders.end())
		{
			shader = it->second;
			SafeAddRef(shader);
		}
		else
		{
			shader = m_graphics->CreateShader_Imp_(
				vertexShader,
				vertexShaderSize,
				pixelShader,
				pixelShaderSize,
				layout,
				true);

			if (shader != nullptr)
			{
				m_shaders[key] = shader;
				shader->SetKey(key);
			}
		}

		if (shader == nullptr) return nullptr;

		return std::shared_ptr<NativeShader_Imp>(shader, ShaderCacheReferenceDeleter());
	}
Beispiel #28
0
	std::shared_ptr<NativeShader_Imp> ShaderCache::CreateFromCode(
		const achar* key,
		const char* vertexShaderCode,
		const char* pixelShaderCode,
		std::vector <VertexLayout>& layout,
		std::vector <Macro>& macro)
	{
		NativeShader_Imp* shader = nullptr;

		auto it = m_shaders.find(key);
		if (it != m_shaders.end())
		{
			shader = it->second;
			SafeAddRef(shader);
		}
		else
		{
			shader = m_graphics->CreateShader_Imp_(
				vertexShaderCode,
				ToUtf8String(key).c_str(),
				pixelShaderCode,
				ToUtf8String(key).c_str(),
				layout,
				true,
				macro);

			if (shader != nullptr)
			{
				m_shaders[key] = shader;
				shader->SetKey(key);
			}
		}
		
		if (shader == nullptr) return nullptr;

		return std::shared_ptr<NativeShader_Imp>(shader, ShaderCacheReferenceDeleter());
	}
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	bool Engine::GenerateCore()
	{
		// DLLからコアを生成する。
		if (m_core == nullptr)
		{
			g_dll = std::shared_ptr<DynamicLinkLibrary>(new DynamicLinkLibrary(), DynamicLinkLibraryDeleter());

#if _WIN32
#if _DEBUG
			const char* path = "ace_core.Debug.dll";
#else
			const char* path = "ace_core.dll";
#endif
#else
#if _DEBUG
			const char* path = "libace_core.so";
#else
			const char* path = "libace_core.so";
#endif
#endif
			if (!g_dll->Load(path))
			{
				g_dll.reset();
				return false;
			}

			{
#if _WIN32
				const char* name = "_CreateCore@0";
#else
				const char* name = "CreateCore";
#endif
				auto pProc = g_dll->GetProc<Core*(*)()>(name);
				if (pProc == NULL)
				{
					return false;
				}

				m_core = pProc();
				m_core->SetRemovedFunctionPpointer(RemovedCore);
				SafeAddRef(g_dll);
			}

			{
#if _WIN32
				const char* name = "_GetGlobalReferenceCount__@0";
#else
				const char* name = "GetGlobalReferenceCount__";
#endif
				auto pProc = g_dll->GetProc<GetIntFunc>(name);
				if (pProc == NULL)
				{
					return false;
				}

				g_GetGlobalRef = pProc;
			}
		}

		return true;
	}
	SpriteRenderer3D::SpriteRenderer3D(Graphics* graphics)
		: m_graphics(nullptr)
	{
		m_graphics = (Graphics_Imp*) graphics;

		SafeAddRef(graphics);

		m_vertexBuffer = m_graphics->CreateVertexBuffer_Imp(sizeof(SpriteVertex), SpriteCount * 4, true);
		m_indexBuffer = m_graphics->CreateIndexBuffer_Imp(SpriteCount * 6, false, true);

		{
			m_indexBuffer->Lock();
			auto ib = m_indexBuffer->GetBuffer<uint32_t>(SpriteCount * 6);

			for (int32_t i = 0; i < SpriteCount; i++)
			{
				ib[i * 6 + 0] = 0 + i * 4;
				ib[i * 6 + 1] = 1 + i * 4;
				ib[i * 6 + 2] = 2 + i * 4;
				ib[i * 6 + 3] = 0 + i * 4;
				ib[i * 6 + 4] = 2 + i * 4;
				ib[i * 6 + 5] = 3 + i * 4;
			}

			m_indexBuffer->Unlock();
		}

		std::vector<asd::VertexLayout> vl;
		vl.push_back(asd::VertexLayout("Pos", asd::VertexLayoutFormat::R32G32B32_FLOAT));
		vl.push_back(asd::VertexLayout("UV", asd::VertexLayoutFormat::R32G32_FLOAT));
		vl.push_back(asd::VertexLayout("Color", asd::VertexLayoutFormat::R8G8B8A8_UNORM));

		std::vector<asd::Macro> macro_tex;
		macro_tex.push_back(Macro("HAS_TEXTURE", "1"));

		std::vector<asd::Macro> macro;

		if (m_graphics->GetGraphicsDeviceType() == GraphicsDeviceType::OpenGL)
		{
			m_shader = m_graphics->GetShaderCache()->CreateFromCode(
				ToAString(L"Internal.3D.SpriteRenderer3D.Texture").c_str(),
				sprite_renderer3d_vs_gl,
				sprite_renderer3d_ps_gl,
				vl,
				macro_tex);
		}
		else
		{
			m_shader = m_graphics->GetShaderCache()->CreateFromCode(
				ToAString(L"Internal.3D.SpriteRenderer3D.Texture").c_str(),
				sprite_renderer3d_vs_dx,
				sprite_renderer3d_ps_dx,
				vl,
				macro_tex);
		}

		if (m_graphics->GetGraphicsDeviceType() == GraphicsDeviceType::OpenGL)
		{
			m_shader_nt = m_graphics->GetShaderCache()->CreateFromCode(
				ToAString(L"Internal.3D.SpriteRenderer3D").c_str(),
				sprite_renderer3d_vs_gl,
				sprite_renderer3d_ps_gl,
				vl,
				macro);
		}
		else
		{
			m_shader_nt = m_graphics->GetShaderCache()->CreateFromCode(
				ToAString(L"Internal.3D.SpriteRenderer3D").c_str(),
				sprite_renderer3d_vs_dx,
				sprite_renderer3d_ps_dx,
				vl,
				macro);
		}
	}