From 14ee963cbcc475fa6541e943095fb2c524be1a36 Mon Sep 17 00:00:00 2001 From: Sylvain Thery Date: Tue, 24 Nov 2015 16:58:47 +0100 Subject: [PATCH] OGL3 texture bug correction --- Apps/Tuto/tuto5.cpp | 6 ++-- CGoGN/include/Utils/text3d.frag | 2 +- CGoGN/src/Utils/text3d.cpp | 51 +++++++++++++++++++++++++----- CGoGN/src/Utils/textureSticker.cpp | 6 ++-- README.md | 5 ++- 5 files changed, 54 insertions(+), 16 deletions(-) diff --git a/Apps/Tuto/tuto5.cpp b/Apps/Tuto/tuto5.cpp index d2af7351a..8043ede7e 100644 --- a/Apps/Tuto/tuto5.cpp +++ b/Apps/Tuto/tuto5.cpp @@ -130,9 +130,9 @@ void MyQT::cb_initGL() m_sprite->setAttributePosition(m_positionVBO); m_sprite->setColor(Geom::Vec4f(1.0f, 0.0f , 0.0f, 1.0f)); - m_strings = new Utils::Strings3D(true, Geom::Vec3f(0.1f,0.0f,0.3f)); - storeVerticesInfo(); - m_strings->sendToVBO(); + m_strings = new Utils::Strings3D(true, Geom::Vec3f(0.1f,0.0f,0.3f)); + storeVerticesInfo(); + m_strings->sendToVBO(); // copy de contenu de VBO a la creation m_dataVBO = new Utils::VBO(*m_positionVBO); diff --git a/CGoGN/include/Utils/text3d.frag b/CGoGN/include/Utils/text3d.frag index 72e86309b..8684df32d 100644 --- a/CGoGN/include/Utils/text3d.frag +++ b/CGoGN/include/Utils/text3d.frag @@ -6,5 +6,5 @@ uniform vec4 color; FRAG_OUT_DEF; 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) diff --git a/CGoGN/src/Utils/text3d.cpp b/CGoGN/src/Utils/text3d.cpp index 46c174f66..617034a8d 100644 --- a/CGoGN/src/Utils/text3d.cpp +++ b/CGoGN/src/Utils/text3d.cpp @@ -62,9 +62,12 @@ Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc, bool with_plan 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)); + 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_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; } else @@ -88,12 +91,13 @@ Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc, bool with_plan else { std::stringstream ss; - ss << "vec4 backColor = vec4(" <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(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE)); // fill buffer @@ -269,7 +289,7 @@ void Strings3D::postdraw() void Strings3D::draw(unsigned int idSt, const Geom::Vec3f& pos) { 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) @@ -290,7 +310,7 @@ void Strings3D::drawAll(const Geom::Vec4f& color) for (unsigned int idSt=0; idStenableVertexAttribs(); - glDrawArrays(GL_QUADS, 0, 4); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); sm_textureMappingShader->disableVertexAttribs(); // Unbind texture mapping shader @@ -134,7 +134,7 @@ void TextureSticker::fullScreenTextureDepth(CGoGNGLuint texId, CGoGNGLuint dtexI // Draw quad sm_depthtextureMappingShader->enableVertexAttribs(); - glDrawArrays(GL_QUADS, 0, 4); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); sm_depthtextureMappingShader->disableVertexAttribs(); // Unbind texture mapping shader @@ -175,7 +175,7 @@ void TextureSticker::fullScreenShader(Utils::GLSLShader* shader) // Draw quad shader->enableVertexAttribs(); - glDrawArrays(GL_QUADS, 0, 4); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); shader->disableVertexAttribs(); // Unbind shader diff --git a/README.md b/README.md index b6090eb1a..40001e1a2 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,10 @@ Dependencies ------------ * install (or compile) Qt (choose 32/64 bits) * 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** -- GitLab