create visual studio project, add Windows initialization code
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,6 @@
|
|||||||
xcuserdata
|
xcuserdata
|
||||||
libs
|
libs
|
||||||
|
|
||||||
|
x64/
|
||||||
|
.vs/
|
||||||
|
engine.vcxproj.user
|
||||||
|
|||||||
28
engine.sln
Normal file
28
engine.sln
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 14
|
||||||
|
VisualStudioVersion = 14.0.25420.1
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "engine", "engine.vcxproj", "{6D5028CE-4D76-4B6A-A7C2-DE5A3268D433}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{6D5028CE-4D76-4B6A-A7C2-DE5A3268D433}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{6D5028CE-4D76-4B6A-A7C2-DE5A3268D433}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{6D5028CE-4D76-4B6A-A7C2-DE5A3268D433}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{6D5028CE-4D76-4B6A-A7C2-DE5A3268D433}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{6D5028CE-4D76-4B6A-A7C2-DE5A3268D433}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{6D5028CE-4D76-4B6A-A7C2-DE5A3268D433}.Release|x64.Build.0 = Release|x64
|
||||||
|
{6D5028CE-4D76-4B6A-A7C2-DE5A3268D433}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{6D5028CE-4D76-4B6A-A7C2-DE5A3268D433}.Release|x86.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
177
engine.vcxproj
Normal file
177
engine.vcxproj
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="14.0" 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>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{6D5028CE-4D76-4B6A-A7C2-DE5A3268D433}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>engine</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</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'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IncludePath>libs\glm;libs\glew-2.0.0\include;libs\stb;$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>libs\glew-2.0.0\lib\Release\$(Platform);$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IncludePath>libs\glm;libs\glew-2.0.0\include;libs\stb;$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>libs\glew-2.0.0\lib\Release\$(Platform);$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IncludePath>libs\glm;libs\glew-2.0.0\include;libs\stb;$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>libs\glew-2.0.0\lib\Release\$(Platform);$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IncludePath>libs\glm;libs\glew-2.0.0\include;libs\stb;$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>libs\glew-2.0.0\lib\Release\$(Platform);$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="engine\app.cpp" />
|
||||||
|
<ClCompile Include="engine\image.cpp" />
|
||||||
|
<ClCompile Include="engine\main.cpp" />
|
||||||
|
<ClCompile Include="engine\pch.cpp">
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="engine\shader.cpp" />
|
||||||
|
<ClCompile Include="engine\shape.cpp" />
|
||||||
|
<ClCompile Include="engine\texture.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="engine\app.hpp" />
|
||||||
|
<ClInclude Include="engine\image.hpp" />
|
||||||
|
<ClInclude Include="engine\pch.h" />
|
||||||
|
<ClInclude Include="engine\shader.hpp" />
|
||||||
|
<ClInclude Include="engine\shape.hpp" />
|
||||||
|
<ClInclude Include="engine\texture.hpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
60
engine.vcxproj.filters
Normal file
60
engine.vcxproj.filters
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="engine\app.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="engine\image.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="engine\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="engine\shader.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="engine\shape.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="engine\texture.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="engine\pch.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="engine\app.hpp">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="engine\image.hpp">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="engine\pch.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="engine\shader.hpp">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="engine\shape.hpp">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="engine\texture.hpp">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@@ -58,7 +58,7 @@ void App::init()
|
|||||||
circle.create<10>(25, Circle::kUVMapping::Tube);
|
circle.create<10>(25, Circle::kUVMapping::Tube);
|
||||||
circle2.create<10>(25, 12, Circle::kUVMapping::Tube);
|
circle2.create<10>(25, 12, Circle::kUVMapping::Tube);
|
||||||
rounded.create<3>(50, 50, 10);
|
rounded.create<3>(50, 50, 10);
|
||||||
slice.create(50, 50, 10, .3);
|
slice.create(50, 50, 10, .3f);
|
||||||
if (!tex.load("data/uvs.jpg"))
|
if (!tex.load("data/uvs.jpg"))
|
||||||
printf("error loading image\n");
|
printf("error loading image\n");
|
||||||
|
|
||||||
@@ -66,15 +66,15 @@ void App::init()
|
|||||||
glEnable(GL_TEXTURE);
|
glEnable(GL_TEXTURE);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glPointSize(5);
|
glPointSize(5);
|
||||||
glLineWidth(15);
|
glLineWidth(1);
|
||||||
|
|
||||||
int n;
|
//int n;
|
||||||
glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
//glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
||||||
for (int i = 0; i < n; i++)
|
//for (int i = 0; i < n; i++)
|
||||||
{
|
//{
|
||||||
const unsigned char* s = glGetStringi(GL_EXTENSIONS, i);
|
// const unsigned char* s = glGetStringi(GL_EXTENSIONS, i);
|
||||||
printf("GL ext %03d: %s\n", i, s);
|
// printf("GL ext %03d: %s\n", i, s);
|
||||||
}
|
//}
|
||||||
printf("GL version: %s\n", glGetString(GL_VERSION));
|
printf("GL version: %s\n", glGetString(GL_VERSION));
|
||||||
printf("GL vendor: %s\n", glGetString(GL_VENDOR));
|
printf("GL vendor: %s\n", glGetString(GL_VENDOR));
|
||||||
printf("GL renderer: %s\n", glGetString(GL_RENDERER));
|
printf("GL renderer: %s\n", glGetString(GL_RENDERER));
|
||||||
@@ -94,7 +94,7 @@ void App::update(float dt)
|
|||||||
// glm::mat4 model = glm::translate(glm::vec3(0, 0, 0));
|
// glm::mat4 model = glm::translate(glm::vec3(0, 0, 0));
|
||||||
// glm::mat4 view = glm::lookAt(glm::vec3(sinf(theta), 0, 1), glm::vec3(0, 0, 0), glm::vec3(0, 1, 0));
|
// glm::mat4 view = glm::lookAt(glm::vec3(sinf(theta), 0, 1), glm::vec3(0, 0, 0), glm::vec3(0, 1, 0));
|
||||||
|
|
||||||
glm::mat4 proj = glm::ortho<float>(0, width, height, 0, -1, 1);
|
glm::mat4 proj = glm::ortho(0.f, (float)width, (float)height, 0.f, -1.f, 1.f);
|
||||||
|
|
||||||
Shape* shapes[] = { &circle, &circle2, &plane, &rounded, &slice };
|
Shape* shapes[] = { &circle, &circle2, &plane, &rounded, &slice };
|
||||||
|
|
||||||
@@ -115,11 +115,11 @@ void App::update(float dt)
|
|||||||
tex.unbind();
|
tex.unbind();
|
||||||
|
|
||||||
shader_color.use();
|
shader_color.use();
|
||||||
shader.u_mat4("mvp", proj * glm::translate(glm::vec3{75 + 120 * 2, 75 + 120 * i, 0.f}) * s);
|
shader_color.u_mat4("mvp", proj * glm::translate(glm::vec3{75 + 120 * 2, 75 + 120 * i, 0.f}) * s);
|
||||||
shader_color.u_vec4("col", {1, 1, 1, 1});
|
shader_color.u_vec4("col", {1, 1, 1, 1});
|
||||||
shapes[i]->draw_stroke();
|
shapes[i]->draw_stroke();
|
||||||
|
|
||||||
shader.u_mat4("mvp", proj * glm::translate(glm::vec3{75 + 120 * 0, 75 + 120 * i, 0.f}) * s);
|
shader_color.u_mat4("mvp", proj * glm::translate(glm::vec3{75 + 120 * 0, 75 + 120 * i, 0.f}) * s);
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
shapes[i]->draw_fill();
|
shapes[i]->draw_fill();
|
||||||
|
|
||||||
|
|||||||
156
engine/main.cpp
156
engine/main.cpp
@@ -5,6 +5,7 @@
|
|||||||
#include "image.hpp"
|
#include "image.hpp"
|
||||||
#include "app.hpp"
|
#include "app.hpp"
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
#include <CoreFoundation/CoreFoundation.h>
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
#include <Cocoa/Cocoa.h>
|
#include <Cocoa/Cocoa.h>
|
||||||
#include <CoreVideo/CoreVideo.h>
|
#include <CoreVideo/CoreVideo.h>
|
||||||
@@ -189,3 +190,158 @@ int main(int argc, const char * argv[])
|
|||||||
[app run];
|
[app run];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
#pragma comment (lib, "opengl32.lib")
|
||||||
|
#pragma comment (lib, "glew32.lib")
|
||||||
|
|
||||||
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
|
||||||
|
HINSTANCE hInst;
|
||||||
|
HWND hWnd;
|
||||||
|
HDC hDC;
|
||||||
|
HGLRC hRC;
|
||||||
|
char *className;
|
||||||
|
bool keys[256];
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
WNDCLASSA wc;
|
||||||
|
PIXELFORMATDESCRIPTOR pfd;
|
||||||
|
|
||||||
|
App::I.create();
|
||||||
|
RECT clientRect = { 0, 0, App::I.width, App::I.height };
|
||||||
|
|
||||||
|
// Inizialize data structures to zero
|
||||||
|
memset(&wc, 0, sizeof(wc));
|
||||||
|
memset(&keys, 0, sizeof(keys));
|
||||||
|
memset(&pfd, 0, sizeof(pfd));
|
||||||
|
|
||||||
|
// Create the main window
|
||||||
|
|
||||||
|
hInst = GetModuleHandle(NULL);
|
||||||
|
className = "DrosophilaMain";
|
||||||
|
|
||||||
|
wc.hInstance = hInst;
|
||||||
|
wc.lpfnWndProc = (WNDPROC)WndProc;
|
||||||
|
wc.lpszClassName = className;
|
||||||
|
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
|
||||||
|
|
||||||
|
RegisterClassA(&wc);
|
||||||
|
|
||||||
|
AdjustWindowRect(&clientRect, WS_OVERLAPPEDWINDOW, false);
|
||||||
|
hWnd = CreateWindowA(wc.lpszClassName, "New Engine", WS_OVERLAPPEDWINDOW,
|
||||||
|
CW_USEDEFAULT, CW_USEDEFAULT, clientRect.right - clientRect.left,
|
||||||
|
clientRect.bottom - clientRect.top, 0, 0, hInst, 0);
|
||||||
|
ShowWindow(hWnd, SW_NORMAL);
|
||||||
|
|
||||||
|
// Setup GL Rendering Context
|
||||||
|
pfd.nSize = sizeof(pfd);
|
||||||
|
pfd.nVersion = 1;
|
||||||
|
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
||||||
|
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||||
|
pfd.cColorBits = 32;
|
||||||
|
pfd.cDepthBits = 16;
|
||||||
|
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||||
|
|
||||||
|
hDC = GetDC(hWnd);
|
||||||
|
int pxfmt = ChoosePixelFormat(hDC, &pfd);
|
||||||
|
SetPixelFormat(hDC, pxfmt, &pfd);
|
||||||
|
hRC = wglCreateContext(hDC); // Create OpenGL 2.1 or less
|
||||||
|
wglMakeCurrent(hDC, hRC);
|
||||||
|
|
||||||
|
// Initialize extensions
|
||||||
|
if (glewInit() != GLEW_OK)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
printf("GL version: %s\n", glGetString(GL_VERSION));
|
||||||
|
printf("GL vendor: %s\n", glGetString(GL_VENDOR));
|
||||||
|
printf("GL renderer: %s\n", glGetString(GL_RENDERER));
|
||||||
|
|
||||||
|
// If supported create a 3.1 context
|
||||||
|
if (wglewIsSupported("WGL_ARB_create_context"))
|
||||||
|
{
|
||||||
|
int attribs[] =
|
||||||
|
{
|
||||||
|
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||||
|
WGL_CONTEXT_MINOR_VERSION_ARB, 1,
|
||||||
|
WGL_CONTEXT_FLAGS_ARB, 0,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
auto oldContext = hRC;
|
||||||
|
hRC = wglCreateContextAttribsARB(hDC, NULL, attribs);
|
||||||
|
wglMakeCurrent(NULL, NULL);
|
||||||
|
wglDeleteContext(oldContext);
|
||||||
|
wglMakeCurrent(hDC, hRC);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If not supported, go fuck yourself we are not gonna use that shit
|
||||||
|
return -1; // A negative number because you are a negative one
|
||||||
|
}
|
||||||
|
|
||||||
|
App::I.init();
|
||||||
|
|
||||||
|
MSG msg;
|
||||||
|
bool running = true;
|
||||||
|
unsigned long t0 = GetTickCount();
|
||||||
|
unsigned long t1;
|
||||||
|
while (running)
|
||||||
|
{
|
||||||
|
// If there any message in the queue process it
|
||||||
|
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
|
||||||
|
{
|
||||||
|
running = !(msg.message == WM_QUIT/* || gl.keys[VK_ESCAPE]*/);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
}
|
||||||
|
else // Otherwise render next frame
|
||||||
|
{
|
||||||
|
t1 = GetTickCount();
|
||||||
|
float dt = (float)(t1 - t0) / 1000.0f;
|
||||||
|
if (dt > 1.0f / 60.0f)
|
||||||
|
{
|
||||||
|
App::I.update((float)(t1 - t0) / 1000.0f);
|
||||||
|
t0 = t1;
|
||||||
|
SwapBuffers(hDC);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Sleep((DWORD)(1.0f / 60.0f * 1000.f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean up
|
||||||
|
DestroyWindow(hWnd);
|
||||||
|
UnregisterClassA(className, hInst);
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||||
|
{
|
||||||
|
switch (msg)
|
||||||
|
{
|
||||||
|
case WM_CLOSE:
|
||||||
|
PostQuitMessage(0);
|
||||||
|
break;
|
||||||
|
case WM_KEYDOWN:
|
||||||
|
keys[wp] = true;
|
||||||
|
break;
|
||||||
|
case WM_KEYUP:
|
||||||
|
keys[wp] = false;
|
||||||
|
break;
|
||||||
|
case WM_MOUSEMOVE:
|
||||||
|
//current->pointerMove(LOWORD(lp), HIWORD(lp));
|
||||||
|
break;
|
||||||
|
case WM_LBUTTONDOWN:
|
||||||
|
//current->pointerDown(LOWORD(lp), HIWORD(lp));
|
||||||
|
break;
|
||||||
|
case WM_LBUTTONUP:
|
||||||
|
//current->pointerUp(LOWORD(lp), HIWORD(lp));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return DefWindowProc(hWnd, msg, wp, lp);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
1
engine/pch.cpp
Normal file
1
engine/pch.cpp
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#include "pch.h"
|
||||||
24
engine/pch.h
24
engine/pch.h
@@ -1,17 +1,27 @@
|
|||||||
#ifndef pch_h
|
#pragma once
|
||||||
#define pch_h
|
|
||||||
|
|
||||||
#include <OpenGL/gl.h>
|
#ifdef __APPLE__
|
||||||
#include <OpenGL/gl3.h>
|
#include <OpenGL/gl.h>
|
||||||
|
#include <OpenGL/gl3.h>
|
||||||
|
#elif _WIN32
|
||||||
|
#define _USE_MATH_DEFINES
|
||||||
|
#include <windows.h>
|
||||||
|
#include <gl\glew.h>
|
||||||
|
#include <gl\wglew.h>
|
||||||
|
#include <gl\GL.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
#define GLM_FORCE_RADIANS
|
||||||
#define GLM_SWIZZLE
|
#define GLM_FORCE_SWIZZLE
|
||||||
|
#define GLM_FORCE_MESSAGES
|
||||||
|
#define GLM_ENABLE_EXPERIMENTAL
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
#include <glm/gtx/rotate_vector.hpp>
|
#include <glm/gtx/rotate_vector.hpp>
|
||||||
#include <glm/gtx/euler_angles.hpp>
|
#include <glm/gtx/euler_angles.hpp>
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ void Circle::create_impl(float radius, int div, GLushort* idx, vertex_t* vertice
|
|||||||
for (int i = 0; i < div; i++)
|
for (int i = 0; i < div; i++)
|
||||||
{
|
{
|
||||||
vertex_t v;
|
vertex_t v;
|
||||||
float theta = (float)i / div * M_PI * 2.f;
|
float theta = (float)i / div * (float)M_PI * 2.f;
|
||||||
glm::vec2 uv = { sinf(theta), cosf(theta) };
|
glm::vec2 uv = { sinf(theta), cosf(theta) };
|
||||||
v.pos = glm::vec4(uv * radius, 0, 1);
|
v.pos = glm::vec4(uv * radius, 0, 1);
|
||||||
v.uvs = (map == kUVMapping::Planar) ? (uv * 0.5f + 0.5f) : glm::vec2((float)i / div, 1.f);
|
v.uvs = (map == kUVMapping::Planar) ? (uv * 0.5f + 0.5f) : glm::vec2((float)i / div, 1.f);
|
||||||
@@ -134,7 +134,7 @@ void Circle::create_impl(float radius_out, float radius_in, int div, GLushort* i
|
|||||||
auto pidx2 = idx + count[0];
|
auto pidx2 = idx + count[0];
|
||||||
for (int i = 0; i < div; i++)
|
for (int i = 0; i < div; i++)
|
||||||
{
|
{
|
||||||
float theta = (float)(i%(div-1)) / (div-1) * M_PI * 2.f;
|
float theta = (float)(i%(div-1)) / (div-1) * (float)M_PI * 2.f;
|
||||||
glm::vec2 uv = { sinf(theta), cosf(theta) };
|
glm::vec2 uv = { sinf(theta), cosf(theta) };
|
||||||
if (map == kUVMapping::Planar)
|
if (map == kUVMapping::Planar)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user