Exemplo n.º 1
0
	void loadAssets()
	{
		// Models
		models.skybox.loadFromFile(vulkanDevice, getAssetPath() + "models/cube.obj", vertexLayout, 0.05f, queue);
		std::vector<std::string> filenames = {"sphere.obj", "teapot.dae", "torusknot.obj"};
		for (auto file : filenames) {
			vks::Model model;
			model.loadFromFile(vulkanDevice, getAssetPath() + "models/" + file, vertexLayout, 0.05f, queue);
			models.objects.push_back(model);
		}

		// Load HDR texture (equirectangular projected)
		// VK_FORMAT_BC6H_UFLOAT_BLOCK is a compressed 16 bit unsigned floating point format for storing HDR content
		textures.envmap.loadFromFile(getAssetPath() + "textures/hdr_uffizi_bc6uf.DDS", VK_FORMAT_BC6H_UFLOAT_BLOCK, vulkanDevice, queue);

		// Custom sampler with clamping adress mode
		vkDestroySampler(device, textures.envmap.sampler, nullptr);
		VkSamplerCreateInfo sampler{};
		sampler.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
		sampler.magFilter = VK_FILTER_LINEAR;
		sampler.minFilter = VK_FILTER_LINEAR;
		sampler.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
		sampler.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
		sampler.addressModeV = sampler.addressModeU;
		sampler.addressModeW = sampler.addressModeU;
		sampler.maxLod = (float)textures.envmap.mipLevels;
		sampler.maxLod = 1.0f;
		sampler.anisotropyEnable = VK_TRUE;
		sampler.maxAnisotropy = vulkanDevice->properties.limits.maxSamplerAnisotropy;
		sampler.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE;
		VK_CHECK_RESULT(vkCreateSampler(vulkanDevice->logicalDevice, &sampler, nullptr, &textures.envmap.sampler));
		textures.envmap.descriptor.sampler = textures.envmap.sampler;
	}
Exemplo n.º 2
0
void Utils::writeCrashLog(std::string path)
{
	string line;
	ifstream myfile;		
	vector<string> cam;
	myfile.open( getAssetPath(path).c_str(), ifstream::in);

	int value = 0;
	
	if (myfile.is_open())
	{
			while ( myfile.good() )
			{
				getline (myfile,line);
				cam.push_back(line);						
			}
			myfile.close();	

		 value = ::atoi(cam[0].c_str());
	}

	value++;

	ofstream myfile1 (getAssetPath(path).c_str());
	if (myfile1.is_open())
	{
		myfile1 << value;		
		myfile.close();
	}
	 

}
	void preparePipelines()
	{
		if (pipeline != VK_NULL_HANDLE) {
			vkDestroyPipeline(device, pipeline, nullptr);
		}

		const std::vector<VkDynamicState> dynamicStateEnables = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };

		VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateCI = vks::initializers::pipelineInputAssemblyStateCreateInfo(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, 0, VK_FALSE);
		VkPipelineColorBlendAttachmentState blendAttachmentState = vks::initializers::pipelineColorBlendAttachmentState(0xf, VK_FALSE);
		VkPipelineColorBlendStateCreateInfo colorBlendStateCI = vks::initializers::pipelineColorBlendStateCreateInfo(1, &blendAttachmentState);
		VkPipelineDepthStencilStateCreateInfo depthStencilStateCI = vks::initializers::pipelineDepthStencilStateCreateInfo(VK_TRUE, VK_FALSE, VK_COMPARE_OP_LESS_OR_EQUAL);
		VkPipelineViewportStateCreateInfo viewportStateCI = vks::initializers::pipelineViewportStateCreateInfo(1, 1, 0);
		VkPipelineMultisampleStateCreateInfo multisampleStateCI = vks::initializers::pipelineMultisampleStateCreateInfo(VK_SAMPLE_COUNT_1_BIT, 0);
		VkPipelineDynamicStateCreateInfo dynamicStateCI = vks::initializers::pipelineDynamicStateCreateInfo(dynamicStateEnables.data(), static_cast<uint32_t>(dynamicStateEnables.size()), 0);

		VkPipelineRasterizationStateCreateInfo rasterizationStateCI{};
		rasterizationStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
		rasterizationStateCI.polygonMode = VK_POLYGON_MODE_FILL;
		rasterizationStateCI.lineWidth = 1.0f;
		rasterizationStateCI.cullMode = VK_CULL_MODE_NONE + cullMode;
		rasterizationStateCI.frontFace = windingOrder == 0 ? VK_FRONT_FACE_CLOCKWISE : VK_FRONT_FACE_COUNTER_CLOCKWISE;

		// Vertex bindings and attributes
		std::vector<VkVertexInputBindingDescription> vertexInputBindings = {
			vks::initializers::vertexInputBindingDescription(0, sizeof(float) * 5, VK_VERTEX_INPUT_RATE_VERTEX),
		};
		std::vector<VkVertexInputAttributeDescription> vertexInputAttributes = {
			vks::initializers::vertexInputAttributeDescription(0, 0, VK_FORMAT_R32G32B32_SFLOAT, 0),				// Position			
			vks::initializers::vertexInputAttributeDescription(0, 1, VK_FORMAT_R32G32_SFLOAT, sizeof(float) * 3),	// uv
		};
		VkPipelineVertexInputStateCreateInfo vertexInputState = vks::initializers::pipelineVertexInputStateCreateInfo();
		vertexInputState.vertexBindingDescriptionCount = static_cast<uint32_t>(vertexInputBindings.size());
		vertexInputState.pVertexBindingDescriptions = vertexInputBindings.data();
		vertexInputState.vertexAttributeDescriptionCount = static_cast<uint32_t>(vertexInputAttributes.size());
		vertexInputState.pVertexAttributeDescriptions = vertexInputAttributes.data();

		VkGraphicsPipelineCreateInfo pipelineCreateInfoCI = vks::initializers::pipelineCreateInfo(pipelineLayout, renderPass, 0);
		//pipelineCreateInfoCI.pVertexInputState = &emptyInputState;
		pipelineCreateInfoCI.pVertexInputState = &vertexInputState;
		pipelineCreateInfoCI.pInputAssemblyState = &inputAssemblyStateCI;
		pipelineCreateInfoCI.pRasterizationState = &rasterizationStateCI;
		pipelineCreateInfoCI.pColorBlendState = &colorBlendStateCI;
		pipelineCreateInfoCI.pMultisampleState = &multisampleStateCI;
		pipelineCreateInfoCI.pViewportState = &viewportStateCI;
		pipelineCreateInfoCI.pDepthStencilState = &depthStencilStateCI;
		pipelineCreateInfoCI.pDynamicState = &dynamicStateCI;

		const std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages = {
			loadShader(getAssetPath() + "shaders/negativeviewportheight/quad.vert.spv", VK_SHADER_STAGE_VERTEX_BIT),
			loadShader(getAssetPath() + "shaders/negativeviewportheight/quad.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT)
		};

		pipelineCreateInfoCI.stageCount = static_cast<uint32_t>(shaderStages.size());
		pipelineCreateInfoCI.pStages = shaderStages.data();

		VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfoCI, nullptr, &pipeline));
	}
