wxArrayProperty::~wxArrayProperty()
{
	sdelete(m_pSubPropertyTemplate);
	sdelete(m_pStructTemplate);
	sdelete(m_pRefTemplate);
	sdelete(m_pLinkTemplate);
}
Ejemplo n.º 2
0
void Mesh::clear()
{
    for (int i = 0; i < (int)m_subMeshs.size(); ++i) {
        delete m_subMeshs[i];
    }
    m_subMeshs.clear();
    m_fname.clear();
    sdelete(m_boundAABB);
    sdelete(m_boundSphere);
}
Ejemplo n.º 3
0
//! Destructor
EEViewPort::~EEViewPort()
{
	sdelete(_glContext);

	EditorSettings::DestroyInstance();
	CameraManager::DestroyInstance();
}
Ejemplo n.º 4
0
SYSCALL mutex_unlock(MUTEX_REC_PTR *mutex_var)
{
 int ps;

  disable(ps);
  if ( ((*mutex_var) == (MUTEX_REC_PTR)NULL) ||
     ((*mutex_var)->pid != currpid) )
   {
     restore(ps);
     return SYSERR;
   } // if

    if ( isempty(semaph[(*mutex_var)->nsem].sqhead))
      {
       sdelete((*mutex_var)->nsem);
       freemem((*mutex_var), sizeof(MUTEX_REC));
       (*mutex_var) = MUTEX_VAR_INITIALIZER;
       restore(ps);
       return OK;
      } /* if */

    signal((*mutex_var)->nsem);

  restore(ps);
  return OK; 

} /* mutex_unlock */
Ejemplo n.º 5
0
	//! initializes this resource
	void MeshResource::ResourceInit()
	{
		auto meshResourcePath = GetTemplatePath();
		m_MeshPath = Utils::GetFilePathNoExt(meshResourcePath) + ".fbx";

		if (!m_sMeshReload)
			m_SubMeshInfos.clear();

#ifndef SHOOT_EDITOR
		LoadFS(m_MeshPath.c_str());
#else
		auto binPath = Utils::GetBinPath(m_MeshPath);
		bool dirty = true;
		if (File::Exists(binPath.c_str()))
			dirty = Utils::IsFileMoreRecent(m_MeshPath, binPath)
				 || Utils::IsFileMoreRecent(meshResourcePath, binPath);

		if (dirty)
		{
			Log.Print("Converting FBX '%s'\n", m_MeshPath.c_str());
			auto binFile = Utils::CreateBinFile(binPath);
			FBXMeshLoader(this).Load(m_MeshPath.c_str(), binFile);
			binFile->Close();
			sdelete(binFile);
		}
		else
			LoadFS(binPath.c_str());
#endif

		for (auto& submesh : m_SubMeshInfos)
			submesh.m_VertexBuffer->SetDynamic(m_bDynamic);		
	}
Ejemplo n.º 6
0
void SceneManager::clear()
{
    sdelete(m_terrain);
    sdelete(m_cameraController);
    sdelete(m_entController);

    for (int i = 0; i < (int)m_nodes.size(); ++i) {
        delete m_nodes[i];
    }
    m_entitys.clear();

    for (int i = 0; i < (int)m_entitys.size(); ++i) {
        delete m_entitys[i];
    }
    m_entitys.clear();
    sdelete(m_camera);
    sdelete(m_light);
}
Ejemplo n.º 7
0
	//! Destructor
	NetworkManager::~NetworkManager()
	{
		SHOOT_WARNING(!m_bActive, "NetworkManager: Shutting down while NetworkThread still active");
		
		if(!m_bActive)
		{
			for(std::list<Operation>::iterator it = m_lOperations.begin(); it != m_lOperations.end(); ++it)
			{
				(*it).Release();
			}
			m_lOperations.clear();
			sdelete(m_pMutex);

#ifdef USE_WINSOCK2
			WSACleanup();
#endif
			sdelete(m_pNetworkThread);
		}
	}
Ejemplo n.º 8
0
/*
 * Part A 2/4. buf_close()
 * buf_close() deallocates all the resources that buffer manager has used.
 */
