Add exercise 2

This commit is contained in:
hodasemi 2019-05-11 10:51:24 +02:00
parent 2be8580dce
commit 09edcfe383
46 changed files with 4296 additions and 0 deletions

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,65 @@
cmake_minimum_required( VERSION 2.6 )
project(exercise2)
# Gebraucht werden OpenGL und GLUT
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
# Definition der Headerdateien
set(HEADERS
../../include/tool_base.h
../../include/application.h
../../include/bresenham_circle_tool.h
../../include/bresenham_line_tool.h
../../include/canvas_renderer.h
../../include/canvas_buffer.h
../../include/dda_line_tool.h
../../include/line_fill_tool.h
../../include/non_recursive_fill_tool.h
../../include/pen_tool.h
../../include/preview_renderer.h
../../include/rectangle_tool.h
../../include/recursive_fill_tool.h
../../include/tiny_vec.h
)
# Definition der Sourcedateien
set(SOURCES
../../src/tool_base.cpp
../../src/application.cpp
../../src/bresenham_circle_tool.cpp
../../src/bresenham_line_tool.cpp
../../src/canvas_renderer.cpp
../../src/canvas_buffer.cpp
../../src/dda_line_tool.cpp
../../src/line_fill_tool.cpp
../../src/main.cpp
../../src/non_recursive_fill_tool.cpp
../../src/pen_tool.cpp
../../src/preview_renderer.cpp
../../src/rectangle_tool.cpp
../../src/recursive_fill_tool.cpp
)
# Includeverzeichnisse setzen
include_directories(
../../include
)
# Support fuer C++-11 aktivieren
set(CMAKE_CXX_FLAGS "-std=c++11")
# Ziel hinzufuegen
add_executable(exercise2
${SOURCES}
${HEADERS}
)
# Bibliotheken linken
target_link_libraries(exercise2 ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} -lpthread)

View file

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "raster_graphics", "raster_graphics.vcxproj", "{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}.Debug|Win32.ActiveCfg = Debug|Win32
{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}.Debug|Win32.Build.0 = Debug|Win32
{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}.Release|Win32.ActiveCfg = Release|Win32
{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,120 @@
<?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>{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}</ProjectGuid>
<RootNamespace>raster_graphics</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../../include;../../dependencies/freeglut/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;FREEGLUT_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<ProjectReference>
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
<Link>
<AdditionalLibraryDirectories>../../dependencies/freeglut/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>../../include;../../dependencies/freeglut/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;FREEGLUT_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>../../dependencies/freeglut/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\application.cpp" />
<ClCompile Include="..\..\src\canvas_buffer.cpp" />
<ClCompile Include="..\..\src\canvas_renderer.cpp" />
<ClCompile Include="..\..\src\main.cpp" />
<ClCompile Include="..\..\src\preview_renderer.cpp" />
<ClCompile Include="..\..\src\bresenham_circle_tool.cpp" />
<ClCompile Include="..\..\src\bresenham_line_tool.cpp" />
<ClCompile Include="..\..\src\dda_line_tool.cpp" />
<ClCompile Include="..\..\src\line_fill_tool.cpp" />
<ClCompile Include="..\..\src\non_recursive_fill_tool.cpp" />
<ClCompile Include="..\..\src\pen_tool.cpp" />
<ClCompile Include="..\..\src\rectangle_tool.cpp" />
<ClCompile Include="..\..\src\recursive_fill_tool.cpp" />
<ClCompile Include="..\..\src\tool_base.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\application.h" />
<ClInclude Include="..\..\include\canvas_buffer.h" />
<ClInclude Include="..\..\include\canvas_renderer.h" />
<ClInclude Include="..\..\include\preview_renderer.h" />
<ClInclude Include="..\..\include\bresenham_circle_tool.h" />
<ClInclude Include="..\..\include\bresenham_line_tool.h" />
<ClInclude Include="..\..\include\dda_line_tool.h" />
<ClInclude Include="..\..\include\line_fill_tool.h" />
<ClInclude Include="..\..\include\non_recursive_fill_tool.h" />
<ClInclude Include="..\..\include\pen_tool.h" />
<ClInclude Include="..\..\include\rectangle_tool.h" />
<ClInclude Include="..\..\include\recursive_fill_tool.h" />
<ClInclude Include="..\..\include\tool_base.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2015
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "raster_graphics", "raster_graphics.vcxproj", "{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}.Debug|Win32.ActiveCfg = Debug|Win32
{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}.Debug|Win32.Build.0 = Debug|Win32
{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}.Release|Win32.ActiveCfg = Release|Win32
{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,136 @@
<?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">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}</ProjectGuid>
<RootNamespace>raster_graphics</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../../include;../../dependencies/freeglut/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<ProjectReference>
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
<Link>
<AdditionalLibraryDirectories>../../dependencies/freeglut/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<TargetMachine>MachineX86</TargetMachine>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>
</IgnoreSpecificDefaultLibraries>
</Link>
<PostBuildEvent>
<Command>xcopy "..\..\dependencies\freeglut\lib\freeglut.dll" "$(SolutionDir)$(Configuration)"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy freeglut .dll to executable location</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>../../include;../../dependencies/freeglut/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>../../dependencies/freeglut/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>
</IgnoreSpecificDefaultLibraries>
</Link>
<PostBuildEvent>
<Command>xcopy "..\..\dependencies\freeglut\lib\freeglut.dll" "$(SolutionDir)$(Configuration)"</Command>
<Message>Copy freeglut .dll to executable location</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\application.cpp" />
<ClCompile Include="..\..\src\canvas_buffer.cpp" />
<ClCompile Include="..\..\src\canvas_renderer.cpp" />
<ClCompile Include="..\..\src\main.cpp" />
<ClCompile Include="..\..\src\preview_renderer.cpp" />
<ClCompile Include="..\..\src\bresenham_circle_tool.cpp" />
<ClCompile Include="..\..\src\bresenham_line_tool.cpp" />
<ClCompile Include="..\..\src\dda_line_tool.cpp" />
<ClCompile Include="..\..\src\line_fill_tool.cpp" />
<ClCompile Include="..\..\src\non_recursive_fill_tool.cpp" />
<ClCompile Include="..\..\src\pen_tool.cpp" />
<ClCompile Include="..\..\src\rectangle_tool.cpp" />
<ClCompile Include="..\..\src\recursive_fill_tool.cpp" />
<ClCompile Include="..\..\src\tool_base.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\application.h" />
<ClInclude Include="..\..\include\canvas_buffer.h" />
<ClInclude Include="..\..\include\canvas_renderer.h" />
<ClInclude Include="..\..\include\preview_renderer.h" />
<ClInclude Include="..\..\include\bresenham_circle_tool.h" />
<ClInclude Include="..\..\include\bresenham_line_tool.h" />
<ClInclude Include="..\..\include\dda_line_tool.h" />
<ClInclude Include="..\..\include\line_fill_tool.h" />
<ClInclude Include="..\..\include\non_recursive_fill_tool.h" />
<ClInclude Include="..\..\include\pen_tool.h" />
<ClInclude Include="..\..\include\rectangle_tool.h" />
<ClInclude Include="..\..\include\recursive_fill_tool.h" />
<ClInclude Include="..\..\include\tool_base.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2017
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "raster_graphics", "raster_graphics.vcxproj", "{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}.Debug|Win32.ActiveCfg = Debug|Win32
{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}.Debug|Win32.Build.0 = Debug|Win32
{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}.Release|Win32.ActiveCfg = Release|Win32
{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,136 @@
<?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">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{ED74E400-FCC9-4F7A-AFD7-90A2C5300D90}</ProjectGuid>
<RootNamespace>raster_graphics</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../../include;../../dependencies/freeglut/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<ProjectReference>
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
<Link>
<AdditionalLibraryDirectories>../../dependencies/freeglut/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<TargetMachine>MachineX86</TargetMachine>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>
</IgnoreSpecificDefaultLibraries>
</Link>
<PostBuildEvent>
<Command>xcopy "..\..\dependencies\freeglut\lib\freeglut.dll" "$(SolutionDir)$(Configuration)"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy freeglut .dll to executable location</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>../../include;../../dependencies/freeglut/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>../../dependencies/freeglut/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>
</IgnoreSpecificDefaultLibraries>
</Link>
<PostBuildEvent>
<Command>xcopy "..\..\dependencies\freeglut\lib\freeglut.dll" "$(SolutionDir)$(Configuration)"</Command>
<Message>Copy freeglut .dll to executable location</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\application.cpp" />
<ClCompile Include="..\..\src\canvas_buffer.cpp" />
<ClCompile Include="..\..\src\canvas_renderer.cpp" />
<ClCompile Include="..\..\src\main.cpp" />
<ClCompile Include="..\..\src\preview_renderer.cpp" />
<ClCompile Include="..\..\src\bresenham_circle_tool.cpp" />
<ClCompile Include="..\..\src\bresenham_line_tool.cpp" />
<ClCompile Include="..\..\src\dda_line_tool.cpp" />
<ClCompile Include="..\..\src\line_fill_tool.cpp" />
<ClCompile Include="..\..\src\non_recursive_fill_tool.cpp" />
<ClCompile Include="..\..\src\pen_tool.cpp" />
<ClCompile Include="..\..\src\rectangle_tool.cpp" />
<ClCompile Include="..\..\src\recursive_fill_tool.cpp" />
<ClCompile Include="..\..\src\tool_base.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\application.h" />
<ClInclude Include="..\..\include\canvas_buffer.h" />
<ClInclude Include="..\..\include\canvas_renderer.h" />
<ClInclude Include="..\..\include\preview_renderer.h" />
<ClInclude Include="..\..\include\bresenham_circle_tool.h" />
<ClInclude Include="..\..\include\bresenham_line_tool.h" />
<ClInclude Include="..\..\include\dda_line_tool.h" />
<ClInclude Include="..\..\include\line_fill_tool.h" />
<ClInclude Include="..\..\include\non_recursive_fill_tool.h" />
<ClInclude Include="..\..\include\pen_tool.h" />
<ClInclude Include="..\..\include\rectangle_tool.h" />
<ClInclude Include="..\..\include\recursive_fill_tool.h" />
<ClInclude Include="..\..\include\tool_base.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -0,0 +1,22 @@
#ifndef __FREEGLUT_H__
#define __FREEGLUT_H__
/*
* freeglut.h
*
* The freeglut library include file
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "freeglut_std.h"
#include "freeglut_ext.h"
/*** END OF FILE ***/
#endif /* __FREEGLUT_H__ */

View file

@ -0,0 +1,271 @@
#ifndef __FREEGLUT_EXT_H__
#define __FREEGLUT_EXT_H__
/*
* freeglut_ext.h
*
* The non-GLUT-compatible extensions to the freeglut library include file
*
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Creation date: Thu Dec 2 1999
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* Additional GLUT Key definitions for the Special key function
*/
#define GLUT_KEY_NUM_LOCK 0x006D
#define GLUT_KEY_BEGIN 0x006E
#define GLUT_KEY_DELETE 0x006F
#define GLUT_KEY_SHIFT_L 0x0070
#define GLUT_KEY_SHIFT_R 0x0071
#define GLUT_KEY_CTRL_L 0x0072
#define GLUT_KEY_CTRL_R 0x0073
#define GLUT_KEY_ALT_L 0x0074
#define GLUT_KEY_ALT_R 0x0075
/*
* GLUT API Extension macro definitions -- behaviour when the user clicks on an "x" to close a window
*/
#define GLUT_ACTION_EXIT 0
#define GLUT_ACTION_GLUTMAINLOOP_RETURNS 1
#define GLUT_ACTION_CONTINUE_EXECUTION 2
/*
* Create a new rendering context when the user opens a new window?
*/
#define GLUT_CREATE_NEW_CONTEXT 0
#define GLUT_USE_CURRENT_CONTEXT 1
/*
* Direct/Indirect rendering context options (has meaning only in Unix/X11)
*/
#define GLUT_FORCE_INDIRECT_CONTEXT 0
#define GLUT_ALLOW_DIRECT_CONTEXT 1
#define GLUT_TRY_DIRECT_CONTEXT 2
#define GLUT_FORCE_DIRECT_CONTEXT 3
/*
* GLUT API Extension macro definitions -- the glutGet parameters
*/
#define GLUT_INIT_STATE 0x007C
#define GLUT_ACTION_ON_WINDOW_CLOSE 0x01F9
#define GLUT_WINDOW_BORDER_WIDTH 0x01FA
#define GLUT_WINDOW_BORDER_HEIGHT 0x01FB
#define GLUT_WINDOW_HEADER_HEIGHT 0x01FB /* Docs say it should always have been GLUT_WINDOW_BORDER_HEIGHT, keep this for backward compatibility */
#define GLUT_VERSION 0x01FC
#define GLUT_RENDERING_CONTEXT 0x01FD
#define GLUT_DIRECT_RENDERING 0x01FE
#define GLUT_FULL_SCREEN 0x01FF
#define GLUT_SKIP_STALE_MOTION_EVENTS 0x0204
#define GLUT_GEOMETRY_VISUALIZE_NORMALS 0x0205
#define GLUT_STROKE_FONT_DRAW_JOIN_DOTS 0x0206 /* Draw dots between line segments of stroke fonts? */
/*
* New tokens for glutInitDisplayMode.
* Only one GLUT_AUXn bit may be used at a time.
* Value 0x0400 is defined in OpenGLUT.
*/
#define GLUT_AUX 0x1000
#define GLUT_AUX1 0x1000
#define GLUT_AUX2 0x2000
#define GLUT_AUX3 0x4000
#define GLUT_AUX4 0x8000
/*
* Context-related flags, see fg_state.c
* Set the requested OpenGL version
*/
#define GLUT_INIT_MAJOR_VERSION 0x0200
#define GLUT_INIT_MINOR_VERSION 0x0201
#define GLUT_INIT_FLAGS 0x0202
#define GLUT_INIT_PROFILE 0x0203
/*
* Flags for glutInitContextFlags, see fg_init.c
*/
#define GLUT_DEBUG 0x0001
#define GLUT_FORWARD_COMPATIBLE 0x0002
/*
* Flags for glutInitContextProfile, see fg_init.c
*/
#define GLUT_CORE_PROFILE 0x0001
#define GLUT_COMPATIBILITY_PROFILE 0x0002
/*
* Process loop function, see fg_main.c
*/
FGAPI void FGAPIENTRY glutMainLoopEvent( void );
FGAPI void FGAPIENTRY glutLeaveMainLoop( void );
FGAPI void FGAPIENTRY glutExit ( void );
/*
* Window management functions, see fg_window.c
*/
FGAPI void FGAPIENTRY glutFullScreenToggle( void );
FGAPI void FGAPIENTRY glutLeaveFullScreen( void );
/*
* Menu functions
*/
FGAPI void FGAPIENTRY glutSetMenuFont( int menuID, void* font );
/*
* Window-specific callback functions, see fg_callbacks.c
*/
FGAPI void FGAPIENTRY glutMouseWheelFunc( void (* callback)( int, int, int, int ) );
FGAPI void FGAPIENTRY glutPositionFunc( void (* callback)( int, int ) );
FGAPI void FGAPIENTRY glutCloseFunc( void (* callback)( void ) );
FGAPI void FGAPIENTRY glutWMCloseFunc( void (* callback)( void ) );
/* And also a destruction callback for menus */
FGAPI void FGAPIENTRY glutMenuDestroyFunc( void (* callback)( void ) );
/*
* State setting and retrieval functions, see fg_state.c
*/
FGAPI void FGAPIENTRY glutSetOption ( GLenum option_flag, int value );
FGAPI int * FGAPIENTRY glutGetModeValues(GLenum mode, int * size);
/* A.Donev: User-data manipulation */
FGAPI void* FGAPIENTRY glutGetWindowData( void );
FGAPI void FGAPIENTRY glutSetWindowData(void* data);
FGAPI void* FGAPIENTRY glutGetMenuData( void );
FGAPI void FGAPIENTRY glutSetMenuData(void* data);
/*
* Font stuff, see fg_font.c
*/
FGAPI int FGAPIENTRY glutBitmapHeight( void* font );
FGAPI GLfloat FGAPIENTRY glutStrokeHeight( void* font );
FGAPI void FGAPIENTRY glutBitmapString( void* font, const unsigned char *string );
FGAPI void FGAPIENTRY glutStrokeString( void* font, const unsigned char *string );
/*
* Geometry functions, see fg_geometry.c
*/
FGAPI void FGAPIENTRY glutWireRhombicDodecahedron( void );
FGAPI void FGAPIENTRY glutSolidRhombicDodecahedron( void );
FGAPI void FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, double offset[3], double scale );
FGAPI void FGAPIENTRY glutSolidSierpinskiSponge ( int num_levels, double offset[3], double scale );
FGAPI void FGAPIENTRY glutWireCylinder( double radius, double height, GLint slices, GLint stacks);
FGAPI void FGAPIENTRY glutSolidCylinder( double radius, double height, GLint slices, GLint stacks);
/*
* Rest of functions for rendering Newell's teaset, found in fg_teapot.c
* NB: front facing polygons have clockwise winding, not counter clockwise
*/
FGAPI void FGAPIENTRY glutWireTeacup( double size );
FGAPI void FGAPIENTRY glutSolidTeacup( double size );
FGAPI void FGAPIENTRY glutWireTeaspoon( double size );
FGAPI void FGAPIENTRY glutSolidTeaspoon( double size );
/*
* Extension functions, see fg_ext.c
*/
typedef void (*GLUTproc)();
FGAPI GLUTproc FGAPIENTRY glutGetProcAddress( const char *procName );
/*
* Multi-touch/multi-pointer extensions
*/
#define GLUT_HAS_MULTI 1
/* TODO: add device_id parameter,
cf. http://sourceforge.net/mailarchive/forum.php?thread_name=20120518071314.GA28061%40perso.beuc.net&forum_name=freeglut-developer */
FGAPI void FGAPIENTRY glutMultiEntryFunc( void (* callback)( int, int ) );
FGAPI void FGAPIENTRY glutMultiButtonFunc( void (* callback)( int, int, int, int, int ) );
FGAPI void FGAPIENTRY glutMultiMotionFunc( void (* callback)( int, int, int ) );
FGAPI void FGAPIENTRY glutMultiPassiveFunc( void (* callback)( int, int, int ) );
/*
* Joystick functions, see fg_joystick.c
*/
/* USE OF THESE FUNCTIONS IS DEPRECATED !!!!! */
/* If you have a serious need for these functions in your application, please either
* contact the "freeglut" developer community at freeglut-developer@lists.sourceforge.net,
* switch to the OpenGLUT library, or else port your joystick functionality over to PLIB's
* "js" library.
*/
int glutJoystickGetNumAxes( int ident );
int glutJoystickGetNumButtons( int ident );
int glutJoystickNotWorking( int ident );
float glutJoystickGetDeadBand( int ident, int axis );
void glutJoystickSetDeadBand( int ident, int axis, float db );
float glutJoystickGetSaturation( int ident, int axis );
void glutJoystickSetSaturation( int ident, int axis, float st );
void glutJoystickSetMinRange( int ident, float *axes );
void glutJoystickSetMaxRange( int ident, float *axes );
void glutJoystickSetCenter( int ident, float *axes );
void glutJoystickGetMinRange( int ident, float *axes );
void glutJoystickGetMaxRange( int ident, float *axes );
void glutJoystickGetCenter( int ident, float *axes );
/*
* Initialization functions, see fg_init.c
*/
/* to get the typedef for va_list */
#include <stdarg.h>
FGAPI void FGAPIENTRY glutInitContextVersion( int majorVersion, int minorVersion );
FGAPI void FGAPIENTRY glutInitContextFlags( int flags );
FGAPI void FGAPIENTRY glutInitContextProfile( int profile );
FGAPI void FGAPIENTRY glutInitErrorFunc( void (* callback)( const char *fmt, va_list ap ) );
FGAPI void FGAPIENTRY glutInitWarningFunc( void (* callback)( const char *fmt, va_list ap ) );
/* OpenGL >= 2.0 support */
FGAPI void FGAPIENTRY glutSetVertexAttribCoord3(GLint attrib);
FGAPI void FGAPIENTRY glutSetVertexAttribNormal(GLint attrib);
FGAPI void FGAPIENTRY glutSetVertexAttribTexCoord2(GLint attrib);
/* Mobile platforms lifecycle */
FGAPI void FGAPIENTRY glutInitContextFunc(void (* callback)());
FGAPI void FGAPIENTRY glutAppStatusFunc(void (* callback)(int));
/* state flags that can be passed to callback set by glutAppStatusFunc */
#define GLUT_APPSTATUS_PAUSE 0x0001
#define GLUT_APPSTATUS_RESUME 0x0002
/*
* GLUT API macro definitions -- the display mode definitions
*/
#define GLUT_CAPTIONLESS 0x0400
#define GLUT_BORDERLESS 0x0800
#define GLUT_SRGB 0x1000
#ifdef __cplusplus
}
#endif
/*** END OF FILE ***/
#endif /* __FREEGLUT_EXT_H__ */

View file

@ -0,0 +1,653 @@
#ifndef __FREEGLUT_STD_H__
#define __FREEGLUT_STD_H__
/*
* freeglut_std.h
*
* The GLUT-compatible part of the freeglut library include file
*
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Creation date: Thu Dec 2 1999
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* Under windows, we have to differentiate between static and dynamic libraries
*/
#ifdef _WIN32
/* #pragma may not be supported by some compilers.
* Discussion by FreeGLUT developers suggests that
* Visual C++ specific code involving pragmas may
* need to move to a separate header. 24th Dec 2003
*/
/* Define FREEGLUT_LIB_PRAGMAS to 1 to include library
* pragmas or to 0 to exclude library pragmas.
* The default behavior depends on the compiler/platform.
*/
# ifndef FREEGLUT_LIB_PRAGMAS
# if ( defined(_MSC_VER) || defined(__WATCOMC__) ) && !defined(_WIN32_WCE)
# define FREEGLUT_LIB_PRAGMAS 1
# else
# define FREEGLUT_LIB_PRAGMAS 0
# endif
# endif
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN 1
# endif
# ifndef NOMINMAX
# define NOMINMAX
# endif
# include <windows.h>
/* Windows static library */
# ifdef FREEGLUT_STATIC
# define FGAPI
# define FGAPIENTRY
/* Link with Win32 static freeglut lib */
# if FREEGLUT_LIB_PRAGMAS
# ifdef NDEBUG
# pragma comment (lib, "freeglut_static.lib")
# else
# pragma comment (lib, "freeglut_staticd.lib")
# endif
# endif
/* Windows shared library (DLL) */
# else
# define FGAPIENTRY __stdcall
# if defined(FREEGLUT_EXPORTS)
# define FGAPI __declspec(dllexport)
# else
# define FGAPI __declspec(dllimport)
/* Link with Win32 shared freeglut lib */
# if FREEGLUT_LIB_PRAGMAS
# ifdef NDEBUG
# pragma comment (lib, "freeglut.lib")
# else
# pragma comment (lib, "freeglutd.lib")
# endif
# endif
# endif
# endif
/* Drag in other Windows libraries as required by FreeGLUT */
# if FREEGLUT_LIB_PRAGMAS
# pragma comment (lib, "glu32.lib") /* link OpenGL Utility lib */
# pragma comment (lib, "opengl32.lib") /* link Microsoft OpenGL lib */
# pragma comment (lib, "gdi32.lib") /* link Windows GDI lib */
# pragma comment (lib, "winmm.lib") /* link Windows MultiMedia lib */
# pragma comment (lib, "user32.lib") /* link Windows user lib */
# endif
#else
/* Non-Windows definition of FGAPI and FGAPIENTRY */
# define FGAPI
# define FGAPIENTRY
#endif
/*
* The freeglut and GLUT API versions
*/
#define FREEGLUT 1
#define GLUT_API_VERSION 4
#define GLUT_XLIB_IMPLEMENTATION 13
/* Deprecated:
cf. http://sourceforge.net/mailarchive/forum.php?thread_name=CABcAi1hw7cr4xtigckaGXB5X8wddLfMcbA_rZ3NAuwMrX_zmsw%40mail.gmail.com&forum_name=freeglut-developer */
#define FREEGLUT_VERSION_2_0 1
/*
* Always include OpenGL and GLU headers
*/
/* Note: FREEGLUT_GLES is only used to cleanly bootstrap headers
inclusion here; use GLES constants directly
(e.g. GL_ES_VERSION_2_0) for all other needs */
#ifdef FREEGLUT_GLES
# include <EGL/egl.h>
# include <GLES/gl.h>
# include <GLES2/gl2.h>
#elif __APPLE__
# include <OpenGL/gl.h>
# include <OpenGL/glu.h>
#else
# include <GL/gl.h>
# include <GL/glu.h>
#endif
/*
* GLUT API macro definitions -- the special key codes:
*/
#define GLUT_KEY_F1 0x0001
#define GLUT_KEY_F2 0x0002
#define GLUT_KEY_F3 0x0003
#define GLUT_KEY_F4 0x0004
#define GLUT_KEY_F5 0x0005
#define GLUT_KEY_F6 0x0006
#define GLUT_KEY_F7 0x0007
#define GLUT_KEY_F8 0x0008
#define GLUT_KEY_F9 0x0009
#define GLUT_KEY_F10 0x000A
#define GLUT_KEY_F11 0x000B
#define GLUT_KEY_F12 0x000C
#define GLUT_KEY_LEFT 0x0064
#define GLUT_KEY_UP 0x0065
#define GLUT_KEY_RIGHT 0x0066
#define GLUT_KEY_DOWN 0x0067
#define GLUT_KEY_PAGE_UP 0x0068
#define GLUT_KEY_PAGE_DOWN 0x0069
#define GLUT_KEY_HOME 0x006A
#define GLUT_KEY_END 0x006B
#define GLUT_KEY_INSERT 0x006C
/*
* GLUT API macro definitions -- mouse state definitions
*/
#define GLUT_LEFT_BUTTON 0x0000
#define GLUT_MIDDLE_BUTTON 0x0001
#define GLUT_RIGHT_BUTTON 0x0002
#define GLUT_DOWN 0x0000
#define GLUT_UP 0x0001
#define GLUT_LEFT 0x0000
#define GLUT_ENTERED 0x0001
/*
* GLUT API macro definitions -- the display mode definitions
*/
#define GLUT_RGB 0x0000
#define GLUT_RGBA 0x0000
#define GLUT_INDEX 0x0001
#define GLUT_SINGLE 0x0000
#define GLUT_DOUBLE 0x0002
#define GLUT_ACCUM 0x0004
#define GLUT_ALPHA 0x0008
#define GLUT_DEPTH 0x0010
#define GLUT_STENCIL 0x0020
#define GLUT_MULTISAMPLE 0x0080
#define GLUT_STEREO 0x0100
#define GLUT_LUMINANCE 0x0200
/*
* GLUT API macro definitions -- windows and menu related definitions
*/
#define GLUT_MENU_NOT_IN_USE 0x0000
#define GLUT_MENU_IN_USE 0x0001
#define GLUT_NOT_VISIBLE 0x0000
#define GLUT_VISIBLE 0x0001
#define GLUT_HIDDEN 0x0000
#define GLUT_FULLY_RETAINED 0x0001
#define GLUT_PARTIALLY_RETAINED 0x0002
#define GLUT_FULLY_COVERED 0x0003
/*
* GLUT API macro definitions -- fonts definitions
*
* Steve Baker suggested to make it binary compatible with GLUT:
*/
#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__WATCOMC__)
# define GLUT_STROKE_ROMAN ((void *)0x0000)
# define GLUT_STROKE_MONO_ROMAN ((void *)0x0001)
# define GLUT_BITMAP_9_BY_15 ((void *)0x0002)
# define GLUT_BITMAP_8_BY_13 ((void *)0x0003)
# define GLUT_BITMAP_TIMES_ROMAN_10 ((void *)0x0004)
# define GLUT_BITMAP_TIMES_ROMAN_24 ((void *)0x0005)
# define GLUT_BITMAP_HELVETICA_10 ((void *)0x0006)
# define GLUT_BITMAP_HELVETICA_12 ((void *)0x0007)
# define GLUT_BITMAP_HELVETICA_18 ((void *)0x0008)
#else
/*
* I don't really know if it's a good idea... But here it goes:
*/
extern void* glutStrokeRoman;
extern void* glutStrokeMonoRoman;
extern void* glutBitmap9By15;
extern void* glutBitmap8By13;
extern void* glutBitmapTimesRoman10;
extern void* glutBitmapTimesRoman24;
extern void* glutBitmapHelvetica10;
extern void* glutBitmapHelvetica12;
extern void* glutBitmapHelvetica18;
/*
* Those pointers will be used by following definitions:
*/
# define GLUT_STROKE_ROMAN ((void *) &glutStrokeRoman)
# define GLUT_STROKE_MONO_ROMAN ((void *) &glutStrokeMonoRoman)
# define GLUT_BITMAP_9_BY_15 ((void *) &glutBitmap9By15)
# define GLUT_BITMAP_8_BY_13 ((void *) &glutBitmap8By13)
# define GLUT_BITMAP_TIMES_ROMAN_10 ((void *) &glutBitmapTimesRoman10)
# define GLUT_BITMAP_TIMES_ROMAN_24 ((void *) &glutBitmapTimesRoman24)
# define GLUT_BITMAP_HELVETICA_10 ((void *) &glutBitmapHelvetica10)
# define GLUT_BITMAP_HELVETICA_12 ((void *) &glutBitmapHelvetica12)
# define GLUT_BITMAP_HELVETICA_18 ((void *) &glutBitmapHelvetica18)
#endif
/*
* GLUT API macro definitions -- the glutGet parameters
*/
#define GLUT_WINDOW_X 0x0064
#define GLUT_WINDOW_Y 0x0065
#define GLUT_WINDOW_WIDTH 0x0066
#define GLUT_WINDOW_HEIGHT 0x0067
#define GLUT_WINDOW_BUFFER_SIZE 0x0068
#define GLUT_WINDOW_STENCIL_SIZE 0x0069
#define GLUT_WINDOW_DEPTH_SIZE 0x006A
#define GLUT_WINDOW_RED_SIZE 0x006B
#define GLUT_WINDOW_GREEN_SIZE 0x006C
#define GLUT_WINDOW_BLUE_SIZE 0x006D
#define GLUT_WINDOW_ALPHA_SIZE 0x006E
#define GLUT_WINDOW_ACCUM_RED_SIZE 0x006F
#define GLUT_WINDOW_ACCUM_GREEN_SIZE 0x0070
#define GLUT_WINDOW_ACCUM_BLUE_SIZE 0x0071
#define GLUT_WINDOW_ACCUM_ALPHA_SIZE 0x0072
#define GLUT_WINDOW_DOUBLEBUFFER 0x0073
#define GLUT_WINDOW_RGBA 0x0074
#define GLUT_WINDOW_PARENT 0x0075
#define GLUT_WINDOW_NUM_CHILDREN 0x0076
#define GLUT_WINDOW_COLORMAP_SIZE 0x0077
#define GLUT_WINDOW_NUM_SAMPLES 0x0078
#define GLUT_WINDOW_STEREO 0x0079
#define GLUT_WINDOW_CURSOR 0x007A
#define GLUT_SCREEN_WIDTH 0x00C8
#define GLUT_SCREEN_HEIGHT 0x00C9
#define GLUT_SCREEN_WIDTH_MM 0x00CA
#define GLUT_SCREEN_HEIGHT_MM 0x00CB
#define GLUT_MENU_NUM_ITEMS 0x012C
#define GLUT_DISPLAY_MODE_POSSIBLE 0x0190
#define GLUT_INIT_WINDOW_X 0x01F4
#define GLUT_INIT_WINDOW_Y 0x01F5
#define GLUT_INIT_WINDOW_WIDTH 0x01F6
#define GLUT_INIT_WINDOW_HEIGHT 0x01F7
#define GLUT_INIT_DISPLAY_MODE 0x01F8
#define GLUT_ELAPSED_TIME 0x02BC
#define GLUT_WINDOW_FORMAT_ID 0x007B
/*
* GLUT API macro definitions -- the glutDeviceGet parameters
*/
#define GLUT_HAS_KEYBOARD 0x0258
#define GLUT_HAS_MOUSE 0x0259
#define GLUT_HAS_SPACEBALL 0x025A
#define GLUT_HAS_DIAL_AND_BUTTON_BOX 0x025B
#define GLUT_HAS_TABLET 0x025C
#define GLUT_NUM_MOUSE_BUTTONS 0x025D
#define GLUT_NUM_SPACEBALL_BUTTONS 0x025E
#define GLUT_NUM_BUTTON_BOX_BUTTONS 0x025F
#define GLUT_NUM_DIALS 0x0260
#define GLUT_NUM_TABLET_BUTTONS 0x0261
#define GLUT_DEVICE_IGNORE_KEY_REPEAT 0x0262
#define GLUT_DEVICE_KEY_REPEAT 0x0263
#define GLUT_HAS_JOYSTICK 0x0264
#define GLUT_OWNS_JOYSTICK 0x0265
#define GLUT_JOYSTICK_BUTTONS 0x0266
#define GLUT_JOYSTICK_AXES 0x0267
#define GLUT_JOYSTICK_POLL_RATE 0x0268
/*
* GLUT API macro definitions -- the glutLayerGet parameters
*/
#define GLUT_OVERLAY_POSSIBLE 0x0320
#define GLUT_LAYER_IN_USE 0x0321
#define GLUT_HAS_OVERLAY 0x0322
#define GLUT_TRANSPARENT_INDEX 0x0323
#define GLUT_NORMAL_DAMAGED 0x0324
#define GLUT_OVERLAY_DAMAGED 0x0325
/*
* GLUT API macro definitions -- the glutVideoResizeGet parameters
*/
#define GLUT_VIDEO_RESIZE_POSSIBLE 0x0384
#define GLUT_VIDEO_RESIZE_IN_USE 0x0385
#define GLUT_VIDEO_RESIZE_X_DELTA 0x0386
#define GLUT_VIDEO_RESIZE_Y_DELTA 0x0387
#define GLUT_VIDEO_RESIZE_WIDTH_DELTA 0x0388
#define GLUT_VIDEO_RESIZE_HEIGHT_DELTA 0x0389
#define GLUT_VIDEO_RESIZE_X 0x038A
#define GLUT_VIDEO_RESIZE_Y 0x038B
#define GLUT_VIDEO_RESIZE_WIDTH 0x038C
#define GLUT_VIDEO_RESIZE_HEIGHT 0x038D
/*
* GLUT API macro definitions -- the glutUseLayer parameters
*/
#define GLUT_NORMAL 0x0000
#define GLUT_OVERLAY 0x0001
/*
* GLUT API macro definitions -- the glutGetModifiers parameters
*/
#define GLUT_ACTIVE_SHIFT 0x0001
#define GLUT_ACTIVE_CTRL 0x0002
#define GLUT_ACTIVE_ALT 0x0004
/*
* GLUT API macro definitions -- the glutSetCursor parameters
*/
#define GLUT_CURSOR_RIGHT_ARROW 0x0000
#define GLUT_CURSOR_LEFT_ARROW 0x0001
#define GLUT_CURSOR_INFO 0x0002
#define GLUT_CURSOR_DESTROY 0x0003
#define GLUT_CURSOR_HELP 0x0004
#define GLUT_CURSOR_CYCLE 0x0005
#define GLUT_CURSOR_SPRAY 0x0006
#define GLUT_CURSOR_WAIT 0x0007
#define GLUT_CURSOR_TEXT 0x0008
#define GLUT_CURSOR_CROSSHAIR 0x0009
#define GLUT_CURSOR_UP_DOWN 0x000A
#define GLUT_CURSOR_LEFT_RIGHT 0x000B
#define GLUT_CURSOR_TOP_SIDE 0x000C
#define GLUT_CURSOR_BOTTOM_SIDE 0x000D
#define GLUT_CURSOR_LEFT_SIDE 0x000E
#define GLUT_CURSOR_RIGHT_SIDE 0x000F
#define GLUT_CURSOR_TOP_LEFT_CORNER 0x0010
#define GLUT_CURSOR_TOP_RIGHT_CORNER 0x0011
#define GLUT_CURSOR_BOTTOM_RIGHT_CORNER 0x0012
#define GLUT_CURSOR_BOTTOM_LEFT_CORNER 0x0013
#define GLUT_CURSOR_INHERIT 0x0064
#define GLUT_CURSOR_NONE 0x0065
#define GLUT_CURSOR_FULL_CROSSHAIR 0x0066
/*
* GLUT API macro definitions -- RGB color component specification definitions
*/
#define GLUT_RED 0x0000
#define GLUT_GREEN 0x0001
#define GLUT_BLUE 0x0002
/*
* GLUT API macro definitions -- additional keyboard and joystick definitions
*/
#define GLUT_KEY_REPEAT_OFF 0x0000
#define GLUT_KEY_REPEAT_ON 0x0001
#define GLUT_KEY_REPEAT_DEFAULT 0x0002
#define GLUT_JOYSTICK_BUTTON_A 0x0001
#define GLUT_JOYSTICK_BUTTON_B 0x0002
#define GLUT_JOYSTICK_BUTTON_C 0x0004
#define GLUT_JOYSTICK_BUTTON_D 0x0008
/*
* GLUT API macro definitions -- game mode definitions
*/
#define GLUT_GAME_MODE_ACTIVE 0x0000
#define GLUT_GAME_MODE_POSSIBLE 0x0001
#define GLUT_GAME_MODE_WIDTH 0x0002
#define GLUT_GAME_MODE_HEIGHT 0x0003
#define GLUT_GAME_MODE_PIXEL_DEPTH 0x0004
#define GLUT_GAME_MODE_REFRESH_RATE 0x0005
#define GLUT_GAME_MODE_DISPLAY_CHANGED 0x0006
/*
* Initialization functions, see fglut_init.c
*/
FGAPI void FGAPIENTRY glutInit( int* pargc, char** argv );
FGAPI void FGAPIENTRY glutInitWindowPosition( int x, int y );
FGAPI void FGAPIENTRY glutInitWindowSize( int width, int height );
FGAPI void FGAPIENTRY glutInitDisplayMode( unsigned int displayMode );
FGAPI void FGAPIENTRY glutInitDisplayString( const char* displayMode );
/*
* Process loop function, see fg_main.c
*/
FGAPI void FGAPIENTRY glutMainLoop( void );
/*
* Window management functions, see fg_window.c
*/
FGAPI int FGAPIENTRY glutCreateWindow( const char* title );
FGAPI int FGAPIENTRY glutCreateSubWindow( int window, int x, int y, int width, int height );
FGAPI void FGAPIENTRY glutDestroyWindow( int window );
FGAPI void FGAPIENTRY glutSetWindow( int window );
FGAPI int FGAPIENTRY glutGetWindow( void );
FGAPI void FGAPIENTRY glutSetWindowTitle( const char* title );
FGAPI void FGAPIENTRY glutSetIconTitle( const char* title );
FGAPI void FGAPIENTRY glutReshapeWindow( int width, int height );
FGAPI void FGAPIENTRY glutPositionWindow( int x, int y );
FGAPI void FGAPIENTRY glutShowWindow( void );
FGAPI void FGAPIENTRY glutHideWindow( void );
FGAPI void FGAPIENTRY glutIconifyWindow( void );
FGAPI void FGAPIENTRY glutPushWindow( void );
FGAPI void FGAPIENTRY glutPopWindow( void );
FGAPI void FGAPIENTRY glutFullScreen( void );
/*
* Display-related functions, see fg_display.c
*/
FGAPI void FGAPIENTRY glutPostWindowRedisplay( int window );
FGAPI void FGAPIENTRY glutPostRedisplay( void );
FGAPI void FGAPIENTRY glutSwapBuffers( void );
/*
* Mouse cursor functions, see fg_cursor.c
*/
FGAPI void FGAPIENTRY glutWarpPointer( int x, int y );
FGAPI void FGAPIENTRY glutSetCursor( int cursor );
/*
* Overlay stuff, see fg_overlay.c
*/
FGAPI void FGAPIENTRY glutEstablishOverlay( void );
FGAPI void FGAPIENTRY glutRemoveOverlay( void );
FGAPI void FGAPIENTRY glutUseLayer( GLenum layer );
FGAPI void FGAPIENTRY glutPostOverlayRedisplay( void );
FGAPI void FGAPIENTRY glutPostWindowOverlayRedisplay( int window );
FGAPI void FGAPIENTRY glutShowOverlay( void );
FGAPI void FGAPIENTRY glutHideOverlay( void );
/*
* Menu stuff, see fg_menu.c
*/
FGAPI int FGAPIENTRY glutCreateMenu( void (* callback)( int menu ) );
FGAPI void FGAPIENTRY glutDestroyMenu( int menu );
FGAPI int FGAPIENTRY glutGetMenu( void );
FGAPI void FGAPIENTRY glutSetMenu( int menu );
FGAPI void FGAPIENTRY glutAddMenuEntry( const char* label, int value );
FGAPI void FGAPIENTRY glutAddSubMenu( const char* label, int subMenu );
FGAPI void FGAPIENTRY glutChangeToMenuEntry( int item, const char* label, int value );
FGAPI void FGAPIENTRY glutChangeToSubMenu( int item, const char* label, int value );
FGAPI void FGAPIENTRY glutRemoveMenuItem( int item );
FGAPI void FGAPIENTRY glutAttachMenu( int button );
FGAPI void FGAPIENTRY glutDetachMenu( int button );
/*
* Global callback functions, see fg_callbacks.c
*/
FGAPI void FGAPIENTRY glutTimerFunc( unsigned int time, void (* callback)( int ), int value );
FGAPI void FGAPIENTRY glutIdleFunc( void (* callback)( void ) );
/*
* Window-specific callback functions, see fg_callbacks.c
*/
FGAPI void FGAPIENTRY glutKeyboardFunc( void (* callback)( unsigned char, int, int ) );
FGAPI void FGAPIENTRY glutSpecialFunc( void (* callback)( int, int, int ) );
FGAPI void FGAPIENTRY glutReshapeFunc( void (* callback)( int, int ) );
FGAPI void FGAPIENTRY glutVisibilityFunc( void (* callback)( int ) );
FGAPI void FGAPIENTRY glutDisplayFunc( void (* callback)( void ) );
FGAPI void FGAPIENTRY glutMouseFunc( void (* callback)( int, int, int, int ) );
FGAPI void FGAPIENTRY glutMotionFunc( void (* callback)( int, int ) );
FGAPI void FGAPIENTRY glutPassiveMotionFunc( void (* callback)( int, int ) );
FGAPI void FGAPIENTRY glutEntryFunc( void (* callback)( int ) );
FGAPI void FGAPIENTRY glutKeyboardUpFunc( void (* callback)( unsigned char, int, int ) );
FGAPI void FGAPIENTRY glutSpecialUpFunc( void (* callback)( int, int, int ) );
FGAPI void FGAPIENTRY glutJoystickFunc( void (* callback)( unsigned int, int, int, int ), int pollInterval );
FGAPI void FGAPIENTRY glutMenuStateFunc( void (* callback)( int ) );
FGAPI void FGAPIENTRY glutMenuStatusFunc( void (* callback)( int, int, int ) );
FGAPI void FGAPIENTRY glutOverlayDisplayFunc( void (* callback)( void ) );
FGAPI void FGAPIENTRY glutWindowStatusFunc( void (* callback)( int ) );
FGAPI void FGAPIENTRY glutSpaceballMotionFunc( void (* callback)( int, int, int ) );
FGAPI void FGAPIENTRY glutSpaceballRotateFunc( void (* callback)( int, int, int ) );
FGAPI void FGAPIENTRY glutSpaceballButtonFunc( void (* callback)( int, int ) );
FGAPI void FGAPIENTRY glutButtonBoxFunc( void (* callback)( int, int ) );
FGAPI void FGAPIENTRY glutDialsFunc( void (* callback)( int, int ) );
FGAPI void FGAPIENTRY glutTabletMotionFunc( void (* callback)( int, int ) );
FGAPI void FGAPIENTRY glutTabletButtonFunc( void (* callback)( int, int, int, int ) );
/*
* State setting and retrieval functions, see fg_state.c
*/
FGAPI int FGAPIENTRY glutGet( GLenum query );
FGAPI int FGAPIENTRY glutDeviceGet( GLenum query );
FGAPI int FGAPIENTRY glutGetModifiers( void );
FGAPI int FGAPIENTRY glutLayerGet( GLenum query );
/*
* Font stuff, see fg_font.c
*/
FGAPI void FGAPIENTRY glutBitmapCharacter( void* font, int character );
FGAPI int FGAPIENTRY glutBitmapWidth( void* font, int character );
FGAPI void FGAPIENTRY glutStrokeCharacter( void* font, int character );
FGAPI int FGAPIENTRY glutStrokeWidth( void* font, int character );
FGAPI GLfloat FGAPIENTRY glutStrokeWidthf( void* font, int character ); /* GLUT 3.8 */
FGAPI int FGAPIENTRY glutBitmapLength( void* font, const unsigned char* string );
FGAPI int FGAPIENTRY glutStrokeLength( void* font, const unsigned char* string );
FGAPI GLfloat FGAPIENTRY glutStrokeLengthf( void* font, const unsigned char *string ); /* GLUT 3.8 */
/*
* Geometry functions, see fg_geometry.c
*/
FGAPI void FGAPIENTRY glutWireCube( double size );
FGAPI void FGAPIENTRY glutSolidCube( double size );
FGAPI void FGAPIENTRY glutWireSphere( double radius, GLint slices, GLint stacks );
FGAPI void FGAPIENTRY glutSolidSphere( double radius, GLint slices, GLint stacks );
FGAPI void FGAPIENTRY glutWireCone( double base, double height, GLint slices, GLint stacks );
FGAPI void FGAPIENTRY glutSolidCone( double base, double height, GLint slices, GLint stacks );
FGAPI void FGAPIENTRY glutWireTorus( double innerRadius, double outerRadius, GLint sides, GLint rings );
FGAPI void FGAPIENTRY glutSolidTorus( double innerRadius, double outerRadius, GLint sides, GLint rings );
FGAPI void FGAPIENTRY glutWireDodecahedron( void );
FGAPI void FGAPIENTRY glutSolidDodecahedron( void );
FGAPI void FGAPIENTRY glutWireOctahedron( void );
FGAPI void FGAPIENTRY glutSolidOctahedron( void );
FGAPI void FGAPIENTRY glutWireTetrahedron( void );
FGAPI void FGAPIENTRY glutSolidTetrahedron( void );
FGAPI void FGAPIENTRY glutWireIcosahedron( void );
FGAPI void FGAPIENTRY glutSolidIcosahedron( void );
/*
* Teapot rendering functions, found in fg_teapot.c
* NB: front facing polygons have clockwise winding, not counter clockwise
*/
FGAPI void FGAPIENTRY glutWireTeapot( double size );
FGAPI void FGAPIENTRY glutSolidTeapot( double size );
/*
* Game mode functions, see fg_gamemode.c
*/
FGAPI void FGAPIENTRY glutGameModeString( const char* string );
FGAPI int FGAPIENTRY glutEnterGameMode( void );
FGAPI void FGAPIENTRY glutLeaveGameMode( void );
FGAPI int FGAPIENTRY glutGameModeGet( GLenum query );
/*
* Video resize functions, see fg_videoresize.c
*/
FGAPI int FGAPIENTRY glutVideoResizeGet( GLenum query );
FGAPI void FGAPIENTRY glutSetupVideoResizing( void );
FGAPI void FGAPIENTRY glutStopVideoResizing( void );
FGAPI void FGAPIENTRY glutVideoResize( int x, int y, int width, int height );
FGAPI void FGAPIENTRY glutVideoPan( int x, int y, int width, int height );
/*
* Colormap functions, see fg_misc.c
*/
FGAPI void FGAPIENTRY glutSetColor( int color, GLfloat red, GLfloat green, GLfloat blue );
FGAPI GLfloat FGAPIENTRY glutGetColor( int color, int component );
FGAPI void FGAPIENTRY glutCopyColormap( int window );
/*
* Misc keyboard and joystick functions, see fg_misc.c
*/
FGAPI void FGAPIENTRY glutIgnoreKeyRepeat( int ignore );
FGAPI void FGAPIENTRY glutSetKeyRepeat( int repeatMode );
FGAPI void FGAPIENTRY glutForceJoystickFunc( void );
/*
* Misc functions, see fg_misc.c
*/
FGAPI int FGAPIENTRY glutExtensionSupported( const char* extension );
FGAPI void FGAPIENTRY glutReportErrors( void );
/* Comment from glut.h of classic GLUT:
Win32 has an annoying issue where there are multiple C run-time
libraries (CRTs). If the executable is linked with a different CRT
from the GLUT DLL, the GLUT DLL will not share the same CRT static
data seen by the executable. In particular, atexit callbacks registered
in the executable will not be called if GLUT calls its (different)
exit routine). GLUT is typically built with the
"/MD" option (the CRT with multithreading DLL support), but the Visual
C++ linker default is "/ML" (the single threaded CRT).
One workaround to this issue is requiring users to always link with
the same CRT as GLUT is compiled with. That requires users supply a
non-standard option. GLUT 3.7 has its own built-in workaround where
the executable's "exit" function pointer is covertly passed to GLUT.
GLUT then calls the executable's exit function pointer to ensure that
any "atexit" calls registered by the application are called if GLUT
needs to exit.
Note that the __glut*WithExit routines should NEVER be called directly.
To avoid the atexit workaround, #define GLUT_DISABLE_ATEXIT_HACK. */
/* to get the prototype for exit() */
#include <stdlib.h>
#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK) && !defined(__WATCOMC__)
FGAPI void FGAPIENTRY __glutInitWithExit(int *argcp, char **argv, void (__cdecl *exitfunc)(int));
FGAPI int FGAPIENTRY __glutCreateWindowWithExit(const char *title, void (__cdecl *exitfunc)(int));
FGAPI int FGAPIENTRY __glutCreateMenuWithExit(void (* func)(int), void (__cdecl *exitfunc)(int));
#ifndef FREEGLUT_BUILDING_LIB
#if defined(__GNUC__)
#define FGUNUSED __attribute__((unused))
#else
#define FGUNUSED
#endif
static void FGAPIENTRY FGUNUSED glutInit_ATEXIT_HACK(int *argcp, char **argv) { __glutInitWithExit(argcp, argv, exit); }
#define glutInit glutInit_ATEXIT_HACK
static int FGAPIENTRY FGUNUSED glutCreateWindow_ATEXIT_HACK(const char *title) { return __glutCreateWindowWithExit(title, exit); }
#define glutCreateWindow glutCreateWindow_ATEXIT_HACK
static int FGAPIENTRY FGUNUSED glutCreateMenu_ATEXIT_HACK(void (* func)(int)) { return __glutCreateMenuWithExit(func, exit); }
#define glutCreateMenu glutCreateMenu_ATEXIT_HACK
#endif
#endif
#ifdef __cplusplus
}
#endif
/*** END OF FILE ***/
#endif /* __FREEGLUT_STD_H__ */