Exemplo n.º 4
0
	void loadTextures()
	{
		textureLoader->loadTexture(
			getAssetPath() + "textures/stonewall_colormap_bc3.dds", 
			VK_FORMAT_BC3_UNORM_BLOCK, 
			&textures.colorMap);
		textureLoader->loadTexture(
			getAssetPath() + "textures/stonewall_heightmap_rgba.dds", 
			VK_FORMAT_R8G8B8A8_UNORM, 
			&textures.heightMap);
	}
Exemplo n.º 5
0
	void loadMeshes()
	{
		// Skybox
		models.skybox.loadFromFile(getAssetPath() + "models/cube.obj", vertexLayout, 0.05f, vulkanDevice, queue);
		// Objects
		std::vector<std::string> filenames = { "sphere.obj", "teapot.dae", "torusknot.obj" };
		for (auto file : filenames) {
			vks::Model model;
			model.loadFromFile(getAssetPath() + "models/" + file, vertexLayout, 0.05f, vulkanDevice, queue);
			models.objects.push_back(model);
		}
	}
Exemplo n.º 6
0
	void loadAssets()
	{
		// Skybox
		models.skybox.loadFromFile(getAssetPath() + "models/cube.obj", vertexLayout, 0.05f, vulkanDevice, queue);
		// Objects
		std::vector<std::string> filenames = { "sphere.obj", "teapot.dae", "torusknot.obj", "venus.fbx" };
		objectNames = { "Sphere", "Teapot", "Torusknot", "Venus" };
		for (auto file : filenames) {
			vks::Model model;
			model.loadFromFile(getAssetPath() + "models/" + file, vertexLayout, 0.05f * (file == "venus.fbx" ? 3.0f : 1.0f), vulkanDevice, queue);
			models.objects.push_back(model);
		}
	}