void buf_close(void) 
{

	dsk_buffer_p tmp;

	for( tmp = buf_head; tmp != NULL;tmp= tmp->next)
	{
		freemem( tmp, sizeof( struct buf));
		sdelete(tmp->sem_b);
	}

}
	//! get ShootFS file data
	void FileSystemGenerator::GetShootFSFileData(const char* strPath, uchar* pDataOut) const
	{
		auto extension = Utils::GetFileExtension(strPath);
		if (Utils::Equals(extension.c_str(), "xml"))
		{
			auto file = File::CreateNative(strPath, File::M_ReadBinary);
			file->Open();			
			uint fileSize = (uint)file->GetSize();
			file->Read(pDataOut, fileSize);
			file->Close();
			sdelete(file);
			return;
		}
		
		auto binPath = Utils::GetBinPath(strPath);		
		auto binFile = File::CreateNative(binPath.c_str(), File::M_ReadBinary);
		binFile->Open();
		auto fileSize = binFile->GetSize();
		binFile->Read(pDataOut, fileSize);
		binFile->Close();
		sdelete(binFile);		
	}
Ejemplo n.º 10
0
	//! reads text from a file
	char* ShaderImpl::ReadFileText(const char* path)
	{
		File* pFile = File::Create(path, File::M_ReadBinary);
		pFile->Open();
		pFile->SetOffset(0, File::OT_End);
		u32 fileSize = pFile->GetOffset();		
		pFile->SetOffset(0, shoot::File::OT_Start);
		char* pText = snew char[fileSize+1];
		pFile->Read(pText, fileSize);
		pText[fileSize] = '\0';
		pFile->Close();
		sdelete(pFile);
		return pText;
	}
Ejemplo n.º 11
0
/*------------------------------------------------------------------------
 *  _ptclear  --  used by pdelete and preset to clear a port
 *------------------------------------------------------------------------
 */
_ptclear(struct pt *ppt, int newstate, void (*dispose)())
{
    struct	ptnode	*p;

    /* put port in limbo until done freeing processes */
    ppt->ptstate = PTLIMBO;
    ppt->ptseq++;
    if ( (p=ppt->pthead) != (struct ptnode *)NULL ) {
        if (dispose != PTNODISP)
            for(; p != (struct ptnode *) NULL ; p=p->ptnext)
                (*dispose)( p->ptmsg );
        (ppt->pttail)->ptnext = ptfree;
        ptfree = ppt->pthead;
    }
    if (newstate == PTALLOC) {
        ppt->pttail = ppt->pthead = (struct ptnode *) NULL;
        sreset(ppt->ptssem, ppt->ptmaxcnt);
        sreset(ppt->ptrsem, 0);
    } else {
        sdelete(ppt->ptssem);
        sdelete(ppt->ptrsem);
    }
    ppt->ptstate = newstate;
}
Ejemplo n.º 12
0
void Mesh::calcBoundSphere() const
{
    if (m_subMeshs.empty()) return;
    sdelete(m_boundSphere);

    for (int i = 0; i < (int)m_subMeshs.size(); ++i) {
        const SubMesh* sub = m_subMeshs[i];
        int vCnt = sub->vertexBuffer.getVertexCount();
        assert(vCnt > 0);
        const Vector3* p = &sub->vertexBuffer.getElementList3<EVEI_position>()[0];
        if (m_boundSphere == NULL) {
            m_boundSphere = new Sphere(Sphere::fromPoints(p, p + vCnt));
        }
        else m_boundSphere->merge(Sphere::fromPoints(p, p + vCnt));
    }
}
Ejemplo n.º 13
0
	//! constructor
	FakeCubeMapTexture::FakeCubeMapTexture(const char* strPath[6])
	{
		sdelete(m_pImpl);
		for(int i=0; i<6; ++i)
		{
			auto texture = snew Texture();
			auto xmlPath = Utils::GetFilePathNoExt(strPath[i]) + ".xml";
			ObjectManager::Instance()->SetTemplatePath(texture, xmlPath);
			//texture->Set32Bits(true);
			texture->SetIgnoreResourceFileOnInit(true);
			texture->ResourceInit();
			
			m_Textures[i] = texture;
		}
		m_vSize = m_Textures[0]->GetSize();
		m_eFormat = m_Textures[0]->GetFormat();
	}