View file

@ -0,0 +1,21 @@
#ifndef __GLUT_H__
#define __GLUT_H__
/*
* glut.h
*
* The freeglut library include file
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "freeglut_std.h"
/*** END OF FILE ***/
#endif /* __GLUT_H__ */

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1 @@
freeglut-3.0.0

View file

@ -0,0 +1,133 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
/*************************************************************************
The main program.
This class provides the functionality of the main program. The program
starts after calling the "run" method. This method initializes the GLUT
system for rendering (using OpenGL) and user interaction. During the
initialization process different methods are connected to certain events
such as "display the window content", "act on mouse motion and buttons"
or "act on key events". Furthermore the main context menu is initialized
by calling the method "setup_context_menu".
Whenever one of the events described above occurs the appropriate functions
are called (They are however not called directly but via static functions
that forward the event. Read the included PDF if you are interested why
this is done and how it works).
The class maintains an instance of an tool_base which is initialized
to a concrete tool in the "context_menu_select" method.
The rendering of the canvas is done by an instance of "canvas_renderer"
while the data storage and modification operations are part of the class
"canvas_buffer".
**************************************************************************/
#pragma once
// Needed for openGL rendering and GLUT commands
#include "GL/glut.h"
// Needed for displaying text in the main window
#include "GL/freeglut_ext.h"
// Provides the storage for the pixels
#include "canvas_buffer.h"
// Renders the canvas_buffer
#include "canvas_renderer.h"
// An abstract tool that needs to be concretized
#include "tool_base.h"
// A helper class responsible for rendering the tool previews
#include "preview_renderer.h"
// An enumeration of menu actions. Whenever something
// from the context menu is selected the method "context_menu_select"
// is invoked with an element of this enumeration as a parameter
enum MenuActions
{
MA_TOOL_PEN = 1, // use pen tool
MA_TOOL_DDA_LINE, // use dda-line tool
MA_TOOL_BRESENHAM_LINE, // use bresenham-line tool
MA_TOOL_CIRCLE, // use bresenham-circle tool
MA_TOOL_RECTANGLE, // use box tool
MA_FILL_RECURSIVE, // use recursive fill tool
MA_FILL_NONRECURSIVE, // use non-recursive fill tool
MA_FILL_LINE, // use line-fill tool
MA_CLEAR_CANVAS, // clear the canvas
MA_TEST_SHAPE, // draw the test shape
MA_RESET_VIEW // reset translation and zoom
};
class application
{
public:
// Initialize all non-GLUT related variables
application();
// Destroy allocated objects
~application();
// Run the program using the command line arguments
int run(int argc, char* argv[]);
private:
// The storage for the pixels
canvas_buffer *canvas;
// The renderer for the pixels
canvas_renderer *renderer;
// A preview helper class
preview_renderer preview;
// The current tool
tool_base *tool;
// When drag operations are used (lines, circles...) then
// start_gx and start_gy store the start coordinates in grid units
int start_gx, start_gy;
// This flag indicates whether drag operations are running
bool is_dragging;
// Last seen mouse position
int last_mouse_x, last_mouse_y;
// True if the canvas is translated when the mouse is moved
bool is_scroll_mode;
// The static instance of this program. Read the PDF for more details
static application *instance;
// Set the current tool
void set_tool(tool_base *new_tool);
// The event method on key presses
void key_down(unsigned char key, int x, int y);
// The event method on mouse button presses
void mouse_button(int button, int state, int x, int y);
// The event method on mouse motions
void mouse_move(int x, int y);
// The event method on mouse wheel rotations
void mouse_wheel(int button, int dir, int x, int y);
// The event method on context menu selections
void context_menu_select(int item);
// The event method on window content rendering
void display();
// Initialize the context menu
void setup_context_menu();
// Static callbacks...
static void key_down_callback(unsigned char key, int x, int y);
static void mouse_button_callback(int button, int state, int x, int y);
static void mouse_move_callback(int x, int y);
static void mouse_wheel_callback(int button, int dir, int x, int y);
static void context_menu_callback(int item);
static void display_callback();
};

