Exemple #1
0
	int GausBlur::init(xdl::xdl_uint width, xdl::xdl_uint height, xdl::XdevLFrameBufferColorFormat textureFormat) {

		PostProcessEffect::init(width, height);

		m_shaderProgram = m_rai->createShaderProgram();

		m_vs = m_rai->createVertexShader();
		m_vs->compileFromFile("resources/shaders/blurGaus_vs.glsl");

		m_fs = m_rai->createFragmentShader();
		m_fs->compileFromFile("resources/shaders/blurGaus_fs.glsl");

		m_shaderProgram->attach(m_vs);
		m_shaderProgram->attach(m_fs);
		m_shaderProgram->link();

		m_textureid 			=  	m_shaderProgram->getUniformLocation("texture0");
		m_blurDirectionid	=  	m_shaderProgram->getUniformLocation("blurDirection");
		m_blurSizeid 			= 	m_shaderProgram->getUniformLocation("blurSize");

		// Create Framebuffer.
		m_frameBuffer = m_rai->createFrameBuffer();
		if(m_frameBuffer->init(m_width, m_height) != xdl::ERR_OK) {
			std::cerr << "GBuffer::Could not create Framebuffer." << std::endl;
			return -1;
		}

		//
		// Create one Framebuffer with one color target to Blur horizontally.
		//
		m_frameBuffer->addColorTarget(0, textureFormat);

		auto texture = m_frameBuffer->getTexture(0);
		texture->lock();
		texture->setTextureFilter(xdl::XDEVL_TEXTURE_MAG_FILTER, xdl::XDEVL_LINEAR);
		texture->setTextureFilter(xdl::XDEVL_TEXTURE_MIN_FILTER, xdl::XDEVL_LINEAR);
		texture->setTextureWrap(xdl::XDEVL_TEXTURE_WRAP_S, xdl::XDEVL_CLAMP_TO_BORDER);
		texture->setTextureWrap(xdl::XDEVL_TEXTURE_WRAP_T, xdl::XDEVL_CLAMP_TO_BORDER);
		texture->unlock();

		//
		// Create one Framebuffer with one color target to Blur vertically.
		//
		m_frameBuffer2 = m_rai->createFrameBuffer();
		if(m_frameBuffer2->init(m_width, m_height) != xdl::ERR_OK) {
			std::cerr << "GBuffer::Could not create Framebuffer." << std::endl;
			return -1;
		}
		m_frameBuffer2->addColorTarget(0, textureFormat);

		auto texture2 = m_frameBuffer2->getTexture(0);
		texture2->lock();
		texture2->setTextureFilter(xdl::XDEVL_TEXTURE_MAG_FILTER, xdl::XDEVL_LINEAR);
		texture2->setTextureFilter(xdl::XDEVL_TEXTURE_MIN_FILTER, xdl::XDEVL_LINEAR);
		texture2->setTextureWrap(xdl::XDEVL_TEXTURE_WRAP_S, xdl::XDEVL_CLAMP_TO_BORDER);
		texture2->setTextureWrap(xdl::XDEVL_TEXTURE_WRAP_T, xdl::XDEVL_CLAMP_TO_BORDER);
		texture2->unlock();

		return 0;
	}
Exemple #2
0
void Image::setWrap(const Image::Wrap &w)
{
	wrap = w;

	bind();
	setTextureWrap(w);
}
Exemple #3
0
appearance::appearance(string tex, int s, int t)
{
	color[0] = 0.5;
	color[1] = 0.5;
	color[2] = 0.5;
	color[3] = 1;

	materialType = CG_GLMAT_COLOR;

	texture=NULL;
	privateTexture=false;

	setTexture(tex);
	setTextureWrap(s,t);
}
Exemple #4
0
CGFappearance::CGFappearance(string tex, int s, int t)
{
	color[0] = 0.5;
	color[1] = 0.5;
	color[2] = 0.5;
	color[3] = 1;

	materialType = CG_GLMAT_COLOR;

	texture=NULL;
	try {
		setTexture(tex);
		setTextureWrap(s,t);
	}
	catch (GLexception& ex) {
		throw ex;
	}
	catch (std::exception&) {
		throw GLexception("CGFappearance::constructor for texture failed");
	}
}