Exemplo n.º 7
0
	void preparePipelines()
	{
		const std::vector<VkDynamicState> dynamicStateEnables = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };

		VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateCI = vks::initializers::pipelineInputAssemblyStateCreateInfo(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, 0, VK_FALSE);
		VkPipelineRasterizationStateCreateInfo rasterizationStateCI = vks::initializers::pipelineRasterizationStateCreateInfo(VK_POLYGON_MODE_FILL, VK_CULL_MODE_BACK_BIT, VK_FRONT_FACE_COUNTER_CLOCKWISE, 0);
		VkPipelineColorBlendAttachmentState blendAttachmentState = vks::initializers::pipelineColorBlendAttachmentState(0xf, VK_FALSE);
		VkPipelineColorBlendStateCreateInfo colorBlendStateCI = vks::initializers::pipelineColorBlendStateCreateInfo(1, &blendAttachmentState);
		VkPipelineDepthStencilStateCreateInfo depthStencilStateCI = vks::initializers::pipelineDepthStencilStateCreateInfo(VK_TRUE, VK_TRUE, VK_COMPARE_OP_LESS_OR_EQUAL);
		VkPipelineViewportStateCreateInfo viewportStateCI = vks::initializers::pipelineViewportStateCreateInfo(1, 1, 0);
		VkPipelineMultisampleStateCreateInfo multisampleStateCI = vks::initializers::pipelineMultisampleStateCreateInfo(VK_SAMPLE_COUNT_1_BIT, 0);
		VkPipelineDynamicStateCreateInfo dynamicStateCI = vks::initializers::pipelineDynamicStateCreateInfo(dynamicStateEnables.data(), static_cast<uint32_t>(dynamicStateEnables.size()), 0);

		// Vertex bindings and attributes
		const std::vector<VkVertexInputBindingDescription> vertexInputBindings = {
			vks::initializers::vertexInputBindingDescription(0, sizeof(vkglTF::Model::Vertex), VK_VERTEX_INPUT_RATE_VERTEX),
		};
		const std::vector<VkVertexInputAttributeDescription> vertexInputAttributes = {
			vks::initializers::vertexInputAttributeDescription(0, 0, VK_FORMAT_R32G32B32_SFLOAT, 0),					// Location 0: Position			
			vks::initializers::vertexInputAttributeDescription(0, 1, VK_FORMAT_R32G32B32_SFLOAT, sizeof(float) * 3),	// Location 1: Normal
			vks::initializers::vertexInputAttributeDescription(0, 2, VK_FORMAT_R32G32_SFLOAT, sizeof(float) * 6),		// Location 2: UV
		};
		VkPipelineVertexInputStateCreateInfo vertexInputState = vks::initializers::pipelineVertexInputStateCreateInfo();
		vertexInputState.vertexBindingDescriptionCount = static_cast<uint32_t>(vertexInputBindings.size());
		vertexInputState.pVertexBindingDescriptions = vertexInputBindings.data();
		vertexInputState.vertexAttributeDescriptionCount = static_cast<uint32_t>(vertexInputAttributes.size());
		vertexInputState.pVertexAttributeDescriptions = vertexInputAttributes.data();

		VkGraphicsPipelineCreateInfo pipelineCreateInfoCI = vks::initializers::pipelineCreateInfo(pipelineLayout, renderPass, 0);
		pipelineCreateInfoCI.pVertexInputState = &vertexInputState;
		pipelineCreateInfoCI.pInputAssemblyState = &inputAssemblyStateCI;
		pipelineCreateInfoCI.pRasterizationState = &rasterizationStateCI;
		pipelineCreateInfoCI.pColorBlendState = &colorBlendStateCI;
		pipelineCreateInfoCI.pMultisampleState = &multisampleStateCI;
		pipelineCreateInfoCI.pViewportState = &viewportStateCI;
		pipelineCreateInfoCI.pDepthStencilState = &depthStencilStateCI;
		pipelineCreateInfoCI.pDynamicState = &dynamicStateCI;

		const std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages = {
			loadShader(getAssetPath() + "shaders/conditionalrender/model.vert.spv", VK_SHADER_STAGE_VERTEX_BIT),
			loadShader(getAssetPath() + "shaders/conditionalrender/model.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT)
		};

		pipelineCreateInfoCI.stageCount = static_cast<uint32_t>(shaderStages.size());
		pipelineCreateInfoCI.pStages = shaderStages.data();

		VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfoCI, nullptr, &pipeline));
	}
Exemplo n.º 8
0
void QRcode::setup()
{	
	qrCodeFon    = *AssetManager::getInstance()->getTexture("images/qrCodeHolder.png");
	qrCodeFont   = Font( loadFile(getAssetPath("fonts/Helvetica Neue Bold.ttf")), 36 );
	errorTexture = AssetManager::getInstance()->getTexture("05_serveraerror.png");
	preloader.setup();
}
Exemplo n.º 9
0
	void loadTextures()
	{
		textureLoader->loadTexture(
			getAssetPath() + "textures/deer.ktx",
			VK_FORMAT_BC3_UNORM_BLOCK,
			&textures.colorMap);
	}