View file

@ -0,0 +1,29 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
/*************************************************************************
Bresenham-Circle tool.
This class is inherited from "tool_base" to define a tool for drawing
circles using the bresenham algorithm on a canvas_buffer.
Read the information in "tool_base.h" for more information.
*************************************************************************/
#pragma once
// provides the declaration of the super class tool_base
#include "tool_base.h"
class bresenham_circle_tool: public tool_base
{
public:
// Initialize the tool and store a reference of a canvas_buffer
bresenham_circle_tool(canvas_buffer &canvas);
// Draw a circle with center (x0, y0) and (x1, y1) on the circle
void draw(int x0, int y0, int x1, int y1);
// Put debug output into the stream "stream" to be displayed in the
// main window
void set_text(std::stringstream& stream);
};

View file

@ -0,0 +1,29 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
/*************************************************************************
Bresenham-Line tool.
This class is inherited from "tool_base" to define a tool for drawing
lines using the bresenham algorithm on a canvas_buffer.
Read the information in "tool_base.h" for more information.
*************************************************************************/
#pragma once
// provides the declaration of the super class tool_base
#include "tool_base.h"
class bresenham_line_tool: public tool_base
{
public:
// Initialize the tool and store a reference of a canvas_buffer
bresenham_line_tool(canvas_buffer &canvas);
// Draw a line from (x0, y0) to (x1, y1)
void draw(int x0, int y0, int x1, int y1);
// Put debug output into the stream "stream" to be displayed in the
// main window
void set_text(std::stringstream& stream);
};

View file

@ -0,0 +1,56 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
/*************************************************************************
Canvas Store.
This class stores a set of boolean pixels of the canvas and provides
methods for modification. Set a pixel with the set_pixel method and get
its state with the method "get_pixel". All methods that have a position
as a parameter will perform a boundary check and put an error message
to stdout if the boundaries are violated.
For debugging purposes the method "draw_test_shape" will draw a shape
that is suitable for testing the correctness of fill algorithms.
*************************************************************************/
#pragma once
class canvas_buffer
{
public:
// Initialize the store with a defined with and height
canvas_buffer(int width, int height);
// Free the memory used for the pixels
~canvas_buffer();
// Set a pixel at (x, y)
void set_pixel(int x, int y);
// Clear the pixel at (x, y)
void clear_pixel(int x, int y);
// Get the state of a pixel at (x, y)
bool get_pixel(int x, int y) const;
// Clear all pixels on the canvas
void clear_canvas();
// Get the width of the canvas in pixels
int get_width() const;
// Get the height of the canvas in pixels
int get_height() const;
// Draw the test shape
void draw_test_shape();
private:
// The actual pixels store as array
bool* pixels;
// Width and height of the canvas
int width, height;
};

View file

@ -0,0 +1,63 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
/*************************************************************************
Canvas Renderer.
This class is responsible for the graphical representation of a canvas
store. Among the "render" method that performs the actual rendering on
a grid a translation and zoom can be specified. Also this class provides
a method to convert screen coordinates to grid coordinates and to
snap screen coordinates to the next center of a pixel cell.
*************************************************************************/
#pragma once
// declares the canvas_buffer
#include "canvas_buffer.h"
class canvas_renderer
{
public:
// Initialize the renderer and store a reference of a canvas_buffer
canvas_renderer(canvas_buffer &canvas);
// Set the translation
void set_translation(double x, double y);
// Get the translation
void get_translation(double &x, double &y) const;
// Set the zoom factor
void set_zoom(double factor);
// Get the zoom factor
double get_zoom() const;
// Convert a screen position to a grid position
void screen_to_grid(int sx, int sy, int &gx, int &gy) const;
// Get the next cell center from the provided position
void snap_screen_coords(int sx, int sy, int &scx, int &scy) const;
// Render the contents of the canvas store
void render() const;
// Get the size of a cell in pixels
double get_cell_size() const;
// Reset translation and zoom factor
void reset_view();
private:
// Translation
double trans_x, trans_y;
// Zoom factor
double zoom_factor;
// A reference on the canvas store
canvas_buffer &canvas;
// Helper method to render the grid
void render_grid() const;
};

View file

