Skip to content

Commit

Permalink
updated based on changes from clion ide suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacey committed Oct 11, 2023
1 parent 0f5dca6 commit 9e16ec0
Show file tree
Hide file tree
Showing 32 changed files with 104 additions and 132 deletions.
4 changes: 2 additions & 2 deletions include/ngl/NGLMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion include/ngl/Obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/ngl/Quaternion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 0 additions & 4 deletions include/ngl/ShaderLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
//----------------------------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion include/ngl/ShaderProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 20 additions & 19 deletions src/AbstractMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -93,30 +93,30 @@ 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
{
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;
}
}
else // need to delete VAO if existing amd reset
{
if(m_vao == true)
if(m_vao)
{
NGLMessage::addWarning("Creating new VAO");
}
Expand All @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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<BBox>(m_minX, m_maxX, m_minY, m_maxY, m_minZ, m_maxZ);

}

std::unique_ptr< AbstractVAO > AbstractMesh::moveVAO() noexcept
Expand All @@ -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);
}
Expand All @@ -262,19 +263,19 @@ 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;
}


void AbstractMesh::unMapVAO() noexcept
{
if(m_vboMapped == true)
if(m_vboMapped)
{
glUnmapBuffer(GL_ARRAY_BUFFER); // unmap it after use
m_vboMapped = false;
Expand Down
3 changes: 1 addition & 2 deletions src/AbstractVAO.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "AbstractVAO.h"
#include <iostream>
namespace ngl
{
AbstractVAO::AbstractVAO(GLenum _mode) : m_mode{_mode}
Expand Down Expand Up @@ -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");
}
Expand Down
5 changes: 2 additions & 3 deletions src/BBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "BBox.h"
#include "VAOFactory.h"
#include "SimpleIndexVAO.h"
#include <iostream>
namespace ngl
{
constexpr GLubyte indices[]= {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/BezierCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 4 additions & 6 deletions src/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<GLuint>(_uvX) * (m_width - 1));
auto yy = static_cast< GLuint >(static_cast<GLuint>(_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)

Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/Mat2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include "Mat2.h"
#include "NGLassert.h"
#include "Util.h"
#include "Vec2.h"
#include <cstring> // for memset
Expand Down
2 changes: 0 additions & 2 deletions src/Mat3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@

#include "Mat3.h"
#include "Mat4.h"
#include "NGLassert.h"
#include "Quaternion.h"
#include "Util.h"
#include "Vec2.h"
#include <cstring> // for memset
#include <iostream>
#ifdef USEGLM
Expand Down
12 changes: 6 additions & 6 deletions src/MultiBufferVAO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand All @@ -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)
{
Expand All @@ -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");
}
Expand All @@ -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");
}
Expand Down
3 changes: 0 additions & 3 deletions src/NGLInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
#include "SimpleVAO.h"
#include "VAOFactory.h"
#include "VAOPrimitives.h"
#include <chrono>
#include <memory>
#include <string>
#include <thread>
#if defined(LINUX) || defined(_WIN32)
#include <cstdlib>
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/NGLMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/NGLStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
#include "Mat4.h"
#include "Quaternion.h"
#include <iostream>
#include <limits>
#include <iomanip>

namespace ngl
{

Expand Down
Loading

0 comments on commit 9e16ec0

Please sign in to comment.