Пример #1
0
bool GLSLShader::loadShaders(const std::string& vs, const std::string& ps, const std::string& gs, GLint inputGeometryPrimitive,GLint outputGeometryPrimitive, int nb_max_vertices)
{
	m_nameVS = vs;
	m_nameFS = ps;
	m_nameGS = gs;

	std::string vss = findFile(vs);
	if(!loadVertexShader(vss)) return false;

	std::string pss = findFile(ps);
	if(!loadFragmentShader(pss)) return false;

	std::string gss = findFile(gs);
	bool geomShaderLoaded = loadGeometryShader(gss);

	if (!geomShaderLoaded)
	{
		CGoGNerr << "Error while loading geometry shader" << CGoGNendl;
	}

	if(!create(inputGeometryPrimitive,outputGeometryPrimitive,nb_max_vertices))
	{
		CGoGNout << "Unable to create the shaders !" << CGoGNendl;
		return false;
	}

	CGoGNout << "Shaders loaded (" << vs << "," << ps << "," << gs <<")" << CGoGNendl;
	return true;
}
Пример #2
0
void CGraphicsResourceManager::handleShaderEvent(ResourceId id, EListenerEvent event,
	IResourceManager* resourceManager)
{
	ResourceId vertex;
	ResourceId tessControl;
	ResourceId tessEval;
	ResourceId geometry;
	ResourceId fragment;

	switch (event)
	{
	case EListenerEvent::Create:
		// TODO Replace assert with log statement and global error handler
		assert(m_shaderPrograms.count(id) == 0 && "Shader id already exists");

		// Load shader source ids
		if (!resourceManager->getShader(id, vertex, tessControl, tessEval, geometry, fragment))
		{
			// TODO Replace assert with log statement and global error handler
			assert(false && "Failed to access shader resource");
		}

		// Load shader objects from source
		if (!loadVertexShader(vertex, resourceManager) ||
			!loadTessControlShader(tessControl, resourceManager) ||
			!loadTessEvalShader(tessEval, resourceManager) ||
			!loadGeometryShader(geometry, resourceManager) ||
			!loadFragmentShader(fragment, resourceManager))
		{
			// TODO Log error
			return;
		}

		// Add create shader program
		m_shaderPrograms[id] = std::move(std::unique_ptr<CShaderProgram>(new CShaderProgram(
			getVertexShaderObject(vertex), getTessControlShaderObject(tessControl),
			getTessEvalShaderObject(tessEval), getGeometryShaderObject(geometry),
			getFragmentShaderObject(fragment))));

		break;

	case EListenerEvent::Change:
		// TODO Implement

	case EListenerEvent::Delete:
		// TODO Keep shader?
		break;

	default:
		// TODO Log error on unknown event?
		break;
	}
}
Пример #3
0
/**
 * @brief Loads a geometry shader from path
 *
 * @param shaderPath
 *      Path of the geometric shader
 */
void Shader::loadGeometryShaderFromFile(const std::string &shaderPath) {
    loadGeometryShader(loadFile(shaderPath));
}
Пример #4
0
bool D3DCodePath::create(VertexLayout* playout, DataStream& vertexshader, DataStream& geometryshader, DataStream& pixelshader)
{
    setVertexLayout(playout);

    return loadVertexShader(vertexshader) && loadGeometryShader(geometryshader) && loadPixelShader(pixelshader);
}