@ -0,0 +1,29 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
/*************************************************************************
DDA-Line tool.
This class is inherited from "tool_base" to define a tool for drawing
lines using the DDA algorithm on a canvas_buffer.
Read the information in "tool_base.h" for more information.
*************************************************************************/
#pragma once
// provides the declaration of the super class tool_base
#include "tool_base.h"
class dda_line_tool: public tool_base
{
public:
// Initialize the tool and store a reference of a canvas_buffer
dda_line_tool(canvas_buffer &canvas);
// Draw a line from (x0, y0) to (x1, y1)
void draw(int from_x, int from_y, int to_x, int to_y);
// Put debug output into the stream "stream" to be displayed in the
// main window
void set_text(std::stringstream& stream);
};

View file

@ -0,0 +1,41 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
/*************************************************************************
Line-fill tool.
This class is inherited from "tool_base" to define a tool for filling
shapes using the scan line algorithm on a canvas_buffer.
Read the information in "tool_base.h" for more information.
*************************************************************************/
#pragma once
// provides the declaration of the super class tool_base
#include "tool_base.h"
// needed for a double ended queue
#include <deque>
using namespace std;
// A line to be filled
struct waiting_line {
int x, y;
};
class line_fill_tool: public tool_base
{
public:
// Initialize the tool and store a reference of a canvas_buffer
line_fill_tool(canvas_buffer &canvas);
// Fill the shape that contains the point (x, y)
void draw(int x, int y);
// Put debug output into the stream "stream" to be displayed in the
// main window
void set_text(stringstream& stream);
};

View file

@ -0,0 +1,29 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
/*************************************************************************
Non-Recursive-fill tool.
This class is inherited from "tool_base" to define a tool for filling
shapes using a generic non-recursive algorithm on a canvas_buffer.
Read the information in "tool_base.h" for more information.
*************************************************************************/
#pragma once
// provides the declaration of the super class tool_base
#include "tool_base.h"
class non_recursive_fill_tool: public tool_base
{
public:
// Initialize the tool and store a reference of a canvas_buffer
non_recursive_fill_tool(canvas_buffer &canvas);
// Fill the shape that contains the point (x, y)
void draw(int x, int y);
// Put debug output into the stream "stream" to be displayed in the
// main window
void set_text(std::stringstream& stream);
};

View file

@ -0,0 +1,29 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
/*************************************************************************
pen tool.
This class is inherited from "tool_base" to define a tool for setting
a single pixel on a canvas_buffer.
Read the information in "tool_base.h" for more information.
*************************************************************************/
#pragma once
// provides the declaration of the super class tool_base
#include "tool_base.h"
class pen_tool: public tool_base
{
public:
// Initialize the tool and store a reference of a canvas_buffer
pen_tool(canvas_buffer &canvas);
// Set the pixel at (x, y)
void draw(int x, int y);
// Put debug output into the stream "stream" to be displayed in the
// main window
void set_text(std::stringstream& stream);
};

View file

@ -0,0 +1,44 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
/*************************************************************************
Helper class to render previews.
This class renders definable shapes. It is used to display the previews
for the drawing tools. It can be enabled/disabled and rendered using the
"render" method.
*************************************************************************/
#pragma once
// provides the declaration of the super class tool_base
#include "tool_base.h"
class preview_renderer
{
public:
// Initialize the preview renderer
preview_renderer();
// Enable rendering of previews
void enable_rendering();
// Disable rendering of previews
void disable_rendering();
// Set the start of a 2-point shape
void set_start(int x, int y);
// Set the destination of a 2-point shape
void set_dest(int x, int y);
// Set the shape
void set_shape(ToolShape shape);
// Render the preview
void render();
private:
// The actual shape id
ToolShape shape;
// Start and destination of the shape
int start_x, start_y, dest_x, dest_y;
// State indicating whether rendering is enabled
bool enabled;
};

View file

@ -0,0 +1,29 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
/*************************************************************************
rectangle tool.
This class is inherited from "tool_base" to define a tool for drawing
a box on a canvas_buffer.
Read the information in "tool_base.h" for more information.
*************************************************************************/
#pragma once
// provides the declaration of the super class tool_base
#include "tool_base.h"
class rectangle_tool: public tool_base
{
public:
// Initialize the tool and store a reference of a canvas_buffer
rectangle_tool(canvas_buffer &canvas);
// Draw a box from (x0, y0) to (x1, y1)
void draw(int x0, int y0, int x1, int y1);
// Put debug output into the stream "stream" to be displayed in the
// main window
void set_text(std::stringstream& stream);
};

View file

@ -0,0 +1,29 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
/*************************************************************************
Recursive-fill tool.
This class is inherited from "tool_base" to define a tool for filling
shapes using a simple recursive algorithm on a canvas_buffer.
Read the information in "tool_base.h" for more information.
*************************************************************************/
#pragma once
// provides the declaration of the super class tool_base
#include "tool_base.h"
class recursive_fill_tool: public tool_base
{
public:
// Initialize the tool and store a reference of a canvas_buffer
recursive_fill_tool(canvas_buffer &canvas);
// Fill the shape that contains the point (x, y)
void draw(int x, int y);
// Put debug output into the stream "stream" to be displayed in the
// main window
void set_text(std::stringstream& stream);
};

View file