Exemplo n.º 10
0
void SplatTestApp::setup() {
  resetCamera();

  {
    connexion::Device::initialize(getRenderer()->getHwnd());
    const auto &ids = connexion::Device::getAllDeviceIds();
    if (!ids.empty()) {
      spaceNav = connexion::Device::create(ids.front());
      spaceNav->getMotionSignal().connect([this](const connexion::MotionEvent &event) {
        cameraTranslation = event.translation;
        cameraRotation = event.rotation;
      });
      spaceNav->getButtonDownSignal().connect(
          [this](const connexion::ButtonDownEvent &event) { resetCamera(); });
    }
  }

  particleSys = std::make_unique<ParticleSys>();
  particleUpdateMainFilepath = getAssetPath("update_cs.glsl");

  wd::watch(particleUpdateMainFilepath, [this](const fs::path &filepath) {
    updateShaderError.clear();
    try {
      particleSys->loadUpdateShaderMain(filepath);
    } catch (const gl::GlslProgCompileExc &exc) {
      updateShaderError = exc.what();
    }
  });

  ui::initialize(ui::Options().autoRender(false));
}
Exemplo n.º 11
0
	void loadAssets()
	{
		models.example.loadFromFile(getAssetPath() + "models/voyager/voyager.dae", vertexLayout, 1.0f, vulkanDevice, queue);
		if (deviceFeatures.textureCompressionBC) {
			textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/voyager_bc3_unorm.ktx", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue);
		}
		else if (deviceFeatures.textureCompressionASTC_LDR) {
			textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/voyager_astc_8x8_unorm.ktx", VK_FORMAT_ASTC_8x8_UNORM_BLOCK, vulkanDevice, queue);
		}
		else if (deviceFeatures.textureCompressionETC2) {
			textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/voyager_etc2_unorm.ktx", VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, vulkanDevice, queue);
		}
		else {
			vks::tools::exitFatal("Device does not support any compressed texture format!", "Error");
		}
	}
Exemplo n.º 12
0
bool SensorFile::init( const string &fileName )
{
	if( mInited )
		return false;

	fs::path fullPath( getAssetPath( string( "capture/" ) + fileName ));
	if( ! fs::exists( fullPath ))
	{
		console() << "Unable to load captured file: " << fileName << endl;
		return false;
	}

	mDoc = XmlTree( loadFile( fullPath ));

	if( mDoc.hasChild( "PulseSensor" ))
	{
		XmlTree &xmlPulseSensor = mDoc.getChild( "PulseSensor" );
		mName = xmlPulseSensor.getAttributeValue<string>( "Name"    , "" );

		if( xmlPulseSensor.hasChild( "Data" ))
		{
			mListXmlData   = &xmlPulseSensor.getChildren();
			mXmlDataActIt  =  mListXmlData->end();
			mInited        =  true;
			mTime          =  getElapsedSeconds();
			return true;
		}
	}

	console() << "Invalid captured file: " << fileName << endl;
	return false;
}
Exemplo n.º 13
0
	void loadTextures()
	{
		textureLoader->loadCubemap(
			getAssetPath() + "textures/cubemap_vulkan.ktx", 
			VK_FORMAT_R8G8B8A8_UNORM, 
			&textures.skybox);
	}
Exemplo n.º 14
0
	void loadTextures()
	{
		textureLoader->loadTexture(
			getAssetPath() + "textures/particle01_rgba.ktx", 
			VK_FORMAT_R8G8B8A8_UNORM, 
			&textureColorMap, 
			false);
	}
Exemplo n.º 15
0
NativeString*
AssetManagerGlue::getCookieName(int cookie)
{
	String8 name(getAssetPath((void*)cookie));
	if (name.length() == 0) {
		return NULL;
	}
	return new NativeString(name);
}
Exemplo n.º 16
0
	void loadAssets()
	{
		std::vector<std::string> filenames = { "geosphere.obj", "teapot.dae", "torusknot.obj", "venus.fbx" };
		for (auto file : filenames) {
			vks::Model model;
			model.loadFromFile(getAssetPath() + "models/" + file, vertexLayout, OBJ_DIM * (file == "venus.fbx" ? 3.0f : 1.0f), vulkanDevice, queue);
			models.objects.push_back(model);
		}
	}
Exemplo n.º 17
0
	void loadAssets()
	{
		model.loadFromFile(getAssetPath() + "models/geosphere.obj", vertexLayout, OBJ_DIM, vulkanDevice, queue);

		// Setup random materials for every object in the scene
		for (uint32_t i = 0; i < objects.size(); i++) {
			objects[i].setRandomMaterial();
		}
	}
Exemplo n.º 18
0
	void loadAssets()
	{
		models.quad.loadFromFile(getAssetPath() + "models/plane_z.obj", vertexLayout, 0.1f, vulkanDevice, queue);

		// Textures
		textures.normalHeightMap.loadFromFile(getAssetPath() + "textures/rocks_normal_height_rgba.dds", VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue);
		if (vulkanDevice->features.textureCompressionBC) {
			textures.colorMap.loadFromFile(getAssetPath() + "textures/rocks_color_bc3_unorm.dds", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue);
		}
		else if (vulkanDevice->features.textureCompressionASTC_LDR) {
			textures.colorMap.loadFromFile(getAssetPath() + "textures/rocks_color_astc_8x8_unorm.ktx", VK_FORMAT_ASTC_8x8_UNORM_BLOCK, vulkanDevice, queue);
		}
		else if (vulkanDevice->features.textureCompressionETC2) {
			textures.colorMap.loadFromFile(getAssetPath() + "textures/rocks_color_etc2_unorm.ktx", VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, vulkanDevice, queue);
		}
		else {
			vks::tools::exitFatal("Device does not support any compressed texture format!", VK_ERROR_FEATURE_NOT_PRESENT);
		}
	}
