ShaderIsoLines::ShaderIsoLines(int maxNbIsoPerTriangle) { m_nameVS = "shaderIsoLines_vs"; m_nameFS = "shaderIsoLines_fs"; m_nameGS = "shaderIsoLines_gs"; std::string glxvert(GLSLShader::defines_gl()); glxvert.append(vertexShaderText); std::string glxgeom = GLSLShader::defines_Geom("triangles", "line_strip", 2*maxNbIsoPerTriangle); glxgeom.append(geometryShaderText); std::string glxfrag(GLSLShader::defines_gl()); glxfrag.append(fragmentShaderText); loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str(), glxgeom.c_str(), GL_TRIANGLES, GL_LINE_STRIP, 2*maxNbIsoPerTriangle); getLocations(); //Default values setColors(Geom::Vec4f(1.0f,0.0f,0.0f,1.0f),Geom::Vec4f(0.0f,1.0f,0.0f,1.0f)); setDataBound(0.0f,1.0f); setNbIso(32); }
ShaderCustomTex::ShaderCustomTex() : m_col(1.0f, 1.0f, 1.0f, 1.0f) { m_nameVS = "ShaderCustomTex_vs"; m_nameFS = "ShaderCustomTex_fs"; m_nameGS = "ShaderCustomTex_gs"; std::string glxvert(*GLSLShader::DEFINES_GL); glxvert.append(vertexShaderText); std::string glxgeom = GLSLShader::defines_Geom("triangles", "triangle_strip", 3); glxgeom.append(geometryShaderText); std::string glxfrag(*GLSLShader::DEFINES_GL); glxfrag.append(fragmentShaderText); // loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str()); loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str(), glxgeom.c_str(), GL_TRIANGLES, GL_TRIANGLE_STRIP, 3); m_unif_unit = glGetUniformLocation(this->program_handler(), "textureUnit"); setBaseColor(m_col); Geom::Matrix44f id; id.identity(); setTransformation(id); }
ShaderExplodeVolumesLines::ShaderExplodeVolumesLines() { m_nameVS = "ShaderExplodeVolumesLines_vs"; m_nameFS = "ShaderExplodeVolumesLines_fs"; m_nameGS = "ShaderExplodeVolumesLines_gs"; std::string glxvert(*GLSLShader::DEFINES_GL); glxvert.append(vertexShaderText); std::string glxgeom(GLSLShader::defines_Geom("triangles", "line_strip", 4)); glxgeom.append(geometryShaderText); std::string glxfrag(*GLSLShader::DEFINES_GL); glxfrag.append(fragmentShaderText); loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str(), glxgeom.c_str(), GL_TRIANGLES , GL_LINE_STRIP,4); getLocations(); //Default values m_explodeV = 0.9f; m_color = Geom::Vec4f(0.05f, 0.05f, 0.05f, 0.0f); m_plane = Geom::Vec4f(0.0f, 0.0f, 1000.f, 1000000000000000000000000000.0f); setParams(m_explodeV, m_color, m_plane); }
ShaderSimpleDepth::ShaderSimpleDepth(bool doubleSided): m_with_color(false), m_ambiant(Geom::Vec4f(0.05f,0.05f,0.1f,0.0f)), m_diffuse(Geom::Vec4f(0.1f,1.0f,0.1f,0.0f)), m_lightPos(Geom::Vec3f(10.0f,10.0f,1000.0f)), m_vboPos(NULL), m_vboColor(NULL) { m_nameVS = "ShaderSimpleDepth_vs"; m_nameFS = "ShaderSimpleDepth_fs"; // m_nameGS = "ShaderSimpleDepth_gs"; // get choose GL defines (2 or 3) // ans compile shaders std::string glxvert(*GLSLShader::DEFINES_GL); glxvert.append(vertexShaderText); std::string glxfrag(*GLSLShader::DEFINES_GL); if (doubleSided) glxfrag.append("#define DOUBLE_SIDED\n"); glxfrag.append(fragmentShaderText); loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str()); // and get and fill uniforms getLocations(); sendParams(); }
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(); }
ShaderSimpleTexture::ShaderSimpleTexture() { std::string glxvert(GLSLShader::defines_gl()); glxvert.append(vertexShaderText); std::string glxfrag(GLSLShader::defines_gl()); glxfrag.append(fragmentShaderText); loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str()); m_unif_unit = glGetUniformLocation(this->program_handler(), "textureUnit"); }
ShaderTextureBlurH::ShaderTextureBlurH() { std::string glxvert(*GLSLShader::DEFINES_GL); glxvert.append(vertexShaderText); std::string glxfrag(*GLSLShader::DEFINES_GL); glxfrag.append(fragmentShaderText); loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str()); m_unifTexUnit = glGetUniformLocation(this->program_handler(), "textureUnit"); m_unifBlurSize = glGetUniformLocation(this->program_handler(), "blurSize"); }
ShaderPhong::ShaderPhong(bool withClipping, bool withEyePosition) : m_with_color(false), m_with_eyepos(withEyePosition), m_doubleSided(1), m_ambiant(Geom::Vec4f(0.05f,0.05f,0.1f,0.0f)), m_diffuse(Geom::Vec4f(0.1f,1.0f,0.1f,0.0f)), m_specular(Geom::Vec4f(1.0f,1.0f,1.0f,0.0f)), m_shininess(100.0f), m_lightPos(Geom::Vec3f(10.0f,10.0f,1000.0f)), m_backColor(0.0f,0.0f,0.0f,0.0f), m_vboPos(NULL), m_vboNormal(NULL), m_vboColor(NULL), m_planeClip(Geom::Vec4f(0.0f,0.0f,0.0f,0.0f)) { std::string glxvert(GLSLShader::defines_gl()); std::string glxfrag(GLSLShader::defines_gl()); if (withClipping) { m_nameVS = "ShaderPhongClip_vs"; m_nameFS = "ShaderPhongClip_fs"; if (m_with_eyepos) glxvert.append("#define WITH_EYEPOSITION"); glxvert.append(vertexShaderClipText); // Use double sided lighting if set //if (doubleSided) // glxfrag.append("#define DOUBLE_SIDED\n"); glxfrag.append(fragmentShaderClipText); } else { m_nameVS = "ShaderPhong_vs"; m_nameFS = "ShaderPhong_fs"; if (m_with_eyepos) glxvert.append("#define WITH_EYEPOSITION"); glxvert.append(vertexShaderText); // Use double sided lighting if set //if (doubleSided) // glxfrag.append("#define DOUBLE_SIDED\n"); glxfrag.append(fragmentShaderText); } loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str()); // and get and fill uniforms getLocations(); sendParams(); }
ShaderScalarField::ShaderScalarField() : m_minValue(0.0f), m_maxValue(0.0f), m_expansion(0) { std::string glxvert(*GLSLShader::DEFINES_GL); glxvert.append(vertexShaderText); std::string glxfrag(*GLSLShader::DEFINES_GL); glxfrag.append(fragmentShaderText); loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str()); // get and fill uniforms getLocations(); sendParams(); }
ShaderTextureDepth::ShaderTextureDepth() { m_nameVS = "ShaderTextureDepth_vs"; m_nameFS = "ShaderTextureDepth_fs"; std::string glxvert(GLSLShader::defines_gl()); glxvert.append(vertexShaderText); std::string glxfrag(GLSLShader::defines_gl()); std::stringstream ss; glxfrag.append(fragmentShaderText); loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str()); m_unif_unit = glGetUniformLocation(this->program_handler(), "textureUnit"); m_unif_depthUnit = glGetUniformLocation(this->program_handler(), "textureDepthUnit"); }
ShaderExplodeVolumesAlpha::ShaderExplodeVolumesAlpha(bool withColorPerFace): m_wcpf(withColorPerFace) { m_nameVS = "ShaderExplodeVolumes_vs"; m_nameFS = "ShaderExplodeVolumes_fs"; m_nameGS = "ShaderExplodeVolumes_gs"; std::string glxvert(*GLSLShader::DEFINES_GL); glxvert.append(vertexShaderText); std::string glxgeom; glxgeom.append(GLSLShader::defines_Geom("lines_witw_adjacency", "triangle_strip", 3)); if (withColorPerFace) glxgeom.append("#define WITH_COLORPF 1\n"); glxgeom.append(geometryShaderText); std::string glxfrag(*GLSLShader::DEFINES_GL); glxfrag.append(fragmentShaderText); loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str(), glxgeom.c_str(), GL_LINES_ADJACENCY_EXT , GL_TRIANGLE_STRIP,4); getLocations(); //Default values m_ambient = Geom::Vec4f(0.05f, 0.05f, 0.1f, 0.0f); m_backColor = Geom::Vec4f(1.0f, 0.1f, 0.1f, 0.0f); m_light_pos = Geom::Vec3f(10.0f, 10.0f, 1000.0f); m_plane = Geom::Vec4f(0.0f, 0.0f, 1000.f, 1000000000000000000000000000.0f); m_depthPeeling = 0; setAmbient(m_ambient); setBackColor(m_backColor); setLightPosition(m_light_pos); setClippingPlane(m_plane); setDepthPeeling(m_depthPeeling); }
ShaderExplodeSmoothVolumes::ShaderExplodeSmoothVolumes(bool withColorPerFace, bool withExplodeFace): m_wcpf(withColorPerFace), m_wef(withExplodeFace) { m_nameVS = "ShaderExplodeSmoothVolumes_vs"; m_nameFS = "ShaderExplodeSmoothVolumes_fs"; m_nameGS = "ShaderExplodeSmoothVolumes_gs"; std::string glxvert(GLSLShader::defines_gl()); glxvert.append(vertexShaderText); std::string glxgeom; glxgeom.append(GLSLShader::defines_Geom("lines_adjacency", "triangle_strip", 3)); if (withColorPerFace) glxgeom.append("#define WITH_COLORPF 1\n"); if (withExplodeFace) glxgeom.append("#define WITH_EXPLODE_FACE 1\n"); glxgeom.append(geometryShaderText); std::string glxfrag(GLSLShader::defines_gl()); glxfrag.append(fragmentShaderText); loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str(), glxgeom.c_str(), GL_LINES_ADJACENCY_EXT , GL_TRIANGLE_STRIP,4); getLocations(); //Default values m_explodeV = 0.9f; m_explodeF = 0.9f; m_ambiant = Geom::Vec4f(0.05f, 0.05f, 0.1f, 0.0f); m_light_pos = Geom::Vec3f(10.0f, 10.0f, 1000.0f); m_plane = Geom::Vec4f(0.0f, 0.0f, 1000.f, 1000000000000000000000000000.0f); setParams(m_explodeV, m_explodeF, m_ambiant, m_light_pos, m_plane); }
ShaderSimpleFlat::ShaderSimpleFlat(bool withClipping, bool doubleSided): m_with_color(false), m_doubleSided(doubleSided), m_ambiant(Geom::Vec4f(0.05f,0.05f,0.1f,0.0f)), m_diffuse(Geom::Vec4f(0.1f,1.0f,0.1f,0.0f)), m_lightPos(Geom::Vec3f(10.0f,10.0f,1000.0f)), m_backColor(0.0f,0.0f,0.0f,0.0f), m_vboPos(NULL), m_vboColor(NULL), m_planeClip(Geom::Vec4f(0.0f,0.0f,0.0f,0.0f)) { std::string glxvert(GLSLShader::defines_gl()); std::string glxfrag(GLSLShader::defines_gl()); if (withClipping) { m_nameVS = "ShaderSimpleFlatClip_vs"; m_nameFS = "ShaderSimpleFlatClip_fs"; glxvert.append(vertexShaderClipText); glxfrag.append(fragmentShaderClipText); } else { m_nameVS = "ShaderSimpleFlat_vs"; m_nameFS = "ShaderSimpleFlat_fs"; // get choose GL defines (2 or 3) // ans compile shaders glxvert.append(vertexShaderText); glxfrag.append(fragmentShaderText); } loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str()); // and get and fill uniforms getLocations(); sendParams(); }
ShaderSimpleColor::ShaderSimpleColor(bool black_is_transparent) { m_nameVS = "ShaderSimpleColor_vs"; m_nameFS = "ShaderSimpleColor_fs"; m_nameGS = "ShaderSimpleColor_gs"; // chose GL defines (2 or 3) // and compile shaders std::string glxvert(*GLSLShader::DEFINES_GL); glxvert.append(vertexShaderText); std::string glxfrag(*GLSLShader::DEFINES_GL); if (black_is_transparent) glxfrag.append("#define BLACK_TRANSPARENCY 1\n"); glxfrag.append(fragmentShaderText); loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str()); *m_unif_color = glGetUniformLocation(this->program_handler(),"color"); //Default values Geom::Vec4f color(0.1f, 0.9f, 0.1f, 0.0f); setColor(color); }
ShaderColorDarts::ShaderColorDarts() : m_lineWidth(0.01f), m_opacity(1.0f), m_planeClip(0.0f,0.0f,0.0f,0.0f) { m_nameVS = "ShaderColorDarts_vs"; m_nameFS = "ShaderColorDarts_fs"; m_nameGS = "ShaderColorDarts_gs"; std::string glxvert(GLSLShader::defines_gl()); glxvert.append(vertexShaderText); std::string glxgeom = GLSLShader::defines_Geom("lines", "triangle_strip", 8); glxgeom.append(geometryShaderText); std::string glxfrag(GLSLShader::defines_gl()); glxfrag.append(fragmentShaderText); loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str(), glxgeom.c_str(), GL_LINES, GL_TRIANGLE_STRIP,8); // get and fill uniforms getLocations(); sendParams(); }