@ -0,0 +1,903 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2015 CGV TU Dresden - All Rights Reserved
//
/*************************************************************************
Template class for vectors.
This template class defines small vectors of a defined dimension with
an arbitrary data type. Basic operations such as addition of vectors and
multiplication of a vector and a scalar are supported via operator
overloading. Also more advanced functions such as normalization and
iterating through the elements are implemented.
At the end of this file the data types "point2d", "point3d" and
"point4d" are specified as a tinyvec of doubles with the according dimension.
*************************************************************************/
#pragma once
#include <iostream>
#include <algorithm>
#pragma warning( disable : 4996 )
template <typename T,int N>
class tiny_vec
{
T _data[N];
public:
typedef T value_type;
typedef T& reference;
typedef const T& const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T* iterator;
typedef const T* const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
tiny_vec();
template <typename InputIterator>
tiny_vec(InputIterator first,InputIterator last)
{
std::copy(first,last,begin());
}
tiny_vec(size_t n, const T* marray);
~tiny_vec();
tiny_vec(const T&x,const T&y);
tiny_vec(const T&x,const T&y, const T&z);
tiny_vec(const T&x, const T&y, const T&z,const T& w);
int size() const;
operator T*();
operator const T*() const;
void set(const T& x);
void set(const T& x, const T& y);
void set(const T& x, const T& y,const T& z);
void set(const T& x, const T& y,const T& z, const T& w);
tiny_vec& operator=(const T &s);
tiny_vec& operator=(int s);
tiny_vec& operator=(const tiny_vec & v);
void fill(const T& s);
void zeros(size_t m);
void zeros();
void ones();
void ones(size_t m);
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
reverse_iterator rbegin();
reverse_iterator rend();
const_reverse_iterator rbegin() const;
const_reverse_iterator rend() const;
bool operator==(const tiny_vec& v) const;
bool operator!=(const tiny_vec& v) const;
tiny_vec operator-() const;
tiny_vec& operator+=(const T& s);
tiny_vec& operator+=(int s);
tiny_vec operator+(const T& s) const;
tiny_vec operator+(int s) const;
tiny_vec& operator-=(const T& s);
tiny_vec& operator-=(int s);
tiny_vec operator-(const T& s) const;
tiny_vec operator-(int s) const;
tiny_vec& operator*=(const T& s);
tiny_vec& operator*=(int s);
tiny_vec operator*(const T& s) const;
tiny_vec operator*(int s) const;
tiny_vec& operator/=(const T& s);
tiny_vec& operator/=(int s);
tiny_vec operator/(const T& s) const;
tiny_vec operator/(int s) const;
tiny_vec& operator+=(const tiny_vec& v);
tiny_vec operator+(const tiny_vec& v) const;
tiny_vec& operator-=(const tiny_vec& v);
tiny_vec operator-(const tiny_vec& v) const;
tiny_vec& operator*=(const tiny_vec& v);
tiny_vec operator*(const tiny_vec& v) const;
tiny_vec& operator/=(const tiny_vec& v);
tiny_vec operator/(const tiny_vec& v) const;
T& operator()(size_t i);
T operator()(size_t i) const;
T& x() {return _data[0];};
T& y() {return _data[1];};
T& z() {return _data[2];};
T x() const {return _data[0];};
T y() const {return _data[1];};
T z() const {return _data[2];};
void sort();
void random_shuffle();
T& min_elem();
size_t min_index();
T& max_elem();
size_t max_index();
T& median_elem();
size_t median_index();
T sqr_length();
T length();
void normalize();
};
template <typename T, int N>
tiny_vec<T,N>::tiny_vec(){}
template <typename T, int N>
tiny_vec<T,N>::tiny_vec(size_t n, const T* marray)
{
std::copy(marray,marray+_size,begin());
}
template <typename T, int N>
tiny_vec<T,N>::~tiny_vec(){}
template <typename T, int N>
tiny_vec<T,N>::tiny_vec(const T&x,const T&y)
{
_data[0]=x;
_data[1]=y;
}
template <typename T, int N>
tiny_vec<T,N>::tiny_vec(const T&x,const T&y, const T&z)
{
_data[0]=x;
_data[1]=y;
_data[2]=z;
}
template <typename T, int N>
tiny_vec<T,N>::tiny_vec(const T&x, const T&y, const T&z,const T& w)
{
_data[0]=x;
_data[1]=y;
_data[2]=z;
_data[3]=w;
}
template <typename T, int N>
void tiny_vec<T,N>::set(const T& x)
{
_data[0]=x;
}
template <typename T, int N>
void tiny_vec<T,N>::set(const T& x, const T& y)
{
_data[0]=x;
_data[1]=y;
}
template <typename T, int N>
void tiny_vec<T,N>::set(const T& x, const T& y,const T& z)
{
_data[0]=x;
_data[1]=y;
_data[2]=z;
}
template <typename T, int N>
void tiny_vec<T,N>::set(const T& x, const T& y,const T& z, const T& w)
{
_data[0]=x;
_data[1]=y;
_data[2]=z;
_data[3]=w;
}
template <typename T, int N>
int tiny_vec<T,N>::size() const
{
return N;
}
template <typename T, int N>
tiny_vec<T,N>::operator T*()
{
return _data;
}
template <typename T, int N>
tiny_vec<T,N>::operator const T*() const
{
return _data;
}
template <typename T, int N>
tiny_vec<T,N>& tiny_vec<T,N>::operator=(const T &s)
{
for(int i=0;i < N;i++)
_data[i]=s;
return *this;
}
template <typename T, int N>
tiny_vec<T,N>& tiny_vec<T,N>::operator=(int s)
{
for(int i=0;i<N;i++)
_data[i]=(T)s;
return *this;
}
template <typename T, int N>
tiny_vec<T,N>& tiny_vec<T,N>::operator=(const tiny_vec & v)
{
if(&v== this) return *this;
std::copy(v.begin(),v.end(),begin());
return *this;
}
template <typename T, int N>
void tiny_vec<T,N>::fill(const T& s)
{
std::fill(begin(),end(),s);
}
template <typename T, int N>
void tiny_vec<T,N>::zeros(size_t m)
{
T zero;
zero=0;
std::fill(begin(), end(), zero);
}
template <typename T, int N>
void tiny_vec<T,N>::zeros()
{
T zero;
zero=0;
std::fill(begin(), end(), zero);
}
template <typename T, int N>
void tiny_vec<T,N>::ones()
{
T one;
one = 1;
std::fill(begin(), end(), one);
}
template <typename T, int N>
void tiny_vec<T,N>::ones(size_t m)
{
resize(m);
T one;
one = 1;
std::fill(begin(), end(), one);
}
template <typename T, int N>
typename tiny_vec<T,N>::iterator tiny_vec<T,N>::begin()
{
return _data;
}
template <typename T, int N>
typename tiny_vec<T,N>::const_iterator tiny_vec<T,N>::begin() const
{
return _data;
}
template <typename T, int N>
typename tiny_vec<T,N>::iterator tiny_vec<T,N>::end()
{
return _data + N;
}
template <typename T, int N>
typename tiny_vec<T,N>::const_iterator tiny_vec<T,N>::end() const
{
return _data +N;
}
template <typename T, int N>
typename tiny_vec<T,N>::reverse_iterator tiny_vec<T,N>::rbegin()
{
return reverse_iterator(end());
}
template <typename T, int N>
typename tiny_vec<T,N>::reverse_iterator tiny_vec<T,N>::rend()
{
return reverse_iterator(begin());
}
template <typename T, int N>
typename tiny_vec<T,N>::const_reverse_iterator tiny_vec<T,N>::rbegin() const
{
return const_reverse_iterator(end());
}
template <typename T, int N>
typename tiny_vec<T,N>::const_reverse_iterator tiny_vec<T,N>:: rend() const
{
return const_reverse_iterator(begin());
}
template <typename T, int N>
bool tiny_vec<T,N>::operator==(const tiny_vec<T,N>& v) const
{
return std::equal(begin(),end(),v.begin());
}
template <typename T, int N>
bool tiny_vec<T,N>::operator!=(const tiny_vec<T,N>& v) const
{
return !(*this == v);
}
template <typename T, int N>
tiny_vec<T,N> tiny_vec<T,N>::operator-() const
{
return (T)-1* *this;
}
template <typename T, int N>
tiny_vec<T,N>& tiny_vec<T,N>::operator+=(const T& s)
{
#ifdef _HAS_CPP0X
std::for_each(begin(),end(),[&s](T& elem){elem+=s;});
#else
for(int i=0;i<size();i++)
_data[i]+=s;
#endif
return *this;
}
template <typename T, int N>
tiny_vec<T,N>& tiny_vec<T,N>::operator+=(int s)
{
#ifdef _HAS_CPP0X
std::for_each(begin(),end(),[&s](T& elem){elem+=(T)s;});
#else
for(int i=0;i<size();i++)
_data[i]+=s;
#endif
return *this;
}
template <typename T, int N>
tiny_vec<T,N> tiny_vec<T,N>::operator+(const T& s) const
{
tiny_vec r = *this;
r += s;
return r;
}
template <typename T, int N>
tiny_vec<T,N> tiny_vec<T,N>::operator+(int s) const
{
tiny_vec r = *this;
r += s;
return r;
}
template <typename T, int N>
tiny_vec<T,N>& tiny_vec<T,N>::operator-=(const T& s)
{
#ifdef _HAS_CPP0X
std::for_each(begin(),end(),[&s](T& elem){elem-=s;});
#else
for(int i=0; i < N;i++)
_data[i]-=s;
#endif
return *this;
}
template <typename T, int N>
tiny_vec<T,N>& tiny_vec<T,N>::operator-=(int s)
{
#ifdef _HAS_CPP0X
std::for_each(begin(),end(),[&s](T& elem){elem-=(T)s;});
#else
for(int i=0;i<N;i++)
_data[i]-=(T)s;
#endif
return *this;
}
template <typename T, int N>
tiny_vec<T,N> tiny_vec<T,N>::operator-(const T& s) const
{
tiny_vec r = *this;
r -= s;
return r;
}
template <typename T, int N>
tiny_vec<T,N> tiny_vec<T,N>::operator-(int s) const
{
tiny_vec r = *this;
r -= (T)s;
return r;
}
template <typename T, int N>
tiny_vec<T,N>& tiny_vec<T,N>::operator*=(const T& s)
{
#ifdef _HAS_CPP0X
std::for_each(begin(),end(),[&s](T& elem){elem *= s;});
#else
for(int i=0;i < N;i++)
_data[i]*=s;
#endif
return *this;
}
template <typename T, int N>
tiny_vec<T,N>& tiny_vec<T,N>::operator*=(int s)
{
#ifdef _HAS_CPP0X
std::for_each(begin(),end(),[&s](T& elem){elem *= (T)s;});
#else
for(int i=0; i <N; i++)
_data[i]*=(T)s;
#endif
return *this;
}
template <typename T, int N>
tiny_vec<T,N> tiny_vec<T,N>::operator*(const T& s) const
{
tiny_vec<T,N> r = *this;
r *= s;
return r;
}
template <typename T, int N>
tiny_vec<T,N> tiny_vec<T,N>::operator*(int s) const
{
tiny_vec<T,N> r = *this;
r *= (T)s;
return r;
}
template <typename T, int N>
tiny_vec<T,N>& tiny_vec<T,N>::operator/=(const T& s)
{
#ifdef _HAS_CPP0X
std::for_each(begin(),end(),[&s](T& elem){elem/=s;});
#else
for(int i=0; i <N; i++)
_data[i]/=s;
#endif
return *this;
}
template <typename T, int N>
tiny_vec<T,N>& tiny_vec<T,N>::operator/=(int s)
{
#ifdef _HAS_CPP0X
std::for_each(begin(),end(),[&s](T& elem){elem/=(T)s;});
#else
for(int i=0;i <N; i++)
_data[i]/=(T)s;
#endif
return *this;
}
template <typename T, int N>
tiny_vec<T,N> tiny_vec<T,N>::operator/(const T& s) const
{
tiny_vec<T,N> r = *this;
r /= s;
return r;
}
template <typename T, int N>
tiny_vec<T,N> tiny_vec<T,N>::operator/(int s) const
{
tiny_vec<T,N> r = *this;
r /= (T)s;
return r;
}
template <typename T, int N>
tiny_vec<T,N>& tiny_vec<T,N>::operator+=(const tiny_vec& v)
{
#ifdef _HAS_CPP0X
const_iterator vit=v.begin();
std::for_each(begin(),end(),[&vit](T& elem){elem+=*vit++;});
#else
for(int i=0; i <N;i++)
_data[i] += v[i];
#endif
return *this;
}
template <typename T, int N>
tiny_vec<T,N> tiny_vec<T,N>::operator+(const tiny_vec& v) const
{
tiny_vec r = *this;
r += v;
return r;
}
template <typename T, int N>
tiny_vec<T,N>& tiny_vec<T,N>::operator-=(const tiny_vec& v)
{
#ifdef _HAS_CPP0X
const_iterator vit=v.begin();
std::for_each(begin(),end(),[&vit](T& elem){elem-=*vit++;});
#else
for(int i =0; i < N; i++)
_data[i]-= v[i];
#endif
return *this;
}
template <typename T, int N>
tiny_vec<T,N> tiny_vec<T,N>::operator-(const tiny_vec& v) const
{
tiny_vec r = *this;
r -= v;
return r;
}
template <typename T, int N>
tiny_vec<T,N>& tiny_vec<T,N>::operator*=(const tiny_vec& v)
{
#ifdef _HAS_CPP0X
auto vit=v.begin();
std::for_each(begin(),end(),[&vit](T& elem){elem*=*vit++;});
#else
for(int i=0; i < N; i++)
_data[i]*= v[i];
#endif
return *this;
}
template <typename T, int N>
tiny_vec<T,N> tiny_vec<T,N>::operator*(const tiny_vec& v) const
{
tiny_vec<T,N> r = *this;
r *= v;
return r;
}
template <typename T, int N>
tiny_vec<T,N>& tiny_vec<T,N>::operator/=(const tiny_vec& v)
{
#ifdef _HAS_CPP0X
auto vit=v.begin();
std::for_each(begin(),end(),[&vit](T& elem){elem/=*vit++;});
#else
for(int i = 0; i < N; i++)
_data[i] /= v[i];
#endif
return *this;
}
template <typename T, int N>
tiny_vec<T,N> tiny_vec<T,N>::operator/(const tiny_vec<T,N>& v) const
{
tiny_vec r = *this;
r /= v;
return r;
}
template <typename T, int N>
T& tiny_vec<T,N>::operator()(size_t i)
{
assert(i >= 0 && i < N);
return _data[i];
}
template <typename T, int N>
T tiny_vec<T,N>::operator()(size_t i) const
{
assert(i >= 0 && i < N);
return _data[i];
}
template <typename T, int N>
void tiny_vec<T,N>::sort()
{
std::sort(begin(),end());
}
template <typename T, int N>
void tiny_vec<T,N>::random_shuffle()
{
std::random_shuffle(begin(),end());
}
template <typename T, int N>
T& tiny_vec<T,N>::min_elem()
{
return *std::min_element(begin(),end());
}
template <typename T, int N>
size_t tiny_vec<T,N>::min_index()
{
return std::distance(begin(),std::min_element(begin(),end()));
}
template <typename T, int N>
T& tiny_vec<T,N>::max_elem()
{
return *std::max_element(begin(),end());
}
template <typename T, int N>
size_t tiny_vec<T,N>::max_index()
{
return std::distance(begin(),std::max_element(begin(),end()));
}
template <typename T, int N>
T& tiny_vec<T,N>::median_elem()
{
iterator it= begin() + _size/2;
std::nth_element(begin(),it,end());
return *it;
}
template <typename T, int N>
size_t tiny_vec<T,N>::median_index()
{
return begin() +_size/2;
}
template <typename T, int N>
T tiny_vec<T,N>::sqr_length()
{
iterator it= begin();
T l = 0;
while(it != end())
l += (*it)*(*it++);
return l;
}
template <typename T, int N>
T tiny_vec<T,N>::length()
{
T l = sqr_length();
return sqrt(l);
}
template <typename T, int N>
tiny_vec<T,N> operator+(const T& s, const tiny_vec<T,N>& v)
{
return v+s;
}
template <typename T, int N>
tiny_vec<T,N> operator+(int s, const tiny_vec<T,N>& v)
{
return v+(T)s;
}
template <typename T, int N>
tiny_vec<T,N> operator-(const T& s, const tiny_vec<T,N>& v)
{
return -v+s;
}
template <typename T, int N>
tiny_vec<T,N> operator-(int s, const tiny_vec<T,N>& v)
{
return -v+(T)s;
}
template <typename T, int N>
tiny_vec<T,N> operator*(const T& s, const tiny_vec<T,N>& v)
{
return v*s;
}
template <typename T, int N>
tiny_vec<T,N> operator*(int s, const tiny_vec<T,N>& v)
{
return v*(T)s;
}
template <typename T, int N>
tiny_vec<T,N> operator/(const T& s, const tiny_vec<T,N>& v)
{
return v*(T)(1.0/s);
}
template <typename T, int N>
tiny_vec<T,N> operator/(int s, const tiny_vec<T,N>& v)
{
return v*(T)(1.0/s);
}
template <typename T, int N>
T dot(const tiny_vec<T,N>& v1, const tiny_vec<T,N>& v2)
{
return std::inner_product(v1.begin(),v1.end(),v2.begin(),(T)0);
}
template <typename T>
tiny_vec<T,3> cross(const tiny_vec<T,3>& b, const tiny_vec<T,3>& c)
{
tiny_vec<T,3> a;
a[0] = b(1)*c(2) - b(2)*c(1);
a[1] = b(2)*c(0) - b(0)*c(2);
a[2] = b(0)*c(1) - b(1)*c(0);
return a;
}
template <typename T, int N>
tiny_vec<T,N+1> homog(const tiny_vec<T,N>& v)
{
tiny_vec<T,N+1> vh;
std::copy(v.begin(),v.end(),vh.begin());
vh(v.size()) = (T)1;
return vh;
}
template <typename T, int N>
tiny_vec<T,N-1> unhomog(const tiny_vec<T,N>& v)
{
tiny_vec<T,N-1> vh;
T w = *(v.end()-1);
#ifdef _HAS_CPP0X
auto vit=v.begin();
std::for_each(vh.begin(),vh.end(),[&](T& elem){elem=*vit++/w;});
#else
for(int i = 0; i < N-1; i++)
vh[i] = v[i]/w;
#endif
return vh;
}
template <typename T, int N>
std::ostream& operator<<(std::ostream& out, const tiny_vec<T,N>& v)
{
#ifdef _HAS_CPP0X
auto it = v.begin();
if(it != v.end())
out << *it ++;
std::for_each(it, v.end(),[&out](const T& elem){ out << " " << elem;});
#else
if(v.size() > 0)
out << v[0];
for(int i = 1; i < v.size(); i++)
out <<" " <<v[i];
#endif
return out;
}
template <typename T,int N>
std::istream& operator>>(std::istream& in, tiny_vec<T,N>& v)
{
#ifdef _HAS_CPP0X
std::for_each(v.begin(), v.end(),[&in](T& elem){ in >> elem;});
#else
for(int i = 0; i < v.size(); i++)
in >> v[i];
#endif
return in;
}
template <typename T, int N>
void tiny_vec<T,N>::normalize()
{
T l = length();
if(l != 0)
operator/=(l);
}
typedef tiny_vec<double, 2> point2d;
typedef tiny_vec<double, 3> point3d;
typedef tiny_vec<double, 4> point4d;

View file

@ -0,0 +1,67 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
/*************************************************************************
Abstract tool.
This class provides the basic superclass for all tools (pen, lines, circle...)
The constructor of the class takes a reference of a canvas_buffer as parameter
on which the pixels are changed.
The user of an instance of a derived class can use two different draw methods:
One version that operates only with the information of a single position
(e.g. the pen or the fill tools) and one that needs two pixel positions
(e.g. the line, circle or box). Also every tool maintains an element of
the enumerations of possible shapes (which are used for the preview tool).
For debugging purpose a method "set_text" is provided which modifies a
text stream that will be displayed in the main window.
*************************************************************************/
#pragma once
// needed for the set_text method
#include <sstream>
// declares the canvas_buffer
#include "canvas_buffer.h"
// Enumeration of possible shapes
enum ToolShape
{
TS_LINE, // a line
TS_BOX, // a box
TS_CIRCLE, // a circle
TS_NONE // no shape
};
class tool_base
{
public:
// Initialize the tool and store a reference of a canvas_buffer
tool_base(canvas_buffer &canvas);
// Draw with one point provided
virtual void draw(int x, int y);
// Draw with two points provided
virtual void draw(int x0, int y0, int x1, int y1);
// Get the shape that this tool will draw
const ToolShape get_shape() const;
// Put a text into the stream "stream" which will be displayed
// in the main window
virtual void set_text(std::stringstream& stream);
// Return true if draw(x, y) is valid during dragging operations
const bool is_tool_draggable() const;
protected:
// The shape which is initialized in the constructor
ToolShape shape;
// A reference of the canvas store
canvas_buffer &canvas;
bool is_draggable;
};

BIN
exercise2/solution.exe Normal file

Binary file not shown.

View file

