From 379f73b6ca6d0a8c7a14debc23722c1794e92766 Mon Sep 17 00:00:00 2001 From: Bruno Herbelin Date: Tue, 29 Aug 2023 14:40:09 +0200 Subject: [PATCH] OSX opengl pedantic update there was a strange warning " POSSIBLE ISSUE: unit 0 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable", related to the first use of the opengl texture. Initializing the white texture seems to fix the problem. --- src/RenderingManager.cpp | 3 ++- src/Scene.cpp | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/RenderingManager.cpp b/src/RenderingManager.cpp index 65e1851..15512ca 100644 --- a/src/RenderingManager.cpp +++ b/src/RenderingManager.cpp @@ -37,7 +37,7 @@ #define GLFW_EXPOSE_NATIVE_X11 #define GLFW_EXPOSE_NATIVE_GLX #endif -#include +//#include #include // glm::translate, glm::rotate, glm::scale #include // glm::perspective @@ -1023,6 +1023,7 @@ bool RenderingWindow::init(int index, GLFWwindow *share) // // default render black // + (void) Resource::getTextureWhite(); // init white texture too textureid_ = Resource::getTextureBlack(); return true; diff --git a/src/Scene.cpp b/src/Scene.cpp index 17b3138..caeff90 100644 --- a/src/Scene.cpp +++ b/src/Scene.cpp @@ -137,9 +137,9 @@ void Primitive::init() glBindVertexArray( vao_ ); // compute the memory needs for points - std::size_t sizeofPoints = sizeof(glm::vec3) * points_.size(); - std::size_t sizeofColors = sizeof(glm::vec4) * colors_.size(); - std::size_t sizeofTexCoords = sizeof(glm::vec2) * texCoords_.size(); + std::size_t sizeofPoints = sizeof(glm::fvec3) * points_.size(); + std::size_t sizeofColors = sizeof(glm::fvec4) * colors_.size(); + std::size_t sizeofTexCoords = sizeof(glm::fvec2) * texCoords_.size(); // setup the array buffers for vertices glBindBuffer( GL_ARRAY_BUFFER, arrayBuffer_ ); @@ -151,16 +151,16 @@ void Primitive::init() // setup the element array for the triangle indices glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer_); - std::size_t sizeofIndices = indices_.size() * sizeof(uint); + std::size_t sizeofIndices = indices_.size() * sizeof(GLuint); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeofIndices, &(indices_[0]), GL_STATIC_DRAW); // explain how to read attributes 0, 1 and 2 (for point, color and textcoord respectively) - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(glm::vec3), (void *)0 ); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(glm::fvec3), (void *)0 ); glEnableVertexAttribArray(0); - glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(glm::vec4), (void *)(sizeofPoints) ); + glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(glm::fvec4), (void *)(sizeofPoints) ); glEnableVertexAttribArray(1); if ( sizeofTexCoords ) { - glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(glm::vec2), (void *)(sizeofPoints + sizeofColors) ); + glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(glm::fvec2), (void *)(sizeofPoints + sizeofColors) ); glEnableVertexAttribArray(2); }