diff options
| author | Mirrorbot <mirrorbot@cogarr.net> | 2025-12-27 17:53:06 -0600 |
|---|---|---|
| committer | Mirrorbot <mirrorbot@cogarr.net> | 2025-12-27 17:53:06 -0600 |
| commit | 71e94ee161447b84c0eaabf6567f8fa62262cd3e (patch) | |
| tree | 391064cc6173a6fe75069af2fdc1978af12f623e /examples/24.CursorControl | |
| download | irrlicht-71e94ee161447b84c0eaabf6567f8fa62262cd3e.tar.gz irrlicht-71e94ee161447b84c0eaabf6567f8fa62262cd3e.tar.bz2 irrlicht-71e94ee161447b84c0eaabf6567f8fa62262cd3e.zip | |
Diffstat (limited to 'examples/24.CursorControl')
| -rw-r--r-- | examples/24.CursorControl/CursorControl.cbp | 57 | ||||
| -rw-r--r-- | examples/24.CursorControl/CursorControl.vcproj | 132 | ||||
| -rw-r--r-- | examples/24.CursorControl/CursorControl_vc10.vcxproj | 188 | ||||
| -rw-r--r-- | examples/24.CursorControl/CursorControl_vc11.vcxproj | 188 | ||||
| -rw-r--r-- | examples/24.CursorControl/CursorControl_vc12.vcxproj | 188 | ||||
| -rw-r--r-- | examples/24.CursorControl/CursorControl_vc8.vcproj | 190 | ||||
| -rw-r--r-- | examples/24.CursorControl/CursorControl_vc9.vcproj | 185 | ||||
| -rw-r--r-- | examples/24.CursorControl/Makefile | 66 | ||||
| -rw-r--r-- | examples/24.CursorControl/main.cpp | 563 | ||||
| -rw-r--r-- | examples/24.CursorControl/tutorial.html | 205 |
10 files changed, 1962 insertions, 0 deletions
diff --git a/examples/24.CursorControl/CursorControl.cbp b/examples/24.CursorControl/CursorControl.cbp new file mode 100644 index 0000000..b8aa231 --- /dev/null +++ b/examples/24.CursorControl/CursorControl.cbp @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_project_file> + <FileVersion major="1" minor="6" /> + <Project> + <Option title="Irrlicht Example 24 Cursor Control" /> + <Option pch_mode="0" /> + <Option compiler="gcc" /> + <Build> + <Target title="Linux"> + <Option platforms="Unix;" /> + <Option output="../../bin/Linux/CursorControl" prefix_auto="0" extension_auto="0" /> + <Option type="1" /> + <Option compiler="gcc" /> + <Compiler> + <Add option="-g" /> + <Add option="-D_IRR_STATIC_LIB_" /> + </Compiler> + <Linker> + <Add library="Xxf86vm" /> + <Add library="GL" /> + <Add library="X11" /> + <Add library="Xcursor" /> + <Add directory="../../lib/Linux" /> + </Linker> + </Target> + <Target title="Windows"> + <Option platforms="Windows;" /> + <Option output="../../bin/Win32-gcc/CursorControl" prefix_auto="0" extension_auto="1" /> + <Option type="1" /> + <Option compiler="gcc" /> + <Option projectResourceIncludeDirsRelation="1" /> + <Compiler> + <Add option="-g" /> + </Compiler> + <Linker> + <Add directory="../../lib/Win32-gcc" /> + </Linker> + </Target> + </Build> + <VirtualTargets> + <Add alias="All" targets="Windows;Linux;" /> + </VirtualTargets> + <Compiler> + <Add option="-g" /> + <Add directory="../../include" /> + </Compiler> + <Linker> + <Add library="Irrlicht" /> + </Linker> + <Unit filename="main.cpp" /> + <Extensions> + <code_completion /> + <debugger /> + <envvars /> + </Extensions> + </Project> +</CodeBlocks_project_file> diff --git a/examples/24.CursorControl/CursorControl.vcproj b/examples/24.CursorControl/CursorControl.vcproj new file mode 100644 index 0000000..1bc2f53 --- /dev/null +++ b/examples/24.CursorControl/CursorControl.vcproj @@ -0,0 +1,132 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="24.CursorControl"
+ ProjectGUID="{02B67A37-50E1-49db-BECF-905BC029C2FE}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="..\..\bin\Win32-VisualStudio\24.CursorControl.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/CursorControl.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="TRUE">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/QIfist /Oa"
+ Optimization="3"
+ GlobalOptimizations="TRUE"
+ InlineFunctionExpansion="2"
+ EnableIntrinsicFunctions="TRUE"
+ FavorSizeOrSpeed="1"
+ OmitFramePointers="TRUE"
+ AdditionalIncludeDirectories="..\..\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+ RuntimeLibrary="4"
+ BufferSecurityCheck="FALSE"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="0"
+ CallingConvention="1"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="..\..\bin\Win32-VisualStudio\24.CursorControl.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+ AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
+ GenerateDebugInformation="FALSE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\main.cpp">
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/examples/24.CursorControl/CursorControl_vc10.vcxproj b/examples/24.CursorControl/CursorControl_vc10.vcxproj new file mode 100644 index 0000000..7eadc6f --- /dev/null +++ b/examples/24.CursorControl/CursorControl_vc10.vcxproj @@ -0,0 +1,188 @@ +<?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="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>24.CursorControl</ProjectName>
+ <ProjectGuid>{02B67A37-50E1-49DB-BECF-905BC029C2FE}</ProjectGuid>
+ <RootNamespace>24.CursorControl</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</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" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </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" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\bin\Win32-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\bin\Win64-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\bin\Win32-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\bin\Win64-VisualStudio\</OutDir>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <OutputFile>..\..\bin\Win32-VisualStudio\24.CursorControl.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)CursorControl.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <OutputFile>..\..\bin\Win64-VisualStudio\24.CursorControl.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)CursorControl.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ <CallingConvention>Cdecl</CallingConvention>
+ </ClCompile>
+ <Link>
+ <OutputFile>..\..\bin\Win32-VisualStudio\24.CursorControl.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ <CallingConvention>Cdecl</CallingConvention>
+ </ClCompile>
+ <Link>
+ <OutputFile>..\..\bin\Win64-VisualStudio\24.CursorControl.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="main.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/examples/24.CursorControl/CursorControl_vc11.vcxproj b/examples/24.CursorControl/CursorControl_vc11.vcxproj new file mode 100644 index 0000000..7eadc6f --- /dev/null +++ b/examples/24.CursorControl/CursorControl_vc11.vcxproj @@ -0,0 +1,188 @@ +<?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="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>24.CursorControl</ProjectName>
+ <ProjectGuid>{02B67A37-50E1-49DB-BECF-905BC029C2FE}</ProjectGuid>
+ <RootNamespace>24.CursorControl</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</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" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </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" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\bin\Win32-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\bin\Win64-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\bin\Win32-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\bin\Win64-VisualStudio\</OutDir>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <OutputFile>..\..\bin\Win32-VisualStudio\24.CursorControl.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)CursorControl.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <OutputFile>..\..\bin\Win64-VisualStudio\24.CursorControl.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)CursorControl.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ <CallingConvention>Cdecl</CallingConvention>
+ </ClCompile>
+ <Link>
+ <OutputFile>..\..\bin\Win32-VisualStudio\24.CursorControl.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ <CallingConvention>Cdecl</CallingConvention>
+ </ClCompile>
+ <Link>
+ <OutputFile>..\..\bin\Win64-VisualStudio\24.CursorControl.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="main.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/examples/24.CursorControl/CursorControl_vc12.vcxproj b/examples/24.CursorControl/CursorControl_vc12.vcxproj new file mode 100644 index 0000000..26fdf87 --- /dev/null +++ b/examples/24.CursorControl/CursorControl_vc12.vcxproj @@ -0,0 +1,188 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.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="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>24.CursorControl</ProjectName>
+ <ProjectGuid>{02B67A37-50E1-49DB-BECF-905BC029C2FE}</ProjectGuid>
+ <RootNamespace>24.CursorControl</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</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" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </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" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\bin\Win32-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\bin\Win64-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\bin\Win32-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\bin\Win64-VisualStudio\</OutDir>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <OutputFile>..\..\bin\Win32-VisualStudio\24.CursorControl.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)CursorControl.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <OutputFile>..\..\bin\Win64-VisualStudio\24.CursorControl.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(OutDir)CursorControl.pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ <CallingConvention>Cdecl</CallingConvention>
+ </ClCompile>
+ <Link>
+ <OutputFile>..\..\bin\Win32-VisualStudio\24.CursorControl.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ <CallingConvention>Cdecl</CallingConvention>
+ </ClCompile>
+ <Link>
+ <OutputFile>..\..\bin\Win64-VisualStudio\24.CursorControl.exe</OutputFile>
+ <AdditionalLibraryDirectories>..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="main.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/examples/24.CursorControl/CursorControl_vc8.vcproj b/examples/24.CursorControl/CursorControl_vc8.vcproj new file mode 100644 index 0000000..6148942 --- /dev/null +++ b/examples/24.CursorControl/CursorControl_vc8.vcproj @@ -0,0 +1,190 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8,00"
+ Name="24.CursorControl_vc8"
+ ProjectGUID="{02B67A37-50E1-49DB-BECF-905BC029C2FE}"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="..\..\bin\Win32-VisualStudio\24.CursorControl.exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/CursorControl.pdb"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ AdditionalIncludeDirectories="..\..\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+ RuntimeLibrary="0"
+ BufferSecurityCheck="false"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="0"
+ CallingConvention="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="..\..\bin\Win32-VisualStudio\24.CursorControl.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
+ GenerateDebugInformation="false"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\main.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/examples/24.CursorControl/CursorControl_vc9.vcproj b/examples/24.CursorControl/CursorControl_vc9.vcproj new file mode 100644 index 0000000..90ebf1f --- /dev/null +++ b/examples/24.CursorControl/CursorControl_vc9.vcproj @@ -0,0 +1,185 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="24.CursorControl_vc9"
+ ProjectGUID="{02B67A37-50E1-49DB-BECF-905BC029C2FE}"
+ RootNamespace="24.CursorControl_vc9"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="..\..\bin\Win32-VisualStudio\24.CursorControl.exe"
+ AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/CursorControl.pdb"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ AdditionalIncludeDirectories="..\..\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+ ExceptionHandling="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="0"
+ CallingConvention="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="..\..\bin\Win32-VisualStudio\24.CursorControl.exe"
+ AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
+ GenerateDebugInformation="false"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\main.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/examples/24.CursorControl/Makefile b/examples/24.CursorControl/Makefile new file mode 100644 index 0000000..bc2a137 --- /dev/null +++ b/examples/24.CursorControl/Makefile @@ -0,0 +1,66 @@ +# Makefile for Irrlicht Examples
+# It's usually sufficient to change just the target name and source file list
+# and be sure that CXX is set to a valid compiler
+
+# Name of the executable created (.exe will be added automatically if necessary)
+Target := 24.CursorControl
+# List of source files, separated by spaces
+Sources := main.cpp
+# Path to Irrlicht directory, should contain include/ and lib/
+IrrlichtHome := ../..
+# Path for the executable. Note that Irrlicht.dll should usually also be there for win32 systems
+BinPath = ../../bin/$(SYSTEM)
+
+# general compiler settings (might need to be set when compiling the lib, too)
+# preprocessor flags, e.g. defines and include paths
+USERCPPFLAGS =
+# compiler flags such as optimization flags
+USERCXXFLAGS = -O3 -ffast-math
+#USERCXXFLAGS = -g -Wall
+# linker flags such as additional libraries and link paths
+USERLDFLAGS =
+
+####
+#no changes necessary below this line
+####
+
+CPPFLAGS = -I$(IrrlichtHome)/include -I/usr/X11R6/include $(USERCPPFLAGS)
+CXXFLAGS = $(USERCXXFLAGS)
+LDFLAGS = $(USERLDFLAGS)
+
+#default target is Linux
+all: all_linux
+
+# target specific settings
+all_linux all_win32 static_win32: LDFLAGS += -L$(IrrlichtHome)/lib/$(SYSTEM) -lIrrlicht
+all_linux: LDFLAGS += -L/usr/X11R6/lib$(LIBSELECT) -lGL -lXxf86vm -lXext -lX11 -lXcursor
+all_linux clean_linux: SYSTEM=Linux
+all_win32 clean_win32 static_win32: SYSTEM=Win32-gcc
+all_win32 clean_win32 static_win32: SUF=.exe
+static_win32: CPPFLAGS += -D_IRR_STATIC_LIB_
+all_win32: LDFLAGS += -lopengl32 -lm
+static_win32: LDFLAGS += -lgdi32 -lwinspool -lcomdlg32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lopengl32
+# name of the binary - only valid for targets which set SYSTEM
+DESTPATH = $(BinPath)/$(Target)$(SUF)
+
+all_linux all_win32 static_win32:
+ $(warning Building...)
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(Sources) -o $(DESTPATH) $(LDFLAGS)
+
+clean: clean_linux clean_win32
+ $(warning Cleaning...)
+
+clean_linux clean_win32:
+ @$(RM) $(DESTPATH)
+
+.PHONY: all all_win32 static_win32 clean clean_linux clean_win32
+
+#multilib handling
+ifeq ($(HOSTTYPE), x86_64)
+LIBSELECT=64
+endif
+#solaris real-time features
+ifeq ($(HOSTTYPE), sun4)
+LDFLAGS += -lrt
+endif
+
diff --git a/examples/24.CursorControl/main.cpp b/examples/24.CursorControl/main.cpp new file mode 100644 index 0000000..ff7c16f --- /dev/null +++ b/examples/24.CursorControl/main.cpp @@ -0,0 +1,563 @@ +/** Example 024 CursorControl
+
+Show how to modify cursors and offer some useful tool-functions for creating cursors.
+It can also be used for experiments with the mouse in general.
+*/
+
+#include <irrlicht.h>
+#include "driverChoice.h"
+
+using namespace irr;
+using namespace core;
+using namespace scene;
+using namespace video;
+using namespace io;
+using namespace gui;
+
+#ifdef _IRR_WINDOWS_
+#pragma comment(lib, "Irrlicht.lib")
+#endif
+
+const int DELAY_TIME = 3000;
+
+enum ETimerAction
+{
+ ETA_MOUSE_VISIBLE,
+ ETA_MOUSE_INVISIBLE,
+};
+
+/*
+ Structure to allow delayed execution of some actions.
+*/
+struct TimerAction
+{
+ u32 TargetTime;
+ ETimerAction Action;
+};
+
+/*
+*/
+struct SAppContext
+{
+ SAppContext()
+ : Device(0), InfoStatic(0), EventBox(0), CursorBox(0), SpriteBox(0)
+ , ButtonSetVisible(0), ButtonSetInvisible(0), ButtonSimulateBadFps(0)
+ , ButtonChangeIcon(0)
+ , SimulateBadFps(false)
+ {
+ }
+
+ void update()
+ {
+ if (!Device)
+ return;
+ u32 timeNow = Device->getTimer()->getTime();
+ for ( u32 i=0; i < TimerActions.size(); ++i )
+ {
+ if ( timeNow >= TimerActions[i].TargetTime )
+ {
+ runTimerAction(TimerActions[i]);
+ TimerActions.erase(i);
+ }
+ else
+ {
+ ++i;
+ }
+ }
+ }
+
+ void runTimerAction(const TimerAction& action)
+ {
+ if (ETA_MOUSE_VISIBLE == action.Action)
+ {
+ Device->getCursorControl()->setVisible(true);
+ ButtonSetVisible->setEnabled(true);
+ }
+ else if ( ETA_MOUSE_INVISIBLE == action.Action)
+ {
+ Device->getCursorControl()->setVisible(false);
+ ButtonSetInvisible->setEnabled(true);
+ }
+ }
+
+ /*
+ Add another icon which the user can click and select as cursor later on.
+ */
+ void addIcon(const stringw& name, const SCursorSprite &sprite, bool addCursor=true)
+ {
+ // Sprites are just icons - not yet cursors. They can be displayed by Irrlicht sprite functions and be used to create cursors.
+ SpriteBox->addItem(name.c_str(), sprite.SpriteId);
+ Sprites.push_back(sprite);
+
+ // create the cursor together with the icon?
+ if ( addCursor )
+ {
+ /* Here we create a hardware cursor from a sprite */
+ Device->getCursorControl()->addIcon(sprite);
+
+ // ... and add it to the cursors selection listbox to the other system cursors.
+ CursorBox->addItem(name.c_str());
+ }
+ }
+
+ IrrlichtDevice * Device;
+ gui::IGUIStaticText * InfoStatic;
+ gui::IGUIListBox * EventBox;
+ gui::IGUIListBox * CursorBox;
+ gui::IGUIListBox * SpriteBox;
+ gui::IGUIButton * ButtonSetVisible;
+ gui::IGUIButton * ButtonSetInvisible;
+ gui::IGUIButton * ButtonSimulateBadFps;
+ gui::IGUIButton * ButtonChangeIcon;
+ array<TimerAction> TimerActions;
+ bool SimulateBadFps;
+ array<SCursorSprite> Sprites;
+};
+
+/*
+ Helper function to print mouse event names into a stringw
+*/
+void PrintMouseEventName(const SEvent& event, stringw &result)
+{
+ switch ( event.MouseInput.Event )
+ {
+ case EMIE_LMOUSE_PRESSED_DOWN: result += stringw(L"EMIE_LMOUSE_PRESSED_DOWN"); break;
+ case EMIE_RMOUSE_PRESSED_DOWN: result += stringw(L"EMIE_RMOUSE_PRESSED_DOWN"); break;
+ case EMIE_MMOUSE_PRESSED_DOWN: result += stringw(L"EMIE_MMOUSE_PRESSED_DOWN"); break;
+ case EMIE_LMOUSE_LEFT_UP: result += stringw(L"EMIE_LMOUSE_LEFT_UP"); break;
+ case EMIE_RMOUSE_LEFT_UP: result += stringw(L"EMIE_RMOUSE_LEFT_UP"); break;
+ case EMIE_MMOUSE_LEFT_UP: result += stringw(L"EMIE_MMOUSE_LEFT_UP"); break;
+ case EMIE_MOUSE_MOVED: result += stringw(L"EMIE_MOUSE_MOVED"); break;
+ case EMIE_MOUSE_WHEEL: result += stringw(L"EMIE_MOUSE_WHEEL"); break;
+ case EMIE_LMOUSE_DOUBLE_CLICK: result += stringw(L"EMIE_LMOUSE_DOUBLE_CLICK"); break;
+ case EMIE_RMOUSE_DOUBLE_CLICK: result += stringw(L"EMIE_RMOUSE_DOUBLE_CLICK"); break;
+ case EMIE_MMOUSE_DOUBLE_CLICK: result += stringw(L"EMIE_MMOUSE_DOUBLE_CLICK"); break;
+ case EMIE_LMOUSE_TRIPLE_CLICK: result += stringw(L"EMIE_LMOUSE_TRIPLE_CLICK"); break;
+ case EMIE_RMOUSE_TRIPLE_CLICK: result += stringw(L"EMIE_RMOUSE_TRIPLE_CLICK"); break;
+ case EMIE_MMOUSE_TRIPLE_CLICK: result += stringw(L"EMIE_MMOUSE_TRIPLE_CLICK"); break;
+ default:
+ break;
+ }
+}
+
+/*
+ Helper function to print all the state information which get from a mouse-event into a stringw
+*/
+void PrintMouseState(const SEvent& event, stringw &result)
+{
+ result += stringw(L"X: ");
+ result += stringw(event.MouseInput.X);
+ result += stringw(L"\n");
+
+ result += stringw(L"Y: ");
+ result += stringw(event.MouseInput.Y);
+ result += stringw(L"\n");
+
+
+ result += stringw(L"Wheel: ");
+ result += stringw(event.MouseInput.Wheel);
+ result += stringw(L"\n");
+
+ result += stringw(L"Shift: ");
+ if ( event.MouseInput.Shift )
+ result += stringw(L"true\n");
+ else
+ result += stringw(L"false\n");
+
+ result += stringw(L"Control: ");
+ if ( event.MouseInput.Control )
+ result += stringw(L"true\n");
+ else
+ result += stringw(L"false\n");
+
+ result += stringw(L"ButtonStates: ");
+ result += stringw(event.MouseInput.ButtonStates);
+ result += stringw(L"\n");
+
+ result += stringw(L"isLeftPressed: ");
+ if ( event.MouseInput.isLeftPressed() )
+ result += stringw(L"true\n");
+ else
+ result += stringw(L"false\n");
+
+ result += stringw(L"isRightPressed: ");
+ if ( event.MouseInput.isRightPressed() )
+ result += stringw(L"true\n");
+ else
+ result += stringw(L"false\n");
+
+ result += stringw(L"isMiddlePressed: ");
+ if ( event.MouseInput.isMiddlePressed() )
+ result += stringw(L"true\n");
+ else
+ result += stringw(L"false\n");
+
+ result += stringw(L"Event: ");
+
+ PrintMouseEventName(event, result);
+
+ result += stringw(L"\n");
+}
+
+/*
+ A typical event receiver.
+*/
+class MyEventReceiver : public IEventReceiver
+{
+public:
+ MyEventReceiver(SAppContext & context) : Context(context) { }
+
+ virtual bool OnEvent(const SEvent& event)
+ {
+ if (event.EventType == EET_GUI_EVENT )
+ {
+ switch ( event.GUIEvent.EventType )
+ {
+ case EGET_BUTTON_CLICKED:
+ {
+ u32 timeNow = Context.Device->getTimer()->getTime();
+ TimerAction action;
+ action.TargetTime = timeNow + DELAY_TIME;
+ if ( event.GUIEvent.Caller == Context.ButtonSetVisible )
+ {
+ action.Action = ETA_MOUSE_VISIBLE;
+ Context.TimerActions.push_back(action);
+ Context.ButtonSetVisible->setEnabled(false);
+ }
+ else if ( event.GUIEvent.Caller == Context.ButtonSetInvisible )
+ {
+ action.Action = ETA_MOUSE_INVISIBLE;
+ Context.TimerActions.push_back(action);
+ Context.ButtonSetInvisible->setEnabled(false);
+ }
+ else if ( event.GUIEvent.Caller == Context.ButtonSimulateBadFps )
+ {
+ Context.SimulateBadFps = Context.ButtonSimulateBadFps->isPressed();
+ }
+ else if ( event.GUIEvent.Caller == Context.ButtonChangeIcon )
+ {
+ /*
+ Replace an existing cursor icon by another icon.
+ The user has to select both - the icon which should be replaced and the icon which will replace it.
+ */
+ s32 selectedCursor = Context.CursorBox->getSelected();
+ s32 selectedSprite = Context.SpriteBox->getSelected();
+ if ( selectedCursor >= 0 && selectedSprite >= 0 )
+ {
+ /*
+ This does replace the icon.
+ */
+ Context.Device->getCursorControl()->changeIcon((ECURSOR_ICON)selectedCursor, Context.Sprites[selectedSprite] );
+
+ /*
+ Do also show the new icon.
+ */
+ Context.Device->getCursorControl()->setActiveIcon( ECURSOR_ICON(selectedCursor) );
+ }
+ }
+ }
+ break;
+ case EGET_LISTBOX_CHANGED:
+ case EGET_LISTBOX_SELECTED_AGAIN:
+ {
+ if ( event.GUIEvent.Caller == Context.CursorBox )
+ {
+ /*
+ Find out which cursor the user selected
+ */
+ s32 selected = Context.CursorBox->getSelected();
+ if ( selected >= 0 )
+ {
+ /*
+ Here we set the new cursor icon which will now be used within our window.
+ */
+ Context.Device->getCursorControl()->setActiveIcon( ECURSOR_ICON(selected) );
+ }
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (event.EventType == EET_MOUSE_INPUT_EVENT)
+ {
+ stringw infoText;
+ PrintMouseState(event, infoText);
+ Context.InfoStatic->setText(infoText.c_str());
+ if ( event.MouseInput.Event != EMIE_MOUSE_MOVED && event.MouseInput.Event != EMIE_MOUSE_WHEEL ) // no spam
+ {
+ infoText = L"";
+ PrintMouseEventName(event, infoText);
+ Context.EventBox->insertItem(0, infoText.c_str(), -1);
+ }
+ }
+
+ return false;
+ }
+
+private:
+ SAppContext & Context;
+};
+
+/*
+ Use several imagefiles as animation frames for a sprite which can be used as cursor icon.
+ The images in those files all need to have the same size.
+ Return sprite index on success or -1 on failure
+*/
+s32 AddAnimatedIconToSpriteBank( gui::IGUISpriteBank * spriteBank, video::IVideoDriver* driver, const array< io::path >& files, u32 frameTime )
+{
+ if ( !spriteBank || !driver || !files.size() )
+ return -1;
+
+ video::ITexture * tex = driver->getTexture( files[0] );
+ if ( tex )
+ {
+ array< rect<s32> >& spritePositions = spriteBank->getPositions();
+ u32 idxRect = spritePositions.size();
+ spritePositions.push_back( rect<s32>(0,0, tex->getSize().Width, tex->getSize().Height) );
+
+ SGUISprite sprite;
+ sprite.frameTime = frameTime;
+
+ array< SGUISprite >& sprites = spriteBank->getSprites();
+ u32 startIdx = spriteBank->getTextureCount();
+ for ( u32 f=0; f < files.size(); ++f )
+ {
+ tex = driver->getTexture( files[f] );
+ if ( tex )
+ {
+ spriteBank->addTexture( driver->getTexture(files[f]) );
+ gui::SGUISpriteFrame frame;
+ frame.rectNumber = idxRect;
+ frame.textureNumber = startIdx+f;
+ sprite.Frames.push_back( frame );
+ }
+ }
+
+ sprites.push_back( sprite );
+ return sprites.size()-1;
+ }
+
+ return -1;
+}
+
+/*
+ Use several images within one imagefile as animation frames for a sprite which can be used as cursor icon
+ The sizes of the icons within that file all need to have the same size
+ Return sprite index on success or -1 on failure
+*/
+s32 AddAnimatedIconToSpriteBank( gui::IGUISpriteBank * spriteBank, video::IVideoDriver* driver, const io::path& file, const array< rect<s32> >& rects, u32 frameTime )
+{
+ if ( !spriteBank || !driver || !rects.size() )
+ return -1;
+
+ video::ITexture * tex = driver->getTexture( file );
+ if ( tex )
+ {
+ array< rect<s32> >& spritePositions = spriteBank->getPositions();
+ u32 idxRect = spritePositions.size();
+ u32 idxTex = spriteBank->getTextureCount();
+ spriteBank->addTexture( tex );
+
+ SGUISprite sprite;
+ sprite.frameTime = frameTime;
+
+ array< SGUISprite >& sprites = spriteBank->getSprites();
+ for ( u32 i=0; i < rects.size(); ++i )
+ {
+ spritePositions.push_back( rects[i] );
+
+ gui::SGUISpriteFrame frame;
+ frame.rectNumber = idxRect+i;
+ frame.textureNumber = idxTex;
+ sprite.Frames.push_back( frame );
+ }
+
+ sprites.push_back( sprite );
+ return sprites.size()-1;
+ }
+
+ return -1;
+}
+
+/*
+ Create a non-animated icon from the given file and position and put it into the spritebank.
+ We can use this icon later on in a cursor.
+*/
+s32 AddIconToSpriteBank( gui::IGUISpriteBank * spriteBank, video::IVideoDriver* driver, const io::path& file, const core::rect<s32>& rect )
+{
+ if ( !spriteBank || !driver )
+ return -1;
+
+ video::ITexture * tex = driver->getTexture( file );
+ if ( tex )
+ {
+ core::array< core::rect<irr::s32> >& spritePositions = spriteBank->getPositions();
+ spritePositions.push_back( rect );
+ array< SGUISprite >& sprites = spriteBank->getSprites();
+ spriteBank->addTexture( tex );
+
+ gui::SGUISpriteFrame frame;
+ frame.rectNumber = spritePositions.size()-1;
+ frame.textureNumber = spriteBank->getTextureCount()-1;
+
+ SGUISprite sprite;
+ sprite.frameTime = 0;
+ sprite.Frames.push_back( frame );
+
+ sprites.push_back( sprite );
+
+ return sprites.size()-1;
+ }
+
+ return -1;
+}
+
+int main()
+{
+ video::E_DRIVER_TYPE driverType = driverChoiceConsole();
+ if (driverType==video::EDT_COUNT)
+ return 1;
+
+ IrrlichtDevice * device = createDevice(driverType, dimension2d<u32>(640, 480));
+ if (device == 0)
+ return 1; // could not create selected driver.
+
+ // It's sometimes of interest to know how the mouse behaves after a resize
+ device->setResizable(true);
+
+ device->setWindowCaption(L"Cursor control - Irrlicht engine tutorial");
+ video::IVideoDriver* driver = device->getVideoDriver();
+ IGUIEnvironment* env = device->getGUIEnvironment();
+
+ gui::IGUISpriteBank * SpriteBankIcons;
+
+ SAppContext context;
+ context.Device = device;
+
+ rect< s32 > rectInfoStatic(10,10, 200, 200);
+ env->addStaticText (L"Cursor state information", rectInfoStatic, true, true);
+ rectInfoStatic.UpperLeftCorner += dimension2di(0, 15);
+ context.InfoStatic = env->addStaticText (L"", rectInfoStatic, true, true);
+ rect< s32 > rectEventBox(10,210, 200, 400);
+ env->addStaticText (L"click events (new on top)", rectEventBox, true, true);
+ rectEventBox.UpperLeftCorner += dimension2di(0, 15);
+ context.EventBox = env->addListBox(rectEventBox);
+ rect< s32 > rectCursorBox(210,10, 400, 250);
+ env->addStaticText (L"cursors, click to set the active one", rectCursorBox, true, true);
+ rectCursorBox.UpperLeftCorner += dimension2di(0, 15);
+ context.CursorBox = env->addListBox(rectCursorBox);
+ rect< s32 > rectSpriteBox(210,260, 400, 400);
+ env->addStaticText (L"sprites", rectSpriteBox, true, true);
+ rectSpriteBox.UpperLeftCorner += dimension2di(0, 15);
+ context.SpriteBox = env->addListBox(rectSpriteBox);
+
+ context.ButtonSetVisible = env->addButton( rect<s32>( 410, 20, 560, 40 ), 0, -1, L"set visible (delayed)" );
+ context.ButtonSetInvisible = env->addButton( rect<s32>( 410, 50, 560, 70 ), 0, -1, L"set invisible (delayed)" );
+ context.ButtonSimulateBadFps = env->addButton( rect<s32>( 410, 80, 560, 100 ), 0, -1, L"simulate bad FPS" );
+ context.ButtonSimulateBadFps->setIsPushButton(true);
+ context.ButtonChangeIcon = env->addButton( rect<s32>( 410, 140, 560, 160 ), 0, -1, L"replace cursor icon\n(cursor+sprite must be selected)" );
+
+ // set the names for all the system cursors
+ for ( int i=0; i < (int)gui::ECI_COUNT; ++i )
+ {
+ context.CursorBox->addItem(stringw( GUICursorIconNames[i] ).c_str());
+ }
+
+ /*
+ Create sprites which then can be used as cursor icons.
+ */
+ SpriteBankIcons = env->addEmptySpriteBank(io::path("cursor_icons"));
+ context.SpriteBox->setSpriteBank(SpriteBankIcons);
+
+ // create one animated icon from several files
+ array< io::path > files;
+ files.push_back( io::path("../../media/icon_crosshairs16x16bw1.png") );
+ files.push_back( io::path("../../media/icon_crosshairs16x16bw2.png") );
+ files.push_back( io::path("../../media/icon_crosshairs16x16bw3.png") );
+ files.push_back( io::path("../../media/icon_crosshairs16x16bw3.png") );
+ files.push_back( io::path("../../media/icon_crosshairs16x16bw2.png") );
+ SCursorSprite spriteBw; // the sprite + some additional information needed for cursors
+ spriteBw.SpriteId = AddAnimatedIconToSpriteBank( SpriteBankIcons, driver, files, 200 );
+ spriteBw.SpriteBank = SpriteBankIcons;
+ spriteBw.HotSpot = position2d<s32>(7,7);
+ context.addIcon(L"crosshair_bw", spriteBw);
+
+ // create one animated icon from one file
+ array< rect<s32> > iconRects;
+ iconRects.push_back( rect<s32>(0,0, 16, 16) );
+ iconRects.push_back( rect<s32>(16,0, 32, 16) );
+ iconRects.push_back( rect<s32>(0,16, 16, 32) );
+ iconRects.push_back( rect<s32>(0,16, 16, 32) );
+ iconRects.push_back( rect<s32>(16,0, 32, 16) );
+ SCursorSprite spriteCol; // the sprite + some additional information needed for cursors
+ spriteCol.SpriteId = AddAnimatedIconToSpriteBank( SpriteBankIcons, driver, io::path("../../media/icon_crosshairs16x16col.png"), iconRects, 200 );
+ spriteCol.HotSpot = position2d<s32>(7,7);
+ spriteCol.SpriteBank = SpriteBankIcons;
+ context.addIcon(L"crosshair_colored", spriteCol);
+
+ // Create some non-animated icons
+ rect<s32> rectIcon;
+ SCursorSprite spriteNonAnimated(SpriteBankIcons, 0, position2d<s32>(7,7));
+
+ rectIcon = rect<s32>(0,0, 16, 16);
+ spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, io::path("../../media/icon_crosshairs16x16col.png"), rectIcon );
+ context.addIcon(L"crosshair_col1", spriteNonAnimated, false);
+
+ rectIcon = rect<s32>(16,0, 32, 16);
+ spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, io::path("../../media/icon_crosshairs16x16col.png"), rectIcon );
+ context.addIcon(L"crosshair_col2", spriteNonAnimated, false);
+
+ rectIcon = rect<s32>(0,16, 16, 32);
+ spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, io::path("../../media/icon_crosshairs16x16col.png"), rectIcon );
+ context.addIcon(L"crosshair_col3", spriteNonAnimated, false);
+
+
+ MyEventReceiver receiver(context);
+ device->setEventReceiver(&receiver);
+
+ while(device->run() && driver)
+ {
+ // if (device->isWindowActive())
+ {
+ u32 realTimeNow = device->getTimer()->getRealTime();
+
+ context.update();
+
+ driver->beginScene(true, true, SColor(0,200,200,200));
+
+ env->drawAll();
+
+ // draw custom sprite with Irrlicht functions for comparison. It should usually look the same as the cursors.
+ if ( context.SpriteBox )
+ {
+ s32 selectedSprite = context.SpriteBox->getSelected();
+ if ( selectedSprite >= 0 && context.Sprites[selectedSprite].SpriteId >= 0 )
+ {
+ SpriteBankIcons->draw2DSprite(u32(context.Sprites[selectedSprite].SpriteId), position2di(580, 140), 0, video::SColor(255, 255, 255, 255), 0, realTimeNow);
+ }
+ }
+
+ driver->endScene();
+ }
+
+ // By simulating bad fps we can find out if hardware-support for cursors works or not. If it works the cursor will move as usual,while it otherwise will just update with 2 fps now.
+ if ( context.SimulateBadFps )
+ {
+ device->sleep(500); // 2 fps
+ }
+ else
+ {
+ device->sleep(10);
+ }
+ }
+
+ device->drop();
+
+ return 0;
+}
+
+/*
+**/
diff --git a/examples/24.CursorControl/tutorial.html b/examples/24.CursorControl/tutorial.html new file mode 100644 index 0000000..08e8b18 --- /dev/null +++ b/examples/24.CursorControl/tutorial.html @@ -0,0 +1,205 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html> +<head> +<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> +<meta http-equiv="X-UA-Compatible" content="IE=9"/> +<meta name="generator" content="Doxygen 1.8.13"/> +<meta name="viewport" content="width=device-width, initial-scale=1"/> +<title>Tutorial 24: CursorControl</title> +<html xmlns="http://www.w3.org/1999/xhtml"> +<!-- Wanted to avoid copying .css to each folder, so copied default .css from doxyen in here, kicked out most stuff we don't need for examples and modified some a little bit. + Target was having a single html in each example folder which is created from the main.cpp files and needs no files besides some images below media folder. + Feel free to improve :) + --> +<style> +body, table, div, p, dl { + font: 400 14px/22px; +} +body { + background-color: #F0F0F0; + color: black; + margin-left: 5%; + margin-right: 5%; +} +p.reference, p.definition { + font: 400 14px/22px; +} +.title { + font: 400 14px/28px; + font-size: 150%; + font-weight: bold; + margin: 10px 2px; +} +h1, h2, h3, h4, h5, h6 { + -webkit-transition: text-shadow 0.5s linear; + -moz-transition: text-shadow 0.5s linear; + -ms-transition: text-shadow 0.5s linear; + -o-transition: text-shadow 0.5s linear; + transition: text-shadow 0.5s linear; + margin-right: 15px; +} +caption { + font-weight: bold; +} +h3.version { + font-size: 90%; + text-align: center; +} +a { + color: #3D578C; + font-weight: normal; + text-decoration: none; +} +.contents a:visited { + color: #4665A2; +} +a:hover { + text-decoration: underline; +} +a.el { + font-weight: bold; +} +a.code, a.code:visited, a.line, a.line:visited { + color: #4665A2; +} +a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited { + color: #4665A2; +} +pre.fragment { + border: 1px solid #C4CFE5; + background-color: #FBFCFD; + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 9pt; + line-height: 125%; + font-family: monospace, fixed; + font-size: 105%; +} +div.fragment { + padding: 0px; + margin: 4px 8px 4px 2px; + background-color: #FBFCFD; + border: 1px solid #C4CFE5; +} +div.line { + font-family: monospace, fixed; + font-size: 13px; + min-height: 13px; + line-height: 1.0; + text-wrap: unrestricted; + white-space: -moz-pre-wrap; /* Moz */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + white-space: pre-wrap; /* CSS3 */ + word-wrap: break-word; /* IE 5.5+ */ + text-indent: -53px; + padding-left: 53px; + padding-bottom: 0px; + margin: 0px; + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} +div.contents { + margin-top: 10px; + margin-left: 12px; + margin-right: 8px; +} +div.center { + text-align: center; + margin-top: 0px; + margin-bottom: 0px; + padding: 0px; +} +div.center img { + border: 0px; +} +span.keyword { + color: #008000 +} +span.keywordtype { + color: #604020 +} +span.keywordflow { + color: #e08000 +} +span.comment { + color: #800000 +} +span.preprocessor { + color: #806020 +} +span.stringliteral { + color: #002080 +} +span.charliteral { + color: #008080 +} +blockquote { + background-color: #F7F8FB; + border-left: 2px solid #9CAFD4; + margin: 0 24px 0 4px; + padding: 0 12px 0 16px; +} +hr { + height: 0px; + border: none; + border-top: 1px solid #4A6AAA; +} +address { + font-style: normal; + color: #2A3D61; +} +div.header { + background-image:url('nav_h.png'); + background-repeat:repeat-x; + background-color: #F9FAFC; + margin: 0px; + border-bottom: 1px solid #C4CFE5; +} +div.headertitle { + padding: 5px 5px 5px 10px; +} +.image { + text-align: center; +} +.caption { + font-weight: bold; +} +div.zoom { + border: 1px solid #90A5CE; +} +tr.heading h2 { + margin-top: 12px; + margin-bottom: 4px; +} +</style> +</head> +<div id="top"><!-- do not remove this div, it is closed by doxygen! --> +<!--END TITLEAREA--> +<!-- end header part --> +<!-- Generated by Doxygen 1.8.13 --> +</div><!-- top --> +<div class="header"> + <div class="headertitle"> +<div class="title">Tutorial 24: CursorControl </div> </div> +</div><!--header--> +<div class="contents"> +<div class="textblock"><div class="image"> +<img src="../../media/024shot.jpg" alt="024shot.jpg"/> +</div> + <p>Show how to modify cursors and offer some useful tool-functions for creating cursors. It can also be used for experiments with the mouse in general. </p><div class="fragment"><div class="line"><span class="preprocessor">#include <irrlicht.h></span></div><div class="line"><span class="preprocessor">#include "driverChoice.h"</span></div><div class="line"></div><div class="line"><span class="keyword">using namespace </span>irr;</div><div class="line"><span class="keyword">using namespace </span>core;</div><div class="line"><span class="keyword">using namespace </span>scene;</div><div class="line"><span class="keyword">using namespace </span>video;</div><div class="line"><span class="keyword">using namespace </span>io;</div><div class="line"><span class="keyword">using namespace </span>gui;</div><div class="line"></div><div class="line"><span class="preprocessor">#ifdef _IRR_WINDOWS_</span></div><div class="line"><span class="preprocessor">#pragma comment(lib, "Irrlicht.lib")</span></div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"></div><div class="line"><span class="keyword">const</span> <span class="keywordtype">int</span> DELAY_TIME = 3000;</div><div class="line"></div><div class="line"><span class="keyword">enum</span> ETimerAction</div><div class="line">{</div><div class="line"> ETA_MOUSE_VISIBLE,</div><div class="line"> ETA_MOUSE_INVISIBLE,</div><div class="line">};</div></div><!-- fragment --><p> Structure to allow delayed execution of some actions. </p><div class="fragment"><div class="line"><span class="keyword">struct </span>TimerAction</div><div class="line">{</div><div class="line"> u32 TargetTime;</div><div class="line"> ETimerAction Action;</div><div class="line">};</div></div><!-- fragment --> <div class="fragment"><div class="line"><span class="keyword">struct </span>SAppContext</div><div class="line">{</div><div class="line"> SAppContext()</div><div class="line"> : Device(0), InfoStatic(0), EventBox(0), CursorBox(0), SpriteBox(0)</div><div class="line"> , ButtonSetVisible(0), ButtonSetInvisible(0), ButtonSimulateBadFps(0)</div><div class="line"> , ButtonChangeIcon(0)</div><div class="line"> , SimulateBadFps(false)</div><div class="line"> {</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> update()</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> (!Device)</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"> u32 timeNow = Device->getTimer()->getTime();</div><div class="line"> <span class="keywordflow">for</span> ( u32 i=0; i < TimerActions.size(); ++i )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( timeNow >= TimerActions[i].TargetTime )</div><div class="line"> {</div><div class="line"> runTimerAction(TimerActions[i]);</div><div class="line"> TimerActions.erase(i);</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> ++i;</div><div class="line"> }</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> runTimerAction(<span class="keyword">const</span> TimerAction& action)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> (ETA_MOUSE_VISIBLE == action.Action)</div><div class="line"> {</div><div class="line"> Device->getCursorControl()->setVisible(<span class="keyword">true</span>);</div><div class="line"> ButtonSetVisible->setEnabled(<span class="keyword">true</span>);</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( ETA_MOUSE_INVISIBLE == action.Action)</div><div class="line"> {</div><div class="line"> Device->getCursorControl()->setVisible(<span class="keyword">false</span>);</div><div class="line"> ButtonSetInvisible->setEnabled(<span class="keyword">true</span>);</div><div class="line"> }</div><div class="line"> }</div></div><!-- fragment --><p> Add another icon which the user can click and select as cursor later on. </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> addIcon(<span class="keyword">const</span> stringw& name, <span class="keyword">const</span> SCursorSprite &sprite, <span class="keywordtype">bool</span> addCursor=<span class="keyword">true</span>)</div><div class="line">{</div><div class="line"> <span class="comment">// Sprites are just icons - not yet cursors. They can be displayed by Irrlicht sprite functions and be used to create cursors.</span></div><div class="line"> SpriteBox->addItem(name.c_str(), sprite.SpriteId);</div><div class="line"> Sprites.push_back(sprite);</div><div class="line"></div><div class="line"> <span class="comment">// create the cursor together with the icon?</span></div><div class="line"> <span class="keywordflow">if</span> ( addCursor )</div><div class="line"> {</div></div><!-- fragment --><p> Here we create a hardware cursor from a sprite</p><div class="fragment"><div class="line"> Device->getCursorControl()->addIcon(sprite);</div><div class="line"></div><div class="line"> <span class="comment">// ... and add it to the cursors selection listbox to the other system cursors.</span></div><div class="line"> CursorBox->addItem(name.c_str());</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> IrrlichtDevice * Device;</div><div class="line"> gui::IGUIStaticText * InfoStatic;</div><div class="line"> gui::IGUIListBox * EventBox;</div><div class="line"> gui::IGUIListBox * CursorBox;</div><div class="line"> gui::IGUIListBox * SpriteBox;</div><div class="line"> gui::IGUIButton * ButtonSetVisible;</div><div class="line"> gui::IGUIButton * ButtonSetInvisible;</div><div class="line"> gui::IGUIButton * ButtonSimulateBadFps;</div><div class="line"> gui::IGUIButton * ButtonChangeIcon;</div><div class="line"> array<TimerAction> TimerActions;</div><div class="line"> <span class="keywordtype">bool</span> SimulateBadFps;</div><div class="line"> array<SCursorSprite> Sprites;</div><div class="line">};</div></div><!-- fragment --><p> Helper function to print mouse event names into a stringw </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> PrintMouseEventName(<span class="keyword">const</span> SEvent& event, stringw &result)</div><div class="line">{</div><div class="line"> <span class="keywordflow">switch</span> ( event.MouseInput.Event )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">case</span> EMIE_LMOUSE_PRESSED_DOWN: result += stringw(L<span class="stringliteral">"EMIE_LMOUSE_PRESSED_DOWN"</span>); <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> EMIE_RMOUSE_PRESSED_DOWN: result += stringw(L<span class="stringliteral">"EMIE_RMOUSE_PRESSED_DOWN"</span>); <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> EMIE_MMOUSE_PRESSED_DOWN: result += stringw(L<span class="stringliteral">"EMIE_MMOUSE_PRESSED_DOWN"</span>); <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> EMIE_LMOUSE_LEFT_UP: result += stringw(L<span class="stringliteral">"EMIE_LMOUSE_LEFT_UP"</span>); <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> EMIE_RMOUSE_LEFT_UP: result += stringw(L<span class="stringliteral">"EMIE_RMOUSE_LEFT_UP"</span>); <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> EMIE_MMOUSE_LEFT_UP: result += stringw(L<span class="stringliteral">"EMIE_MMOUSE_LEFT_UP"</span>); <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> EMIE_MOUSE_MOVED: result += stringw(L<span class="stringliteral">"EMIE_MOUSE_MOVED"</span>); <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> EMIE_MOUSE_WHEEL: result += stringw(L<span class="stringliteral">"EMIE_MOUSE_WHEEL"</span>); <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> EMIE_LMOUSE_DOUBLE_CLICK: result += stringw(L<span class="stringliteral">"EMIE_LMOUSE_DOUBLE_CLICK"</span>); <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> EMIE_RMOUSE_DOUBLE_CLICK: result += stringw(L<span class="stringliteral">"EMIE_RMOUSE_DOUBLE_CLICK"</span>); <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> EMIE_MMOUSE_DOUBLE_CLICK: result += stringw(L<span class="stringliteral">"EMIE_MMOUSE_DOUBLE_CLICK"</span>); <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> EMIE_LMOUSE_TRIPLE_CLICK: result += stringw(L<span class="stringliteral">"EMIE_LMOUSE_TRIPLE_CLICK"</span>); <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> EMIE_RMOUSE_TRIPLE_CLICK: result += stringw(L<span class="stringliteral">"EMIE_RMOUSE_TRIPLE_CLICK"</span>); <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> EMIE_MMOUSE_TRIPLE_CLICK: result += stringw(L<span class="stringliteral">"EMIE_MMOUSE_TRIPLE_CLICK"</span>); <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">default</span>:</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><p> Helper function to print all the state information which get from a mouse-event into a stringw </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> PrintMouseState(<span class="keyword">const</span> SEvent& event, stringw &result)</div><div class="line">{</div><div class="line"> result += stringw(L<span class="stringliteral">"X: "</span>);</div><div class="line"> result += stringw(event.MouseInput.X);</div><div class="line"> result += stringw(L<span class="stringliteral">"\n"</span>);</div><div class="line"></div><div class="line"> result += stringw(L<span class="stringliteral">"Y: "</span>);</div><div class="line"> result += stringw(event.MouseInput.Y);</div><div class="line"> result += stringw(L<span class="stringliteral">"\n"</span>);</div><div class="line"></div><div class="line"></div><div class="line"> result += stringw(L<span class="stringliteral">"Wheel: "</span>);</div><div class="line"> result += stringw(event.MouseInput.Wheel);</div><div class="line"> result += stringw(L<span class="stringliteral">"\n"</span>);</div><div class="line"></div><div class="line"> result += stringw(L<span class="stringliteral">"Shift: "</span>);</div><div class="line"> <span class="keywordflow">if</span> ( event.MouseInput.Shift )</div><div class="line"> result += stringw(L<span class="stringliteral">"true\n"</span>);</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> result += stringw(L<span class="stringliteral">"false\n"</span>);</div><div class="line"></div><div class="line"> result += stringw(L<span class="stringliteral">"Control: "</span>);</div><div class="line"> <span class="keywordflow">if</span> ( event.MouseInput.Control )</div><div class="line"> result += stringw(L<span class="stringliteral">"true\n"</span>);</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> result += stringw(L<span class="stringliteral">"false\n"</span>);</div><div class="line"></div><div class="line"> result += stringw(L<span class="stringliteral">"ButtonStates: "</span>);</div><div class="line"> result += stringw(event.MouseInput.ButtonStates);</div><div class="line"> result += stringw(L<span class="stringliteral">"\n"</span>);</div><div class="line"></div><div class="line"> result += stringw(L<span class="stringliteral">"isLeftPressed: "</span>);</div><div class="line"> <span class="keywordflow">if</span> ( event.MouseInput.isLeftPressed() )</div><div class="line"> result += stringw(L<span class="stringliteral">"true\n"</span>);</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> result += stringw(L<span class="stringliteral">"false\n"</span>);</div><div class="line"></div><div class="line"> result += stringw(L<span class="stringliteral">"isRightPressed: "</span>);</div><div class="line"> <span class="keywordflow">if</span> ( event.MouseInput.isRightPressed() )</div><div class="line"> result += stringw(L<span class="stringliteral">"true\n"</span>);</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> result += stringw(L<span class="stringliteral">"false\n"</span>);</div><div class="line"></div><div class="line"> result += stringw(L<span class="stringliteral">"isMiddlePressed: "</span>);</div><div class="line"> <span class="keywordflow">if</span> ( event.MouseInput.isMiddlePressed() )</div><div class="line"> result += stringw(L<span class="stringliteral">"true\n"</span>);</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> result += stringw(L<span class="stringliteral">"false\n"</span>);</div><div class="line"></div><div class="line"> result += stringw(L<span class="stringliteral">"Event: "</span>);</div><div class="line"></div><div class="line"> PrintMouseEventName(event, result);</div><div class="line"></div><div class="line"> result += stringw(L<span class="stringliteral">"\n"</span>);</div><div class="line">}</div></div><!-- fragment --><p> A typical event receiver. </p><div class="fragment"><div class="line"><span class="keyword">class </span>MyEventReceiver : <span class="keyword">public</span> IEventReceiver</div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line"> MyEventReceiver(SAppContext & context) : Context(context) { }</div><div class="line"></div><div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent& event)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> (event.EventType == EET_GUI_EVENT )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">switch</span> ( event.GUIEvent.EventType )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">case</span> EGET_BUTTON_CLICKED:</div><div class="line"> {</div><div class="line"> u32 timeNow = Context.Device->getTimer()->getTime();</div><div class="line"> TimerAction action;</div><div class="line"> action.TargetTime = timeNow + DELAY_TIME;</div><div class="line"> <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.ButtonSetVisible )</div><div class="line"> {</div><div class="line"> action.Action = ETA_MOUSE_VISIBLE;</div><div class="line"> Context.TimerActions.push_back(action);</div><div class="line"> Context.ButtonSetVisible->setEnabled(<span class="keyword">false</span>);</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.ButtonSetInvisible )</div><div class="line"> {</div><div class="line"> action.Action = ETA_MOUSE_INVISIBLE;</div><div class="line"> Context.TimerActions.push_back(action);</div><div class="line"> Context.ButtonSetInvisible->setEnabled(<span class="keyword">false</span>);</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.ButtonSimulateBadFps )</div><div class="line"> {</div><div class="line"> Context.SimulateBadFps = Context.ButtonSimulateBadFps->isPressed();</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.ButtonChangeIcon )</div><div class="line"> {</div></div><!-- fragment --><p> Replace an existing cursor icon by another icon. The user has to select both - the icon which should be replaced and the icon which will replace it. </p><div class="fragment"><div class="line">s32 selectedCursor = Context.CursorBox->getSelected();</div><div class="line">s32 selectedSprite = Context.SpriteBox->getSelected();</div><div class="line"><span class="keywordflow">if</span> ( selectedCursor >= 0 && selectedSprite >= 0 )</div><div class="line">{</div></div><!-- fragment --><p> This does replace the icon. </p><div class="fragment"><div class="line">Context.Device->getCursorControl()->changeIcon((ECURSOR_ICON)selectedCursor, Context.Sprites[selectedSprite] );</div></div><!-- fragment --><p> Do also show the new icon. </p><div class="fragment"><div class="line"> Context.Device->getCursorControl()->setActiveIcon( ECURSOR_ICON(selectedCursor) );</div><div class="line"> }</div><div class="line"> }</div><div class="line">}</div><div class="line"><span class="keywordflow">break</span>;</div><div class="line"><span class="keywordflow">case</span> EGET_LISTBOX_CHANGED:</div><div class="line"><span class="keywordflow">case</span> EGET_LISTBOX_SELECTED_AGAIN:</div><div class="line">{</div><div class="line"> <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.CursorBox )</div><div class="line"> {</div></div><!-- fragment --><p> Find out which cursor the user selected </p><div class="fragment"><div class="line">s32 selected = Context.CursorBox->getSelected();</div><div class="line"><span class="keywordflow">if</span> ( selected >= 0 )</div><div class="line">{</div></div><!-- fragment --><p> Here we set the new cursor icon which will now be used within our window. </p><div class="fragment"><div class="line"> Context.Device->getCursorControl()->setActiveIcon( ECURSOR_ICON(selected) );</div><div class="line"> }</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">default</span>:</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (event.EventType == EET_MOUSE_INPUT_EVENT)</div><div class="line"> {</div><div class="line"> stringw infoText;</div><div class="line"> PrintMouseState(event, infoText);</div><div class="line"> Context.InfoStatic->setText(infoText.c_str());</div><div class="line"> <span class="keywordflow">if</span> ( event.MouseInput.Event != EMIE_MOUSE_MOVED && event.MouseInput.Event != EMIE_MOUSE_WHEEL ) <span class="comment">// no spam</span></div><div class="line"> {</div><div class="line"> infoText = L<span class="stringliteral">""</span>;</div><div class="line"> PrintMouseEventName(event, infoText);</div><div class="line"> Context.EventBox->insertItem(0, infoText.c_str(), -1);</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"><span class="keyword">private</span>:</div><div class="line"> SAppContext & Context;</div><div class="line">};</div></div><!-- fragment --><p> Use several imagefiles as animation frames for a sprite which can be used as cursor icon. The images in those files all need to have the same size. Return sprite index on success or -1 on failure </p><div class="fragment"><div class="line">s32 AddAnimatedIconToSpriteBank( gui::IGUISpriteBank * spriteBank, video::IVideoDriver* driver, <span class="keyword">const</span> array< io::path >& files, u32 frameTime )</div><div class="line">{</div><div class="line"> <span class="keywordflow">if</span> ( !spriteBank || !driver || !files.size() )</div><div class="line"> <span class="keywordflow">return</span> -1;</div><div class="line"></div><div class="line"> video::ITexture * tex = driver->getTexture( files[0] );</div><div class="line"> <span class="keywordflow">if</span> ( tex )</div><div class="line"> {</div><div class="line"> array< rect<s32> >& spritePositions = spriteBank->getPositions();</div><div class="line"> u32 idxRect = spritePositions.size();</div><div class="line"> spritePositions.push_back( rect<s32>(0,0, tex->getSize().Width, tex->getSize().Height) );</div><div class="line"></div><div class="line"> SGUISprite sprite;</div><div class="line"> sprite.frameTime = frameTime;</div><div class="line"></div><div class="line"> array< SGUISprite >& sprites = spriteBank->getSprites();</div><div class="line"> u32 startIdx = spriteBank->getTextureCount();</div><div class="line"> <span class="keywordflow">for</span> ( u32 f=0; f < files.size(); ++f )</div><div class="line"> {</div><div class="line"> tex = driver->getTexture( files[f] );</div><div class="line"> <span class="keywordflow">if</span> ( tex )</div><div class="line"> {</div><div class="line"> spriteBank->addTexture( driver->getTexture(files[f]) );</div><div class="line"> gui::SGUISpriteFrame frame;</div><div class="line"> frame.rectNumber = idxRect;</div><div class="line"> frame.textureNumber = startIdx+f;</div><div class="line"> sprite.Frames.push_back( frame );</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> sprites.push_back( sprite );</div><div class="line"> <span class="keywordflow">return</span> sprites.size()-1;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> -1;</div><div class="line">}</div></div><!-- fragment --><p> Use several images within one imagefile as animation frames for a sprite which can be used as cursor icon The sizes of the icons within that file all need to have the same size Return sprite index on success or -1 on failure </p><div class="fragment"><div class="line">s32 AddAnimatedIconToSpriteBank( gui::IGUISpriteBank * spriteBank, video::IVideoDriver* driver, <span class="keyword">const</span> io::path& file, <span class="keyword">const</span> array< rect<s32> >& rects, u32 frameTime )</div><div class="line">{</div><div class="line"> <span class="keywordflow">if</span> ( !spriteBank || !driver || !rects.size() )</div><div class="line"> <span class="keywordflow">return</span> -1;</div><div class="line"></div><div class="line"> video::ITexture * tex = driver->getTexture( file );</div><div class="line"> <span class="keywordflow">if</span> ( tex )</div><div class="line"> {</div><div class="line"> array< rect<s32> >& spritePositions = spriteBank->getPositions();</div><div class="line"> u32 idxRect = spritePositions.size();</div><div class="line"> u32 idxTex = spriteBank->getTextureCount();</div><div class="line"> spriteBank->addTexture( tex );</div><div class="line"></div><div class="line"> SGUISprite sprite;</div><div class="line"> sprite.frameTime = frameTime;</div><div class="line"></div><div class="line"> array< SGUISprite >& sprites = spriteBank->getSprites();</div><div class="line"> <span class="keywordflow">for</span> ( u32 i=0; i < rects.size(); ++i )</div><div class="line"> {</div><div class="line"> spritePositions.push_back( rects[i] );</div><div class="line"></div><div class="line"> gui::SGUISpriteFrame frame;</div><div class="line"> frame.rectNumber = idxRect+i;</div><div class="line"> frame.textureNumber = idxTex;</div><div class="line"> sprite.Frames.push_back( frame );</div><div class="line"> }</div><div class="line"></div><div class="line"> sprites.push_back( sprite );</div><div class="line"> <span class="keywordflow">return</span> sprites.size()-1;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> -1;</div><div class="line">}</div></div><!-- fragment --><p> Create a non-animated icon from the given file and position and put it into the spritebank. We can use this icon later on in a cursor. </p><div class="fragment"><div class="line">s32 AddIconToSpriteBank( gui::IGUISpriteBank * spriteBank, video::IVideoDriver* driver, <span class="keyword">const</span> io::path& file, <span class="keyword">const</span> core::rect<s32>& rect )</div><div class="line">{</div><div class="line"> <span class="keywordflow">if</span> ( !spriteBank || !driver )</div><div class="line"> <span class="keywordflow">return</span> -1;</div><div class="line"></div><div class="line"> video::ITexture * tex = driver->getTexture( file );</div><div class="line"> <span class="keywordflow">if</span> ( tex )</div><div class="line"> {</div><div class="line"> core::array< core::rect<irr::s32> >& spritePositions = spriteBank->getPositions();</div><div class="line"> spritePositions.push_back( rect );</div><div class="line"> array< SGUISprite >& sprites = spriteBank->getSprites();</div><div class="line"> spriteBank->addTexture( tex );</div><div class="line"></div><div class="line"> gui::SGUISpriteFrame frame;</div><div class="line"> frame.rectNumber = spritePositions.size()-1;</div><div class="line"> frame.textureNumber = spriteBank->getTextureCount()-1;</div><div class="line"></div><div class="line"> SGUISprite sprite;</div><div class="line"> sprite.frameTime = 0;</div><div class="line"> sprite.Frames.push_back( frame );</div><div class="line"></div><div class="line"> sprites.push_back( sprite );</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> sprites.size()-1;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> -1;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main()</div><div class="line">{</div><div class="line"> video::E_DRIVER_TYPE driverType = driverChoiceConsole();</div><div class="line"> <span class="keywordflow">if</span> (driverType==video::EDT_COUNT)</div><div class="line"> <span class="keywordflow">return</span> 1;</div><div class="line"></div><div class="line"> IrrlichtDevice * device = createDevice(driverType, dimension2d<u32>(640, 480));</div><div class="line"> <span class="keywordflow">if</span> (device == 0)</div><div class="line"> <span class="keywordflow">return</span> 1; <span class="comment">// could not create selected driver.</span></div><div class="line"></div><div class="line"> <span class="comment">// It's sometimes of interest to know how the mouse behaves after a resize</span></div><div class="line"> device->setResizable(<span class="keyword">true</span>);</div><div class="line"></div><div class="line"> device->setWindowCaption(L<span class="stringliteral">"Cursor control - Irrlicht engine tutorial"</span>);</div><div class="line"> video::IVideoDriver* driver = device->getVideoDriver();</div><div class="line"> IGUIEnvironment* env = device->getGUIEnvironment();</div><div class="line"></div><div class="line"> gui::IGUISpriteBank * SpriteBankIcons;</div><div class="line"></div><div class="line"> SAppContext context;</div><div class="line"> context.Device = device;</div><div class="line"></div><div class="line"> rect< s32 > rectInfoStatic(10,10, 200, 200);</div><div class="line"> env->addStaticText (L<span class="stringliteral">"Cursor state information"</span>, rectInfoStatic, <span class="keyword">true</span>, <span class="keyword">true</span>);</div><div class="line"> rectInfoStatic.UpperLeftCorner += dimension2di(0, 15);</div><div class="line"> context.InfoStatic = env->addStaticText (L<span class="stringliteral">""</span>, rectInfoStatic, <span class="keyword">true</span>, <span class="keyword">true</span>);</div><div class="line"> rect< s32 > rectEventBox(10,210, 200, 400);</div><div class="line"> env->addStaticText (L<span class="stringliteral">"click events (new on top)"</span>, rectEventBox, <span class="keyword">true</span>, <span class="keyword">true</span>);</div><div class="line"> rectEventBox.UpperLeftCorner += dimension2di(0, 15);</div><div class="line"> context.EventBox = env->addListBox(rectEventBox);</div><div class="line"> rect< s32 > rectCursorBox(210,10, 400, 250);</div><div class="line"> env->addStaticText (L<span class="stringliteral">"cursors, click to set the active one"</span>, rectCursorBox, <span class="keyword">true</span>, <span class="keyword">true</span>);</div><div class="line"> rectCursorBox.UpperLeftCorner += dimension2di(0, 15);</div><div class="line"> context.CursorBox = env->addListBox(rectCursorBox);</div><div class="line"> rect< s32 > rectSpriteBox(210,260, 400, 400);</div><div class="line"> env->addStaticText (L<span class="stringliteral">"sprites"</span>, rectSpriteBox, <span class="keyword">true</span>, <span class="keyword">true</span>);</div><div class="line"> rectSpriteBox.UpperLeftCorner += dimension2di(0, 15);</div><div class="line"> context.SpriteBox = env->addListBox(rectSpriteBox);</div><div class="line"></div><div class="line"> context.ButtonSetVisible = env->addButton( rect<s32>( 410, 20, 560, 40 ), 0, -1, L<span class="stringliteral">"set visible (delayed)"</span> );</div><div class="line"> context.ButtonSetInvisible = env->addButton( rect<s32>( 410, 50, 560, 70 ), 0, -1, L<span class="stringliteral">"set invisible (delayed)"</span> );</div><div class="line"> context.ButtonSimulateBadFps = env->addButton( rect<s32>( 410, 80, 560, 100 ), 0, -1, L<span class="stringliteral">"simulate bad FPS"</span> );</div><div class="line"> context.ButtonSimulateBadFps->setIsPushButton(<span class="keyword">true</span>);</div><div class="line"> context.ButtonChangeIcon = env->addButton( rect<s32>( 410, 140, 560, 160 ), 0, -1, L<span class="stringliteral">"replace cursor icon\n(cursor+sprite must be selected)"</span> );</div><div class="line"></div><div class="line"> <span class="comment">// set the names for all the system cursors</span></div><div class="line"> <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i < (int)gui::ECI_COUNT; ++i )</div><div class="line"> {</div><div class="line"> context.CursorBox->addItem(stringw( GUICursorIconNames[i] ).c_str());</div><div class="line"> }</div></div><!-- fragment --><p> Create sprites which then can be used as cursor icons. </p><div class="fragment"><div class="line"> SpriteBankIcons = env->addEmptySpriteBank(io::path(<span class="stringliteral">"cursor_icons"</span>));</div><div class="line"> context.SpriteBox->setSpriteBank(SpriteBankIcons);</div><div class="line"></div><div class="line"> <span class="comment">// create one animated icon from several files</span></div><div class="line"> array< io::path > files;</div><div class="line"> files.push_back( io::path(<span class="stringliteral">"../../media/icon_crosshairs16x16bw1.png"</span>) );</div><div class="line"> files.push_back( io::path(<span class="stringliteral">"../../media/icon_crosshairs16x16bw2.png"</span>) );</div><div class="line"> files.push_back( io::path(<span class="stringliteral">"../../media/icon_crosshairs16x16bw3.png"</span>) );</div><div class="line"> files.push_back( io::path(<span class="stringliteral">"../../media/icon_crosshairs16x16bw3.png"</span>) );</div><div class="line"> files.push_back( io::path(<span class="stringliteral">"../../media/icon_crosshairs16x16bw2.png"</span>) );</div><div class="line"> SCursorSprite spriteBw; <span class="comment">// the sprite + some additional information needed for cursors</span></div><div class="line"> spriteBw.SpriteId = AddAnimatedIconToSpriteBank( SpriteBankIcons, driver, files, 200 );</div><div class="line"> spriteBw.SpriteBank = SpriteBankIcons;</div><div class="line"> spriteBw.HotSpot = position2d<s32>(7,7);</div><div class="line"> context.addIcon(L<span class="stringliteral">"crosshair_bw"</span>, spriteBw);</div><div class="line"></div><div class="line"> <span class="comment">// create one animated icon from one file</span></div><div class="line"> array< rect<s32> > iconRects;</div><div class="line"> iconRects.push_back( rect<s32>(0,0, 16, 16) );</div><div class="line"> iconRects.push_back( rect<s32>(16,0, 32, 16) );</div><div class="line"> iconRects.push_back( rect<s32>(0,16, 16, 32) );</div><div class="line"> iconRects.push_back( rect<s32>(0,16, 16, 32) );</div><div class="line"> iconRects.push_back( rect<s32>(16,0, 32, 16) );</div><div class="line"> SCursorSprite spriteCol; <span class="comment">// the sprite + some additional information needed for cursors</span></div><div class="line"> spriteCol.SpriteId = AddAnimatedIconToSpriteBank( SpriteBankIcons, driver, io::path(<span class="stringliteral">"../../media/icon_crosshairs16x16col.png"</span>), iconRects, 200 );</div><div class="line"> spriteCol.HotSpot = position2d<s32>(7,7);</div><div class="line"> spriteCol.SpriteBank = SpriteBankIcons;</div><div class="line"> context.addIcon(L<span class="stringliteral">"crosshair_colored"</span>, spriteCol);</div><div class="line"></div><div class="line"> <span class="comment">// Create some non-animated icons</span></div><div class="line"> rect<s32> rectIcon;</div><div class="line"> SCursorSprite spriteNonAnimated(SpriteBankIcons, 0, position2d<s32>(7,7));</div><div class="line"></div><div class="line"> rectIcon = rect<s32>(0,0, 16, 16);</div><div class="line"> spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, io::path(<span class="stringliteral">"../../media/icon_crosshairs16x16col.png"</span>), rectIcon );</div><div class="line"> context.addIcon(L<span class="stringliteral">"crosshair_col1"</span>, spriteNonAnimated, <span class="keyword">false</span>);</div><div class="line"></div><div class="line"> rectIcon = rect<s32>(16,0, 32, 16);</div><div class="line"> spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, io::path(<span class="stringliteral">"../../media/icon_crosshairs16x16col.png"</span>), rectIcon );</div><div class="line"> context.addIcon(L<span class="stringliteral">"crosshair_col2"</span>, spriteNonAnimated, <span class="keyword">false</span>);</div><div class="line"></div><div class="line"> rectIcon = rect<s32>(0,16, 16, 32);</div><div class="line"> spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, io::path(<span class="stringliteral">"../../media/icon_crosshairs16x16col.png"</span>), rectIcon );</div><div class="line"> context.addIcon(L<span class="stringliteral">"crosshair_col3"</span>, spriteNonAnimated, <span class="keyword">false</span>);</div><div class="line"></div><div class="line"></div><div class="line"> MyEventReceiver receiver(context);</div><div class="line"> device->setEventReceiver(&receiver);</div><div class="line"></div><div class="line"> <span class="keywordflow">while</span>(device->run() && driver)</div><div class="line"> {</div><div class="line"> <span class="comment">// if (device->isWindowActive())</span></div><div class="line"> {</div><div class="line"> u32 realTimeNow = device->getTimer()->getRealTime();</div><div class="line"></div><div class="line"> context.update();</div><div class="line"></div><div class="line"> driver->beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, SColor(0,200,200,200));</div><div class="line"></div><div class="line"> env->drawAll();</div><div class="line"></div><div class="line"> <span class="comment">// draw custom sprite with Irrlicht functions for comparison. It should usually look the same as the cursors.</span></div><div class="line"> <span class="keywordflow">if</span> ( context.SpriteBox )</div><div class="line"> {</div><div class="line"> s32 selectedSprite = context.SpriteBox->getSelected();</div><div class="line"> <span class="keywordflow">if</span> ( selectedSprite >= 0 && context.Sprites[selectedSprite].SpriteId >= 0 )</div><div class="line"> {</div><div class="line"> SpriteBankIcons->draw2DSprite(u32(context.Sprites[selectedSprite].SpriteId), position2di(580, 140), 0, video::SColor(255, 255, 255, 255), 0, realTimeNow);</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> driver->endScene();</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// By simulating bad fps we can find out if hardware-support for cursors works or not. If it works the cursor will move as usual,while it otherwise will just update with 2 fps now.</span></div><div class="line"> <span class="keywordflow">if</span> ( context.SimulateBadFps )</div><div class="line"> {</div><div class="line"> device->sleep(500); <span class="comment">// 2 fps</span></div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> device->sleep(10);</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> device->drop();</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line">}</div></div><!-- fragment --> </div></div><!-- contents --> +<!-- HTML footer for doxygen 1.8.13--> +<!-- start footer part --> +<p> </p> +</body> +</html> |