@ -0,0 +1,441 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
#include "application.h"
#include <sstream>
#include <math.h>
#include "pen_tool.h"
#include "dda_line_tool.h"
#include "bresenham_line_tool.h"
#include "bresenham_circle_tool.h"
#include "recursive_fill_tool.h"
#include "non_recursive_fill_tool.h"
#include "line_fill_tool.h"
#include "rectangle_tool.h"
application::application()
{
instance = this;
// No dragging, so invalidate the start coordinates
start_gx = -1;
start_gy = -1;
is_dragging = false;
// Initialize the canvas with a size of 100x100
canvas = new canvas_buffer(100, 100);
// Initialize the renderer
renderer = new canvas_renderer(*canvas);
// No tool selected
tool = 0;
// Not in scroll mode
is_scroll_mode = false;
}
application::~application()
{
delete canvas;
delete renderer;
}
// Run the program using the command line arguments
int application::run(int argc, char* argv[])
{
// Initialize the GLUT system and let it evaluate additional
// command line arguments.
glutInit(&argc, argv);
// Set the openGL display mode to double buffering and have
// channels R,G,B active.
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
// Initialize main window size
glutInitWindowSize(620, 640);
// Set a title
glutCreateWindow("ECG Rastergraphik");
// Set the context menu
setup_context_menu();
// Initialize the starting tool
context_menu_select(MA_TOOL_PEN);
// The following section tells GLUT which methods to call
// whenever certain events happen.
// ... when the screen shall be displayed
glutDisplayFunc(display_callback);
// ... when a key was pressed
glutKeyboardFunc(key_down_callback);
// ... when a mouse button was pressed
glutMouseFunc(mouse_button_callback);
// ... when the mouse was moved with buttons pressed
glutMotionFunc(mouse_move_callback);
// ... when the wheel was pressed or moved
glutMouseWheelFunc(mouse_wheel_callback);
// The main loop runs the program itself. It repeatedly asks
// the operating system whether there are events to process
// and, according to the type of the event, calls the right
// method (that was defined above).
glutMainLoop();
return 0;
}
// The event method on context menu selections
void application::context_menu_select(int item)
{
switch(item)
{
// Set the pen as tool
case MA_TOOL_PEN:
set_tool(new pen_tool(*canvas));
break;
// Set the dda line tool
case MA_TOOL_DDA_LINE:
set_tool(new dda_line_tool(*canvas));
break;
// Set the bresenham line tool
case MA_TOOL_BRESENHAM_LINE:
set_tool(new bresenham_line_tool(*canvas));
break;
// Set the bresenham circle tool
case MA_TOOL_CIRCLE:
set_tool(new bresenham_circle_tool(*canvas));
break;
// Set the box tool
case MA_TOOL_RECTANGLE:
set_tool(new rectangle_tool(*canvas));
break;
// Set the recursive fill tool
case MA_FILL_RECURSIVE:
set_tool(new recursive_fill_tool(*canvas));
break;
// Set the non-recursive fill tool
case MA_FILL_NONRECURSIVE:
set_tool(new non_recursive_fill_tool(*canvas));
break;
// Set the line fill tool
case MA_FILL_LINE:
set_tool(new line_fill_tool(*canvas));
break;
// Clear the canvas
case MA_CLEAR_CANVAS:
canvas->clear_canvas();
break;
// Draw the test shape
case MA_TEST_SHAPE:
canvas->draw_test_shape();
break;
// Reset translation and zoom
case MA_RESET_VIEW:
renderer->reset_view();
break;
}
// Update display
display();
}
// Set the current tool to use
void application::set_tool(tool_base *new_tool)
{
if (tool)
delete tool;
tool = new_tool;
// Also update the preview helper class
preview.set_shape(tool->get_shape());
}
// Initialize the context menu
void application::setup_context_menu()
{
glutCreateMenu(context_menu_callback);
// Set the menu entries and associate them with the
// appropriate menu action ID
glutAddMenuEntry(" ------ Primitive Tools ------ ", -1);
glutAddMenuEntry(" Pen (p) ", MA_TOOL_PEN);
glutAddMenuEntry(" -------- Shape Tools -------- ", -1);
glutAddMenuEntry(" Line (using DDA) (d) ", MA_TOOL_DDA_LINE);
glutAddMenuEntry(" Line (using Bresenham) (b) ", MA_TOOL_BRESENHAM_LINE);
glutAddMenuEntry(" Circle (using Bresenham) (o) ", MA_TOOL_CIRCLE);
glutAddMenuEntry(" Rectangle (s) ", MA_TOOL_RECTANGLE);
glutAddMenuEntry(" ------------ Fill ----------- ", -1);
glutAddMenuEntry(" Recursive Fill (r) ", MA_FILL_RECURSIVE);
glutAddMenuEntry(" Non-recursive Fill (f) ", MA_FILL_NONRECURSIVE);
glutAddMenuEntry(" Line-Fill (l) ", MA_FILL_LINE);
glutAddMenuEntry(" ------- Miscellaneous ------- ", -1);
glutAddMenuEntry(" Clear canvas (c) ", MA_CLEAR_CANVAS);
glutAddMenuEntry(" Draw test shape (t) ", MA_TEST_SHAPE);
glutAddMenuEntry(" Reset view (bcks) ", MA_RESET_VIEW);
// Attach the menu to the right mouse button
glutAttachMenu(GLUT_RIGHT_BUTTON);
}
// The event method on window content rendering
void application::display()
{
// Set the projection to use orthogonal projection with
// a coordinate system that increases from left to right
// and from top to bottom where one unit corresponds to
// one screen pixel
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT), 0, 1.0, -1.0);
// Reset Modelview transformations
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// Clear the screen
glClearColor(1,1,1,0);
glClear(GL_COLOR_BUFFER_BIT);
// Render the grid
renderer->render();
// Render the preview (if enabled)
preview.render();
// Render the debug output
std::stringstream stream;
tool->set_text(stream);
glColor3d(0.0, 0.0, 0.0);
// Go to the bottom left of the window
glRasterPos2i(10, glutGet(GLUT_WINDOW_HEIGHT)-10);
glutBitmapString(GLUT_BITMAP_HELVETICA_12, reinterpret_cast<const unsigned char*>(stream.str().c_str()) );
// Swap the just filled back buffer with the front buffer
// to display the result
glutSwapBuffers();
}
// The event method on key presses
void application::key_down(unsigned char key, int x, int y)
{
// According to the key different actions are performed
// by using the "context_menu_select" method.
switch(key)
{
case 'p': context_menu_select(MA_TOOL_PEN); break;
case 'd': context_menu_select(MA_TOOL_DDA_LINE); break;
case 'b': context_menu_select(MA_TOOL_BRESENHAM_LINE); break;
case 'o': context_menu_select(MA_TOOL_CIRCLE); break;
case 's': context_menu_select(MA_TOOL_RECTANGLE); break;
case 'r': context_menu_select(MA_FILL_RECURSIVE); break;
case 'f': context_menu_select(MA_FILL_NONRECURSIVE); break;
case 'l': context_menu_select(MA_FILL_LINE); break;
// Space or "c" clears the canvas
case 'c':
case ' ': context_menu_select(MA_CLEAR_CANVAS); break;
// Return or "t" displays the test shape
case 13:
case 't': context_menu_select(MA_TEST_SHAPE); break;
// Backspace resets the view
case 8: context_menu_select(MA_RESET_VIEW); break;
// ESC destroys the window and quits the program
case 27: glutDestroyWindow(1); break;
}
}
// The event method on mouse button presses
void application::mouse_button(int button, int state, int x, int y)
{
int gx, gy, snapped_x, snapped_y;
// If the mouse wheel was pressed
if (button == GLUT_MIDDLE_BUTTON) {
// If the wheel is pressed then we are in scroll mode
// otherwise we leave this mode
is_scroll_mode = (state == GLUT_DOWN);
last_mouse_x = -1;
last_mouse_y = -1;
}
// All button handling is for the left mouse button only
if (button != GLUT_LEFT_BUTTON)
return;
// Transform mouse coordinates to grid coordinates
renderer->screen_to_grid(x, y, gx, gy);
// Get the next center of a canvas cell
renderer->snap_screen_coords(x, y, snapped_x, snapped_y);
// If the left mouse button was pressed then enable
// preview rendering and set the start position
if (state == GLUT_DOWN) {
preview.enable_rendering();
preview.set_start(snapped_x, snapped_y);
is_dragging = true;
start_gx = gx;
start_gy = gy;
if (gx>=0 && gx<canvas->get_width() && gy>=0 && gy<canvas->get_height())
tool->draw(gx, gy);
}
else
// If the mouse button was released and starting positions are
// set then disable the preview rendering and draw the two-coordinate
// shape
if (is_dragging) {
preview.disable_rendering();
tool->draw(start_gx, start_gy, gx, gy);
is_dragging = false;
}
display();
}
// The event method on mouse motions (with pressed buttons)
void application::mouse_move(int x, int y)
{
int gx, gy, snapped_x, snapped_y;
double trans_x, trans_y;
// If we are in scroll mode (wheel is pressed) then add the mouse
// movements to the canvas translation
if (is_scroll_mode && last_mouse_x != -1 && last_mouse_y != -1) {
renderer->get_translation(trans_x, trans_y);
trans_x += x-last_mouse_x;
trans_y += y-last_mouse_y;
renderer->set_translation(trans_x, trans_y);
}
// Transform mouse coordinates to grid coordinates
renderer->screen_to_grid(x, y, gx, gy);
// Get the next center of a canvas cell
renderer->snap_screen_coords(x, y, snapped_x, snapped_y);
// If the grid position is valid then draw the one-position shape
// If the tool is not draggable (i.e. only clicks and not drag operations
// draw) then do nothing
if (gx>=0 && gx<canvas->get_width() && gy>=0 && gy<canvas->get_height() &&
is_dragging && tool->is_tool_draggable())
tool->draw(gx, gy);
// Update the destination in the preview tool
preview.set_dest(snapped_x, snapped_y);
last_mouse_x = x;
last_mouse_y = y;
display();
}
// The event method on mouse wheel rotations
void application::mouse_wheel(int button, int dir, int x, int y)
{
double trans_x, trans_y;
double zoom, zoom_old;
// Get the current zoom factor
zoom = renderer->get_zoom();
zoom_old = zoom;
// If the wheel is moved up then increase the zoom factor
// otherwise decrease it
if (dir>0) {
zoom+=0.2;
}
else {
zoom-=0.2;
if (zoom<0.2)
zoom = 0.2;
}
// Set the new factor
renderer->set_zoom(zoom);
// Also change the translation so that the location of the
// mouse keeps its position. This is done by adding the difference
// of the zoomed mouse location and its original position
// [the difference is expressed through (1.0 - zoom/zoom_old) which
// is an exclusion of (x-trans_x) or (y-trans_y) resp.]
renderer->get_translation(trans_x, trans_y);
trans_x += (x-trans_x)*(1.0-zoom/zoom_old);
trans_y += (y-trans_y)*(1.0-zoom/zoom_old);
renderer->set_translation(trans_x, trans_y);
display();
}
application *application::instance = 0;
void application::key_down_callback(unsigned char key, int x, int y)
{
instance->key_down(key, x, y);
}
void application::mouse_button_callback(int button, int state, int x, int y)
{
instance->mouse_button(button, state, x, y);
}
void application::mouse_move_callback(int x, int y)
{
instance->mouse_move(x, y);
}
void application::display_callback()
{
instance->display();
}
void application::context_menu_callback(int item)
{
instance->context_menu_select(item);
}
void application::mouse_wheel_callback(int button, int dir, int x, int y)
{
instance->mouse_wheel(button, dir, x, y);
}

View file

@ -0,0 +1,43 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
#include "bresenham_circle_tool.h"
#include <algorithm>
#include <math.h>
// Initialize the tool and store a reference of a canvas_buffer
bresenham_circle_tool::bresenham_circle_tool(canvas_buffer& canvas): tool_base(canvas)
{
// This tool draws circles!
shape = TS_CIRCLE;
}
// Draw a circle with center (x0, y0) and (x1, y1) on the circle
void bresenham_circle_tool::draw(int x0, int y0, int x1, int y1)
{
// Calculate the radius
int r = static_cast<int>(sqrt(static_cast<double>((x0-x1)*(x0-x1) + (y0-y1)*(y0-y1))));
/************
Additional task: Implement circle rasterization using the bresenham algorithm.
The circle shall have its center at (x0, y0) with a
radius of "r".
Zusatzaufgabe: Implementieren Sie die Rasterisierung eines Kreises mit dem
Bresenham-Algorithmus. Der Kreis soll seinen Mittelpunkt bei
(x0, y0) und einen Radius von "r" haben.
*************/
}
// Put debug output into the stream "stream" to be displayed in the
// main window
void bresenham_circle_tool::set_text(std::stringstream& stream)
{
stream<<"Tool: Bresenham-Circle (click and drag mouse to draw)";
}

View file

@ -0,0 +1,48 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
#include "bresenham_line_tool.h"
#include <algorithm>
#include <math.h>
// Initialize the tool and store a reference of a canvas_buffer
bresenham_line_tool::bresenham_line_tool(canvas_buffer& canvas): tool_base(canvas)
{
// This tool draws lines!
shape = TS_LINE;
}
// Draw a line from (x0, y0) to (x1, y1)
void bresenham_line_tool::draw(int x0, int y0, int x1, int y1)
{
/************
Task 3.1.2. Implement the Bresenham algorithm to raster a line from (x0, y0)
to (x1, y1). To set a pixel use "canvas.set_pixel(x, y)" where
"x" and "y" is the desired pixel position. This method
handles border violations. Establish the standard case in the
first step. If you need to swap the value of two variables you
can use the method "std::swap(a, b)".
Aufgabe 3.1.2. Implementieren Sie den Bresenham-Algorithmus um eine Linie von
(x0, y0) nach (x1, y1) zu rastern. Verwenden Sie
"canvas.set_pixel(x, y)" um einen Pixel zu setzen, wobei
"x" und "y" den gewünschten Pixelpositionen entsprechen.
Diese Methode behandelt auch Randverletzungen. Stellen Sie zunaechst
den Standardfall her. Falls Sie den Wert zweier Variablen vertauschen
muessen koennen Sie dafür die Methode "std::swap(a, b)" verwenden.
*************/
}
// Put debug output into the stream "stream" to be displayed in the
// main window
void bresenham_line_tool::set_text(std::stringstream& stream)
{
stream<<"Tool: Bresenham-Line (click and drag mouse to draw)";
}

View file

@ -0,0 +1,108 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
#include "canvas_buffer.h"
#include <iostream>
// Initialize the store with a defined with and height
canvas_buffer::canvas_buffer(int width, int height)
{
this->width = width;
this->height = height;
pixels = new bool[width*height];
clear_canvas();
}
// Free the memory used for the pixels
canvas_buffer::~canvas_buffer()
{
delete [] pixels;
}
// Set a pixel at (x, y)
void canvas_buffer::set_pixel(int x, int y)
{
// Display an error message if the position is out of bounds
if (x<0 || y<0 || x>=width || y>=height) {
std::cout<<"Error in set_pixel: Coordinates "<<x<<", "<<y<<" are out of range ("<<width<<" x "<<height<<")"<<std::endl;
return;
}
pixels[x+y*width] = true;
}
// Clear the pixel at (x, y)
void canvas_buffer::clear_pixel(int x, int y)
{
// Display an error message if the position is out of bounds
if (x<0 || y<0 || x>=width || y>=height) {
std::cout<<"Error in clear_pixel: Coordinates "<<x<<", "<<y<<" are out of range ("<<width<<" x "<<height<<")"<<std::endl;
return;
}
pixels[x+y*width] = false;
}
// Get the state of a pixel at (x, y)
bool canvas_buffer::get_pixel(int x, int y) const
{
// Display an error message if the position is out of bounds
if (x<0 || y<0 || x>=width || y>=height) {
std::cout<<"Error in get_pixel: Coordinates "<<x<<", "<<y<<" are out of range ("<<width<<" x "<<height<<")"<<std::endl;
return false;
}
return pixels[x+y*width];
}
// Clear all pixels on the canvas
void canvas_buffer::clear_canvas()
{
for (int i=0; i<width*height; i++)
pixels[i] = false;
}
// Get the width of the canvas in pixels
int canvas_buffer::get_width() const
{
return width;
}
// Get the height of the canvas in pixels
int canvas_buffer::get_height() const
{
return height;
}
// Draw the test shape
void canvas_buffer::draw_test_shape()
{
// Two horizontal lines
for (int i = 1; i < width-1; i++) {
set_pixel(i, 1);
set_pixel(i, height-2);
}
// 2 vertical lines crossing with a gap of one pixel in the middle
for (int i = 1; i < width/2; i++) {
set_pixel(i, i);
set_pixel(i, width - i - 1);
set_pixel(width-i, i);
set_pixel(width-i, width - i - 1);
}
}

View file