Ejemplo n.º 14
0
	//! Saves the object to XML
	void Object::SaveToXML(const char* strPath)
	{
		rapidxml::xml_document<> doc;
		auto root = doc.allocate_node(rapidxml::node_element, GetClassName());		
		doc.append_node(root);

		PropertyStream stream(SM_Write);
		Serialize(stream);

		stream.WriteToXML(root);
		
		std::string xml_as_string;
		rapidxml::print(std::back_inserter(xml_as_string), doc);
		auto file = File::Create(strPath, shoot::File::M_Write);
		if(file->Open())
		{
			file->Write(xml_as_string.c_str(), (int)xml_as_string.length());
			file->Close();
		}
		sdelete(file);
	}
Ejemplo n.º 15
0
int main(void *arg)
{
        int sem, i;

        (void)arg;

        assert(screate(-2) == -1);
        assert((sem = screate(2)) >= 0);
        assert(signaln(sem, -4) < 0);
        assert(sreset(sem, -3) == -1);
        assert(scount(sem) == 2);
        assert(signaln(sem, 32760) == 0);
        assert(signaln(sem, 6) == -2);
        assert(scount(sem) == 32762);
        assert(wait(sem) == 0);
        assert(scount(sem) == 32761);
        assert(signaln(sem, 30000) == -2);
        assert(scount(sem) == 32761);
        assert(wait(sem) == 0);
        assert(scount(sem) == 32760);
        assert(signaln(sem, -2) < 0);
        assert(scount(sem) == 32760);
        assert(wait(sem) == 0);
        assert(scount(sem) == 32759);
        assert(signaln(sem, 8) == 0);
        assert(scount(sem) == 32767);
        assert(signaln(sem, 1) == -2);
        assert(scount(sem) == 32767);
        assert(signal(sem) == -2);
        assert(scount(sem) == 32767);
        for (i=0; i<32767; i++) {
                assert(wait(sem) == 0);
        }
        assert(try_wait(sem) == -3);
        assert(scount(sem) == 0);
        assert(sdelete(sem) == 0);
        printf("ok.\n");
}
Ejemplo n.º 16
0
	//! destructor
	AppSDL::~AppSDL()
	{
		Engine* pEngine = shoot::Engine::Instance();
		sdelete(pEngine);
		SDL_Quit();
	}	
Ejemplo n.º 17
0
void Mesh::setBoundAABB(const AABB& aabb)
{
    sdelete(m_boundAABB);
    m_boundAABB = new AABB(aabb);
}
Ejemplo n.º 18
0
void SceneManager::setCameraController(ICameraController *controller)
{
    sdelete(m_cameraController);
    m_cameraController = controller;
}
Ejemplo n.º 19
0
void SceneManager::setTerrain(ITerrain *terrain)
{
    sdelete(m_terrain);
    m_terrain = terrain;
}
Ejemplo n.º 20
0
	//! constructor
	FakeCubeMapTexture::FakeCubeMapTexture()
	{
		sdelete(m_pImpl);
	}
	//! Destructor
	EntityRenderer::~EntityRenderer()
	{
		sdelete(m_pScreenAlignedQuad);
	}
Ejemplo n.º 22
0
	//! destructor
	Texture::~Texture()
	{
		ResourceUninit();
		sdelete(m_pImpl);
	}
Ejemplo n.º 23
0
	//! ResourceInit
	void Texture::ResourceInit()
	{
		if (m_pData)
		{
			SHOOT_LOG_WARNING(false, "Texture '%s' disk data already loaded", GetTemplatePath().c_str());
			return;
		}

		int channels;
		auto texResourcePath = GetTemplatePath();
		auto pngPath = Utils::GetFilePathNoExt(texResourcePath) + ".png";

#ifndef SHOOT_EDITOR
		LoadFromBinPng(pngPath, channels, m_bpp);
#else
		auto binPath = Utils::GetBinPath(pngPath);
		bool dirty = true;
		if (File::Exists(binPath.c_str()))
		{
			dirty = Utils::IsFileMoreRecent(pngPath, binPath);
			dirty = dirty || (!m_IgnoreResourceFileOnInit && Utils::IsFileMoreRecent(texResourcePath, binPath));
		}			

		if (dirty)
		{
			Log.Print("Converting PNG '%s'\n", pngPath.c_str());
			auto binFile = Utils::CreateBinFile(binPath);

			int width, height;
			m_pData = PNGLoader::LoadFromRawPng(pngPath, width, height, channels, m_bpp, binFile, m_32Bits);
			m_vSize.Set(float(width), float(height));

			binFile->Close();
			sdelete(binFile);
		}
		else
			LoadFromBinPng(binPath, channels, m_bpp);
#endif

		if (!m_pData)
			return;

		m_pImpl->InitHardwareSize();

		// Emulate non-pow 2
		{
			Size size((int)m_vSize.X, (int)m_vSize.Y);
			Size hwSize((int)m_vHardwareSize.X, (int)m_vHardwareSize.Y);
			if ((size != hwSize))
			{
				uchar* pOldData = static_cast<uchar*>(m_pData);
				uchar* pNewData = snew uchar[hwSize.Width * hwSize.Height * m_bpp];
				memset(pNewData, 0, hwSize.Width * hwSize.Height * m_bpp);

				for (int row = 0; row < size.Height; ++row)
					memcpy(pNewData + row*hwSize.Width*m_bpp, pOldData + row*size.Width*m_bpp, size.Width*m_bpp);

				if (m_bOwnData)
				{
					sdelete_array(pOldData);
				}
				m_pData = pNewData;
				m_bOwnData = true;
			}
		}

		switch (channels)
		{
		case 3:	m_eFormat = TF_RGB;	break;
		case 4:	m_eFormat = TF_RGBA; break;
		default: SHOOT_ASSERT(0, "Texture '%s' has unsupported format", pngPath.c_str());
		}
	}
Ejemplo n.º 24
0
	//! Load from the shoot file system
	void MeshResource::LoadFS(const char* strPath)
	{
		uint numSubMeshes = 0;
		File* pFile = File::Create(strPath, File::M_ReadBinary);
		pFile->Open();
		pFile->ReadData(&numSubMeshes, 1);
		for(uint i=0; i<numSubMeshes; ++i)
		{
			uint numVertices = 0;
			//uint numIndices = 0;
			uint format = 0;
			Vector3 vPosition;
			pFile->ReadData(&vPosition, 1);
			pFile->ReadData(&numVertices, 1);
			//pFile->ReadData(&numIndices, 1);
			pFile->ReadData(&format, 1);

			uint nameLength = 0;
			pFile->ReadData(&nameLength, 1);
			SHOOT_ASSERT(nameLength < 512, "nameLength too long");
			char name[512];
			pFile->ReadData(name, nameLength);
			name[nameLength] = '\0';
			std::string strName(name);
			
			// if vertex buffer already present, do not create a new instance. 
			// This is needed in Android when reloading graphic objects.
			// TODO: verify that this doesn't f**k up editor reloading.			
			MeshResource::SubMeshInfo* subMeshInfo = NULL;
			for (auto& info : m_SubMeshInfos)
			{
				if (info.m_VertexBuffer->GetName() == strName)
				{
					subMeshInfo = &info;
					break;
				}
			}
			if (!subMeshInfo)
			{
				MeshResource::SubMeshInfo newInfo;
				newInfo.m_VertexBuffer = GraphicsDriver::Instance()->CreateVertexBuffer(m_bInstancedRendering);
				newInfo.m_VertexBuffer->SetName(strName);
				m_SubMeshInfos.push_back(newInfo);
				subMeshInfo = &m_SubMeshInfos.back();
			}

			subMeshInfo->m_vPosition = vPosition;
			
			Vertex3D* pVertices = snew Vertex3D[numVertices];
			//void* pIndices = _32bitIndices ? ((void*)snew uint[numIndices]) : ((void*)snew ushort[numIndices]);
			//if (_32bitIndices)
			//	pFile->ReadData<uint>((uint*)pIndices, numIndices);
			//else
			//	pFile->ReadData<ushort>((ushort*)pIndices, numIndices);
			pFile->ReadData(pVertices, numVertices);
			subMeshInfo->m_VertexBuffer->SetVertices(pVertices, numVertices, format);
			//subMeshInfo.m_VertexBuffer->SetIndices(pIndices, numIndices, _32bitIndices);

			Material::CreationInfo materialInfo;
			pFile->ReadData(&materialInfo.m_Color, 1);
			uint numTextures = 0;
			pFile->ReadData(&numTextures, 1);
			for(uint i=0; i<numTextures; ++i)
			{
				uint texturePathLength = 0;
				pFile->ReadData(&texturePathLength, 1);
				SHOOT_ASSERT(texturePathLength < 512, "texturePathLength too long");
				char texturePath[512];
				pFile->ReadData(texturePath, texturePathLength);
				texturePath[texturePathLength] = '\0';
				if (File::Exists(texturePath))
					materialInfo.AddTexture(texturePath);
				else
					SHOOT_LOG_WARNING(false, "Texture '%s' not found", texturePath);
			}

			subMeshInfo->m_MaterialInfo = materialInfo;
		}
		pFile->Close();
		sdelete(pFile);
	}
