mirror of
				https://github.com/Ed94/DuctTaped_GL.git
				synced 2025-10-29 14:00:56 -07:00 
			
		
		
		
	Got tired of everything and just used loctite ultra gel control on the generate normals.
Locktite ultra is the shit.
This commit is contained in:
		| @@ -1,175 +0,0 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||
|   <ItemGroup Label="ProjectConfigurations"> | ||||
|     <ProjectConfiguration Include="Debug|Win32"> | ||||
|       <Configuration>Debug</Configuration> | ||||
|       <Platform>Win32</Platform> | ||||
|     </ProjectConfiguration> | ||||
|     <ProjectConfiguration Include="Release|Win32"> | ||||
|       <Configuration>Release</Configuration> | ||||
|       <Platform>Win32</Platform> | ||||
|     </ProjectConfiguration> | ||||
|     <ProjectConfiguration Include="Debug|x64"> | ||||
|       <Configuration>Debug</Configuration> | ||||
|       <Platform>x64</Platform> | ||||
|     </ProjectConfiguration> | ||||
|     <ProjectConfiguration Include="Release|x64"> | ||||
|       <Configuration>Release</Configuration> | ||||
|       <Platform>x64</Platform> | ||||
|     </ProjectConfiguration> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="Actions.hpp" /> | ||||
|     <ClInclude Include="Cpp_Alias.hpp" /> | ||||
|     <ClInclude Include="DGL_Buffers.hpp" /> | ||||
|     <ClInclude Include="DGL_Model.hpp" /> | ||||
|     <ClInclude Include="DGL_Space.hpp" /> | ||||
|     <ClInclude Include="DGL_Enum.hpp" /> | ||||
|     <ClInclude Include="DGL_FundamentalTypes.hpp" /> | ||||
|     <ClInclude Include="DGL_MiscTypes.hpp" /> | ||||
|     <ClInclude Include="DGL.hpp" /> | ||||
|     <ClInclude Include="DGL_Shader.hpp" /> | ||||
|     <ClInclude Include="DGL_Variable.hpp" /> | ||||
|     <ClInclude Include="ShaderFromTut.hpp" /> | ||||
|     <ClInclude Include="Testing.hpp" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="Execution.cpp" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <None Include="3.3.shader.frag" /> | ||||
|     <None Include="3.3.shader.vert" /> | ||||
|     <None Include="5.1.transform.frag" /> | ||||
|     <None Include="5.1.transform.vert" /> | ||||
|     <None Include="6.3.coordinate_systems.frag" /> | ||||
|     <None Include="6.3.coordinate_systems.vert" /> | ||||
|     <None Include="BasicLamp.frag" /> | ||||
|     <None Include="BasicLighting.frag" /> | ||||
|     <None Include="PhongShader.frag" /> | ||||
|     <None Include="PhongShader.vert" /> | ||||
|     <None Include="SingleColor.frag" /> | ||||
|     <None Include="SimpleFragmentShader.frag" /> | ||||
|     <None Include="SimpleTransform.vert" /> | ||||
|     <None Include="SimpleVertexShader.vert" /> | ||||
|   </ItemGroup> | ||||
|   <PropertyGroup Label="Globals"> | ||||
|     <VCProjectVersion>16.0</VCProjectVersion> | ||||
|     <ProjectGuid>{4F39A7F3-8E88-4B30-A89D-44BE8F5DD0A9}</ProjectGuid> | ||||
|     <RootNamespace>CompGraphics</RootNamespace> | ||||
|     <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> | ||||
|   </PropertyGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>true</UseDebugLibraries> | ||||
|     <PlatformToolset>v142</PlatformToolset> | ||||
|     <CharacterSet>MultiByte</CharacterSet> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>false</UseDebugLibraries> | ||||
|     <PlatformToolset>v142</PlatformToolset> | ||||
|     <WholeProgramOptimization>true</WholeProgramOptimization> | ||||
|     <CharacterSet>MultiByte</CharacterSet> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>true</UseDebugLibraries> | ||||
|     <PlatformToolset>v142</PlatformToolset> | ||||
|     <CharacterSet>MultiByte</CharacterSet> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>false</UseDebugLibraries> | ||||
|     <PlatformToolset>v142</PlatformToolset> | ||||
|     <WholeProgramOptimization>true</WholeProgramOptimization> | ||||
|     <CharacterSet>MultiByte</CharacterSet> | ||||
|   </PropertyGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||||
|   <ImportGroup Label="ExtensionSettings"> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="Shared"> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <PropertyGroup Label="UserMacros" /> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
|     <IncludePath>F:\Development\cpp_libs\glfw-3.3.2.bin.WIN64\include\GLFW;$(IncludePath)</IncludePath> | ||||
|     <LibraryPath>F:\Development\cpp_libs\glfw-3.3.2.bin.WIN64\lib-vc2019;$(LibraryPath)</LibraryPath> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||||
|     <ExecutablePath>$(ExecutablePath)</ExecutablePath> | ||||
|     <IncludePath>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)</IncludePath> | ||||
|     <LibraryPath>F:\Development\cpp_libs\glfw-3.3.2.bin.WIN64\lib-vc2019;F:\Development\cpp_libs\glew-2.1.0\lib\Release\x64;$(LibraryPath)</LibraryPath> | ||||
|   </PropertyGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
|     <ClCompile> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <Optimization>Disabled</Optimization> | ||||
|       <SDLCheck>true</SDLCheck> | ||||
|       <ConformanceMode>true</ConformanceMode> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Console</SubSystem> | ||||
|       <AdditionalDependencies>glfw3.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies> | ||||
|       <AdditionalLibraryDirectories>F:\Development\cpp_libs\glfw-3.3.2.bin.WIN64\lib-vc2019;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||||
|     </Link> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||||
|     <ClCompile> | ||||
|       <WarningLevel>Level4</WarningLevel> | ||||
|       <Optimization>Disabled</Optimization> | ||||
|       <SDLCheck>true</SDLCheck> | ||||
|       <ConformanceMode>true</ConformanceMode> | ||||
|       <LanguageStandard>stdcpp17</LanguageStandard> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Console</SubSystem> | ||||
|       <AdditionalLibraryDirectories>F:\Development\cpp_libs\glfw-3.3.2.bin.WIN64\lib-vc2019;F:\Development\cpp_libs\glew-2.1.0\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||||
|       <AdditionalDependencies>glfw3.lib;opengl32.lib;glew32.lib;%(AdditionalDependencies)</AdditionalDependencies> | ||||
|     </Link> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||||
|     <ClCompile> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <Optimization>MaxSpeed</Optimization> | ||||
|       <FunctionLevelLinking>true</FunctionLevelLinking> | ||||
|       <IntrinsicFunctions>true</IntrinsicFunctions> | ||||
|       <SDLCheck>true</SDLCheck> | ||||
|       <ConformanceMode>true</ConformanceMode> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Console</SubSystem> | ||||
|       <EnableCOMDATFolding>true</EnableCOMDATFolding> | ||||
|       <OptimizeReferences>true</OptimizeReferences> | ||||
|     </Link> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||||
|     <ClCompile> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <Optimization>MaxSpeed</Optimization> | ||||
|       <FunctionLevelLinking>true</FunctionLevelLinking> | ||||
|       <IntrinsicFunctions>true</IntrinsicFunctions> | ||||
|       <SDLCheck>true</SDLCheck> | ||||
|       <ConformanceMode>true</ConformanceMode> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Console</SubSystem> | ||||
|       <EnableCOMDATFolding>true</EnableCOMDATFolding> | ||||
|       <OptimizeReferences>true</OptimizeReferences> | ||||
|     </Link> | ||||
|   </ItemDefinitionGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||||
|   <ImportGroup Label="ExtensionTargets"> | ||||
|   </ImportGroup> | ||||
| </Project> | ||||
| @@ -1,93 +0,0 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="Cpp_Alias.hpp" /> | ||||
|     <ClInclude Include="DGL_FundamentalTypes.hpp"> | ||||
|       <Filter>Ducktape_GL</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="DGL_Shader.hpp"> | ||||
|       <Filter>Ducktape_GL</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="DGL_Enum.hpp"> | ||||
|       <Filter>Ducktape_GL</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="DGL_Buffers.hpp"> | ||||
|       <Filter>Ducktape_GL</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="DGL_MiscTypes.hpp"> | ||||
|       <Filter>Ducktape_GL</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="DGL.hpp"> | ||||
|       <Filter>Ducktape_GL</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="DGL_Variable.hpp"> | ||||
|       <Filter>Ducktape_GL</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="ShaderFromTut.hpp"> | ||||
|       <Filter>Ducktape_GL</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="DGL_Space.hpp"> | ||||
|       <Filter>Ducktape_GL</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="Testing.hpp" /> | ||||
|     <ClInclude Include="Actions.hpp" /> | ||||
|     <ClInclude Include="DGL_Model.hpp"> | ||||
|       <Filter>Ducktape_GL</Filter> | ||||
|     </ClInclude> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="Execution.cpp" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Filter Include="Ducktape_GL"> | ||||
|       <UniqueIdentifier>{dffb88da-bab3-4079-8f08-9bb1e7475f9d}</UniqueIdentifier> | ||||
|     </Filter> | ||||
|     <Filter Include="Shaders"> | ||||
|       <UniqueIdentifier>{05484b5d-cbf0-49d7-a593-8fffa98fadb3}</UniqueIdentifier> | ||||
|     </Filter> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <None Include="3.3.shader.frag"> | ||||
|       <Filter>Shaders</Filter> | ||||
|     </None> | ||||
|     <None Include="3.3.shader.vert"> | ||||
|       <Filter>Shaders</Filter> | ||||
|     </None> | ||||
|     <None Include="5.1.transform.frag"> | ||||
|       <Filter>Shaders</Filter> | ||||
|     </None> | ||||
|     <None Include="5.1.transform.vert"> | ||||
|       <Filter>Shaders</Filter> | ||||
|     </None> | ||||
|     <None Include="6.3.coordinate_systems.frag"> | ||||
|       <Filter>Shaders</Filter> | ||||
|     </None> | ||||
|     <None Include="6.3.coordinate_systems.vert"> | ||||
|       <Filter>Shaders</Filter> | ||||
|     </None> | ||||
|     <None Include="SimpleFragmentShader.frag"> | ||||
|       <Filter>Shaders</Filter> | ||||
|     </None> | ||||
|     <None Include="SimpleTransform.vert"> | ||||
|       <Filter>Shaders</Filter> | ||||
|     </None> | ||||
|     <None Include="SimpleVertexShader.vert"> | ||||
|       <Filter>Shaders</Filter> | ||||
|     </None> | ||||
|     <None Include="SingleColor.frag"> | ||||
|       <Filter>Shaders</Filter> | ||||
|     </None> | ||||
|     <None Include="BasicLighting.frag"> | ||||
|       <Filter>Shaders</Filter> | ||||
|     </None> | ||||
|     <None Include="BasicLamp.frag"> | ||||
|       <Filter>Shaders</Filter> | ||||
|     </None> | ||||
|     <None Include="PhongShader.vert"> | ||||
|       <Filter>Shaders</Filter> | ||||
|     </None> | ||||
|     <None Include="PhongShader.frag"> | ||||
|       <Filter>Shaders</Filter> | ||||
|     </None> | ||||
|   </ItemGroup> | ||||
| </Project> | ||||
| @@ -1,6 +0,0 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||
|   <PropertyGroup> | ||||
|     <ShowAllFiles>false</ShowAllFiles> | ||||
|   </PropertyGroup> | ||||
| </Project> | ||||
| @@ -3,6 +3,7 @@ | ||||
| // OpenGL | ||||
| #include <glew.h                  > | ||||
| #include <glm/detail/type_vec3.hpp> | ||||
| #include <glm/detail/type_vec2.hpp> | ||||
|  | ||||
|  | ||||
| // Duck Tape | ||||
| @@ -19,6 +20,9 @@ namespace DGL | ||||
| 	{ | ||||
| 		template<typename Type> | ||||
| 		using Vector3 = glm::tvec3<Type>; | ||||
|  | ||||
| 		template<typename Type> | ||||
| 		using Vector2 = glm::tvec2<Type>; | ||||
| 	} | ||||
|  | ||||
| 	using DataPtr = ptr<GLvoid>; | ||||
| @@ -35,6 +39,7 @@ namespace DGL | ||||
| 	class Shader       ; | ||||
| 	class ShaderProgram; | ||||
| 	class VertexArray  ; | ||||
| 	class TextureBuffer; | ||||
| 	class ElementBuffer; | ||||
|  | ||||
|  | ||||
|   | ||||
							
								
								
									
										225
									
								
								DGL_Model.hpp
									
									
									
									
									
								
							
							
						
						
									
										225
									
								
								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<void>(_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<Face>; | ||||
|  | ||||
|  | ||||
|  | ||||
| 	struct FaceGenerator | ||||
| 	{ | ||||
| 		using ComponentList = std::vector< gUInt>; | ||||
| @@ -103,10 +117,13 @@ namespace DGL | ||||
| 			{ | ||||
| 				generated.Vertexes[index] = vertIndexes[index]; | ||||
|  | ||||
| 				if (index < 2) | ||||
| 				{ | ||||
| 					if (uvIndexes.size() > 0) | ||||
| 					{ | ||||
| 						//generated.UVs[index] = uvIndexes[index]; | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				if (normals.size() > 0) | ||||
| 				{ | ||||
| @@ -114,25 +131,23 @@ 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<VN>; | ||||
|  | ||||
| 		ID<VertexArray  > VAO; | ||||
| 		ID<VertexBuffer > VBO; | ||||
| 		ID<NormalBuffer > NBO; | ||||
| 		ID<TextureBuffer> TBO; | ||||
| 		ID<ElementBuffer> EBO; | ||||
|  | ||||
| 		const string FilePath; | ||||
| @@ -147,6 +162,8 @@ namespace DGL | ||||
| 		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; | ||||
|  | ||||
|  | ||||
| 			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<typename Type> | ||||
| 		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,50 +381,16 @@ 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<Vector3>(0, EDataType::Float, ZeroOffset(), 3, EBool::False); | ||||
|  | ||||
| 			EnableVertexAttributeArray(0); | ||||
|  | ||||
| 			FormatVertexAttributes<Vector3>(1, EDataType::Float, Offset(sizeof(Vector3)), 3, EBool::False); | ||||
|  | ||||
| 			EnableVertexAttributeArray(1);*/ | ||||
| 			 | ||||
| 			BindVertexArray(VAO); | ||||
|  | ||||
| 			BindBuffer(EBufferTarget::VertexAttributes, VBO); | ||||
| @@ -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<Vector2>(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()); | ||||
|  | ||||
|   | ||||
| @@ -488,10 +488,12 @@ namespace DGL | ||||
|  | ||||
| 			EnableVertexAttributeArray(0); | ||||
| 			EnableVertexAttributeArray(1); | ||||
| 			//EnableVertexAttributeArray(2); | ||||
| 		} | ||||
|  | ||||
| 		sfn Stop() | ||||
| 		{ | ||||
| 			//DisableVertexAttributeArray(2); | ||||
| 			DisableVertexAttributeArray(1); | ||||
| 			DisableVertexAttributeArray(0); | ||||
| 		} | ||||
|   | ||||
| @@ -386,7 +386,7 @@ namespace Execution | ||||
|  | ||||
| 		//RAW_RotateLitCube(PhysicsDelta); | ||||
|  | ||||
| 		RAW_LightRotate(PhysicsDelta); | ||||
| 		RAW_UpdateLightTransform(PhysicsDelta); | ||||
|  | ||||
| 		ProperCube::Rotate(PhysicsDelta); | ||||
|  | ||||
|   | ||||
| @@ -2,13 +2,11 @@ | ||||
|  | ||||
| out vec4 FragColor; | ||||
|  | ||||
|  | ||||
| in vec3 FragPosition     ; | ||||
| in vec3 Normal           ; | ||||
| in vec3 LightViewPosition; | ||||
| in vec3 LightRawPos      ; | ||||
|  | ||||
|  | ||||
| uniform vec3 ObjectColor; | ||||
| uniform vec3 LightColor  ; | ||||
| uniform vec3 ViewPosition; | ||||
| @@ -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);   | ||||
|  | ||||
|   | ||||
| @@ -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           ; | ||||
|   | ||||
							
								
								
									
										27
									
								
								Testing.hpp
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								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)); | ||||
|   | ||||
							
								
								
									
										46
									
								
								blenderCube.obj
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								blenderCube.obj
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
		Reference in New Issue
	
	Block a user