Commit 0249c626 authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'develop' of icube-forge.unistra.fr:thery/cgogn into develop

parents b0d91d17 14ee963c
...@@ -6,5 +6,5 @@ uniform vec4 color; ...@@ -6,5 +6,5 @@ uniform vec4 color;
FRAG_OUT_DEF; FRAG_OUT_DEF;
void main (void) void main (void)
{ {
float lum = TEXTURE2D(FontTexture, tex_coord).s;; float lum = TEXTURE2D(FontTexture, tex_coord).s;
// no } because it is added in the shader class code (with other things) // no } because it is added in the shader class code (with other things)
...@@ -62,9 +62,12 @@ Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc, bool with_plan ...@@ -62,9 +62,12 @@ Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc, bool with_plan
glGenTextures(1, &(*m_idTexture)); glGenTextures(1, &(*m_idTexture));
glBindTexture(GL_TEXTURE_2D, *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)); glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, WIDTHTEXTURE, HEIGHTTEXTURE, 0, GL_RED, GL_UNSIGNED_BYTE, (GLvoid*)(buff));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
delete[] buff; delete[] buff;
} }
else else
...@@ -88,12 +91,13 @@ Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc, bool with_plan ...@@ -88,12 +91,13 @@ Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc, bool with_plan
else else
{ {
std::stringstream ss; std::stringstream ss;
ss << "vec4 backColor = vec4(" <<bgc[0] << "," << bgc[1] << "," << bgc[2] << ",color[3]);\n"; ss << " vec4 backColor = vec4(" <<bgc[0] << "," << bgc[1] << "," << bgc[2] << ",color[3]);\n";
// ss << "vec4 backColor = vec4(0.2,0.1,0.4);\n";
glxfrag.append(ss.str()); glxfrag.append(ss.str());
glxfrag.append(fragmentShaderText3); glxfrag.append(fragmentShaderText3);
} }
std::cout << glxfrag << std::endl;
loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str()); loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str());
m_vbo1 = new Utils::VBO(); m_vbo1 = new Utils::VBO();
...@@ -178,6 +182,7 @@ unsigned int Strings3D::sendOneStringToVBO(const std::string& str, float **buffe ...@@ -178,6 +182,7 @@ unsigned int Strings3D::sendOneStringToVBO(const std::string& str, float **buffe
float u2 = u + float(REALWIDTHFONT) / float(WIDTHTEXTURE); float u2 = u + float(REALWIDTHFONT) / float(WIDTHTEXTURE);
float v2 = v + float(WIDTHFONT - 1) / float(HEIGHTTEXTURE); float v2 = v + float(WIDTHFONT - 1) / float(HEIGHTTEXTURE);
// 0
*buffer++ = x; *buffer++ = x;
*buffer++ = 0; *buffer++ = 0;
*buffer++ = u; *buffer++ = u;
...@@ -185,16 +190,31 @@ unsigned int Strings3D::sendOneStringToVBO(const std::string& str, float **buffe ...@@ -185,16 +190,31 @@ unsigned int Strings3D::sendOneStringToVBO(const std::string& str, float **buffe
float xf = x + float(REALWIDTHFONT) / 25.f; float xf = x + float(REALWIDTHFONT) / 25.f;
// 1
*buffer++ = xf; *buffer++ = xf;
*buffer++ = 0; *buffer++ = 0;
*buffer++ = u2; *buffer++ = u2;
*buffer++ = v2; *buffer++ = v2;
// 2
*buffer++ = xf;
*buffer++ = float(WIDTHFONT) / 25.f;
*buffer++ = u2;
*buffer++ = v;
// 0
*buffer++ = x;
*buffer++ = 0;
*buffer++ = u;
*buffer++ = v2;
// 2
*buffer++ = xf; *buffer++ = xf;
*buffer++ = float(WIDTHFONT) / 25.f; *buffer++ = float(WIDTHFONT) / 25.f;
*buffer++ = u2; *buffer++ = u2;
*buffer++ = v; *buffer++ = v;
// 3
*buffer++ = x; *buffer++ = x;
*buffer++ = float(WIDTHFONT) / 25.f; *buffer++ = float(WIDTHFONT) / 25.f;
*buffer++ = u; *buffer++ = u;
...@@ -205,7 +225,7 @@ unsigned int Strings3D::sendOneStringToVBO(const std::string& str, float **buffe ...@@ -205,7 +225,7 @@ unsigned int Strings3D::sendOneStringToVBO(const std::string& str, float **buffe
*buffervbo = buffer; *buffervbo = buffer;
return 4 * nbc; return 6 * nbc;
} }
void Strings3D::sendToVBO() void Strings3D::sendToVBO()
...@@ -214,7 +234,7 @@ void Strings3D::sendToVBO() ...@@ -214,7 +234,7 @@ void Strings3D::sendToVBO()
// alloc buffer // alloc buffer
m_vbo1->bind(); m_vbo1->bind();
glBufferData(GL_ARRAY_BUFFER, m_nbChars * 16 * sizeof(float), 0, GL_STREAM_DRAW); glBufferData(GL_ARRAY_BUFFER, m_nbChars * 24 * sizeof(float), 0, GL_STREAM_DRAW);
float* buffer = reinterpret_cast<float*>(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE)); float* buffer = reinterpret_cast<float*>(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE));
// fill buffer // fill buffer
...@@ -269,7 +289,7 @@ void Strings3D::postdraw() ...@@ -269,7 +289,7 @@ void Strings3D::postdraw()
void Strings3D::draw(unsigned int idSt, const Geom::Vec3f& pos) void Strings3D::draw(unsigned int idSt, const Geom::Vec3f& pos)
{ {
glUniform3fv(*m_uniform_position, 1, pos.data()); glUniform3fv(*m_uniform_position, 1, pos.data());
glDrawArrays(GL_QUADS, m_strpos[idSt].first , m_strpos[idSt].second ); glDrawArrays(GL_TRIANGLES, m_strpos[idSt].first , m_strpos[idSt].second );
} }
void Strings3D::drawAll(const Geom::Vec4f& color) void Strings3D::drawAll(const Geom::Vec4f& color)
...@@ -290,7 +310,7 @@ void Strings3D::drawAll(const Geom::Vec4f& color) ...@@ -290,7 +310,7 @@ void Strings3D::drawAll(const Geom::Vec4f& color)
for (unsigned int idSt=0; idSt<nb; ++idSt) for (unsigned int idSt=0; idSt<nb; ++idSt)
{ {
glUniform3fv(*m_uniform_position, 1, m_strTranslate[idSt].data()); glUniform3fv(*m_uniform_position, 1, m_strTranslate[idSt].data());
glDrawArrays(GL_QUADS, m_strpos[idSt].first , m_strpos[idSt].second ); glDrawArrays(GL_TRIANGLES, m_strpos[idSt].first , m_strpos[idSt].second );
} }
postdraw(); postdraw();
} }
...@@ -316,23 +336,38 @@ void Strings3D::updateString(unsigned int idSt, const std::string& str) ...@@ -316,23 +336,38 @@ void Strings3D::updateString(unsigned int idSt, const std::string& str)
float u2 = u + float(REALWIDTHFONT) / float(WIDTHTEXTURE); float u2 = u + float(REALWIDTHFONT) / float(WIDTHTEXTURE);
float v2 = v + float(WIDTHFONT - 1) / float(HEIGHTTEXTURE); float v2 = v + float(WIDTHFONT - 1) / float(HEIGHTTEXTURE);
// 0
*buffer++ = x; *buffer++ = x;
*buffer++ = 0; *buffer++ = 0;
*buffer++ = u; *buffer++ = u;
*buffer++ = v2; *buffer++ = v2;
float xf = x + float(REALWIDTHFONT) / 25.f; float xf = x + float(REALWIDTHFONT) / 25.f;
// 1
*buffer++ = xf; *buffer++ = xf;
*buffer++ = 0; *buffer++ = 0;
*buffer++ = u2; *buffer++ = u2;
*buffer++ = v2; *buffer++ = v2;
// 2
*buffer++ = xf;
*buffer++ = float(WIDTHFONT) / 25.f;
*buffer++ = u2;
*buffer++ = v;
// 0
*buffer++ = x;
*buffer++ = 0;
*buffer++ = u;
*buffer++ = v2;
// 2
*buffer++ = xf; *buffer++ = xf;
*buffer++ = float(WIDTHFONT) / 25.f; *buffer++ = float(WIDTHFONT) / 25.f;
*buffer++ = u2; *buffer++ = u2;
*buffer++ = v; *buffer++ = v;
// 3
*buffer++ = x; *buffer++ = x;
*buffer++ = float(WIDTHFONT) / 25.f; *buffer++ = float(WIDTHFONT) / 25.f;
*buffer++ = u; *buffer++ = u;
......
...@@ -86,7 +86,7 @@ void TextureSticker::fullScreenTexture(CGoGNGLuint texId) ...@@ -86,7 +86,7 @@ void TextureSticker::fullScreenTexture(CGoGNGLuint texId)
// Draw quad // Draw quad
sm_textureMappingShader->enableVertexAttribs(); sm_textureMappingShader->enableVertexAttribs();
glDrawArrays(GL_QUADS, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
sm_textureMappingShader->disableVertexAttribs(); sm_textureMappingShader->disableVertexAttribs();
// Unbind texture mapping shader // Unbind texture mapping shader
...@@ -134,7 +134,7 @@ void TextureSticker::fullScreenTextureDepth(CGoGNGLuint texId, CGoGNGLuint dtexI ...@@ -134,7 +134,7 @@ void TextureSticker::fullScreenTextureDepth(CGoGNGLuint texId, CGoGNGLuint dtexI
// Draw quad // Draw quad
sm_depthtextureMappingShader->enableVertexAttribs(); sm_depthtextureMappingShader->enableVertexAttribs();
glDrawArrays(GL_QUADS, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
sm_depthtextureMappingShader->disableVertexAttribs(); sm_depthtextureMappingShader->disableVertexAttribs();
// Unbind texture mapping shader // Unbind texture mapping shader
...@@ -175,7 +175,7 @@ void TextureSticker::fullScreenShader(Utils::GLSLShader* shader) ...@@ -175,7 +175,7 @@ void TextureSticker::fullScreenShader(Utils::GLSLShader* shader)
// Draw quad // Draw quad
shader->enableVertexAttribs(); shader->enableVertexAttribs();
glDrawArrays(GL_QUADS, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
shader->disableVertexAttribs(); shader->disableVertexAttribs();
// Unbind shader // Unbind shader
......
...@@ -78,7 +78,10 @@ Dependencies ...@@ -78,7 +78,10 @@ Dependencies
------------ ------------
* install (or compile) Qt (choose 32/64 bits) * install (or compile) Qt (choose 32/64 bits)
* install python 2.7 (choose 32/64 bits) (Needed for SCHNApps) * install python 2.7 (choose 32/64 bits) (Needed for SCHNApps)
* Other Windows dependencies are furnished at http://cgogn.unistra.fr/Dependencies/ * Other Windows dependencies are furnished at:
- http://cgogn.unistra.fr/Dependencies/dependencies.txt
- http://cgogn.unistra.fr/Dependencies/windows_dependencies32.zip
- http://cgogn.unistra.fr/Dependencies/windows_dependencies64.zip
**Supported compilers: Visual C++ 2013 (12.0) or greater** **Supported compilers: Visual C++ 2013 (12.0) or greater**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment