void ShaderExplodeSmoothVolumes::restoreUniformsAttribs()
{
	bind();

	*m_unif_explodeV   = glGetUniformLocation(program_handler(),"explodeV");
	glUniform1f (*m_unif_explodeV, m_explodeV);

	*m_unif_explodeF   = glGetUniformLocation(program_handler(),"explodeF");
	glUniform1f (*m_unif_explodeF, m_explodeF);

	*m_unif_ambiant   = glGetUniformLocation(program_handler(),"ambient");
	glUniform4fv(*m_unif_ambiant,  1, m_ambiant.data());

	*m_unif_lightPos =  glGetUniformLocation(program_handler(),"lightPosition");
	glUniform3fv(*m_unif_lightPos, 1, m_light_pos.data());

	*m_unif_plane   = glGetUniformLocation(program_handler(),"plane");
	glUniform4fv(*m_unif_plane,    1, m_plane.data());

	bindVA_VBO("VertexPosition", m_vboPos);
	bindVA_VBO("VertexColor", m_vboColors);
	bindVA_VBO("VertexNormal", m_vboNormals);

	unbind();
}
Exemple #2
0
void ClippingShader::updateClippingUniforms()
{
	// Plane clipping uniforms
	if (getClipPlanesCount() > 0)
	{
		// Get uniform location
		m_unif_clipPlanesEquations = glGetUniformLocation(program_handler(), "clip_clipPlanesEquations");
		errorRaiseUniformNotFoundInShader((m_unif_clipPlanesEquations == -1), "ClippingShader::updateClippingUniforms", "clip_clipPlanesEquations");

		// Send again uniform value
		sendClipPlanesEquationsUniform();
	}

	// Sphere clipping uniforms
	if (getClipSpheresCount() > 0)
	{
		// Get uniform location
		m_unif_clipSpheresCentersAndRadiuses = glGetUniformLocation(program_handler(), "clip_clipSpheresCentersAndRadiuses");
		errorRaiseUniformNotFoundInShader((m_unif_clipSpheresCentersAndRadiuses == -1), "ClippingShader::updateClippingUniforms", "clip_clipSpheresCentersAndRadiuses");

		// Send again uniform value
		sendClipSpheresCentersAndRadiusesUniform();
	}

	// Global clipping uniforms
	if ((getClipPlanesCount() > 0) || (getClipSpheresCount() > 0))
	{
		// Get uniform location
		m_unif_clipColorAttenuationFactor = glGetUniformLocation(program_handler(), "clip_clipColorAttenuationFactor");
		errorRaiseUniformNotFoundInShader((m_unif_clipColorAttenuationFactor == -1), "ClippingShader::updateClippingUniforms", "clip_clipColorAttenuationFactor");

		// Send again uniform value
		sendClipColorAttenuationFactorUniform();
	}
}
void ShaderExplodeVolumesLines::getLocations()
{
	bind();
	*m_unif_explodeV  = glGetUniformLocation(program_handler(),"explodeV");
	*m_unif_color  = glGetUniformLocation(program_handler(),"color");
	*m_unif_plane   = glGetUniformLocation(program_handler(),"plane");
	unbind();
}
Exemple #4
0
Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc) : m_nbChars(0),m_scale(1.0f)
{
    if (m_instance0 == NULL)
    {
        m_instance0 = this;
        std::string font_filename = Utils::GLSLShader::findFile("font_cgogn.gz");
        igzstream fs(font_filename.c_str(), std::ios::in|std::ios::binary);
        char* buff = new char[WIDTHTEXTURE*HEIGHTTEXTURE];
        fs.read(reinterpret_cast<char*>(buff), WIDTHTEXTURE*HEIGHTTEXTURE );
        fs.close();

        glGenTextures(1, &(*m_idTexture));
        glBindTexture(GL_TEXTURE_2D, *m_idTexture);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, WIDTHTEXTURE, HEIGHTTEXTURE, 0, GL_LUMINANCE,  GL_UNSIGNED_BYTE, (GLvoid*)(buff));
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        delete[] buff;
    }
    else
    {
        *m_idTexture = *(this->m_idTexture);
    }

    std::string glxvert(*GLSLShader::DEFINES_GL);
    glxvert.append(vertexShaderText);
    std::string glxfrag(*GLSLShader::DEFINES_GL);

    glxfrag.append(fragmentShaderText1);

    std::string background;
    if (!withBackground)
        glxfrag.append("if (lum == 0.0) discard;\n");
    else if (bgc*bgc > 0.0)
    {
        std::stringstream ss;
        ss << "	if (lum==0.0) gl_FragColor=vec4(";
        ss << bgc[0] << "," << bgc[1] << "," << bgc[2] << ",0.0);\n		else\n";
        background.append(ss.str());
    }
    glxfrag.append(background);
    glxfrag.append(fragmentShaderText2);

    loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str());

    m_vbo1 = new Utils::VBO();
    m_vbo1->setDataSize(4);

    bindVA_VBO("VertexPosition", m_vbo1);

    bind();
    *m_uniform_position = glGetUniformLocation(program_handler(), "strPos");
    *m_uniform_color = glGetUniformLocation(program_handler(), "color");
    *m_uniform_scale = glGetUniformLocation(program_handler(), "scale");
    *m_uniform_texture = glGetUniformLocation(program_handler(), "FontTexture");
    glUniform1f(*m_uniform_scale, 1.0f);
    unbind();
}
void ShaderExplodeSmoothVolumes::getLocations()
{
	bind();
	*m_unif_explodeV  = glGetUniformLocation(program_handler(),"explodeV");
	*m_unif_explodeF  = glGetUniformLocation(program_handler(),"explodeF");
	*m_unif_ambiant  = glGetUniformLocation(program_handler(),"ambient");
	*m_unif_lightPos = glGetUniformLocation(program_handler(),"lightPosition");
	*m_unif_plane   = glGetUniformLocation(program_handler(),"plane");
	unbind();
}
void ShaderIsoLines::getLocations()
{
	bind();
	*m_unif_colorMin = glGetUniformLocation(program_handler(),"colorMin");
	*m_unif_colorMax = glGetUniformLocation(program_handler(),"colorMax");
	*m_unif_vmin = glGetUniformLocation(program_handler(),"vmin");
	*m_unif_vmax = glGetUniformLocation(program_handler(),"vmax");
	*m_unif_vnb = glGetUniformLocation(program_handler(),"vnb");
	unbind();
}
void ShaderExplodeVolumesLines::restoreUniformsAttribs()
{
	*m_unif_explodeV   = glGetUniformLocation(program_handler(),"explodeV");
	*m_unif_color   = glGetUniformLocation(program_handler(),"color");
	*m_unif_plane   = glGetUniformLocation(program_handler(),"plane");

	bind();

	glUniform1f (*m_unif_explodeV, m_explodeV);
	glUniform4fv(*m_unif_color,  1, m_color.data());
	glUniform4fv(*m_unif_plane,    1, m_plane.data());

	bindVA_VBO("VertexPosition", m_vboPos);

	unbind();
}
Exemple #8
0
void ShaderCustomTex::setTransformation(Geom::Matrix44f t)
{
	bind();
	CGoGNGLuint m_transf;
	*m_transf  = glGetUniformLocation(program_handler(),"TransformationMatrix");
	glUniformMatrix4fv(*m_transf, 1, false, &t(0,0));
	unbind();
}
Exemple #9
0
void ShaderCustomTex::setBaseColor(Geom::Vec4f col)
{
	m_col = col;

	bind();
	CGoGNGLuint m_unif_ambiant;
	*m_unif_ambiant  = glGetUniformLocation(program_handler(),"ambient");
	glUniform4fv(*m_unif_ambiant, 1, m_col.data());
	unbind();
}
Exemple #10
0
void ShaderExplodeVolumesAlpha::restoreUniformsAttribs()
{
	bind();

	*m_unif_ambient   = glGetUniformLocation(program_handler(),"ambient");
	glUniform4fv(*m_unif_ambient,  1, m_ambient.data());

	*m_unif_backColor = glGetUniformLocation(program_handler(),"backColor");
	glUniform4fv(*m_unif_backColor, 1, m_backColor.data());

	*m_unif_lightPos =  glGetUniformLocation(program_handler(),"lightPosition");
	glUniform3fv(*m_unif_lightPos, 1, m_light_pos.data());

	*m_unif_plane   = glGetUniformLocation(program_handler(),"plane");
	glUniform4fv(*m_unif_plane,    1, m_plane.data());

	*m_unif_unit   = glGetUniformLocation(program_handler(),"textureUnit");
	glUniform1iARB(*m_unif_unit, 0);

	bindVA_VBO("VertexPosition", m_vboPos);
	bindVA_VBO("VertexColor", m_vboColors);
	unbind();
}
Exemple #11
0
void ShaderExplodeVolumesAlpha::getLocations()
{
	*m_unif_ambient      = glGetUniformLocation(program_handler(), "ambient");
	*m_unif_backColor    = glGetUniformLocation(program_handler(), "backColor");
	*m_unif_lightPos     = glGetUniformLocation(program_handler(), "lightPosition");
	*m_unif_plane        = glGetUniformLocation(program_handler(), "plane");
	*m_unif_unit         = glGetUniformLocation(program_handler(), "textureUnit");
	*m_unif_depthPeeling = glGetUniformLocation(program_handler(), "depthPeeling");
}