diff --git a/CompGraphics.vcxproj b/CompGraphics.vcxproj
deleted file mode 100644
index 9b4dff5..0000000
--- a/CompGraphics.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 16.0
- {4F39A7F3-8E88-4B30-A89D-44BE8F5DD0A9}
- CompGraphics
- 10.0
-
-
-
- Application
- true
- v142
- MultiByte
-
-
- Application
- false
- v142
- true
- MultiByte
-
-
- Application
- true
- v142
- MultiByte
-
-
- Application
- false
- v142
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- F:\Development\cpp_libs\glfw-3.3.2.bin.WIN64\include\GLFW;$(IncludePath)
- F:\Development\cpp_libs\glfw-3.3.2.bin.WIN64\lib-vc2019;$(LibraryPath)
-
-
- $(ExecutablePath)
- F:\Development\cpp_libs\glfw-3.3.2.bin.WIN64\include\GLFW;F:\Development\cpp_libs\glew-2.1.0\include\GL;F:\Development\cpp_libs\glm;$(IncludePath)
- F:\Development\cpp_libs\glfw-3.3.2.bin.WIN64\lib-vc2019;F:\Development\cpp_libs\glew-2.1.0\lib\Release\x64;$(LibraryPath)
-
-
-
- Level3
- Disabled
- true
- true
-
-
- Console
- glfw3.lib;opengl32.lib;%(AdditionalDependencies)
- F:\Development\cpp_libs\glfw-3.3.2.bin.WIN64\lib-vc2019;%(AdditionalLibraryDirectories)
-
-
-
-
- Level4
- Disabled
- true
- true
- stdcpp17
-
-
- Console
- F:\Development\cpp_libs\glfw-3.3.2.bin.WIN64\lib-vc2019;F:\Development\cpp_libs\glew-2.1.0\lib\x64;%(AdditionalLibraryDirectories)
- glfw3.lib;opengl32.lib;glew32.lib;%(AdditionalDependencies)
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- true
-
-
- Console
- true
- true
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- true
-
-
- Console
- true
- true
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CompGraphics.vcxproj.filters b/CompGraphics.vcxproj.filters
deleted file mode 100644
index 96fca07..0000000
--- a/CompGraphics.vcxproj.filters
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
-
-
-
- Ducktape_GL
-
-
- Ducktape_GL
-
-
- Ducktape_GL
-
-
- Ducktape_GL
-
-
- Ducktape_GL
-
-
- Ducktape_GL
-
-
- Ducktape_GL
-
-
- Ducktape_GL
-
-
- Ducktape_GL
-
-
-
-
- Ducktape_GL
-
-
-
-
-
-
-
- {dffb88da-bab3-4079-8f08-9bb1e7475f9d}
-
-
- {05484b5d-cbf0-49d7-a593-8fffa98fadb3}
-
-
-
-
- Shaders
-
-
- Shaders
-
-
- Shaders
-
-
- Shaders
-
-
- Shaders
-
-
- Shaders
-
-
- Shaders
-
-
- Shaders
-
-
- Shaders
-
-
- Shaders
-
-
- Shaders
-
-
- Shaders
-
-
- Shaders
-
-
- Shaders
-
-
-
\ No newline at end of file
diff --git a/CompGraphics.vcxproj.user b/CompGraphics.vcxproj.user
deleted file mode 100644
index 5df420f..0000000
--- a/CompGraphics.vcxproj.user
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
- false
-
-
\ No newline at end of file
diff --git a/DGL_MiscTypes.hpp b/DGL_MiscTypes.hpp
index 2560b54..29d22d2 100644
--- a/DGL_MiscTypes.hpp
+++ b/DGL_MiscTypes.hpp
@@ -3,6 +3,7 @@
// OpenGL
#include
#include
+#include
// Duck Tape
@@ -19,6 +20,9 @@ namespace DGL
{
template
using Vector3 = glm::tvec3;
+
+ template
+ using Vector2 = glm::tvec2;
}
using DataPtr = ptr;
@@ -35,6 +39,7 @@ namespace DGL
class Shader ;
class ShaderProgram;
class VertexArray ;
+ class TextureBuffer;
class ElementBuffer;
diff --git a/DGL_Model.hpp b/DGL_Model.hpp
index 6e24698..92bf19f 100644
--- a/DGL_Model.hpp
+++ b/DGL_Model.hpp
@@ -1,14 +1,26 @@
#pragma once
+// DGL
#include "DGL_Buffers.hpp"
#include "DGL_Space.hpp"
+// C++
#include "Cpp_Alias.hpp"
namespace DGL
{
+ using std::string;
+
+ using UVList = std ::vector < Vector2>;
+ using Vec3Int = Generic::Vector3< gUInt >;
+ using Vec2Int = Generic::Vector2< gUInt >;
+ using VertexList = std ::vector < Vector3>;
+ using VIndexList = std ::vector < gInt >;
+
+
+
sfn Offset(gInt _offsetAmount)
{
return ptr(_offsetAmount);
@@ -19,22 +31,29 @@ namespace DGL
return 0;
}
- using std::string;
-
- using VertexList = std ::vector < Vector3>;
- using UVList = std ::vector < Vector2>;
- using VecInt = Generic::Vector3< gUInt >;
- using VIndexList = std ::vector < gInt >;
-
-
struct VertexGenerator
{
using ComponentList = std::vector< gFloat>;
+
+
ComponentList comp;
+
+
+ // TODO: De-hard-code this generator to do any vector size.
+ sfn GetVector() -> Vector3
+ {
+ return Vector3(comp.at(0), comp.at(1), comp.at(2));
+ }
+
+ sfn GetVector2() -> Vector2
+ {
+ return Vector2(comp.at(0), comp.at(1));
+ }
+
void Normalize()
{
using std::pow ;
@@ -56,24 +75,19 @@ namespace DGL
*element /= magnitude;
}
}
-
-
- // TODO: De-hard-code this generator to do any vector size.
- sfn GetVector() -> Vector3
- {
- return Vector3(comp.at(0), comp.at(1), comp.at(2));
- }
};
+
+
struct Face
{
- VecInt Vertexes,
- Normals;
- //UVs[3];
+ Vec3Int Vertexes, Normals;
};
using FaceList = std::vector;
+
+
struct FaceGenerator
{
using ComponentList = std::vector< gUInt>;
@@ -103,9 +117,12 @@ namespace DGL
{
generated.Vertexes[index] = vertIndexes[index];
- if (uvIndexes.size() > 0)
+ if (index < 2)
{
- //generated.UVs[index] = uvIndexes[index];
+ if (uvIndexes.size() > 0)
+ {
+ //generated.UVs[index] = uvIndexes[index];
+ }
}
if (normals.size() > 0)
@@ -114,39 +131,39 @@ namespace DGL
}
}
+ if (uvIndexes.size() == 0)
+ {
+ //generated.UVs = { 0, 0 };
+ }
+
return generated;
}
};
+
+
struct Model
{
-
- struct VN
- {
- Vector3 Vertex, Normal;
-
- VN(Vector3 _v, Vector3 _n) : Vertex(_v), Normal(_n) {};
- };
-
- using VNList = std::vector;
-
ID VAO;
ID VBO;
ID NBO;
+ ID TBO;
ID EBO;
const string FilePath;
- VertexList Verticies ;
- VertexList VertNormals ;
+ VertexList Verticies ;
+ VertexList VertNormals;
- VertexList RAWVertex ;
+ VertexList RAWVertex ;
VertexList VertNormalsRAW;
UVList TextureMap ;
FaceList Faces ;
VIndexList Indicies ;
+
+
Model(const Ref(string) _filePath) :
VAO(-1),
VBO(-1),
@@ -164,17 +181,18 @@ namespace DGL
{
using std::cout ;
using std::endl ;
+ using std::get ;
+ using std::getline ;
using std::ifstream ;
using std::ios ;
using std::stringstream;
- using std::getline;
- using std::ws;
- using std::get;
+ using std::ws ;
- ifstream fileBuffer;
- fileBuffer.open(FilePath);
+ ifstream fileBuffer; fileBuffer.open(FilePath);
+
+
deduce processVertex = [&](Ref(stringstream) _vertexStream)
{
@@ -206,6 +224,20 @@ namespace DGL
VertNormals.push_back(normal.GetVector());
};
+ deduce processTexture = [&](Ref(stringstream) _normalStream)
+ {
+ VertexGenerator texture; gFloat componentValue;
+
+ while (not _normalStream.eof())
+ {
+ _normalStream >> componentValue >> ws;
+
+ texture.comp.push_back(componentValue);
+ }
+
+ TextureMap.push_back(texture.GetVector2());
+ };
+
deduce processFace = [&](Ref(stringstream) _faceStream)
{
FaceGenerator faceMade; gUInt vertexIndex, textureIndex, normalIndex;
@@ -255,6 +287,8 @@ namespace DGL
Faces.push_back(faceMade.GetFace());
};
+
+
if (fileBuffer.is_open())
{
stringstream stringBuffer;
@@ -281,6 +315,10 @@ namespace DGL
{
processNormals(lineStream);
}
+ else if (lineSig == "vt")
+ {
+ processTexture(lineStream);
+ }
else if (lineSig == "f")
{
processFace(lineStream);
@@ -294,10 +332,39 @@ namespace DGL
throw std::runtime_error("Could not open file to load model.");
}
-
fileBuffer.close();
}
+
+
+
+
+ sfn GenerateNormals()
+ {
+ VertNormals.resize(Verticies.size());
+
+ for (int index = 0; index < Faces.size(); index++)
+ {
+ int vertexIndex1 = Faces[index].Vertexes[0],
+ vertexIndex2 = Faces[index].Vertexes[1],
+ vertexIndex3 = Faces[index].Vertexes[2];
+
+ Vector3 edge1 = Verticies[vertexIndex2] - Verticies[vertexIndex1],
+ edge2 = Verticies[vertexIndex3] - Verticies[vertexIndex1],
+
+ normal = GetDirection(GetCrossNormal(edge1, edge2));
+
+ Faces[index].Normals[0] = vertexIndex1;
+ Faces[index].Normals[1] = vertexIndex2;
+ Faces[index].Normals[2] = vertexIndex3;
+
+ VertNormals[vertexIndex1] = normal;
+ VertNormals[vertexIndex2] = normal;
+ VertNormals[vertexIndex3] = normal;
+ }
+ }
+
+
template
sfn RoundOff(Type _value, gInt _numDigitsToKeep) -> Type
{
@@ -306,42 +373,7 @@ namespace DGL
return round(_value * Rounder) / Rounder;
}
- sfn GenerateNormals()
- {
- for (int index = 0; index < Faces.size(); index++)
- {
- int vertexIndex1 = Faces[index].Vertexes[0],
- vertexIndex2 = Faces[index].Vertexes[1],
- vertexIndex3 = Faces[index].Vertexes[2];
- Vector3 edge1 = Verticies[vertexIndex2] - Verticies[vertexIndex1],
- edge2 = Verticies[vertexIndex3] - Verticies[vertexIndex2],
-
- normal = GetDirection(GetCrossNormal(edge2, edge1));
-
-
- normal[0] = normal[0]; // RoundOff(normal[0], 7);
- normal[1] = normal[1]; // RoundOff(normal[1], 7);
- normal[2] = normal[1]; // RoundOff(normal[2], 7);
-
-
- bool normalExists = false;
-
- for (int normIndex = 0; normIndex < VertNormals.size(); normIndex++)
- {
- if (normal == VertNormals[normIndex])
- {
- normalExists = true;
- }
- }
-
-
- if (!normalExists)
- {
- VertNormals.push_back(normal);
- }
- }
- }
// Hardcoded to only do the verticies and normals for now...
sfn Buffer()
@@ -349,49 +381,15 @@ namespace DGL
GenerateVertexBuffers(Address(VAO), 1);
GenerateBuffers (Address(VBO), 1);
GenerateBuffers (Address(NBO), 1);
+ //glGenTextures (1, Address(TBO));
GenerateBuffers (Address(EBO), 1);
- /*if (VertNormals.size() == 0)
+ if (VertNormals.size() == 0)
{
GenerateNormals();
- }*/
-
- /*for (int index = 0; index < Faces.size(); index++)
- {
- cout << "FaceID: " << index << endl << endl;
-
- for (int vertIndex = 0; vertIndex < 3; vertIndex++)
- {
- cout << "Vert Index: " << Faces[index].Vertexes[vertIndex] << endl;
- cout << "Face Index: " << Faces[index].Normals[vertIndex] << endl;
-
- RAWVertex.push_back
- (
- Verticies[Faces[index].Vertexes[vertIndex]]
- );
-
- RAWVertex.push_back
- (
- VertNormals[Faces[index].Normals[vertIndex]]
- );
- }
}
-
- BindVertexArray(VAO);
-
- BindBuffer(EBufferTarget::VertexAttributes, VBO);
-
- BufferData(Address(RAWVertex[0]), RAWVertex.size() * sizeof(Vector3), EBufferTarget::VertexAttributes, EBufferUsage::StaticDraw);
-
- FormatVertexAttributes(0, EDataType::Float, ZeroOffset(), 3, EBool::False);
-
- EnableVertexAttributeArray(0);
-
- FormatVertexAttributes(1, EDataType::Float, Offset(sizeof(Vector3)), 3, EBool::False);
-
- EnableVertexAttributeArray(1);*/
BindVertexArray(VAO);
@@ -404,6 +402,7 @@ namespace DGL
EnableVertexAttributeArray(0);
+
if (VertNormals.size() != 0)
{
BindBuffer(EBufferTarget::VertexAttributes, NBO);
@@ -416,6 +415,20 @@ namespace DGL
}
+
+ /*if (TextureMap.size() != 0)
+ {
+ glBindTexture(TBO, GL_TEXTURE_2D);
+
+ BufferData(Address(TextureMap[0]), TextureMap.size() * sizeof(Vector2), EBufferTarget::TextureData, EBufferUsage::StaticDraw);
+
+ FormatVertexAttributes(2, EDataType::Float, ZeroOffset(), 2, EBool::False);
+
+ EnableVertexAttributeArray(2);
+ }*/
+
+
+
BindBuffer(EBufferTarget::VertexIndices, EBO);
BufferData(Address(Faces[0]), Faces.size() * sizeof(Face), EBufferTarget::VertexIndices, EBufferUsage::StaticDraw);
@@ -427,13 +440,11 @@ namespace DGL
{
BindVertexArray(VAO);
- BindBuffer(EBufferTarget::VertexAttributes, VBO);
-
+
gInt Size; GetBufferParameterIV(EBufferTarget::VertexIndices, EBufferParam::Size, Address(Size));
- Size /= sizeof(gInt);
+ Size /= sizeof(gUInt);
- //DrawArrays(EPrimitives::Triangles, 0, RAWVertex.size());
DrawElements(EPrimitives::Triangles, Size, EDataType::UnsignedInt, ZeroOffset());
diff --git a/DGL_Shader.hpp b/DGL_Shader.hpp
index 179a325..2f6482e 100644
--- a/DGL_Shader.hpp
+++ b/DGL_Shader.hpp
@@ -488,10 +488,12 @@ namespace DGL
EnableVertexAttributeArray(0);
EnableVertexAttributeArray(1);
+ //EnableVertexAttributeArray(2);
}
sfn Stop()
{
+ //DisableVertexAttributeArray(2);
DisableVertexAttributeArray(1);
DisableVertexAttributeArray(0);
}
diff --git a/Execution.cpp b/Execution.cpp
index 7f33143..feea748 100644
--- a/Execution.cpp
+++ b/Execution.cpp
@@ -386,7 +386,7 @@ namespace Execution
//RAW_RotateLitCube(PhysicsDelta);
- RAW_LightRotate(PhysicsDelta);
+ RAW_UpdateLightTransform(PhysicsDelta);
ProperCube::Rotate(PhysicsDelta);
diff --git a/PhongShader.frag b/PhongShader.frag
index 191b3b6..137e41a 100644
--- a/PhongShader.frag
+++ b/PhongShader.frag
@@ -2,12 +2,10 @@
out vec4 FragColor;
-
in vec3 FragPosition ;
in vec3 Normal ;
in vec3 LightViewPosition;
-in vec3 LightRawPos;
-
+in vec3 LightRawPos ;
uniform vec3 ObjectColor;
uniform vec3 LightColor ;
@@ -25,7 +23,7 @@ void main()
// Diffuse
- vec3 direction = normalize(Normal );
+ vec3 direction = normalize(Normal );
vec3 lightDirection = normalize(LightViewPosition - FragPosition);
float diffuseStrength = max(dot(direction, lightDirection), 0.0);
@@ -35,8 +33,8 @@ void main()
float specularStrength = 0.5;
- vec3 viewDirection = normalize(ViewPosition - FragPosition);
-// vec3 viewDirection = normalize(-FragPosition);
+// vec3 viewDirection = normalize(ViewPosition - FragPosition);
+ vec3 viewDirection = normalize(-FragPosition);
vec3 reflectionDirection = reflect(-lightDirection, direction);
diff --git a/PhongShader.vert b/PhongShader.vert
index 934be17..c5d7804 100644
--- a/PhongShader.vert
+++ b/PhongShader.vert
@@ -2,9 +2,7 @@
layout (location = 0) in vec3 VertPosition;
layout (location = 1) in vec3 VertNormal ;
-
-varying vec3 vPosInterp;
-varying vec3 vNormalInterp;
+layout (location = 2) in vec3 VertTexture ;
out vec3 FragPosition ;
out vec3 Normal ;
diff --git a/Testing.hpp b/Testing.hpp
index 4821890..ff5d373 100644
--- a/Testing.hpp
+++ b/Testing.hpp
@@ -18,6 +18,11 @@ using DGL::LinearColor;
using DGL::Vector3;
using DGL::ZeroOffset;
+struct RAWBS
+{
+ float bullshit[6 * 6 * 2 *3];
+};
+
float vertices[] = {
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
@@ -356,7 +361,7 @@ sfn RAW_RenderCube()
LinearColor CoralColor(1.0f, 0.5f, 0.31f, 1.0f);
LinearColor LightColor(1.0f, 1.0f, 1.0f , 1.0f);
-Vector3 LightPosition(1.2f, 2.0f, 0.5f);
+Vector3 LightPosition(1.2f, 1.0f, 1.75f);
Vector3 LightScale = Vector3(0.2f);
@@ -383,10 +388,8 @@ sfn RAW_MakeLightVAO()
LightTransform = DGL::Scale (LightTransform, LightScale );
}
-sfn RAW_LightRotate(gFloat _delta)
+sfn RAW_UpdateLightTransform(gFloat _delta)
{
- //LightTransform = DGL::Rotate(LightTransform, 0.1f, Vector3(1, 0, 0));
-
static bool test = true;
LightTransform = CoordSpace(1.0f);
@@ -478,10 +481,12 @@ sfn RAW_RenderLitCube(CoordSpace _projection, CoordSpace _viewport)
}
+using DGL::NormalBuffer;
+
namespace ProperCube
{
- Model model("cube.obj");
+ Model model("topology.obj");
Vector3 position = Vector3(0.0f);
@@ -489,9 +494,11 @@ namespace ProperCube
CoordSpace transform = Matrix4x4(1.0f);
+
+
sfn Rotate(gFloat _delta)
{
- //transform = DGL::Rotate(transform, 1.5f * _delta, Vector3(0, 1, 0));
+ transform = DGL::Rotate(transform, 0.75f * _delta, Vector3(0, 1, 0));
}
sfn Render(Ref(CoordSpace) _projection, Ref(CoordSpace) _viewport, Ref(Vector3) _cameraPosition)
@@ -511,21 +518,17 @@ namespace ProperCube
_cameraPosition
);
- //DGL::Basic_LightingShader::Use(screenspaceTransform, color, lightColor);
-
model.Render();
- DGL::Basic_LightingShader::Stop();
-
DGL::PhongShader::Stop();
}
+ using DGL::Offset;
+
sfn Setup()
{
model.Load();
- //model.GenVN();
-
model.Buffer();
//transform = DGL::Scale(transform, Vector3(0.01));
diff --git a/blenderCube.obj b/blenderCube.obj
new file mode 100644
index 0000000..98d8e96
--- /dev/null
+++ b/blenderCube.obj
@@ -0,0 +1,46 @@
+# Blender v2.80 (sub 74) OBJ File: ''
+# www.blender.org
+mtllib blenderCube.mtl
+o Cube
+v 1.000000 1.000000 -1.000000
+v 1.000000 -1.000000 -1.000000
+v 1.000000 1.000000 1.000000
+v 1.000000 -1.000000 1.000000
+v -1.000000 1.000000 -1.000000
+v -1.000000 -1.000000 -1.000000
+v -1.000000 1.000000 1.000000
+v -1.000000 -1.000000 1.000000
+vt 0.375000 0.000000
+vt 0.625000 0.000000
+vt 0.625000 0.250000
+vt 0.375000 0.250000
+vt 0.375000 0.250000
+vt 0.625000 0.250000
+vt 0.625000 0.500000
+vt 0.375000 0.500000
+vt 0.625000 0.750000
+vt 0.375000 0.750000
+vt 0.625000 0.750000
+vt 0.625000 1.000000
+vt 0.375000 1.000000
+vt 0.125000 0.500000
+vt 0.375000 0.500000
+vt 0.375000 0.750000
+vt 0.125000 0.750000
+vt 0.625000 0.500000
+vt 0.875000 0.500000
+vt 0.875000 0.750000
+vn 0.0000 1.0000 0.0000
+vn 0.0000 0.0000 1.0000
+vn -1.0000 0.0000 0.0000
+vn 0.0000 -1.0000 0.0000
+vn 1.0000 0.0000 0.0000
+vn 0.0000 0.0000 -1.0000
+usemtl Material
+s off
+f 1/1/1 5/2/1 7/3/1 3/4/1
+f 4/5/2 3/6/2 7/7/2 8/8/2
+f 8/8/3 7/7/3 5/9/3 6/10/3
+f 6/10/4 2/11/4 4/12/4 8/13/4
+f 2/14/5 1/15/5 3/16/5 4/17/5
+f 6/18/6 5/19/6 1/20/6 2/11/6
diff --git a/bunny.nf25k.obj b/bunny.obj
similarity index 100%
rename from bunny.nf25k.obj
rename to bunny.obj
diff --git a/cube.obj b/cube.obj
index db3da8d..f5173d6 100644
--- a/cube.obj
+++ b/cube.obj
@@ -2,9 +2,6 @@
#
#
-mtllib cube.mtl
-
-
#
# cube Mesh
#