Exemplo n.º 19
0
void DataManager::loadDataSet( GenomeDataStructure ds ){
    Buffer b = Buffer( loadFile( getAssetPath(ds.pathBases) ) );
    size_t size = b.getDataSize();
    mDataBuffer = b;

    mCurrentDataSet.basePairsCount = size;
    mCurrentDataSet.chromosomeDescription = ds.name;
    mCurrentDataSet.chromosomeID = ds.id;

    Buffer bmap = Buffer( loadFile( getAssetPath(ds.pathMap) ) );
    generateChromosomeMap( &bmap );
    
    vector<GenomeData::ROIDataSet>::const_iterator it;
    for(it=mRoiMap.begin();it!=mRoiMap.end();++it){
        int roiID = (*it).roiId;
        mRoiMapVisited[roiID] = roiID;
//        XXX
    }
    sOnDataStructureChange();
}
Exemplo n.º 20
0
	void loadAssets()
	{
		textures.CW.loadFromFile(getAssetPath() + "textures/texture_orientation_cw_rgba.ktx", VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue);
		textures.CCW.loadFromFile(getAssetPath() + "textures/texture_orientation_ccw_rgba.ktx", VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue);

		// [POI] Create two quads with different Y orientations 

		struct Vertex {
			float pos[3];
			float uv[2];
		};

		const float ar = (float)height / (float)width;

		// OpenGL style (y points upwards) 
		std::vector<Vertex> verticesYPos = {
			{ -1.0f * ar,  1.0f, 1.0f, 0.0f, 1.0f },
			{ -1.0f * ar, -1.0f, 1.0f, 0.0f, 0.0f },
			{  1.0f * ar, -1.0f, 1.0f, 1.0f, 0.0f },
			{  1.0f * ar,  1.0f, 1.0f, 1.0f, 1.0f },
		};

		// Vulkan style (y points downwards)
		std::vector<Vertex> verticesYNeg = {
			{ -1.0f * ar, -1.0f, 1.0f, 0.0f, 1.0f },
			{ -1.0f * ar,  1.0f, 1.0f, 0.0f, 0.0f },
			{  1.0f * ar,  1.0f, 1.0f, 1.0f, 0.0f },
			{  1.0f * ar, -1.0f, 1.0f, 1.0f, 1.0f },
		};

		const VkMemoryPropertyFlags memoryPropertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;

		VK_CHECK_RESULT(vulkanDevice->createBuffer(VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, memoryPropertyFlags, &quad.verticesYUp, sizeof(Vertex) * 4, verticesYPos.data()));
		VK_CHECK_RESULT(vulkanDevice->createBuffer(VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, memoryPropertyFlags, &quad.verticesYDown,  sizeof(Vertex) * 4, verticesYNeg.data()));

		// [POI] Create two set of indices, one for counter clock wise, and one for clock wise rendering
		std::vector<uint32_t> indices = { 2,1,0, 0,3,2 };
		VK_CHECK_RESULT(vulkanDevice->createBuffer(VK_BUFFER_USAGE_INDEX_BUFFER_BIT, memoryPropertyFlags, &quad.indicesCCW, indices.size() * sizeof(uint32_t), indices.data()));
		indices = { 0,1,2, 2,3,0 };
		VK_CHECK_RESULT(vulkanDevice->createBuffer(VK_BUFFER_USAGE_INDEX_BUFFER_BIT, memoryPropertyFlags, &quad.indicesCW, indices.size() * sizeof(uint32_t), indices.data()));
	}
Exemplo n.º 21
0
void fsExperiments::setupEyes()
{
	GlobalData& data = GlobalData::get();

	data.mAiEyes = assimp::AssimpLoader( getAssetPath( "models/eyes.dae" ) );
	data.mAiEyes.disableSkinning();
	//data.mAiEyes.disableMaterials();
	data.mAiEyes.enableMaterials();

	// FIXME: load positions from export/eye
	data.mLeftEyeRef = data.mAiEyes.getAssimpNode( "left" );
	assert( data.mLeftEyeRef );
	data.mLeftEyeRef->setPosition( Vec3f( 31.3636, -24.4065, -24.7222 ) );

	data.mRightEyeRef = data.mAiEyes.getAssimpNode( "right" );
	assert( data.mRightEyeRef );
	data.mRightEyeRef->setPosition( Vec3f( -31.1631, -26.0238, -24.7322 ) );
}
Exemplo n.º 22
0
void ResourceManager::initResources()
{
//    mFont = Font(loadAsset("Blender-BOOK.ttf"), 14);
//    mFont = Font(loadAsset("Blender-BOLD.ttf"), 14);
    mFont = Font(loadAsset("Overlock-Bold.ttf"), 12);
    gl::TextureFont::Format format;
//    format.premultiply();
    mTextureFont = gl::TextureFont::create(mFont, format);
    
    mPlusTexture = loadImage(getAssetPath("plus.png"));
    
    colors.push_back(Color::hex(0xdc534e));
    colors.push_back(Color::hex(0x5f78b4));
    colors.push_back(Color::hex(0x5b3a6f));
    colors.push_back(Color::hex(0xbaa326));
    colors.push_back(Color::hex(0xF26835));
    
    ResourceManager::mainIsolate = v8::Isolate::New();
    ResourceManager::mainIsolate->Enter();
}
Exemplo n.º 23
0
void DataManager::generateXmlFile(){
    XmlTree dataTree;
    dataTree.setTag("QLT_Genome_Data");

    dataTree.push_back(XmlTree("datapath","./data/exons/"));
    
    XmlTree datas("datasets","");
    for(int i=0;i<23;i++){
        XmlTree dataset("dataset","");
        dataset.setAttribute("id", i);
        dataset.push_back( XmlTree("title","Chromosome "+toString(i+1)) );
        dataset.push_back( XmlTree("map","exons."+toString(i+1)+".locations") );
        dataset.push_back( XmlTree("bases","exons."+toString(i+1)+".bases") );
        datas.push_back( dataset );
    }
    dataTree.push_back( datas );

    DataTargetPathRef f = writeFile( getAssetPath( "QLT_Genome_Data.xml" ), true );
    dataTree.write( f );
    
}
Exemplo n.º 24
0
bool Utils::readFlag(std::string path)
{
	string line;
	ifstream myfile;		
	vector<string> cam;
	myfile.open( getAssetPath(path).c_str(), ifstream::in);
	
	if (myfile.is_open())
	{
			while ( myfile.good() )
			{
				getline (myfile,line);
				cam.push_back(line);						
			}
			myfile.close();	

		 return ::atoi(cam[0].c_str()) == 1;
	}

	return false;
}
Exemplo n.º 25
0
void tracking::setup(){
    
    mWindow = getWindow();
    mCbMouseDown = mWindow->getSignalMouseDown().connect( std::bind( &tracking::mouseDown, this, std::placeholders::_1 ) );
    mCbMouseDrag = mWindow->getSignalMouseDrag().connect( std::bind( &tracking::mouseDrag, this, std::placeholders::_1 ) );
    mCbMouseMove = mWindow->getSignalMouseMove().connect( std::bind( &tracking::mouseMove, this, std::placeholders::_1 ) );
    mCbMouseUp = mWindow->getSignalMouseUp().connect( std::bind( &tracking::mouseUp, this, std::placeholders::_1 ) );
    
    mCbKeyDown = mWindow->getSignalKeyDown().connect( std::bind( &tracking::keyDown, this, std::placeholders::_1 ) );
    mCbKeyUp = mWindow->getSignalKeyUp().connect( std::bind( &tracking::keyUp, this, std::placeholders::_1 ) );
    mCbResize = mWindow->getSignalResize().connect(std::bind(&tracking::resize,this));
    
    mUseBeginEnd = false;
    // initialize warps
    mSettings = getAssetPath( "" ) / "warps.xml";
    if( fs::exists( mSettings ) ) {
        mWarps = Warp::readSettings( loadFile( mSettings ) );
    }
    else {
        mWarps.push_back( WarpPerspective::create() );
    }
    
    mTexturePlaceholder = gl::Texture::create(500,500);

    // load test image
    try {
        mImage = gl::Texture::create( loadImage( loadAsset( "help.png" ) ),
                                     gl::Texture2d::Format().loadTopDown().mipmap( true ).minFilter( GL_LINEAR_MIPMAP_LINEAR ) );
        
        mSrcArea = mImage->getBounds();
        
        // adjust the content size of the warps
        Warp::setSize( mWarps, mImage->getSize() );
    }
    catch( const std::exception &e ) {
        console() << e.what() << std::endl;
    }
}
Exemplo n.º 26
0
void fsExperiments::setupParams()
{
	fs::path paramsXml( getAssetPath( "params.xml" ));
	if ( paramsXml.empty() )
	{
#if defined( CINDER_MAC )
		fs::path assetPath( getResourcePath() / "assets" );
#else
		fs::path assetPath( getAppPath() / "assets" );
#endif
		createDirectories( assetPath );
		paramsXml = assetPath / "params.xml" ;
	}
	params::PInterfaceGl::load( paramsXml );

	GlobalData& data = GlobalData::get();
	data.mParams = params::PInterfaceGl( "Parameters", Vec2i( 200, 300 ) );
	data.mParams.addPersistentSizeAndPosition();

	data.mParams.addParam( "Fps", &mFps, "", false );
	data.mParams.addPersistentParam( "Background", &mBackground, Color::gray( .1 ) );

	// effect params setup
	mCurrentEffect = 0;
	vector< string > effectNames;
	for ( vector< fsExpRef >::iterator it = mEffects.begin(); it != mEffects.end(); ++it )
	{
		effectNames.push_back( (*it)->getName() );
	}
	data.mParams.addParam( "Effect", effectNames, &mCurrentEffect );

	for ( vector< fsExpRef >::iterator it = mEffects.begin(); it != mEffects.end(); ++it )
	{
		(*it)->setupParams();
	}
}
Exemplo n.º 27
0
	void loadTextures()
	{
		// Vulkan core supports three different compressed texture formats
		// As the support differs between implemementations we need to check device features and select a proper format and file
		std::string filename;
		VkFormat format;
		if (deviceFeatures.textureCompressionBC) {
			filename = "cubemap_yokohama_bc3_unorm.ktx";
			format = VK_FORMAT_BC2_UNORM_BLOCK;
		}
		else if (deviceFeatures.textureCompressionASTC_LDR) {
			filename = "cubemap_yokohama_astc_8x8_unorm.ktx";
			format = VK_FORMAT_ASTC_8x8_UNORM_BLOCK;
		}
		else if (deviceFeatures.textureCompressionETC2) {
			filename = "cubemap_yokohama_etc2_unorm.ktx";
			format = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
		}
		else {
			vks::tools::exitFatal("Device does not support any compressed texture format!", "Error");
		}

		loadCubemap(getAssetPath() + "textures/" + filename, format, false);
	}
