diff --git a/include/ngl/NGLMessage.h b/include/ngl/NGLMessage.h index 6cd37954..b7301f35 100644 --- a/include/ngl/NGLMessage.h +++ b/include/ngl/NGLMessage.h @@ -75,8 +75,8 @@ class NGLMessage static std::future< void > s_futureExit; void consume(const Message &_message); void setTimeFormat(TimeFormat _f); - std::string getTimeString(const TimeFormat &_t) const; - std::string getColourString(const Colours &_colour) const; + static std::string getTimeString(const TimeFormat &_t) ; + static std::string getColourString(const Colours &_colour) ; std::string m_timeString = "%I:%M%p"; static Colours s_currentColour; static std::ofstream s_logFile; diff --git a/include/ngl/Obj.h b/include/ngl/Obj.h index 23c3bb55..8f14acfc 100644 --- a/include/ngl/Obj.h +++ b/include/ngl/Obj.h @@ -84,7 +84,7 @@ class NGL_DLLEXPORT Obj : public AbstractMesh virtual bool parseVertex(std::vector< std::string > &_tokens) noexcept; virtual bool parseNormal(std::vector< std::string > &_tokens) noexcept; virtual bool parseUV(std::vector< std::string > &_tokens) noexcept; - std::istream &safeGetline(std::istream &is, std::string &t); + static std::istream &safeGetline(std::istream &is, std::string &t); // face parsing is complex we have different layouts. // don't forget we can also have negative indices diff --git a/include/ngl/Quaternion.h b/include/ngl/Quaternion.h index d86d8a51..cc7b7b88 100644 --- a/include/ngl/Quaternion.h +++ b/include/ngl/Quaternion.h @@ -288,7 +288,7 @@ class NGL_DLLEXPORT Quaternion /// @brief[in] _r the rotation Quat /// @brief[inout] io_p the point to be rotated (result we be set in this point) - void rotatePoint(const Quaternion& _r,Vec3 & io_p) const noexcept; + static void rotatePoint(const Quaternion& _r,Vec3 & io_p) noexcept; /// @brief return the axis and angle of the current quat (angle in degrees) /// @brief[out] o_axis the axis of rotation ( diff --git a/include/ngl/ShaderLib.h b/include/ngl/ShaderLib.h index e25045e2..85284446 100644 --- a/include/ngl/ShaderLib.h +++ b/include/ngl/ShaderLib.h @@ -310,10 +310,6 @@ class NGL_DLLEXPORT ShaderLib /// @brief flag to indicate the debug state //---------------------------------------------------------------------------------------------------------------------- static bool m_debugState; - //---------------------------------------------------------------------------------------------------------------------- - /// @brief the number of shaders loaded - //---------------------------------------------------------------------------------------------------------------------- - static unsigned int m_numShaders; static bool m_defaultShadersLoaded; //---------------------------------------------------------------------------------------------------------------------- diff --git a/include/ngl/ShaderProgram.h b/include/ngl/ShaderProgram.h index 2f5378e9..3985bcca 100644 --- a/include/ngl/ShaderProgram.h +++ b/include/ngl/ShaderProgram.h @@ -151,7 +151,7 @@ class NGL_DLLEXPORT ShaderProgram /// @param [in] _colourNumber The color number to bind the user-defined varying out variable to /// @param [in] _name the name of the output variable to bind //---------------------------------------------------------------------------------------------------------------------- - void bindFragDataLocation(GLuint _colourNumber, const char *_name) noexcept; + void bindFragDataLocation(GLuint _colourNumber, const char *_name) const noexcept; //---------------------------------------------------------------------------------------------------------------------- /// @brief get the index of a uniform bloc /// @param[in] _uniformBlockName the name of the uniform block to get the id for diff --git a/src/AbstractMesh.cpp b/src/AbstractMesh.cpp index e54bd537..346ec569 100644 --- a/src/AbstractMesh.cpp +++ b/src/AbstractMesh.cpp @@ -52,7 +52,7 @@ void AbstractMesh::scale(Real _sx, Real _sy, Real _sz) noexcept AbstractMesh::~AbstractMesh() noexcept { - if(m_loaded == true) + if(m_loaded) { m_verts.erase(m_verts.begin(), m_verts.end()); m_norm.erase(m_norm.begin(), m_norm.end()); @@ -93,14 +93,14 @@ return std::all_of(std::begin(m_face),std::end(m_face),[](auto f){ // clang doesn't have a problem tho struct VertData { - GLfloat x; // position from obj - GLfloat y; - GLfloat z; - GLfloat nx; // normal from obj mesh - GLfloat ny; - GLfloat nz; - GLfloat u; // tex cords - GLfloat v; // tex cords + GLfloat x=0.0f; // position from obj + GLfloat y=0.0f; + GLfloat z=0.0f; + GLfloat nx=0.0f; // normal from obj mesh + GLfloat ny=0.0f; + GLfloat nz=0.0f; + GLfloat u=0.0f; // tex cords + GLfloat v=0.0f; // tex cords }; void AbstractMesh::createVAO(ResetVAO _reset) noexcept @@ -108,7 +108,7 @@ void AbstractMesh::createVAO(ResetVAO _reset) noexcept if(_reset == AbstractMesh::ResetVAO::False) { // if we have already created a VBO just return. - if(m_vao == true) + if(m_vao) { NGLMessage::addWarning("VAO exist so returning"); return; @@ -116,7 +116,7 @@ void AbstractMesh::createVAO(ResetVAO _reset) noexcept } else // need to delete VAO if existing amd reset { - if(m_vao == true) + if(m_vao) { NGLMessage::addWarning("Creating new VAO"); } @@ -134,7 +134,7 @@ void AbstractMesh::createVAO(ResetVAO _reset) noexcept exit(EXIT_FAILURE); } - // now we are going to process and pack the mesh into an ngl::VertexArrayObject + // now we are going to process and pack the mesh into a ngl::VertexArrayObject std::vector< VertData > vboMesh; VertData d; @@ -204,7 +204,7 @@ void AbstractMesh::createVAO(ResetVAO _reset) noexcept // x,y,z,nx,ny,nz,u,v // If you look at the shader we have the following attributes being used // attribute vec3 inVert; attribute 0 - // attribute vec3 inNormal; attribure 1 + // attribute vec3 inNormal; attribute 1 // attribute vec2 inUV; attribute 2 // so we need to set the vertexAttributePointer so the correct size and type as follows m_vaoMesh->setVertexAttributePointer(0, 3, GL_FLOAT, sizeof(VertData), 0); @@ -224,7 +224,8 @@ void AbstractMesh::createVAO(ResetVAO _reset) noexcept m_vao = true; m_vbo = true; // create a new bbox based on the new object size - m_ext.reset(new BBox(m_minX, m_maxX, m_minY, m_maxY, m_minZ, m_maxZ)); + m_ext=std::make_unique(m_minX, m_maxX, m_minY, m_maxY, m_minZ, m_maxZ); + } std::unique_ptr< AbstractVAO > AbstractMesh::moveVAO() noexcept @@ -246,9 +247,9 @@ void AbstractMesh::unbindVAO() const noexcept void AbstractMesh::draw() const noexcept { - if(m_vao == true) + if(m_vao) { - if(m_texture == true) + if(m_texture) { glBindTexture(GL_TEXTURE_2D, m_textureID); } @@ -262,11 +263,11 @@ void AbstractMesh::draw() const noexcept Real *AbstractMesh::mapVAOVerts() noexcept { - Real *ptr = nullptr; + // bind our VBO data m_vaoMesh->bind(); glBindBuffer(GL_ARRAY_BUFFER, m_vaoMesh->getBufferID(0)); - ptr = static_cast< Real * >(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE)); + auto ptr = static_cast< Real * >(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE)); m_vboMapped = true; return ptr; } @@ -274,7 +275,7 @@ Real *AbstractMesh::mapVAOVerts() noexcept void AbstractMesh::unMapVAO() noexcept { - if(m_vboMapped == true) + if(m_vboMapped) { glUnmapBuffer(GL_ARRAY_BUFFER); // unmap it after use m_vboMapped = false; diff --git a/src/AbstractVAO.cpp b/src/AbstractVAO.cpp index f0ff8205..40dd7814 100644 --- a/src/AbstractVAO.cpp +++ b/src/AbstractVAO.cpp @@ -1,5 +1,4 @@ #include "AbstractVAO.h" -#include namespace ngl { AbstractVAO::AbstractVAO(GLenum _mode) : m_mode{_mode} @@ -33,7 +32,7 @@ void AbstractVAO::unbind() void AbstractVAO::setVertexAttributePointer(GLuint _id, GLint _size, GLenum _type, GLsizei _stride, unsigned int _dataOffset, bool _normalise) const noexcept { - if(m_bound != true) + if(!m_bound) { NGLMessage::addWarning("Warning trying to set attribute on Unbound VOA"); } diff --git a/src/BBox.cpp b/src/BBox.cpp index 9b98f1eb..4367f29f 100644 --- a/src/BBox.cpp +++ b/src/BBox.cpp @@ -21,7 +21,6 @@ #include "BBox.h" #include "VAOFactory.h" #include "SimpleIndexVAO.h" -#include namespace ngl { constexpr GLubyte indices[]= { @@ -58,7 +57,7 @@ BBox::BBox( const Vec3& _center, Real _width, Real _height, Real _depth, bool _ m_vert[6].m_x=_center.m_x+(_width/2.0f); m_vert[6].m_y=_center.m_y-(_height/2.0f); m_vert[6].m_z=_center.m_z+(_depth/2.0f); m_vert[7].m_x=_center.m_x-(_width/2.0f); m_vert[7].m_y=_center.m_y-(_height/2.0f); m_vert[7].m_z=_center.m_z+(_depth/2.0f); - // Setup the Plane Normals for Collision Detection + // Set up the Plane Normals for Collision Detection m_norm[0].set(0.0f,1.0f,0.0f); m_norm[1].set(0.0f,-1.0f,0.0f); m_norm[2].set(1.0f,0.0f,0.0f); @@ -168,7 +167,7 @@ void BBox::setDrawMode( GLenum _mode) noexcept void BBox::setVAO() { - if(m_noGL == true) return; + if(m_noGL) return; // if were not doing line drawing then use tris if(m_drawMode !=GL_LINE) { diff --git a/src/BezierCurve.cpp b/src/BezierCurve.cpp index a6bd1a9c..d1668804 100644 --- a/src/BezierCurve.cpp +++ b/src/BezierCurve.cpp @@ -135,7 +135,7 @@ m_vaoCurve->unbind(); Vec3 BezierCurve::getPointOnCurve( Real _value ) const noexcept { Vec3 p; - // sum the effect of all CV's on the curve at this point to + // sum the effect of all CVs on the curve at this point to // get the evaluated curve point // for(unsigned int i=0;i!=m_numCP;++i) diff --git a/src/Image.cpp b/src/Image.cpp index 91f4cfea..cdce69e2 100644 --- a/src/Image.cpp +++ b/src/Image.cpp @@ -120,8 +120,8 @@ Vec4 Image::getColour(const GLuint _x, const GLuint _y) const noexcept Vec4 Image::getColour(const Real _uvX, const Real _uvY) const noexcept { - auto xx = static_cast< GLuint >(static_cast(_uvX) * (m_width - 1)); - auto yy = static_cast< GLuint >(static_cast(_uvY) * (m_height - 1)); + auto xx = static_cast< GLuint >(_uvX * (m_width - 1)); + auto yy = static_cast< GLuint >(_uvY * (m_height - 1)); NGL_ASSERT(xx < m_width && yy < m_height) @@ -150,8 +150,6 @@ bool Image::save(std::string_view _fname,bool _flipY) const noexcept m_channels == 4 ) { ngl::NGLMessage::addWarning("Trying to save RGBA image as jpg which doesn't support it"); - - } #if defined(USEQIMAGE) @@ -170,11 +168,11 @@ bool Image::save(std::string_view _fname,bool _flipY) const noexcept int scanlinesize = m_width * m_channels; // note this flips the image vertically on writing // (see http://www.openimageio.org/openimageio.pdf pg 20 for details) - out->write_image(TypeDesc::UINT8, m_data.get() + (m_height - 1) * scanlinesize, AutoStride, -scanlinesize, AutoStride); + isSaved=out->write_image(TypeDesc::UINT8, m_data.get() + (m_height - 1) * scanlinesize, AutoStride, -scanlinesize, AutoStride); } else { - out->write_image(TypeDesc::UINT8, m_data.get() ); + isSaved=out->write_image(TypeDesc::UINT8, m_data.get() ); } out->close(); #endif diff --git a/src/Mat2.cpp b/src/Mat2.cpp index a3888cd4..47697bb3 100644 --- a/src/Mat2.cpp +++ b/src/Mat2.cpp @@ -16,7 +16,6 @@ */ #include "Mat2.h" -#include "NGLassert.h" #include "Util.h" #include "Vec2.h" #include // for memset diff --git a/src/Mat3.cpp b/src/Mat3.cpp index 8f02f667..e2cec768 100644 --- a/src/Mat3.cpp +++ b/src/Mat3.cpp @@ -17,10 +17,8 @@ #include "Mat3.h" #include "Mat4.h" -#include "NGLassert.h" #include "Quaternion.h" #include "Util.h" -#include "Vec2.h" #include // for memset #include #ifdef USEGLM diff --git a/src/MultiBufferVAO.cpp b/src/MultiBufferVAO.cpp index 23cbd737..e119b491 100644 --- a/src/MultiBufferVAO.cpp +++ b/src/MultiBufferVAO.cpp @@ -11,11 +11,11 @@ namespace ngl void MultiBufferVAO::draw() const { - if(m_allocated == false) + if(!m_allocated) { NGLMessage::addWarning("trying to draw an unallocated VOA"); } - if(m_bound == false) + if(!m_bound) { NGLMessage::addWarning("trying to draw an unbound VOA"); } @@ -24,11 +24,11 @@ namespace ngl void MultiBufferVAO::removeVAO() { - if(m_bound == true) + if(m_bound) { unbind(); } - if( m_allocated ==true) + if(m_allocated) { for(auto b : m_vboIDs) { @@ -40,7 +40,7 @@ namespace ngl } void MultiBufferVAO::setData(const VertexData &_data) { - if(m_bound == false) + if(!m_bound) { NGLMessage::addWarning("trying to set VOA data when unbound"); } @@ -57,7 +57,7 @@ namespace ngl void MultiBufferVAO::setData(size_t _index, const VertexData &_data ) { - if(m_bound == false) + if(!m_bound) { NGLMessage::addWarning("trying to set VOA data when unbound"); } diff --git a/src/NGLInit.cpp b/src/NGLInit.cpp index 431af09d..3c0b6b5d 100644 --- a/src/NGLInit.cpp +++ b/src/NGLInit.cpp @@ -21,10 +21,7 @@ #include "SimpleVAO.h" #include "VAOFactory.h" #include "VAOPrimitives.h" -#include #include -#include -#include #if defined(LINUX) || defined(_WIN32) #include #endif diff --git a/src/NGLMessage.cpp b/src/NGLMessage.cpp index 0829c0df..d71afda1 100644 --- a/src/NGLMessage.cpp +++ b/src/NGLMessage.cpp @@ -93,7 +93,7 @@ void NGLMessage::setTimeFormat(TimeFormat _f) } } -std::string NGLMessage::getTimeString(const TimeFormat &_t) const +std::string NGLMessage::getTimeString(const TimeFormat &_t) { std::string time; switch(_t) @@ -114,7 +114,7 @@ std::string NGLMessage::getTimeString(const TimeFormat &_t) const return time; } -std::string NGLMessage::getColourString(const Colours &_colour) const +std::string NGLMessage::getColourString(const Colours &_colour) { std::string output; switch(_colour) diff --git a/src/NGLStream.cpp b/src/NGLStream.cpp index 46ca4610..98f01664 100644 --- a/src/NGLStream.cpp +++ b/src/NGLStream.cpp @@ -6,8 +6,7 @@ #include "Mat4.h" #include "Quaternion.h" #include -#include -#include + namespace ngl { diff --git a/src/Obj.cpp b/src/Obj.cpp index c60a195b..ae92a8a7 100644 --- a/src/Obj.cpp +++ b/src/Obj.cpp @@ -45,7 +45,7 @@ namespace ps = pystring; Obj::Obj(std::string_view _fname, CalcBB _calcBB) noexcept : AbstractMesh() { - if(load(_fname, _calcBB) == false) + if(!load(_fname, _calcBB) ) { NGLMessage::addError(fmt::format("Error loading file {0} ", _fname.data())); exit(EXIT_FAILURE); @@ -55,7 +55,7 @@ Obj::Obj(std::string_view _fname, CalcBB _calcBB) noexcept Obj::Obj(std::string_view _fname, std::string_view _texName, CalcBB _calcBB) noexcept : AbstractMesh() { - if(load(_fname, _calcBB) == false) + if(!load(_fname, _calcBB)) { NGLMessage::addError(fmt::format("Error loading file {0} ", _fname.data())); exit(EXIT_FAILURE); @@ -119,7 +119,7 @@ void Obj::addFace(const ngl::Face &_f) noexcept bool Obj::save(std::string_view _fname) const noexcept { std::ofstream out(_fname.data()); - if(out.is_open() != true) + if(!out.is_open() ) { NGLMessage::addError(fmt::format(" could not open file {0} for writing ", _fname.data())); return false; @@ -150,7 +150,7 @@ bool Obj::save(std::string_view _fname) const noexcept // we now have V/T/N for each to write out for(unsigned int i = 0; i < f.m_vert.size(); ++i) { - // don't forget that obj indices start from 1 not 0 (i did originally !) + // don't forget that obj indices start from 1 not 0 (I did originally !) out << f.m_vert[i] + 1; if( ! m_uv.empty() ) { @@ -215,7 +215,7 @@ std::istream &Obj::safeGetline(std::istream &is, std::string &t) bool Obj::load(std::string_view _fname, CalcBB _calcBB) noexcept { std::ifstream in(_fname.data()); - if(in.is_open() != true) + if(!in.is_open() ) { NGLMessage::addError(fmt::format(" file {0} not found ", _fname.data())); return false; @@ -228,7 +228,7 @@ bool Obj::load(std::string_view _fname, CalcBB _calcBB) noexcept { bool status = true; // Line contains string of length > 0 then parse it - if(str.size() > 0) + if(!str.empty()) { std::vector< std::string > tokens; ps::split(str, tokens); @@ -251,7 +251,7 @@ bool Obj::load(std::string_view _fname, CalcBB _calcBB) noexcept } } // str.size() // early out sanity checks! - if(status == false) + if(!status ) return false; } // while diff --git a/src/Plane.cpp b/src/Plane.cpp index b7ac7d72..fd30e4db 100644 --- a/src/Plane.cpp +++ b/src/Plane.cpp @@ -54,7 +54,7 @@ void Plane::setFloats(Real _a,Real _b, Real _c, Real _d) noexcept { // set the normal vector m_normal.set(_a,_b,_c); - //compute the lenght of the vector + //compute the length of the vector Real l = m_normal.length(); // normalize the vector m_normal.normalize(); diff --git a/src/Quaternion.cpp b/src/Quaternion.cpp index 5ab464d9..f88cc920 100644 --- a/src/Quaternion.cpp +++ b/src/Quaternion.cpp @@ -287,7 +287,7 @@ void Quaternion::fromEulerAngles(const Real _x,const Real _y,const Real _z) noex m_z=cx*cy*sz - sx*sy*cz; } -void Quaternion::rotatePoint(const Quaternion& _r,Vec3 & io_p) const noexcept +void Quaternion::rotatePoint(const Quaternion& _r,Vec3 & io_p) noexcept { Quaternion temp = -_r; Quaternion point(0.0,io_p.m_x, io_p.m_y, io_p.m_z); diff --git a/src/Random.cpp b/src/Random.cpp index 04999025..fa020eab 100644 --- a/src/Random.cpp +++ b/src/Random.cpp @@ -16,7 +16,6 @@ */ #include "Random.h" -#include // for time #include //---------------------------------------------------------------------------------------------------------------------- diff --git a/src/Shader.cpp b/src/Shader.cpp index 498f05cc..fad5f677 100644 --- a/src/Shader.cpp +++ b/src/Shader.cpp @@ -113,7 +113,7 @@ bool Shader::compile() noexcept GLint compileStatus = 0; glGetShaderiv(m_shaderHandle, GL_COMPILE_STATUS, &compileStatus); m_compiled = static_cast< bool >(compileStatus); - if(m_debugState == true) + if(m_debugState) { NGLMessage::addMessage(fmt::format("Compiling Shader {0}", m_name)); if(compileStatus == GL_FALSE) @@ -134,7 +134,7 @@ bool Shader::editShader(std::string_view _toFind, std::string_view _edit) NGLMessage::addError("No shader source to edit"); return false; } - if(m_edited != true) + if(!m_edited) { m_source = pystring::replace(m_originalSource, _toFind.data(), _edit.data()); m_edited = true; @@ -178,7 +178,7 @@ void Shader::load(std::string_view _name) noexcept glShaderSource(m_shaderHandle, 1, &data, nullptr); m_compiled = false; - if(m_debugState == true) + if(m_debugState) { printInfoLog(m_shaderHandle); } diff --git a/src/ShaderLib.cpp b/src/ShaderLib.cpp index 91fb1930..de6638c6 100644 --- a/src/ShaderLib.cpp +++ b/src/ShaderLib.cpp @@ -43,13 +43,12 @@ std::unordered_map< std::string, std::unique_ptr< Shader > > ShaderLib::m_shader std::string ShaderLib::m_currentShader = "NULL"; bool ShaderLib::m_debugState = true; -unsigned int ShaderLib::m_numShaders = 0; bool ShaderLib::m_defaultShadersLoaded = false; void ShaderLib::loadDefaultShaders() { std::cerr << "calling loadDefaultShaders\n"; - if(m_defaultShadersLoaded == true) + if(m_defaultShadersLoaded) return; else { @@ -166,7 +165,7 @@ GLuint ShaderLib::getShaderID(std::string_view _shaderName) noexcept void ShaderLib::attachShader(std::string_view _name, ShaderType _type, ErrorExit _exitOnError) noexcept { m_shaders[_name.data()] = std::make_unique< Shader >(_name, _type, _exitOnError); - if(m_debugState == true) + if(m_debugState) { NGLMessage::addMessage(fmt::format("just attached {0} to ngl::ShaderLib", _name.data())); } @@ -230,7 +229,7 @@ void ShaderLib::attachShaderToProgram(std::string_view _program, std::string_vie // now increment the shader ref count so we know if how many references shader->second->incrementRefCount(); - if(m_debugState == true) + if(m_debugState) { NGLMessage::addMessage(fmt::format("{0} attached to program", _shader.data())); } @@ -285,7 +284,7 @@ void ShaderLib::setJsonUniform(std::string_view _name, std::string_view _type, s { namespace ps = pystring; - if(m_debugState == true) + if(m_debugState) NGLMessage::addMessage(fmt::format("Setting Uniform {0}", _name)); if(_type == "int") @@ -387,7 +386,7 @@ bool ShaderLib::loadFromJson(std::string_view _fname) noexcept NGLMessage::addError(fmt::format("This does not seem to be a valid shader json file")); return false; } - if(m_debugState == true) + if(m_debugState) { NGLMessage::drawLine(); NGLMessage::addMessage(fmt::format("***************Loading Shaders from JSON*****************")); @@ -518,7 +517,7 @@ bool ShaderLib::linkProgramObject(std::string_view _name) noexcept // make sure we have a valid program if(auto program = m_shaderPrograms.find(_name.data()); program != m_shaderPrograms.end()) { - if(m_debugState == true) + if(m_debugState) { NGLMessage::addMessage(fmt::format("Linking {0}", _name.data())); } diff --git a/src/ShaderProgram.cpp b/src/ShaderProgram.cpp index 30e38bdb..8224f644 100644 --- a/src/ShaderProgram.cpp +++ b/src/ShaderProgram.cpp @@ -20,7 +20,6 @@ //---------------------------------------------------------------------------------------------------------------------- #include "ShaderProgram.h" #include "Mat3.h" -#include "Mat4.h" #include #include #include @@ -52,7 +51,7 @@ GLuint ShaderProgram::getID() const noexcept ShaderProgram::~ShaderProgram() { if(m_programName == "NULL") return; - if(m_debugState == true) + if(m_debugState) std::cerr << fmt::format("removing ShaderProgram {0}\n", m_programName); glDeleteProgram(m_programID); for(auto &block : m_registeredUniformBlocks) @@ -85,7 +84,7 @@ void ShaderProgram::attachShader(Shader *_shader) noexcept //---------------------------------------------------------------------------------------------------------------------- void ShaderProgram::bindAttribute(GLuint _index, std::string_view _attribName) noexcept { - if(m_linked == true) + if(m_linked) { NGLMessage::addMessage(fmt::format("binding attribute {0} after link ", _attribName.data())); } @@ -96,7 +95,7 @@ void ShaderProgram::bindAttribute(GLuint _index, std::string_view _attribName) n void ShaderProgram::bindFragDataLocation(GLuint _index, std::string_view _attribName) noexcept { - if(m_linked == true) + if(m_linked) { NGLMessage::addMessage(fmt::format("binding attribute {0} after link ", _attribName.data())); } @@ -110,7 +109,7 @@ bool ShaderProgram::link() noexcept { m_linked = false; glLinkProgram(m_programID); - if(m_debugState == true) + if(m_debugState) { NGLMessage::addMessage(fmt::format("linking Shader {0} ", m_programName.c_str())); } @@ -129,7 +128,7 @@ bool ShaderProgram::link() noexcept glGetProgramInfoLog(m_programID, infologLength, &charsWritten, infoLog.get()); NGLMessage::addMessage(infoLog.get(), Colours::WHITE, TimeFormat::NONE); - if(m_linked == false) + if(!m_linked) { NGLMessage::addError("Program link failed (will exit if errorExit enabled else return false)"); if(m_errorExit == ErrorExit::ON) @@ -173,13 +172,13 @@ void ShaderProgram::printProperties() const noexcept //---------------------------------------------------------------------------------------------------------------------- void ShaderProgram::printActiveUniforms() const noexcept { - if(m_active != true) + if(!m_active) { NGLMessage::addWarning("calling printActiveUniforms on unbound shader program"); } GLint nUniforms; glGetProgramiv(m_programID, GL_ACTIVE_UNIFORMS, &nUniforms); - std::array name; + std::array name={}; GLsizei l; for(GLint i = 0; i < nUniforms; ++i) { @@ -196,7 +195,7 @@ void ShaderProgram::printActiveAttributes() const noexcept GLint size; GLenum type; GLsizei l; - std::array name; + std::array name={}; for(GLint i = 0; i < nAttribs; ++i) { std::string Type; @@ -270,7 +269,7 @@ void ShaderProgram::disableAttribArray(const char *_name) const noexcept glDisableVertexAttribArray(getUniformLocation(_name)); } -void ShaderProgram::bindFragDataLocation(GLuint _colourNumber, const char *_name) noexcept +void ShaderProgram::bindFragDataLocation(GLuint _colourNumber, const char *_name) const noexcept { glBindFragDataLocation(m_programID, _colourNumber, _name); } @@ -285,9 +284,9 @@ void ShaderProgram::autoRegisterUniformBlocks() noexcept GLint nUniforms; m_registeredUniformBlocks.clear(); glGetProgramiv(m_programID, GL_ACTIVE_UNIFORM_BLOCKS, &nUniforms); - if(m_debugState == true) + if(m_debugState) NGLMessage::addMessage(fmt::format("FOUND UNIFORM BLOCKS {0}", nUniforms), Colours::WHITE, TimeFormat::NONE); - std::array name; + std::array name={}; uniformBlockData data; for(GLint i = 0; i < nUniforms; ++i) { @@ -367,42 +366,42 @@ std::string ShaderProgram::getValueFromShader(const uniformData &_d) const noexc std::string value; if(_d.type == GL_FLOAT || _d.type == GL_BOOL) { - float v; - getRegisteredUniform(_d.name.c_str(), v); + float v=0.0f; + getRegisteredUniform(_d.name, v); value = fmt::format("[{:.4f}]", v); } else if(_d.type == GL_FLOAT_VEC2) { - std::array v; - getRegisteredUniform(_d.name.c_str(), v); + std::array v={0.0f,0.0f}; + getRegisteredUniform(_d.name, v); value = fmt::format("[{:.4f},{:.4f}]", v[0], v[1]); } else if(_d.type == GL_FLOAT_VEC3) { - std::array v; - getRegisteredUniform(_d.name.c_str(), v); + std::array v={0.0f,0.0f,0.0f}; + getRegisteredUniform(_d.name, v); value = fmt::format("[{:.4f},{:.4f},{:.4f}]", v[0], v[1], v[2]); } else if(_d.type == GL_FLOAT_VEC4) { - std::array v; - getRegisteredUniform(_d.name.c_str(), v); + std::array v={0.0f,0.0f,0.0f,1.0f}; + getRegisteredUniform(_d.name, v); value = fmt::format("[{:.4f},{:.4f},{:.4f},{:.4f}]", v[0], v[1], v[2], v[3]); } else if(_d.type == GL_FLOAT_MAT2) { - std::array v; - getRegisteredUniform(_d.name.c_str(), v); + std::array v={0.0f,0.0f,0.0f,1.0f}; + getRegisteredUniform(_d.name, v); value = fmt::format("\n[{:.4f},{:.4f}]\n" "[{:.4f},{:.4f}]", v[0], v[1], v[2], v[3]); } else if(_d.type == GL_FLOAT_MAT3) { - std::array v; + std::array v={1.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,1.0f}; - getRegisteredUniform(_d.name.c_str(), v); + getRegisteredUniform(_d.name, v); value = fmt::format("\n[{:.4f},{:.4f},{:.4f}]\n" "[{:.4f},{:.4f},{:.4f}]\n" "[{:.4f},{:.4f},{:.4f}]", @@ -410,9 +409,9 @@ std::string ShaderProgram::getValueFromShader(const uniformData &_d) const noexc } else if(_d.type == GL_FLOAT_MAT4) { - std::array v; + std::array v={1.0f,0.0f,0.0f,0.0f, 0.0f, 1.0f,0.0f,0.0f, 0.0f,0.0f,1.0f,0.0f, 0.0f,0.0f,0.0f,1.0f}; - getRegisteredUniform(_d.name.c_str(), v); + getRegisteredUniform(_d.name, v); value = fmt::format("\n[{:.4f},{:.4f},{:.4f},{:.4f}]\n" "[{:.4f},{:.4f},{:.4f},{:.4f}]\n" "[{:.4f},{:.4f},{:.4f},{:.4f}]\n" @@ -518,7 +517,7 @@ void ShaderProgram::printRegisteredUniforms() const noexcept {GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE, "uimage2DMS"}, {GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY, "uimage2DMSArray"}, {GL_UNSIGNED_INT_ATOMIC_COUNTER, "atomic_uint"}, -#endif // apple +#endif // __APPLE__ {GL_SAMPLER_2D, "sampler2D"}, {GL_SAMPLER_3D, "sampler3D"}, {GL_SAMPLER_CUBE, "samplerCube"}, diff --git a/src/SimpleIndexVAO.cpp b/src/SimpleIndexVAO.cpp index 89f6c0cd..35083951 100644 --- a/src/SimpleIndexVAO.cpp +++ b/src/SimpleIndexVAO.cpp @@ -9,11 +9,11 @@ SimpleIndexVAO::~SimpleIndexVAO() void SimpleIndexVAO::draw() const { - if(m_allocated == false) + if(!m_allocated) { NGLMessage::addWarning("Warning trying to draw an unallocated VOA"); } - if(m_bound == false) + if(!m_bound) { NGLMessage::addWarning("Warning trying to draw an unbound VOA"); } @@ -22,11 +22,11 @@ void SimpleIndexVAO::draw() const void SimpleIndexVAO::removeVAO() { - if(m_bound == true) + if(m_bound) { unbind(); } - if(m_allocated == true) + if(m_allocated) { glDeleteBuffers(1, &m_buffer); glDeleteBuffers(1, &m_idxBuffer); @@ -38,11 +38,11 @@ void SimpleIndexVAO::removeVAO() void SimpleIndexVAO::setData(const AbstractVAO::VertexData &_data) { auto data = static_cast< const VertexData & >(_data); - if(m_bound == false) + if(!m_bound) { NGLMessage::addWarning("trying to set VOA data when unbound"); } - if(m_allocated == true) + if(m_allocated) { glDeleteBuffers(1, &m_buffer); } diff --git a/src/SimpleVAO.cpp b/src/SimpleVAO.cpp index 7b48b11c..d782864b 100644 --- a/src/SimpleVAO.cpp +++ b/src/SimpleVAO.cpp @@ -1,5 +1,4 @@ #include "SimpleVAO.h" -#include namespace ngl { SimpleVAO::~SimpleVAO() @@ -9,11 +8,11 @@ SimpleVAO::~SimpleVAO() void SimpleVAO::draw() const { - if(m_allocated == false) + if(!m_allocated) { NGLMessage::addWarning("Trying to draw an unallocated VOA"); } - if(m_bound == false) + if(!m_bound) { NGLMessage::addWarning("Warning trying to draw an unbound VOA"); } @@ -22,11 +21,11 @@ void SimpleVAO::draw() const void SimpleVAO::removeVAO() { - if(m_bound == true) + if(m_bound) { unbind(); } - if(m_allocated == true) + if(m_allocated) { glDeleteBuffers(1, &m_buffer); } @@ -76,11 +75,11 @@ void SimpleVAO::setData(size_t _size, const std::vector< Vec3 > &_data) void SimpleVAO::setData(const VertexData &_data) { - if(m_bound == false) + if(!m_bound) { NGLMessage::addWarning("trying to set VOA data when unbound"); } - if(m_allocated == true) + if(m_allocated) { glDeleteBuffers(1, &m_buffer); } @@ -94,11 +93,10 @@ void SimpleVAO::setData(const VertexData &_data) Real *SimpleVAO::mapBuffer(unsigned int _index, GLenum _accessMode) { NGL_UNUSED(_index) - Real *ptr = nullptr; bind(); glBindBuffer(GL_ARRAY_BUFFER, m_id); - ptr = static_cast< Real * >(glMapBuffer(GL_ARRAY_BUFFER, _accessMode)); - // modern GL allows this but not on mac! + auto *ptr = static_cast< Real * >(glMapBuffer(GL_ARRAY_BUFFER, _accessMode)); + // modern GL allows this but not on Mac! // ptr = static_cast(glMapNamedBuffer(m_id, _accessMode)); return ptr; diff --git a/src/Text.cpp b/src/Text.cpp index 202e43d8..179d24db 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -18,7 +18,6 @@ #include #include -#include #include FT_FREETYPE_H #include "NGLStream.h" @@ -26,7 +25,6 @@ #include "Text.h" #include "Util.h" #include -#include namespace ngl { diff --git a/src/Texture.cpp b/src/Texture.cpp index d9fa3f88..7d02ecb5 100644 --- a/src/Texture.cpp +++ b/src/Texture.cpp @@ -19,7 +19,6 @@ /// @brief implementation files for Texture class //---------------------------------------------------------------------------------------------------------------------- #include "Texture.h" -#include "NGLassert.h" #include "Util.h" #include diff --git a/src/Transformation.cpp b/src/Transformation.cpp index 80a1b0d7..ea0d58d1 100644 --- a/src/Transformation.cpp +++ b/src/Transformation.cpp @@ -194,7 +194,7 @@ void Transformation::computeMatrices() noexcept m_matrix.m_m[3][2] = m_position.m_z; m_matrix.m_m[3][3] = 1.0f; - // tranpose matrix + // transpose matrix m_transposeMatrix = rotationScale; m_transposeMatrix.transpose(); m_transposeMatrix.m_m[0][3] = m_position.m_x; diff --git a/src/Types.cpp b/src/Types.cpp index ebc9329a..e2353623 100644 --- a/src/Types.cpp +++ b/src/Types.cpp @@ -1,7 +1,5 @@ -#include "Types.h" -#include "NGLMessage.h" + namespace ngl { -// static Message object for all NGL comms - //std::unique_ptr msg =std::move(NGLMessage::init()); + } diff --git a/src/Util.cpp b/src/Util.cpp index cf254a59..a7450df6 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -18,7 +18,6 @@ #include "Mat4.h" #include "Vec4.h" #include -#include #include //---------------------------------------------------------------------------------------------------------------------- /// @file Util.cpp @@ -344,7 +343,7 @@ NGL_DLLEXPORT std::vector generateDistinctColours(int _n) noexcept { break; } - colours.push_back(ngl::Vec3(r/255.0f,g/255.0f, b/255.0f)); + colours.emplace_back(Vec3(r/255.0f,g/255.0f, b/255.0f)); } } } diff --git a/src/VAOPrimitives.cpp b/src/VAOPrimitives.cpp index 67366424..e530102a 100644 --- a/src/VAOPrimitives.cpp +++ b/src/VAOPrimitives.cpp @@ -20,8 +20,6 @@ #include "Util.h" #include "VAOFactory.h" #include -#include -#include #include /// @file VAOPrimitives.cpp /// @brief implementation files for VAOPrimitives class diff --git a/src/Vec4.cpp b/src/Vec4.cpp index 5afb4a16..11bfe938 100644 --- a/src/Vec4.cpp +++ b/src/Vec4.cpp @@ -15,7 +15,6 @@ along with this program. If not, see . */ #include "Vec4.h" -#include "Vec2.h" #include "Vec3.h" #include "Mat4.h"