This repository has been archived by the owner. It is now read-only.
Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Adding GLTSF (somewhat based on SFML, no actual TSF code yet)
- Loading branch information
Showing
with
722 additions
and 0 deletions.
- +20 −0 EXCLUDE/GLTSF/GLTSF.sln
- +97 −0 EXCLUDE/GLTSF/GLTSF.vcxproj
- +45 −0 EXCLUDE/GLTSF/GLTSF.vcxproj.filters
- +26 −0 EXCLUDE/GLTSF/include/App.hpp
- +30 −0 EXCLUDE/GLTSF/include/Video_Mode.hpp
- +55 −0 EXCLUDE/GLTSF/include/Window.hpp
- +13 −0 EXCLUDE/GLTSF/include/Window_Listener.hpp
- +56 −0 EXCLUDE/GLTSF/src/App.cpp
- +17 −0 EXCLUDE/GLTSF/src/Main.cpp
- +100 −0 EXCLUDE/GLTSF/src/Video_Mode.cpp
- +263 −0 EXCLUDE/GLTSF/src/Window.cpp
@@ -0,0 +1,20 @@ | ||
| ||
Microsoft Visual Studio Solution File, Format Version 11.00 | ||
# Visual Studio 2010 | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GLTSF", "GLTSF.vcxproj", "{790D58BA-E5F6-4286-A9C6-0DC28779789D}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Win32 = Debug|Win32 | ||
Release|Win32 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{790D58BA-E5F6-4286-A9C6-0DC28779789D}.Debug|Win32.ActiveCfg = Debug|Win32 | ||
{790D58BA-E5F6-4286-A9C6-0DC28779789D}.Debug|Win32.Build.0 = Debug|Win32 | ||
{790D58BA-E5F6-4286-A9C6-0DC28779789D}.Release|Win32.ActiveCfg = Release|Win32 | ||
{790D58BA-E5F6-4286-A9C6-0DC28779789D}.Release|Win32.Build.0 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
@@ -0,0 +1,97 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="4.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> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>{790D58BA-E5F6-4286-A9C6-0DC28779789D}</ProjectGuid> | ||
<Keyword>Win32Proj</Keyword> | ||
<RootNamespace>GLTSF</RootNamespace> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</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> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<LinkIncremental>true</LinkIncremental> | ||
<OutDir>$(SolutionDir)bin\</OutDir> | ||
<IntDir>obj\$(Configuration)\</IntDir> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<LinkIncremental>false</LinkIncremental> | ||
<OutDir>$(SolutionDir)bin\</OutDir> | ||
<IntDir>obj\$(Configuration)\</IntDir> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<ClCompile> | ||
<PrecompiledHeader> | ||
</PrecompiledHeader> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>Disabled</Optimization> | ||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<AdditionalIncludeDirectories>include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<PrecompiledHeader> | ||
</PrecompiledHeader> | ||
<Optimization>MaxSpeed</Optimization> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<AdditionalIncludeDirectories>include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ClInclude Include="include\App.hpp" /> | ||
<ClInclude Include="include\Video_Mode.hpp" /> | ||
<ClInclude Include="include\Window.hpp" /> | ||
<ClInclude Include="include\Window_Listener.hpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="src\App.cpp" /> | ||
<ClCompile Include="src\Main.cpp" /> | ||
<ClCompile Include="src\Video_Mode.cpp" /> | ||
<ClCompile Include="src\Window.cpp" /> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
@@ -0,0 +1,45 @@ | ||
<?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;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> | ||
<ClInclude Include="include\App.hpp"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="include\Video_Mode.hpp"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="include\Window.hpp"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="include\Window_Listener.hpp"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="src\App.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="src\Main.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="src\Video_Mode.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="src\Window.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
</ItemGroup> | ||
</Project> |
@@ -0,0 +1,26 @@ | ||
#ifndef APP_HPP | ||
#define APP_HPP | ||
|
||
#include "Window.hpp" | ||
|
||
class App : public Window_Listener | ||
{ | ||
public: | ||
App(); | ||
virtual ~App(); | ||
|
||
void Initialize(); | ||
void Finalize(); | ||
|
||
void Run(); | ||
|
||
virtual void On_Close(); | ||
virtual void On_Key_Down(int Key); | ||
virtual void On_Key_Up(int Key); | ||
|
||
private: | ||
Window my_Window; | ||
bool my_Done; | ||
}; | ||
|
||
#endif |
@@ -0,0 +1,30 @@ | ||
#ifndef VIDEO_MODE_HPP | ||
#define VIDEO_MODE_HPP | ||
|
||
#include <cstddef> | ||
|
||
class Video_Mode | ||
{ | ||
public: | ||
Video_Mode(); | ||
Video_Mode(unsigned int The_Width, unsigned int The_Height, unsigned int The_Bits_Per_Pixel); | ||
|
||
static Video_Mode Get_Desktop_Mode(); | ||
|
||
static std::size_t Get_Mode_Count(); | ||
static Video_Mode Get_Mode(std::size_t Index); | ||
|
||
bool Is_Valid() const; | ||
|
||
bool operator==(const Video_Mode &Mode) const; | ||
bool operator!=(const Video_Mode &Mode) const; | ||
|
||
unsigned int Width; | ||
unsigned int Height; | ||
unsigned int Bits_Per_Pixel; | ||
|
||
private: | ||
static void Initialize_Modes(); | ||
}; | ||
|
||
#endif |
@@ -0,0 +1,55 @@ | ||
#ifndef WINDOW_HPP | ||
#define WINDOW_HPP | ||
|
||
#include <string> | ||
|
||
#define WIN32_LEAN_AND_MEAN | ||
#include <Windows.h> | ||
|
||
#include "Video_Mode.hpp" | ||
#include "Window_Listener.hpp" | ||
|
||
class Window | ||
{ | ||
public: | ||
Window(); | ||
~Window(); | ||
|
||
void Initialize(const std::wstring &Title, const Video_Mode &Mode, bool Fullscreen); | ||
void Finalize(); | ||
|
||
void Set_Listener(Window_Listener *Listener); | ||
|
||
void Show(); | ||
void Hide(); | ||
|
||
void Update(); | ||
void Display(); | ||
|
||
private: | ||
static const wchar_t *Window_Class_Name; | ||
|
||
void Register_Class(); | ||
void Unregister_Class(); | ||
|
||
void Create_Window(const std::wstring &Title, const Video_Mode &Mode, bool Fullscreen); | ||
void Destroy_Window(); | ||
|
||
void Create_Context(const Video_Mode &Mode); | ||
void Destroy_Context(); | ||
|
||
void Switch_To_Fullscreen(const Video_Mode &Mode); | ||
|
||
LRESULT Handle_Message(HWND Handle, UINT Message, WPARAM wParam, LPARAM lParam); | ||
static LRESULT CALLBACK Window_Procedure(HWND Handle, UINT Message, WPARAM wParam, LPARAM lParam); | ||
|
||
HWND my_Handle; | ||
Video_Mode my_Video_Mode; | ||
bool my_Fullscreen; | ||
HDC my_Device_Context; | ||
HGLRC my_GL_Context; | ||
bool my_Class_Registered; | ||
Window_Listener *my_Listener; | ||
}; | ||
|
||
#endif |
@@ -0,0 +1,13 @@ | ||
#ifndef WINDOW_LISTENER_HPP | ||
#define WINDOW_LISTENER_HPP | ||
|
||
class Window_Listener | ||
{ | ||
public: | ||
virtual void On_Close(){} | ||
|
||
virtual void On_Key_Down(int Key){} | ||
virtual void On_Key_Up(int Key){} | ||
}; | ||
|
||
#endif |
@@ -0,0 +1,56 @@ | ||
#include "App.hpp" | ||
|
||
App::App() : my_Done(false) | ||
{ | ||
|
||
} | ||
|
||
App::~App() | ||
{ | ||
Finalize(); | ||
} | ||
|
||
void App::Initialize() | ||
{ | ||
Finalize(); | ||
|
||
my_Window.Initialize(L"GLTSF", Video_Mode(800, 600, 32), false); | ||
my_Window.Set_Listener(this); | ||
my_Window.Show(); | ||
} | ||
|
||
void App::Finalize() | ||
{ | ||
my_Window.Finalize(); | ||
} | ||
|
||
void App::Run() | ||
{ | ||
Initialize(); | ||
while (!my_Done) | ||
{ | ||
my_Window.Update(); | ||
my_Window.Display(); | ||
} | ||
} | ||
|
||
void App::On_Close() | ||
{ | ||
my_Done = true; | ||
my_Window.Hide(); | ||
} | ||
|
||
void App::On_Key_Down(int Key) | ||
{ | ||
switch (Key) | ||
{ | ||
case VK_ESCAPE: | ||
On_Close(); | ||
break; | ||
} | ||
} | ||
|
||
void App::On_Key_Up(int Key) | ||
{ | ||
|
||
} |
@@ -0,0 +1,17 @@ | ||
#include "App.hpp" | ||
#include <stdexcept> | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
try | ||
{ | ||
App theApp; | ||
theApp.Run(); | ||
} | ||
catch (const std::exception& e) | ||
{ | ||
printf("Error: %s\n", e.what()); | ||
return 1; | ||
} | ||
return 0; | ||
} |
Oops, something went wrong.