Ejemplo n.º 25
0
void Mesh::setBoundSphere(const Sphere& sphere)
{
    sdelete(m_boundSphere);
    m_boundSphere = new Sphere(sphere);
}
	//! destroys the driver
	void GraphicExtensionHandler::DestroyInstance()
	{
		sdelete(m_spInstance);
	}
Ejemplo n.º 27
0
	//! returns the ShootFS file size
	uint FileSystemGenerator::GetShootFSFileSize(const char* strPath) const
	{
		auto extension = Utils::GetFileExtension(strPath);
		if (Utils::Equals(extension.c_str(), "xml"))
		{
			auto file = File::CreateNative(strPath, File::M_ReadBinary);
			file->Open();
			auto fileSize = file->GetSize();
			file->Close();
			sdelete(file);
			return (uint)fileSize;
		}

		auto binPath = Utils::GetBinPath(strPath);
		auto dirty = true;
		if (File::Exists(binPath.c_str()))
			dirty = Utils::IsFileMoreRecent(strPath, binPath);

		File* binFile = NULL;
		uint fileSize = 0;
		if (dirty)
		{
			Log << "Converting " << strPath << "\n";
			binFile = Utils::CreateBinFile(binPath);
			if (Utils::Equals(extension.c_str(), "png"))
			{
				auto textureResourcePath = Utils::GetFilePathNoExt(strPath) + ".xml";
				bool _32Bits = false;
				if (File::Exists(textureResourcePath.c_str()))
				{
					auto textureResource = static_cast<Texture*>(ObjectManager::Instance()->Load(textureResourcePath));
					_32Bits = textureResource->Is32Bits();
					sdelete(textureResource);
				}				
				int width = 0, height = 0, channels = 0, bpp = 0;
				auto data = (uchar*)PNGLoader::LoadFromRawPng(strPath, width, height, channels, bpp, binFile, _32Bits);
				fileSize = (uint)binFile->GetOffset();
				sdelete_array(data);
				
			}
			else if (Utils::Equals(extension.c_str(), "fbx"))
			{
				std::string meshResourcePath = Utils::GetFilePathNoExt(strPath) + ".xml";
				auto meshResource = static_cast<MeshResource*>(ObjectManager::Instance()->Load(meshResourcePath));
				FBXMeshLoader(meshResource).Load(strPath, binFile, true);
				fileSize = (uint)binFile->GetOffset();
				sdelete(meshResource);
			}
#ifdef DX11
			else if (Utils::Equals(extension.c_str(), "hlsl"))
			{
				bool bVS = path.find("vs") != std::string::npos;
				bool bPS = path.find("ps") != std::string::npos;
				SHOOT_ASSERT(bVS || bPS, "Couldn't determine type of HLSL file: %s", strPath);
				const char* strEntryPoint = bVS ? "VSMain" : "PSMain";
				const char* strLevel = bVS ? "vs_4_0_level_9_3" : "ps_4_0_level_9_3";
				COMReference<ID3DBlob> blob = ShaderDX11::CompileHLSL(strPath, strEntryPoint, strLevel);
				fileSize += binFile->Write(static_cast<u8*>(blob->GetBufferPointer()), blob->GetBufferSize());
			}
#endif
			else
			{				
				auto file = File::CreateNative(strPath, File::M_ReadBinary);
				file->Open();
				fileSize = (uint)file->GetSize();
				auto data = new uchar[fileSize];
				file->Read(data, fileSize);				
				binFile->Write(data, fileSize);
				file->Close();
				sdelete(file);				
			}			
		}
		else
		{
			binFile = File::CreateNative(binPath.c_str(), File::M_ReadBinary);
			binFile->Open();
			fileSize = (uint)binFile->GetSize();
		}

		binFile->Close();
		sdelete(binFile);
		return fileSize;		
	}
Ejemplo n.º 28
0
void xsdelete(struct sem *s)
{
        assert(sdelete(s->sem) == 0);
}