Exemplo n.º 28
0
	void preparePipelines()
	{
		VkResult err;

		VkPipelineInputAssemblyStateCreateInfo inputAssemblyState =
			vkTools::initializers::pipelineInputAssemblyStateCreateInfo(
				VK_PRIMITIVE_TOPOLOGY_PATCH_LIST,
				0,
				VK_FALSE);

		VkPipelineRasterizationStateCreateInfo rasterizationState =
			vkTools::initializers::pipelineRasterizationStateCreateInfo(
				VK_POLYGON_MODE_FILL,
				VK_CULL_MODE_NONE,
				VK_FRONT_FACE_COUNTER_CLOCKWISE,
				0);

		VkPipelineColorBlendAttachmentState blendAttachmentState =
			vkTools::initializers::pipelineColorBlendAttachmentState(
				0xf,
				VK_FALSE);

		VkPipelineColorBlendStateCreateInfo colorBlendState =
			vkTools::initializers::pipelineColorBlendStateCreateInfo(
				1,
				&blendAttachmentState);

		VkPipelineDepthStencilStateCreateInfo depthStencilState =
			vkTools::initializers::pipelineDepthStencilStateCreateInfo(
				VK_TRUE,
				VK_TRUE,
				VK_COMPARE_OP_LESS_OR_EQUAL);

		VkPipelineViewportStateCreateInfo viewportState =
			vkTools::initializers::pipelineViewportStateCreateInfo(1, 1, 0);

		VkPipelineMultisampleStateCreateInfo multisampleState =
			vkTools::initializers::pipelineMultisampleStateCreateInfo(
				VK_SAMPLE_COUNT_1_BIT,
				0);

		std::vector<VkDynamicState> dynamicStateEnables = {
			VK_DYNAMIC_STATE_VIEWPORT,
			VK_DYNAMIC_STATE_SCISSOR,
			VK_DYNAMIC_STATE_LINE_WIDTH
		};
		VkPipelineDynamicStateCreateInfo dynamicState =
			vkTools::initializers::pipelineDynamicStateCreateInfo(
				dynamicStateEnables.data(),
				dynamicStateEnables.size(),
				0);

		VkPipelineTessellationStateCreateInfo tessellationState =
			vkTools::initializers::pipelineTessellationStateCreateInfo(3);

		// Tessellation pipeline
		// Load shaders
		std::array<VkPipelineShaderStageCreateInfo, 4> shaderStages;
		shaderStages[0] = loadShader(getAssetPath() + "shaders/displacement/base.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
		shaderStages[1] = loadShader(getAssetPath() + "shaders/displacement/base.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
		shaderStages[2] = loadShader(getAssetPath() + "shaders/displacement/displacement.tesc.spv", VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
		shaderStages[3] = loadShader(getAssetPath() + "shaders/displacement/displacement.tese.spv", VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT);

		VkGraphicsPipelineCreateInfo pipelineCreateInfo =
			vkTools::initializers::pipelineCreateInfo(
				pipelineLayout,
				renderPass,
				0);

		pipelineCreateInfo.pVertexInputState = &vertices.inputState;
		pipelineCreateInfo.pInputAssemblyState = &inputAssemblyState;
		pipelineCreateInfo.pRasterizationState = &rasterizationState;
		pipelineCreateInfo.pColorBlendState = &colorBlendState;
		pipelineCreateInfo.pMultisampleState = &multisampleState;
		pipelineCreateInfo.pViewportState = &viewportState;
		pipelineCreateInfo.pDepthStencilState = &depthStencilState;
		pipelineCreateInfo.pDynamicState = &dynamicState;
		pipelineCreateInfo.pTessellationState = &tessellationState;
		pipelineCreateInfo.stageCount = shaderStages.size();
		pipelineCreateInfo.pStages = shaderStages.data();
		pipelineCreateInfo.renderPass = renderPass;

		// Solid pipeline
		err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.solid);
		assert(!err);
		// Wireframe pipeline
		rasterizationState.polygonMode = VK_POLYGON_MODE_LINE;
		err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.wire);
		assert(!err);

		// Pass through pipelines
		// Load pass through tessellation shaders (Vert and frag are reused)
		shaderStages[2] = loadShader(getAssetPath() + "shaders/displacement/passthrough.tesc.spv", VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
		shaderStages[3] = loadShader(getAssetPath() + "shaders/displacement/passthrough.tese.spv", VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT);
		// Solid
		rasterizationState.polygonMode = VK_POLYGON_MODE_FILL;
		err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.solidPassThrough);
		assert(!err);
		// Wireframe
		rasterizationState.polygonMode = VK_POLYGON_MODE_LINE;
		err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.wirePassThrough);
		assert(!err);
	}