@ -0,0 +1,194 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
#include "canvas_renderer.h"
#include "GL/glut.h"
#include <math.h>
// Initialize the renderer and store a reference of a canvas_buffer
canvas_renderer::canvas_renderer(canvas_buffer& canvas): canvas(canvas)
{
reset_view();
}
// Reset translation and zoom factor
void canvas_renderer::reset_view()
{
zoom_factor = 1;
trans_x = 10;
trans_y = 10;
}
// Set the zoom factor
void canvas_renderer::set_zoom(double factor)
{
zoom_factor = factor;
}
// Get the zoom factor
double canvas_renderer::get_zoom() const
{
return zoom_factor;
}
// Get the translation
void canvas_renderer::get_translation(double &x, double &y) const
{
x = trans_x;
y = trans_y;
}
// Set the translation
void canvas_renderer::set_translation(double x, double y)
{
trans_x = x;
trans_y = y;
}
// Render the contents of the canvas store
void canvas_renderer::render() const
{
double cell_size = get_cell_size();
int width = canvas.get_width();
int height = canvas.get_height();
// Enable a scissor test to prevent rendering above the debug messages
// in the main window
glEnable(GL_SCISSOR_TEST);
glScissor(0, 29, glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT)-29);
glPushMatrix();
// Translate and scale so that one unit corresponds to one pixel
glTranslated(trans_x, trans_y, 0);
glScaled(cell_size, cell_size, 1);
glColor3d(0, 0, 0);
glBegin(GL_QUADS);
for (int x=0; x<width; x++)
for (int y=0; y<height; y++)
// Whenever a pixel is set draw a black quad
if (canvas.get_pixel(x, y)) {
glVertex2d(x, y);
glVertex2d(x+1, y);
glVertex2d(x+1, y+1);
glVertex2d(x, y+1);
}
glEnd();
glPopMatrix();
// Render the grid
render_grid();
glDisable(GL_SCISSOR_TEST);
}
// Convert a screen position to a grid position
void canvas_renderer::screen_to_grid(int sx, int sy, int &gx, int &gy) const
{
double cell_size = get_cell_size();
gx = static_cast<int>(floor((sx-trans_x)/cell_size));
gy = static_cast<int>(floor((sy-trans_y)/cell_size));
}
// Get the next cell center from the provided position
void canvas_renderer::snap_screen_coords(int sx, int sy, int &scx, int &scy) const
{
double cell_size = get_cell_size();
// Align the coordinates to the border of a cell and add half the cell
// size to place them in the center
scx = static_cast<int>((floor((sx-trans_x)/cell_size) + 0.5) * cell_size + trans_x);
scy = static_cast<int>((floor((sy-trans_y)/cell_size) + 0.5) * cell_size + trans_y);
}
// Get the size of a cell in pixels
double canvas_renderer::get_cell_size() const
{
double cell_x = (glutGet(GLUT_WINDOW_WIDTH)-20)*zoom_factor/static_cast<double>(canvas.get_width());
double cell_y = (glutGet(GLUT_WINDOW_HEIGHT)-40)*zoom_factor/static_cast<double>(canvas.get_height());
double cell = cell_x;
if (cell_y<cell)
cell = cell_y;
return cell;
}
// Helper method to render the grid
void canvas_renderer::render_grid() const
{
double cell_size = get_cell_size();
int width = canvas.get_width();
int height = canvas.get_height();
glPushMatrix();
// Translate and scale so that one unit corresponds to one pixel
glTranslated(trans_x, trans_y, 0);
glScaled(cell_size, cell_size, 1);
// Enable blending and make the grid more transparent the smaller
// the cells are. This prevents the view from being cluttered
// with grid lines.
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
if (cell_size<5)
glColor4d(0.8, 0.8, 0.8, (cell_size-2)/3.0);
else
glColor3d(0.8, 0.8, 0.8);
glBegin(GL_LINES);
// Draw vertical lines
for (int x=1; x<width; x++) {
glVertex2d(x, 0);
glVertex2d(x, height);
}
// Draw horizontal lines
for (int y=1; y<height; y++) {
glVertex2d(0, y);
glVertex2d(width, y);
}
glEnd();
glDisable(GL_BLEND);
glColor3d(0.8, 0.8, 0.8);
// Draw the border lines which shall not be affected by the blending
glBegin(GL_LINE_STRIP);
glVertex2d(0, 0);
glVertex2d(0, height);
glVertex2d(width, height);
glVertex2d(width, 0);
glVertex2d(0, 0);
glEnd();
glPopMatrix();
}

View file

@ -0,0 +1,47 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
#include "dda_line_tool.h"
#include <algorithm>
// Initialize the tool and store a reference of a canvas_buffer
dda_line_tool::dda_line_tool(canvas_buffer& canvas): tool_base(canvas)
{
shape = TS_LINE;
}
// Draw a line from (x0, y0) to (x1, y1)
void dda_line_tool::draw(int x0, int y0, int x1, int y1)
{
/************
Task 3.1.1. Implement the DDA algorithm to raster a line from (x0, y0)
to (x1, y1). To set a pixel use "canvas.set_pixel(x, y)" where
"x" and "y" is the desired pixel position. This method
handles border violations. Establish the standard case in the
first step. If you need to swap the value of two variables you
can use the method "std::swap(a, b)".
Aufgabe 3.1.1. Implementieren Sie den DDA-Algorithmus um eine Linie von
(x0, y0) nach (x1, y1) zu rastern. Verwenden Sie
"canvas.set_pixel(x, y)" um einen Pixel zu setzen, wobei
"x" und "y" den gewünschten Pixelpositionen entsprechen.
Diese Methode behandelt auch Randverletzungen. Stellen Sie zunaechst
den Standardfall her. Falls Sie den Wert zweier Variablen vertauschen
muessen koennen Sie dafür die Methode "std::swap(a, b)" verwenden.
*************/
}
// Put debug output into the stream "stream" to be displayed in the
// main window
void dda_line_tool::set_text(std::stringstream& stream)
{
stream<<"Tool: DDA-Line (click and drag mouse to draw)";
}

View file

@ -0,0 +1,42 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
#include "line_fill_tool.h"
#include <deque>
// Initialize the tool and store a reference of a canvas_buffer
line_fill_tool::line_fill_tool(canvas_buffer& canvas): tool_base(canvas)
{
// This tool has no shape and is not draggable
shape = TS_NONE;
is_draggable = false;
}
// Fill the shape that contains the point (x, y)
void line_fill_tool::draw(int x, int y)
{
/************
Additional task: Implement the line fill algorithm. You can declare
helper methods and properties in the header file if needed and
implement them here.
Zusatzaufgabe: Implementieren Sie den Line-Fill-Algorithmus. Falls benoetigt
koennen Sie sich Helfermethoden in der dazugehoerigen Header-Datei
deklarieren und in dieser Datei definieren.
*************/
}
// Put debug output into the stream "stream" to be displayed in the
// main window
void line_fill_tool::set_text(stringstream& stream)
{
stream<<"Tool: Line Fill (click to fill)";
}

20
exercise2/src/main.cpp Normal file
View file

@ -0,0 +1,20 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
#include <iostream>
#include <vector>
#include <sstream>
#include "application.h"
int main(int argc, char* argv[])
{
// Instanciate the application...
application app;
// ... and let it run!
return app.run(argc, argv);
}

View file

@ -0,0 +1,80 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
#include "non_recursive_fill_tool.h"
#include <deque>
// Initialize the tool and store a reference of a canvas_buffer
non_recursive_fill_tool::non_recursive_fill_tool(canvas_buffer& canvas): tool_base(canvas)
{
// This tool has no shape and is not draggable
shape = TS_NONE;
is_draggable = false;
}
// A pixel to be put into the queue of pixels to process
struct waiting_pixel {
int x, y;
};
void non_recursive_fill_tool::draw(int x, int y)
{
waiting_pixel p;
std::deque<waiting_pixel> stack;
/************
Task 3.2.2. Implement a filling algothim without recursion. Use a stack instead.
The source code below inserts the first element into the stack and
starts a loop that reads the front element from the stack and removes
it. Your task is to fill the functionality in the loop. Before you begin
think about when to set the pixel (at the beginning of the loop or after
the stack was updated with neighbours). Use "canvas.set_pixel" to set
a pixel and "canvas.get_pixel" to read the state of a pixel.
Aufgabe 3.2.2. Implementieren Sie einen Füllalgorithmus ohne Rekursion zu verwenden.
Nutzen Sie stattdessen einen Stack. Der vorgegebene Quelltext unten fuegt
das erste Element in den Stack ein und startet eine Schleife, die das
vorderste Element aus dem Stack liest und es anschließend entfernt.
Ihre Aufgabe ist es die Funktionalitaet im Inneren der Schleife zu
ergaenzen. Bevor Sie beginnen machen Sie sich Gedanken an welcher Stelle
das tatsaechliche Setzen eines Pixels erfolgt (am Beginn der Schleife oder
nachdem der Stack mit Nachbarinformationen aktualisiert wurde). Nutzen
Sie "canvas.set_pixel" um einen Pixel zu setzen und "canvas.get_pixel" um
den Zustand eines Pixels zu erhalten.
*************/
// Put the initial pixel into the stack
if (!canvas.get_pixel(x, y)) {
p.x = x;
p.y = y;
canvas.set_pixel(x, y);
stack.push_back(p);
}
// While there are pixels to be checked
while (!stack.empty()) {
int cur_x = stack.front().x;
int cur_y = stack.front().y;
// Complete the algorithm here
stack.pop_front();
}
}
// Put debug output into the stream "stream" to be displayed in the
// main window
void non_recursive_fill_tool::set_text(std::stringstream& stream)
{
stream<<"Tool: Non-Recursive Fill (click to fill)";
}

View file

@ -0,0 +1,30 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
#include "pen_tool.h"
// Initialize the tool and store a reference of a canvas_buffer
pen_tool::pen_tool(canvas_buffer &canvas): tool_base(canvas)
{
shape = TS_NONE;
}
// Set the pixel at (x, y)
void pen_tool::draw(int x, int y)
{
// The pen algorithm is too complicated to be commented :).
canvas.set_pixel(x, y);
}
// Put debug output into the stream "stream" to be displayed in the
// main window
void pen_tool::set_text(std::stringstream& stream)
{
stream<<"Tool: Pen (click and hold left button to draw)";
}

View file

@ -0,0 +1,111 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
#include "preview_renderer.h"
#include "GL/glut.h"
// define math constants such as M_PI in math.h
#define _USE_MATH_DEFINES
// needed for mathematical operations
#include <math.h>
// Initialize the preview renderer
preview_renderer::preview_renderer()
{
// Initially disabled with no shape
start_x = 0;
start_y = 0;
dest_x = 0;
dest_y = 0;
shape = TS_NONE;
enabled = false;
}
// Enable rendering of previews
void preview_renderer::enable_rendering()
{
enabled = true;
}
// Disable rendering of previews
void preview_renderer::disable_rendering()
{
enabled = false;
}
// Set the start of a 2-point shape
void preview_renderer::set_start(int x, int y)
{
start_x = x;
start_y = y;
dest_x = start_x;
dest_y = start_y;
}
// Set the destination of a 2-point shape
void preview_renderer::set_dest(int x, int y)
{
dest_x = x;
dest_y = y;
}
// Set the shape
void preview_renderer::set_shape(ToolShape shape)
{
this->shape = shape;
}
// Render the preview
void preview_renderer::render()
{
// Do nothing if rendering is disabled
if (!enabled)
return;
// Set the color to green
glColor3d(0, 1, 0);
// Render different shapes according to the value in "shape"
// which was set using the "set_shape" command
switch(shape) {
// Render a line
case TS_LINE:
glBegin(GL_LINES);
glVertex2d(start_x, start_y);
glVertex2d(dest_x, dest_y);
glEnd();
break;
// Render a box
case TS_BOX:
glBegin(GL_LINE_STRIP);
glVertex2d(start_x, start_y);
glVertex2d(dest_x, start_y);
glVertex2d(dest_x, dest_y);
glVertex2d(start_x, dest_y);
glVertex2d(start_x, start_y);
glEnd();
break;
// Render a circle
case TS_CIRCLE:
glBegin(GL_LINE_STRIP);
// Calculate the radius
double radius = sqrt(static_cast<double>((dest_x-start_x)*(dest_x-start_x) + (dest_y-start_y)*(dest_y-start_y)));
// Render the circle by providing consecutive points with
// the calculated radius around the start point in 5deg steps
for (int a=0; a<=360; a+=5)
glVertex2d(start_x+cos(a/180.0*M_PI)*radius, start_y+sin(a/180.0*M_PI)*radius);
glEnd();
}
}

View file

@ -0,0 +1,36 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
#include "rectangle_tool.h"
#include <algorithm>
// Initialize the tool and store a reference of a canvas_buffer
rectangle_tool::rectangle_tool(canvas_buffer& canvas): tool_base(canvas)
{
shape = TS_BOX;
}
// Draw a box from (x0, y0) to (x1, y1)
void rectangle_tool::draw(int x0, int y0, int x1, int y1)
{
/************
Additional task: Implement the rasterization of a rectangle that
ranges from (x0, y0) to (x1, y1).
Zusatzaufgabe: Implementieren Sie die Rasterisierung eines
Rechtecks, das von (x0, y0) nach (x1, y1) geht.
*************/
}
// Put debug output into the stream "stream" to be displayed in the
// main window
void rectangle_tool::set_text(std::stringstream& stream)
{
stream<<"Tool: Rectangle (click and drag mouse to draw)";
}

View file

@ -0,0 +1,45 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
#include "recursive_fill_tool.h"
// Initialize the tool and store a reference of a canvas_buffer
recursive_fill_tool::recursive_fill_tool(canvas_buffer& canvas): tool_base(canvas)
{
// This tool has no shape and is not draggable
shape = TS_NONE;
is_draggable = false;
}
// Fill the shape that contains the point (x, y)
void recursive_fill_tool::draw(int x, int y)
{
/************
Task 3.2.1. Implement the recursive fill algorithm by checking the
state of the neighbouring pixels (via "canvas.get_pixel(x, y)"
where "x" and "y" defines the position to check) and recursively
call "draw" if the pixel is not set. A pixel can be set with
"canvas.set_pixel(x, y)".
This method will make the application crash if the area which shall
be filled is too big.
Aufgabe 3.2.1. Implementieren Sie den rekursiven Füllalgorithmus, indem Sie den
Zustand der Nachbarpixel überprüfen (mittels "canvas.get_pixel(x, y)"
wobei "x" und "y" die Position des zu überprüfenden Pixels definieren)
und rufen Sie rekursiv die "draw"-Methode auf, wenn die Pixel nicht
gesetzt sind. Ein Pixel kann durch "canvas.set_pixel(x, y)" gesetzt
werden.
*************/
}
// Put debug output into the stream "stream" to be displayed in the
// main window
void recursive_fill_tool::set_text(std::stringstream& stream)
{
stream<<"Tool: Recursive Fill (click to fill)";
}

View file

@ -0,0 +1,56 @@
//
// This source code is property of the Computer Graphics and Visualization
// chair of the TU Dresden. Do not distribute in modified or unmodified form!
// Copyright (C) 2016 CGV TU Dresden - All Rights Reserved
//
#include "tool_base.h"
// Initialize the tool and store a reference of a canvas_buffer
tool_base::tool_base(canvas_buffer &canvas): canvas(canvas)
{
shape = TS_NONE;
is_draggable = true;
}
// Draw with one point provided
void tool_base::draw(int x, int y)
{
// Nothing implemented here. Children of this class can implement
// this method if needed
}
// Draw with two points provided
void tool_base::draw(int from_x, int from_y, int to_x, int to_y)
{
// Nothing implemented here. Children of this class can implement
// this method if needed
}
// Get the shape that this tool will draw
const ToolShape tool_base::get_shape() const
{
return shape;
}
// Put a text into the stream "stream" which will be displayed
// in the main window
void tool_base::set_text(std::stringstream &stream)
{
// Nothing implemented here. Children of this class can implement
// this method if needed
}
// Return true if draw(x, y) is valid during dragging operations
const bool tool_base::is_tool_draggable() const
{
return is_draggable;
}