Skip to content
Snippets Groups Projects
Commit 84c3bbed authored by Jonas Johan Solsvik's avatar Jonas Johan Solsvik
Browse files

a bunch of small changes

parent 47097b31
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,7 @@ struct Vertex
struct Triangle
{
int a, b, c;
GLuint a, b, c;
};
struct Mesh
......
......@@ -29,6 +29,7 @@ class Parser
int startofline = 0;
int endofline = 9999999;
int linecount = 0;
std::string currentLine = "<top>";
const std::string whitelistedCharacters = "0123456789abcdefghijklmnopqrstuvwxyzæøåABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ-:";
public:
......
......@@ -41,10 +41,10 @@ namespace overkill
m_position += m_velocity * dt;
m_rotation += m_angularVelocity * dt;
printf("\n\n\nm_rotation %f, %f, %f\nm_angVel %f, %f, %f\ndeltatime %f",
/* printf("\n\n\nm_rotation %f, %f, %f\nm_angVel %f, %f, %f\ndeltatime %f",
m_rotation.x, m_rotation.y, m_rotation.z,
m_angularVelocity.x, m_angularVelocity.y, m_angularVelocity.z,
dt);
dt);*/
}
}
\ No newline at end of file
......@@ -116,7 +116,7 @@ namespace overkill
if (m_fovy < C::MinFOV) m_fovy = C::MinFOV;
if (m_fovy > C::MaxFOV) m_fovy = C::MaxFOV;
printf("Scroll: x: %f,\ty:%f\t\tfovy:%f\n", x, y, m_fovy);
// printf("Scroll: x: %f,\ty:%f\t\tfovy:%f\n", x, y, m_fovy);
}
void Input::OnMouseClick(GLFWwindow* window, int button, int action, int mods)
......
......@@ -52,6 +52,8 @@ void ModelSystem::load()
std::vector<std::string> tags {
"cube",
"out",
"Suzanne",
"Icosphere"
// "teapot-base", // @TODO find a way to dynamically load the file names(tags) into the system
// "teapot-top",
};
......@@ -136,6 +138,8 @@ void ModelSystem::load()
}
std::vector<GLuint> indices;
LOG_DEBUG("tricount: %d", triCount);
// Triangles
for(int j = 0; j < triCount; ++j)
{
......@@ -147,6 +151,7 @@ void ModelSystem::load()
indices.push_back(triangle.a);
indices.push_back(triangle.b);
indices.push_back(triangle.c);
}
// Construct mesh, buffer ElementBuffer data to GPU
......
......@@ -10,48 +10,38 @@ Parser::Parser(std::string_view _strview)
auto Parser::nextLine() -> std::string
{
endofline = strview.find('\n', startofline);
startofline = strview.find_first_of(whitelistedCharacters, startofline);
if (size_t(startofline) == std::string::npos) {
std::cout << "\nPARSER ERROR ---->>> (startofline == std::string::npos)\n\n"
<< "Line: " << linecount;
LOG_WARN("No whitelisted characters found after new-line character!! Line:");
return "";
}
if (size_t(endofline) == std::string::npos) {
std::cout << "\nPARSER ERROR ---->>> (endofline == std::string::npos)\n\n"
<< "Line: " << linecount;
LOG_WARN("No end of file (new-line) character found! Line:");
return "";
}
linecount++;
// Skip empty lines in between and eat whitespace
while (endofline - startofline <= 0) {
startofline = endofline + 1;
endofline = strview.find('\n', startofline);
do {
if (startofline != 0) {
startofline = endofline + 1;
}
endofline = strview.find('\n', startofline);
startofline = strview.find_first_of(whitelistedCharacters, startofline);
if (size_t(startofline) == std::string::npos) {
std::cout << "\nPARSER ERROR ---->>> (startofline == std::string::npos)\n\n"
<< "Line: " << linecount;
LOG_WARN("No whitelisted characters found after new-line character!! Line:");
LOG_WARN("No whitelisted characters found after new-line character!! Line:%s", currentLine.data());
return "";
}
if (size_t(endofline) == std::string::npos) {
std::cout << "PARSER ERROR ---->>> (endofline == std::string::npos)"
std::cout << "\nPARSER ERROR ---->>> (endofline == std::string::npos)\n\n"
<< "Line: " << linecount;
LOG_WARN("No end of file (new-line) character found! Line:");
return "";
LOG_WARN("No end of file (new-line) character found! Line:%s", currentLine.data());
return "";
}
linecount++;
}
} while (endofline - startofline <= 0);
auto line = std::string{
strview.substr(startofline, endofline - startofline)
};
currentLine = line;
size_t lastCharacter = (endofline - startofline) - 1;
size_t lastValidCharacter = line.find_last_of(whitelistedCharacters);
if (lastValidCharacter != lastCharacter) {
......@@ -82,7 +72,8 @@ auto Parser::nextLine() -> std::string
auto Parser::nextKeyString() -> KeyString
{
auto line = nextLine();
LOG_DEBUG("%s", line.data());
if(line == "")
return KeyString{"","", PARSE_ERROR};
......@@ -92,19 +83,6 @@ auto Parser::nextKeyString() -> KeyString
if (line.find(":") + 2 < line.size())
valueString = line.substr(line.find(":") + 2);
/*
#ifdef DEBUG
std::stringstream ss;
ss << " key: "
<< std::setw(18) << std::left
<< key
<< " val: "
<< valueString;
LOG_DEBUG("%s", ss.str().c_str());
#endif
*/
return KeyString{ key, valueString, PARSE_SUCCESS };
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment