mirror of
https://github.com/Ed94/DuctTaped_GL.git
synced 2024-11-10 04:24:52 -08:00
Added lithium grease between pieces of blue tape for phong shader.
This commit is contained in:
parent
aa560c34b6
commit
ea17618c98
@ -194,7 +194,7 @@ namespace Actions
|
||||
using QueueType = std::deque< ptr<IAction>>;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
template<typename FunctionType, typename... ActionParams>
|
||||
sfn AddToQueue(Delegate< FunctionType> _actionToQueue, ActionParams... _paramsForAction)
|
||||
{
|
||||
@ -243,6 +243,8 @@ namespace Actions
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
QueueType actionQueue;
|
||||
};
|
||||
}
|
||||
|
175
CompGraphics.vcxproj
Normal file
175
CompGraphics.vcxproj
Normal file
@ -0,0 +1,175 @@
|
||||
<?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>
|
93
CompGraphics.vcxproj.filters
Normal file
93
CompGraphics.vcxproj.filters
Normal file
@ -0,0 +1,93 @@
|
||||
<?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>
|
6
CompGraphics.vcxproj.user
Normal file
6
CompGraphics.vcxproj.user
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>false</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@ -119,6 +119,10 @@ namespace DGL
|
||||
A = GLFW_KEY_A ,
|
||||
D = GLFW_KEY_D ,
|
||||
E = GLFW_KEY_E ,
|
||||
I = GLFW_KEY_I ,
|
||||
J = GLFW_KEY_J ,
|
||||
K = GLFW_KEY_K ,
|
||||
L = GLFW_KEY_L ,
|
||||
Q = GLFW_KEY_Q ,
|
||||
S = GLFW_KEY_S ,
|
||||
W = GLFW_KEY_W ,
|
||||
|
@ -29,7 +29,7 @@ namespace DGL
|
||||
// ID Reference Types
|
||||
|
||||
class VertexBuffer ;
|
||||
class NormalBuffer;
|
||||
class NormalBuffer ;
|
||||
class Vec3 ;
|
||||
class Matrix ;
|
||||
class Shader ;
|
||||
|
101
DGL_Model.hpp
101
DGL_Model.hpp
@ -63,33 +63,48 @@ namespace DGL
|
||||
}
|
||||
};
|
||||
|
||||
/*struct Face
|
||||
{
|
||||
VecInt Vertexes, UVs, Normals;
|
||||
};*/
|
||||
|
||||
struct Face
|
||||
{
|
||||
VecInt Vertexes, uvIndex, Normals;
|
||||
VecInt Vertexes, UVs, Normals;
|
||||
};
|
||||
|
||||
struct FaceVertexIndex
|
||||
{
|
||||
gUInt Vertex, UV, Normal;
|
||||
|
||||
FaceVertexIndex() : Vertex(0), UV(0), Normal(0) {};
|
||||
|
||||
FaceVertexIndex(gUInt _vertex, gUInt _uv, gUInt _norm) : Vertex(_vertex), UV(_uv), Normal(_norm) {};
|
||||
};
|
||||
|
||||
using VertexIndexList = Generic::Vector3<FaceVertexIndex>;
|
||||
|
||||
|
||||
// A face primitive is a triangle.
|
||||
//struct Face
|
||||
//{
|
||||
// //FaceVertexIndex Indicies[3];
|
||||
|
||||
// gInt Vertex[3], Normal[3], UV[3];
|
||||
//};
|
||||
|
||||
struct FaceGenerator
|
||||
{
|
||||
using ComponentList = std::vector< gInt>;
|
||||
using ComponentList = std::vector< gUInt>;
|
||||
|
||||
ComponentList vertIndexes, uvIndexes, normals;
|
||||
|
||||
sfn AddVertexIndex(gInt _index)
|
||||
sfn AddVertexIndex(gUInt _index)
|
||||
{
|
||||
vertIndexes.push_back(_index);
|
||||
}
|
||||
|
||||
sfn AddUVIndex(gInt _index)
|
||||
sfn AddUVIndex(gUInt _index)
|
||||
{
|
||||
uvIndexes.push_back(_index);
|
||||
}
|
||||
|
||||
sfn AddNormalIndex(gInt _index)
|
||||
sfn AddNormalIndex(gUInt _index)
|
||||
{
|
||||
normals.push_back(_index);
|
||||
}
|
||||
@ -98,35 +113,33 @@ namespace DGL
|
||||
{
|
||||
Face generated;
|
||||
|
||||
if (vertIndexes.size() != 0)
|
||||
for (int index = 0; index < 3; index++)
|
||||
{
|
||||
for (int index = 0; index < vertIndexes.size(); index++)
|
||||
generated.Vertexes[index] = vertIndexes[index];
|
||||
|
||||
if (uvIndexes.size() > 0)
|
||||
{
|
||||
generated.Vertexes[index] = vertIndexes.at(index);
|
||||
}
|
||||
}
|
||||
if (uvIndexes.size() != 0)
|
||||
{
|
||||
for (int index = 0; index < uvIndexes.size(); index++)
|
||||
{
|
||||
generated.uvIndex[index] = uvIndexes.at(index);
|
||||
}
|
||||
}
|
||||
if (normals.size() != 0)
|
||||
{
|
||||
for (int index = 0; index < normals.size(); index++)
|
||||
{
|
||||
generated.Normals[index] = normals.at(index);
|
||||
}
|
||||
generated.UVs[index] = uvIndexes[index];
|
||||
}
|
||||
|
||||
if (uvIndexes.size() == 0)
|
||||
if (normals.size() > 0)
|
||||
{
|
||||
generated.uvIndex = VecInt(0, 0, 0);
|
||||
generated.Normals[index] = normals[index];
|
||||
}
|
||||
if (normals.size() == 0)
|
||||
|
||||
|
||||
|
||||
/*generated.Vertex[index] = vertIndexes[index];
|
||||
|
||||
if (uvIndexes.size() > 0)
|
||||
{
|
||||
generated.Normals = VecInt(0, 0, 0);
|
||||
generated.UV[index] = uvIndexes[index];
|
||||
}
|
||||
|
||||
if (normals.size() > 0)
|
||||
{
|
||||
generated.Normal[index] = normals[index];
|
||||
}*/
|
||||
}
|
||||
|
||||
return generated;
|
||||
@ -225,7 +238,7 @@ namespace DGL
|
||||
|
||||
deduce processFace = [&](Ref(stringstream) _faceStream)
|
||||
{
|
||||
FaceGenerator faceMade; gInt vertexIndex, textureIndex, normalIndex;
|
||||
FaceGenerator faceMade; gUInt vertexIndex, textureIndex, normalIndex;
|
||||
|
||||
while (not _faceStream.eof())
|
||||
{
|
||||
@ -325,32 +338,28 @@ namespace DGL
|
||||
|
||||
BindVertexArray(VAO);
|
||||
|
||||
|
||||
|
||||
BindBuffer(EBufferTarget::VertexAttributes, VBO);
|
||||
|
||||
BufferData(Address(Verticies[0]), Verticies.size() * sizeof(Vector3), EBufferTarget::VertexAttributes, EBufferUsage::StaticDraw);
|
||||
|
||||
EnableVertexAttributeArray(0);
|
||||
|
||||
FormatVertexAttributes<Vector3>(0, EDataType::Float, ZeroOffset(), 3, EBool::False);
|
||||
|
||||
if (VertNormals.size() != 0)
|
||||
{
|
||||
BindBuffer(EBufferTarget::VertexAttributes, NBO);
|
||||
|
||||
BufferData(Address(VertNormals[0]), VertNormals.size() * sizeof(Vector3), EBufferTarget::VertexAttributes, EBufferUsage::StaticDraw);
|
||||
}
|
||||
|
||||
EnableVertexAttributeArray(1);
|
||||
|
||||
FormatVertexAttributes<Vector3>(1, EDataType::Float, ZeroOffset(), 3, EBool::False);
|
||||
}
|
||||
|
||||
BindBuffer(EBufferTarget::VertexIndices, EBO);
|
||||
|
||||
BufferData(Address(Faces[0]), Faces.size() * sizeof(Face), EBufferTarget::VertexIndices, EBufferUsage::StaticDraw);
|
||||
//BufferData(Address(Indicies[0]), Indicies.size() * sizeof(gUInt), EBufferTarget::VertexIndices, EBufferUsage::StaticDraw);
|
||||
|
||||
|
||||
|
||||
EnableVertexAttributeArray(0);
|
||||
FormatVertexAttributes<Vector3>(0, EDataType::Float, ZeroOffset(), 3, EBool::False);
|
||||
|
||||
/*EnableVertexAttributeArray(1);
|
||||
FormatVertexAttributes<gInt>(1, EDataType::Float, ZeroOffset(), 3, EBool::False);*/
|
||||
|
||||
BindVertexArray(0);
|
||||
}
|
||||
@ -363,7 +372,7 @@ namespace DGL
|
||||
|
||||
gInt Size; GetBufferParameterIV(EBufferTarget::VertexIndices, EBufferParam::Size, Address(Size));
|
||||
|
||||
Size /= sizeof(gFloat);
|
||||
Size /= sizeof(gInt);
|
||||
|
||||
DrawElements(EPrimitives::Triangles, Size, EDataType::UnsignedInt, ZeroOffset());
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
//DGL
|
||||
#include "DGL_Enum.hpp"
|
||||
#include "DGL_FundamentalTypes.hpp"
|
||||
#include "DGL_MiscTypes.hpp"
|
||||
#include "DGL_Enum.hpp"
|
||||
#include "DGL_Buffers.hpp"
|
||||
#include "DGL_Space.hpp"
|
||||
|
||||
|
||||
@ -384,7 +385,7 @@ namespace DGL
|
||||
LightColorID = GetUniformVariable(Shader, "LightColor" );
|
||||
}
|
||||
|
||||
sfn SetupRender(Ref(CoordSpace) _cubeTransform, Ref(Vector3) _objectColor, Ref(Vector3) _lightColor)
|
||||
sfn Use(Ref(CoordSpace) _cubeTransform, Ref(Vector3) _objectColor, Ref(Vector3) _lightColor)
|
||||
{
|
||||
UseProgramShader(Shader);
|
||||
|
||||
@ -392,6 +393,15 @@ namespace DGL
|
||||
|
||||
SetUniformVariable_Vector3(ObjectColorID, 1, Address(_objectColor[0]));
|
||||
SetUniformVariable_Vector3(LightColorID , 1, Address(_lightColor [0]));
|
||||
|
||||
EnableVertexAttributeArray(0);
|
||||
EnableVertexAttributeArray(1);
|
||||
}
|
||||
|
||||
sfn Stop()
|
||||
{
|
||||
DisableVertexAttributeArray(0);
|
||||
DisableVertexAttributeArray(1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -413,6 +423,15 @@ namespace DGL
|
||||
UseProgramShader(Shader);
|
||||
|
||||
SetUniformVariable_MVA(ScreenSpaceVarID, 1, EBool::False, Address(_lampTransform[0][0]));
|
||||
|
||||
EnableVertexAttributeArray(0);
|
||||
EnableVertexAttributeArray(1);
|
||||
}
|
||||
|
||||
sfn Stop()
|
||||
{
|
||||
DisableVertexAttributeArray(0);
|
||||
DisableVertexAttributeArray(1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -420,9 +439,9 @@ namespace DGL
|
||||
{
|
||||
ID<ShaderProgram> ShaderID;
|
||||
|
||||
ID<CoordSpace> ModelScreenSpaceID, ModelSpaceID;
|
||||
ID<CoordSpace> ModelSpaceID, InverseModelSpaceID, ViewportID, ProjectionID;
|
||||
|
||||
ID<Vec3> LightPositionID;
|
||||
ID<Vec3> LightPositionID, ViewPositionID;
|
||||
|
||||
ID<Vec3> ObjectColorID, LightColorID;
|
||||
|
||||
@ -430,32 +449,51 @@ namespace DGL
|
||||
{
|
||||
ShaderID = LoadShaders("PhongShader.vert", "PhongShader.frag");
|
||||
|
||||
ModelScreenSpaceID = GetUniformVariable(ShaderID, "ModelScreenSpace");
|
||||
InverseModelSpaceID = GetUniformVariable(ShaderID, "InverseModelSpace");
|
||||
ModelSpaceID = GetUniformVariable(ShaderID, "ModelSpace" );
|
||||
ProjectionID = GetUniformVariable(ShaderID, "Projection" );
|
||||
ViewportID = GetUniformVariable(ShaderID, "Viewport" );
|
||||
|
||||
ObjectColorID = GetUniformVariable(ShaderID, "ObjectColor" );
|
||||
LightColorID = GetUniformVariable(ShaderID, "LightColor" );
|
||||
LightPositionID = GetUniformVariable(ShaderID, "LightPositionID");
|
||||
LightPositionID = GetUniformVariable(ShaderID, "LightPosition");
|
||||
ViewPositionID = GetUniformVariable(ShaderID, "ViewPosition" );
|
||||
}
|
||||
|
||||
sfn SetupRender
|
||||
(
|
||||
Ref(CoordSpace) _screenSapceTransform,
|
||||
Ref(CoordSpace) _projection ,
|
||||
Ref(CoordSpace) _viewport ,
|
||||
Ref(CoordSpace) _objectTransform ,
|
||||
Ref(Vector3 ) _objectColor ,
|
||||
Ref(Vector3 ) _lightPosition ,
|
||||
Ref(Vector3 ) _lightColor
|
||||
Ref(Vector3 ) _lightColor ,
|
||||
Ref(Vector3 ) _viewPosition
|
||||
)
|
||||
{
|
||||
CoordSpace inverseTransform = Inverse(_objectTransform);
|
||||
|
||||
UseProgramShader(ShaderID);
|
||||
|
||||
SetUniformVariable_MVA(ModelScreenSpaceID, 1, EBool::False, Address(_screenSapceTransform[0][0]));
|
||||
SetUniformVariable_MVA(ModelSpaceID , 1, EBool::False, Address(_objectTransform [0][0]));
|
||||
SetUniformVariable_MVA(InverseModelSpaceID, 1, EBool::False, Address(inverseTransform[0][0]));
|
||||
SetUniformVariable_MVA(ModelSpaceID , 1, EBool::False, Address(_objectTransform[0][0]));
|
||||
SetUniformVariable_MVA(ProjectionID , 1, EBool::False, Address(_projection [0][0]));
|
||||
SetUniformVariable_MVA(ViewportID , 1, EBool::False, Address(_viewport [0][0]));
|
||||
|
||||
SetUniformVariable_Vector3(LightPositionID, 1, Address(_lightPosition[0]));
|
||||
|
||||
SetUniformVariable_Vector3(ObjectColorID, 1, Address(_objectColor[0]));
|
||||
SetUniformVariable_Vector3(ObjectColorID , 1, Address(_objectColor [0]));
|
||||
SetUniformVariable_Vector3(LightColorID , 1, Address(_lightColor [0]));
|
||||
SetUniformVariable_Vector3(ViewPositionID, 1, Address(_viewPosition[0]));
|
||||
|
||||
EnableVertexAttributeArray(0);
|
||||
EnableVertexAttributeArray(1);
|
||||
}
|
||||
|
||||
sfn Stop()
|
||||
{
|
||||
DisableVertexAttributeArray(1);
|
||||
DisableVertexAttributeArray(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,11 @@ namespace DGL
|
||||
return glm::normalize(_vectorSpecified);
|
||||
}
|
||||
|
||||
sfn Inverse(const Matrix4x4 _matrix)
|
||||
{
|
||||
return glm::inverse(_matrix);
|
||||
}
|
||||
|
||||
sfn Rotate(const Matrix4x4 _matrix, gFloat _rotationAngleAmount, Vector3 _axis) -> Matrix4x4
|
||||
{
|
||||
return glm::rotate(_matrix, _rotationAngleAmount, _axis);
|
||||
|
@ -88,6 +88,8 @@ namespace Execution
|
||||
|
||||
double CursorX, CursorY; // Cursor axis position on the window.
|
||||
|
||||
bool CursorOff = true;
|
||||
|
||||
gFloat CamMoveSpeed = 8.0f, // Rate at which the camera should move.
|
||||
CamRotationSpeed = 27.0f ; // Rate at which the camera should rotate.
|
||||
|
||||
@ -199,7 +201,10 @@ namespace Execution
|
||||
|
||||
_inputProcedure(DefaultWindow);
|
||||
|
||||
if (CursorOff)
|
||||
{
|
||||
ResetCursor(DefaultWindow, ScreenCenterWidth, ScreenCenterHeight);
|
||||
}
|
||||
|
||||
InputDelta = 0.0;
|
||||
}
|
||||
@ -269,11 +274,15 @@ namespace Execution
|
||||
{
|
||||
ActionsToComplete.AddToQueue(delegate , _currentWindowContext, EMouseMode::Cursor , ECursorMode::Disable);
|
||||
ActionsToComplete.AddToQueue(delegateRaw, _currentWindowContext, EMouseMode::RawMouse, EBool ::True );
|
||||
|
||||
CursorOff = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ActionsToComplete.AddToQueue(delegate , _currentWindowContext, EMouseMode::Cursor , ECursorMode::Normal);
|
||||
ActionsToComplete.AddToQueue(delegateRaw, _currentWindowContext, EMouseMode::RawMouse, EBool ::False );
|
||||
|
||||
CursorOff = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,6 +306,8 @@ namespace Execution
|
||||
ActionsToComplete.AddToQueue(SetPolyModeDelegate, DGL::EFace::Front_and_Back, DGL::ERenderMode::Fill);
|
||||
}
|
||||
|
||||
if (CursorOff)
|
||||
{
|
||||
if (CursorX != 0)
|
||||
{
|
||||
ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Yaw, CursorX * CamRotationSpeed, PhysicsDelta);
|
||||
@ -306,6 +317,7 @@ namespace Execution
|
||||
{
|
||||
ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Pitch, CursorY * CamRotationSpeed, PhysicsDelta);
|
||||
}
|
||||
}
|
||||
|
||||
if (KeyPressed(_currentWindowContext, EKeyCodes::E))
|
||||
{
|
||||
@ -336,6 +348,26 @@ namespace Execution
|
||||
{
|
||||
ActionsToComplete.AddToQueue(MoveCamDelegate, EDirection::Backward, CamMoveSpeed, PhysicsDelta);
|
||||
}
|
||||
|
||||
if (KeyPressed(_currentWindowContext, EKeyCodes::I))
|
||||
{
|
||||
ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Pitch, -6.0f * CamRotationSpeed, PhysicsDelta);
|
||||
}
|
||||
|
||||
if (KeyPressed(_currentWindowContext, EKeyCodes::K))
|
||||
{
|
||||
ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Pitch, 6.0f * CamRotationSpeed, PhysicsDelta);
|
||||
}
|
||||
|
||||
if (KeyPressed(_currentWindowContext, EKeyCodes::J))
|
||||
{
|
||||
ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Yaw, -6.0f * CamRotationSpeed, PhysicsDelta);
|
||||
}
|
||||
|
||||
if (KeyPressed(_currentWindowContext, EKeyCodes::L))
|
||||
{
|
||||
ActionsToComplete.AddToQueue(RotateCamDelegate, ERotationAxis::Yaw, 6.0f * CamRotationSpeed, PhysicsDelta);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -360,6 +392,8 @@ namespace Execution
|
||||
|
||||
//RAW_RotateLitCube(PhysicsDelta);
|
||||
|
||||
RAW_LightRotate(PhysicsDelta);
|
||||
|
||||
ProperCube::Rotate(PhysicsDelta);
|
||||
|
||||
UpdateThisShit();
|
||||
@ -371,27 +405,9 @@ namespace Execution
|
||||
{
|
||||
glfwSetWindowTitle(DefaultWindow, somethingtoupdate.str().c_str());
|
||||
|
||||
EnableVertexAttributeArray(VertexAttributeIndex);
|
||||
|
||||
EnableVertexAttributeArray(1);
|
||||
|
||||
|
||||
//UseProgramShader(DGL::SS_Transformed::Shader);
|
||||
|
||||
//BindVertexArray(VertexArrayObj);
|
||||
|
||||
//DrawElements(EPrimitives::Triangles, 6, EDataType::UnsignedInt, ZeroOffset());
|
||||
|
||||
RAW_RenderLight(WorldCamera.Perspective, WorldCamera.Viewport);
|
||||
|
||||
|
||||
//RAW_RenderLitCube(WorldCamera.Perspective, WorldCamera.Viewport);
|
||||
|
||||
ProperCube::Render(WorldCamera.Perspective, WorldCamera.Viewport);
|
||||
|
||||
DisableVertexAttributeArray(VertexAttributeIndex);
|
||||
|
||||
DisableVertexAttributeArray(1);
|
||||
ProperCube::Render(WorldCamera.Perspective, WorldCamera.Viewport, WorldCamera.Position);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,32 +3,45 @@
|
||||
out vec4 FragColor;
|
||||
|
||||
|
||||
//in vec3 FragPosition;
|
||||
//in vec3 Normal ;
|
||||
in vec3 FragPosition;
|
||||
in vec3 Normal ;
|
||||
|
||||
|
||||
|
||||
uniform vec3 ObjectColor;
|
||||
|
||||
|
||||
//uniform vec3 LightPosition;
|
||||
uniform vec3 LightPosition;
|
||||
uniform vec3 LightColor ;
|
||||
|
||||
uniform vec3 ViewPosition;
|
||||
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
float AmbientStrength = 0.1;
|
||||
float SpecularStrength = 0.5;
|
||||
|
||||
vec3 ambient = AmbientStrength * LightColor ;
|
||||
|
||||
// vec3 Direction = normalize(Normal );
|
||||
// vec3 LightDirection = normalize(LightPosition - FragPosition);
|
||||
//
|
||||
// float DiffuseStrength = max(dot(Normal, LightDirection), 0.0);
|
||||
// vec3 diffuse = DiffuseStrength * LightColor ;
|
||||
vec3 Direction = normalize(Normal );
|
||||
vec3 LightDirection = normalize(LightPosition - FragPosition);
|
||||
|
||||
vec3 result = (ambient ) * ObjectColor;
|
||||
float DiffuseStrength = max(dot(Normal, LightDirection), 0.0);
|
||||
|
||||
vec3 diffuse = DiffuseStrength * LightColor ;
|
||||
|
||||
vec3 ViewDirection = normalize(ViewPosition - FragPosition);
|
||||
|
||||
vec3 ReflectionDirection = reflect(-LightDirection, Normal);
|
||||
|
||||
float Spec = pow(max(dot(ViewDirection, ReflectionDirection), 0.0), 32);
|
||||
|
||||
vec3 specular = SpecularStrength * Spec * LightColor;
|
||||
|
||||
vec3 result = (ambient + diffuse + specular) * ObjectColor;
|
||||
|
||||
FragColor = vec4(result, 1.0);
|
||||
|
||||
}
|
@ -1,26 +1,25 @@
|
||||
#version 330 core
|
||||
|
||||
layout (location = 0) in vec3 VertPosition;
|
||||
//layout (location = 1) in vec3 VertNormal ;
|
||||
layout (location = 1) in vec3 VertNormal ;
|
||||
|
||||
out vec3 FragPosition;
|
||||
out vec3 Normal ;
|
||||
|
||||
|
||||
//out vec3 FragPosition;
|
||||
//out vec3 Normal ;
|
||||
|
||||
|
||||
|
||||
uniform mat4 ModelScreenSpace ;
|
||||
uniform mat4 ModelSpace ;
|
||||
uniform mat4 Viewport ;
|
||||
uniform mat4 Projection ;
|
||||
|
||||
uniform mat4 InverseModelSpace;
|
||||
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ModelScreenSpace * vec4(VertPosition, 1.0);
|
||||
FragPosition = vec3(ModelSpace * vec4(VertPosition, 1.0));
|
||||
|
||||
// FragPosition = vec3(ModelSpace * vec4(VertPosition, 1.0));
|
||||
Normal = mat3(transpose(InverseModelSpace)) * VertNormal;
|
||||
// Normal = VertNormal;
|
||||
|
||||
// Normal = mat3(transpose(InverseModelSpace));
|
||||
gl_Position = Projection * Viewport * ModelSpace * vec4(FragPosition, 1.0);
|
||||
}
|
69
Testing.hpp
69
Testing.hpp
@ -370,7 +370,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, 1.0f, 2.0f);
|
||||
Vector3 LightPosition(1.2f, 2.0f, 3.0f);
|
||||
|
||||
Vector3 LightScale = Vector3(0.2f);
|
||||
|
||||
@ -397,6 +397,40 @@ sfn RAW_MakeLightVAO()
|
||||
LightTransform = DGL::Scale (LightTransform, LightScale );
|
||||
}
|
||||
|
||||
sfn RAW_LightRotate(gFloat _delta)
|
||||
{
|
||||
//LightTransform = DGL::Rotate(LightTransform, 0.1f, Vector3(1, 0, 0));
|
||||
|
||||
static bool test = true;
|
||||
|
||||
LightTransform = CoordSpace(1.0f);
|
||||
|
||||
if (test)
|
||||
{
|
||||
LightPosition.x += 0.001f + _delta;
|
||||
|
||||
if (LightPosition.x > 4)
|
||||
{
|
||||
test = false;
|
||||
}
|
||||
|
||||
LightTransform = DGL::Translate(LightTransform, LightPosition);
|
||||
LightTransform = DGL::Scale (LightTransform, LightScale );
|
||||
}
|
||||
else
|
||||
{
|
||||
LightPosition.x -= 0.001f + _delta;
|
||||
|
||||
if (LightPosition.x < -4)
|
||||
{
|
||||
test = true;
|
||||
}
|
||||
|
||||
LightTransform = DGL::Translate(LightTransform, LightPosition);
|
||||
LightTransform = DGL::Scale (LightTransform, LightScale );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
using DGL::GetBufferParameterIV;
|
||||
|
||||
@ -409,6 +443,8 @@ sfn RAW_RenderLight(CoordSpace _projection, CoordSpace _viewport)
|
||||
DGL::BindVertexArray(LightVAO);
|
||||
|
||||
RAW_RenderCube();
|
||||
|
||||
DGL::Basic_LampShader::Stop();
|
||||
}
|
||||
|
||||
|
||||
@ -448,7 +484,7 @@ sfn RAW_RenderLitCube(CoordSpace _projection, CoordSpace _viewport)
|
||||
|
||||
Vector3 lightColor = LightColor.Vector();
|
||||
|
||||
DGL::PhongShader::SetupRender(screenspaceTransform, LitCubeTransform, CubeColor, LightPosition, lightColor);
|
||||
//DGL::PhongShader::SetupRender(screenspaceTransform, LitCubeTransform, CubeColor, LightPosition, lightColor);
|
||||
|
||||
DGL::BindVertexArray(LitCubeVAO);
|
||||
|
||||
@ -459,7 +495,7 @@ sfn RAW_RenderLitCube(CoordSpace _projection, CoordSpace _viewport)
|
||||
|
||||
namespace ProperCube
|
||||
{
|
||||
Model model("cube.obj");
|
||||
Model model("Cube.obj");
|
||||
|
||||
Vector3 position = Vector3(0.0f);
|
||||
|
||||
@ -469,20 +505,33 @@ namespace ProperCube
|
||||
|
||||
sfn Rotate(gFloat _delta)
|
||||
{
|
||||
transform = DGL::Rotate(transform, 3.5f * _delta, Vector3(0, 1, 0));
|
||||
//transform = DGL::Rotate(transform, 1.5f * _delta, Vector3(0, 1, 0));
|
||||
}
|
||||
|
||||
sfn Render(Ref(CoordSpace) _projection, Ref(CoordSpace) _viewport)
|
||||
sfn Render(Ref(CoordSpace) _projection, Ref(CoordSpace) _viewport, Ref(Vector3) _cameraPosition)
|
||||
{
|
||||
CoordSpace screenspaceTransform = _projection * _viewport * transform;
|
||||
|
||||
Vector3 lightColor = LightColor.Vector();
|
||||
|
||||
//DGL::PhongShader::SetupRender(screenspaceTransform, transform, color, LightPosition, lightColor);
|
||||
DGL::PhongShader::SetupRender
|
||||
(
|
||||
_projection ,
|
||||
_viewport ,
|
||||
transform ,
|
||||
color ,
|
||||
LightPosition ,
|
||||
lightColor ,
|
||||
_cameraPosition
|
||||
);
|
||||
|
||||
DGL::Basic_LightingShader::SetupRender(screenspaceTransform, color, lightColor);
|
||||
//DGL::Basic_LightingShader::Use(screenspaceTransform, color, lightColor);
|
||||
|
||||
model.Render();
|
||||
|
||||
DGL::Basic_LightingShader::Stop();
|
||||
|
||||
DGL::PhongShader::Stop();
|
||||
}
|
||||
|
||||
sfn Setup()
|
||||
@ -496,9 +545,3 @@ namespace ProperCube
|
||||
//transform = DGL::Scale(transform, Vector3(0.01));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user