Exemplo n.º 29
0
	void loadMeshes()
	{
		loadMesh(getAssetPath() + "models/torus.obj", &meshes.object, vertexLayout, 0.25f);
	}
Exemplo n.º 30
0
	void preparePipelines()
	{
		VkPipelineInputAssemblyStateCreateInfo inputAssemblyState =
			vks::initializers::pipelineInputAssemblyStateCreateInfo(
				VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
				0,
				VK_FALSE);

		VkPipelineRasterizationStateCreateInfo rasterizationState =
			vks::initializers::pipelineRasterizationStateCreateInfo(
				VK_POLYGON_MODE_FILL,
				VK_CULL_MODE_BACK_BIT,
				VK_FRONT_FACE_COUNTER_CLOCKWISE,
				0);

		VkPipelineColorBlendAttachmentState blendAttachmentState =
			vks::initializers::pipelineColorBlendAttachmentState(
				0xf,
				VK_FALSE);

		VkPipelineColorBlendStateCreateInfo colorBlendState =
			vks::initializers::pipelineColorBlendStateCreateInfo(
				1, 
				&blendAttachmentState);

		VkPipelineDepthStencilStateCreateInfo depthStencilState =
			vks::initializers::pipelineDepthStencilStateCreateInfo(
				VK_FALSE,
				VK_FALSE,
				VK_COMPARE_OP_LESS_OR_EQUAL);

		VkPipelineViewportStateCreateInfo viewportState =
			vks::initializers::pipelineViewportStateCreateInfo(1, 1, 0);

		VkPipelineMultisampleStateCreateInfo multisampleState =
			vks::initializers::pipelineMultisampleStateCreateInfo(
				VK_SAMPLE_COUNT_1_BIT,
				0);

		std::vector<VkDynamicState> dynamicStateEnables = {
			VK_DYNAMIC_STATE_VIEWPORT,
			VK_DYNAMIC_STATE_SCISSOR
		};
		VkPipelineDynamicStateCreateInfo dynamicState =
			vks::initializers::pipelineDynamicStateCreateInfo(
				dynamicStateEnables.data(),
				dynamicStateEnables.size(),
				0);

		// Skybox pipeline (background cube)
		std::array<VkPipelineShaderStageCreateInfo,2> shaderStages;

		shaderStages[0] = loadShader(getAssetPath() + "shaders/cubemap/skybox.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
		shaderStages[1] = loadShader(getAssetPath() + "shaders/cubemap/skybox.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);

		VkGraphicsPipelineCreateInfo pipelineCreateInfo =
			vks::initializers::pipelineCreateInfo(
				pipelineLayout,
				renderPass,
				0);

		pipelineCreateInfo.pVertexInputState = &vertices.inputState;
		pipelineCreateInfo.pInputAssemblyState = &inputAssemblyState;
		pipelineCreateInfo.pRasterizationState = &rasterizationState;
		pipelineCreateInfo.pColorBlendState = &colorBlendState;
		pipelineCreateInfo.pMultisampleState = &multisampleState;
		pipelineCreateInfo.pViewportState = &viewportState;
		pipelineCreateInfo.pDepthStencilState = &depthStencilState;
		pipelineCreateInfo.pDynamicState = &dynamicState;
		pipelineCreateInfo.stageCount = shaderStages.size();
		pipelineCreateInfo.pStages = shaderStages.data();

		VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.skybox));

		// Cube map reflect pipeline
		shaderStages[0] = loadShader(getAssetPath() + "shaders/cubemap/reflect.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
		shaderStages[1] = loadShader(getAssetPath() + "shaders/cubemap/reflect.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
		// Enable depth test and write
		depthStencilState.depthWriteEnable = VK_TRUE;
		depthStencilState.depthTestEnable = VK_TRUE;
		// Flip cull mode
		rasterizationState.cullMode = VK_CULL_MODE_FRONT_BIT;
		VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.reflect));
	}