Showing preview only (1,504K chars total). Download the full file or copy to clipboard to get everything.
Repository: GameTechDev/OutdoorLightScattering
Branch: master
Commit: 3b31b3b8c1aa
Files: 168
Total size: 15.6 MB
Directory structure:
gitextract_u9hxjrts/
├── .gitattributes
├── .gitignore
├── CPUT/
│ ├── CPUT/
│ │ ├── CPUT.h
│ │ ├── CPUTAssetLibrary.cpp
│ │ ├── CPUTAssetLibrary.h
│ │ ├── CPUTAssetLibraryDX11.cpp
│ │ ├── CPUTAssetLibraryDX11.h
│ │ ├── CPUTAssetSet.cpp
│ │ ├── CPUTAssetSet.h
│ │ ├── CPUTAssetSetDX11.cpp
│ │ ├── CPUTAssetSetDX11.h
│ │ ├── CPUTBuffer.cpp
│ │ ├── CPUTBuffer.h
│ │ ├── CPUTBufferDX11.cpp
│ │ ├── CPUTBufferDX11.h
│ │ ├── CPUTButton.cpp
│ │ ├── CPUTButton.h
│ │ ├── CPUTCallbackHandler.h
│ │ ├── CPUTCamera.cpp
│ │ ├── CPUTCamera.h
│ │ ├── CPUTCheckbox.cpp
│ │ ├── CPUTCheckbox.h
│ │ ├── CPUTComputeShaderDX11.cpp
│ │ ├── CPUTComputeShaderDX11.h
│ │ ├── CPUTConfigBlock.cpp
│ │ ├── CPUTConfigBlock.h
│ │ ├── CPUTControl.cpp
│ │ ├── CPUTControl.h
│ │ ├── CPUTDomainShaderDX11.cpp
│ │ ├── CPUTDomainShaderDX11.h
│ │ ├── CPUTDropdown.cpp
│ │ ├── CPUTDropdown.h
│ │ ├── CPUTEventHandler.h
│ │ ├── CPUTFont.cpp
│ │ ├── CPUTFont.h
│ │ ├── CPUTFontDX11.cpp
│ │ ├── CPUTFontDX11.h
│ │ ├── CPUTFrustum.cpp
│ │ ├── CPUTFrustum.h
│ │ ├── CPUTGeometryShaderDX11.cpp
│ │ ├── CPUTGeometryShaderDX11.h
│ │ ├── CPUTGuiController.cpp
│ │ ├── CPUTGuiController.h
│ │ ├── CPUTGuiControllerDX11.cpp
│ │ ├── CPUTGuiControllerDX11.h
│ │ ├── CPUTHullShaderDX11.cpp
│ │ ├── CPUTHullShaderDX11.h
│ │ ├── CPUTITTTaskMarker.cpp
│ │ ├── CPUTITTTaskMarker.h
│ │ ├── CPUTInputLayoutCache.h
│ │ ├── CPUTInputLayoutCacheDX11.cpp
│ │ ├── CPUTInputLayoutCacheDX11.h
│ │ ├── CPUTLight.cpp
│ │ ├── CPUTLight.h
│ │ ├── CPUTMaterial.cpp
│ │ ├── CPUTMaterial.h
│ │ ├── CPUTMaterialDX11.cpp
│ │ ├── CPUTMaterialDX11.h
│ │ ├── CPUTMath.h
│ │ ├── CPUTMesh.cpp
│ │ ├── CPUTMesh.h
│ │ ├── CPUTMeshDX11.cpp
│ │ ├── CPUTMeshDX11.h
│ │ ├── CPUTModel.cpp
│ │ ├── CPUTModel.h
│ │ ├── CPUTModelDX11.cpp
│ │ ├── CPUTModelDX11.h
│ │ ├── CPUTNullNode.cpp
│ │ ├── CPUTNullNode.h
│ │ ├── CPUTOSServicesWin.cpp
│ │ ├── CPUTOSServicesWin.h
│ │ ├── CPUTPerfTaskMarker.cpp
│ │ ├── CPUTPerfTaskMarker.h
│ │ ├── CPUTPixelShaderDX11.cpp
│ │ ├── CPUTPixelShaderDX11.h
│ │ ├── CPUTPostProcess.cpp
│ │ ├── CPUTPostProcess.h
│ │ ├── CPUTRefCount.h
│ │ ├── CPUTRenderNode.cpp
│ │ ├── CPUTRenderNode.h
│ │ ├── CPUTRenderParams.h
│ │ ├── CPUTRenderParamsDX.h
│ │ ├── CPUTRenderStateBlock.cpp
│ │ ├── CPUTRenderStateBlock.h
│ │ ├── CPUTRenderStateBlockDX11.cpp
│ │ ├── CPUTRenderStateBlockDX11.h
│ │ ├── CPUTRenderStateMapsDX11.h
│ │ ├── CPUTRenderTarget.cpp
│ │ ├── CPUTRenderTarget.h
│ │ ├── CPUTResource.h
│ │ ├── CPUTShaderDX11.cpp
│ │ ├── CPUTShaderDX11.h
│ │ ├── CPUTSlider.cpp
│ │ ├── CPUTSlider.h
│ │ ├── CPUTSprite.cpp
│ │ ├── CPUTSprite.h
│ │ ├── CPUTText.cpp
│ │ ├── CPUTText.h
│ │ ├── CPUTTexture.cpp
│ │ ├── CPUTTexture.h
│ │ ├── CPUTTextureDX11.cpp
│ │ ├── CPUTTextureDX11.h
│ │ ├── CPUTTimer.h
│ │ ├── CPUTTimerWin.cpp
│ │ ├── CPUTTimerWin.h
│ │ ├── CPUTVertexShaderDX11.cpp
│ │ ├── CPUTVertexShaderDX11.h
│ │ ├── CPUTWindowWin.cpp
│ │ ├── CPUTWindowWin.h
│ │ ├── CPUT_DX11.cpp
│ │ └── CPUT_DX11.h
│ ├── CPUT-DX11.sln
│ ├── CPUT-DX11.vcxproj
│ ├── CPUT-DX11.vcxproj.filters
│ ├── CPUT-DX11_2012.vcxproj
│ ├── CPUT-DX11_2012.vcxproj.filters
│ └── resources/
│ ├── controls/
│ │ ├── atlas/
│ │ │ ├── atlas.cmd
│ │ │ ├── atlas.set
│ │ │ ├── lambert1.mtl
│ │ │ └── polySurface1.mdl
│ │ └── atlas.dds
│ ├── fonts/
│ │ └── font_Arial_12.dds
│ └── shaders/
│ ├── GUIRenderState.rs
│ ├── GUIShaderDX.ps
│ └── GUIShaderDX.vs
├── Default_Config.txt
├── LightSctrPostProcess.cpp
├── LightSctrPostProcess.h
├── OutdoorLightScattering.cpp
├── OutdoorLightScattering.h
├── OutdoorLightScattering_2010.rc
├── OutdoorLightScattering_2010.sln
├── OutdoorLightScattering_2010.vcxproj
├── OutdoorLightScattering_2010.vcxproj.filters
├── OutdoorLightScattering_2012.sln
├── OutdoorLightScattering_2012.vcxproj
├── OutdoorLightScattering_2012.vcxproj.filters
├── RenderTechnique.cpp
├── RenderTechnique.h
├── ShaderMacroHelper.h
├── Terrain/
│ ├── ConfigFile.cpp
│ ├── DynamicQuadTreeNode.h
│ ├── EarthHemisphere.cpp
│ ├── EarthHemisphere.h
│ ├── ElevationDataSource.cpp
│ ├── ElevationDataSource.h
│ ├── Errors.h
│ ├── HierarchyArray.h
│ └── stdafx.cpp
├── fx/
│ ├── Common.fxh
│ ├── LightScattering.fx
│ ├── RefineSampleLocations.fx
│ ├── Structures.fxh
│ ├── Terrain.fx
│ └── TerrainStructs.fxh
├── license.txt
├── media/
│ ├── Terrain/
│ │ └── HeightMap.tif
│ └── Tiles/
│ ├── cliff_DM.dds
│ ├── cliff_NM.dds
│ ├── grassDark_DM.dds
│ ├── grass_DM.dds
│ ├── grass_NM.dds
│ ├── gravel_DM.dds
│ ├── gravel_NM.dds
│ └── snow_DM.dds
├── readme.txt
├── resource.h
└── stdafx.h
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
================================================
FILE: .gitignore
================================================
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#############
## Windows detritus
#############
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
#############
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg
================================================
FILE: CPUT/CPUT/CPUT.h
================================================
////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
////////////////////////////////////////////////////////////////////////////////
#ifndef __CPUTBASE_H__
#define __CPUTBASE_H__
// Master #defines for which target
#define CPUT_FOR_DX11
#include <stdlib.h>
#include <crtdbg.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <assert.h>
#include "CPUTMath.h"
#include "CPUTEventHandler.h"
#include "CPUTCallbackHandler.h"
#include "CPUTTimer.h"
#ifdef CPUT_GPA_INSTRUMENTATION
// For D3DPERF_* calls, you also need d3d9.lib included
#include <d3d9.h> // required for all the pix D3DPERF_BeginEvent()/etc calls
#include <ittnotify.h>
#include "CPUTITTTaskMarker.h" // markup helper for GPA Platform Analyzer tags
#include "CPUTPerfTaskMarker.h" // markup helper for GPA Frame Analyzer tags
// GLOBAL instrumentation junk
enum CPUT_GPA_INSTRUMENTATION_STRINGS{
GPA_HANDLE_CPUT_CREATE = 0,
GPA_HANDLE_CONTEXT_CREATION,
GPA_HANDLE_SYSTEM_INITIALIZATION,
GPA_HANDLE_MAIN_MESSAGE_LOOP,
GPA_HANDLE_EVENT_DISPATCH_AND_HANDLE,
GPA_HANDLE_LOAD_SET,
GPA_HANDLE_LOAD_MODEL,
GPA_HANDLE_LOAD_MATERIAL,
GPA_HANDLE_LOAD_TEXTURE,
GPA_HANDLE_LOAD_CAMERAS,
GPA_HANDLE_LOAD_LIGHTS,
GPA_HANDLE_LOAD_VERTEX_SHADER,
GPA_HANDLE_LOAD_GEOMETRY_SHADER,
GPA_HANDLE_LOAD_PIXEL_SHADER,
GPA_HANDLE_DRAW_GUI,
GPA_HANDLE_STRING_ENUMS_SIZE,
};
#endif // CPUT_GPA_INSTRUMENTATION
// Heap corruption, ASSERT, and TRACE defines
//-----------------------------------------------------------------------------
#ifdef _DEBUG
#include <tchar.h>
#define TRACE(String) {OutputDebugString(String);}
#define DEBUGMESSAGEBOX(Title, Text) { CPUTOSServices::GetOSServices()->OpenMessageBox(Title, Text);}
#define ASSERT(Condition, Message) { if( !(Condition) ) { cString msg = cString(_T(__FUNCTION__)) + _L(": ") + Message; OutputDebugString(msg.c_str()); DEBUGMESSAGEBOX(_L("Assert"), msg ); } assert(Condition);}
#define HEAPCHECK { int heapstatus = _heapchk(); ASSERT(_HEAPOK == heapstatus, _L("Heap corruption") ); }
// #define HEAPCHECK {}
#else
#define ASSERT(Condition, Message)
#define TRACE(String)
#define DEBUGMESSAGEBOX(Title, Text)
#define HEAPCHECK
#endif // _DEBUG
// Error codes
//-----------------------------------------------------------------------------
typedef enum CPUTResult
{
// success
CPUT_SUCCESS = 0x00000000,
// warnings
// CPUT_WARNING_OUT_OF_RANGE,
CPUT_WARNING_NOT_FOUND,
// CPUT_WARNING_ALREADY_EXISTS,
// CPUT_WARNING_FILE_IN_SEARCH_PATH_BUT_NOT_WHERE_SPECIFIED,
// CPUT_WARNING_PHONG_SHADER_MISSING_TEXTURE,
CPUT_WARNING_CANCELED,
// CPUT_WARNING_NO_SUITABLE_FORMAT_FOUND,
//
CPUT_WARNING_SHADER_INPUT_SLOT_NOT_MATCHED,
//
// // file errors
CPUT_ERROR_FILE_NOT_FOUND = 0xF0000001,
CPUT_ERROR_FILE_READ_ERROR = CPUT_ERROR_FILE_NOT_FOUND+1,
CPUT_ERROR_FILE_CLOSE_ERROR = CPUT_ERROR_FILE_NOT_FOUND+2,
CPUT_ERROR_FILE_IO_ERROR = CPUT_ERROR_FILE_NOT_FOUND+3,
CPUT_ERROR_FILE_NO_SUCH_DEVICE_OR_ADDRESS = CPUT_ERROR_FILE_NOT_FOUND+4,
CPUT_ERROR_FILE_BAD_FILE_NUMBER = CPUT_ERROR_FILE_NOT_FOUND+5,
CPUT_ERROR_FILE_NOT_ENOUGH_MEMORY = CPUT_ERROR_FILE_NOT_FOUND+6,
CPUT_ERROR_FILE_PERMISSION_DENIED = CPUT_ERROR_FILE_NOT_FOUND+7,
CPUT_ERROR_FILE_DEVICE_OR_RESOURCE_BUSY = CPUT_ERROR_FILE_NOT_FOUND+8,
CPUT_ERROR_FILE_EXISTS = CPUT_ERROR_FILE_NOT_FOUND+9,
CPUT_ERROR_FILE_IS_A_DIRECTORY = CPUT_ERROR_FILE_NOT_FOUND+10,
CPUT_ERROR_FILE_TOO_MANY_OPEN_FILES = CPUT_ERROR_FILE_NOT_FOUND+11,
CPUT_ERROR_FILE_TOO_LARGE = CPUT_ERROR_FILE_NOT_FOUND+12,
CPUT_ERROR_FILE_DEVICE_FULL = CPUT_ERROR_FILE_NOT_FOUND+13,
CPUT_ERROR_FILE_FILENAME_TOO_LONG = CPUT_ERROR_FILE_NOT_FOUND+14,
CPUT_ERROR_FILE_PATH_ERROR = CPUT_ERROR_FILE_NOT_FOUND+15,
CPUT_ERROR_FILE_ERROR = CPUT_ERROR_FILE_NOT_FOUND+16,
//
// CPUT_ERROR_DIRECTORY_NOT_FOUND = CPUT_ERROR_FILE_NOT_FOUND+21,
//
// // subsystem errors
CPUT_ERROR_INVALID_PARAMETER = 0xF0000100,
CPUT_ERROR_NOT_FOUND = CPUT_ERROR_INVALID_PARAMETER+1,
// CPUT_ERROR_COMPONENT_NOT_INITIALIZED = CPUT_ERROR_INVALID_PARAMETER+2,
// CPUT_ERROR_SUBSYSTEM_OUT_OF_MEMORY = CPUT_ERROR_INVALID_PARAMETER+3,
// CPUT_ERROR_OUT_OF_BOUNDS = CPUT_ERROR_INVALID_PARAMETER+4,
// CPUT_ERROR_HEAP_CORRUPTION = CPUT_ERROR_INVALID_PARAMETER+5,
//
// // image format errors
CPUT_ERROR_UNSUPPORTED_IMAGE_FORMAT = 0xF0000200,
// CPUT_ERROR_ERROR_LOADING_IMAGE = CPUT_ERROR_UNSUPPORTED_IMAGE_FORMAT+1,
CPUT_ERROR_UNSUPPORTED_SRGB_IMAGE_FORMAT,
//
// // shader loading errors
// CPUT_SHADER_LOAD_ERROR = 0xF0000300,
// CPUT_SHADER_COMPILE_ERROR = CPUT_SHADER_LOAD_ERROR+1,
// CPUT_SHADER_LINK_ERROR = CPUT_SHADER_LOAD_ERROR+2,
// CPUT_SHADER_REGISTRATION_ERROR = CPUT_SHADER_LOAD_ERROR+3,
// CPUT_SHADER_CONSTANT_BUFFER_ERROR = CPUT_SHADER_LOAD_ERROR+4,
// CPUT_SHADER_REFLECTION_ERROR = CPUT_SHADER_LOAD_ERROR+5,
//
// // texture loading errors
CPUT_TEXTURE_LOAD_ERROR = 0xF0000400,
CPUT_ERROR_TEXTURE_FILE_NOT_FOUND = CPUT_TEXTURE_LOAD_ERROR+1,
//
// // GUI errors
CPUT_GUI_GEOMETRY_CREATION_ERROR = 0xF0000500,
// CPUT_GUI_SAMPLER_CREATION_ERROR = CPUT_GUI_GEOMETRY_CREATION_ERROR+1,
// CPUT_GUI_TEXTURE_CREATION_ERROR = CPUT_GUI_GEOMETRY_CREATION_ERROR+2,
// CPUT_GUI_CANNOT_CREATE_CONTROL = CPUT_GUI_GEOMETRY_CREATION_ERROR+3,
CPUT_GUI_INVALID_CONTROL_ID = CPUT_GUI_GEOMETRY_CREATION_ERROR+4,
//
// // Texture loading errors
// CPUT_FONT_TEXTURE_TYPE_ERROR = 0xF0000600,
// CPUT_FONT_TEXTURE_LOAD_ERROR = CPUT_FONT_TEXTURE_TYPE_ERROR+1,
//
// // Model loading errors
// CPUT_ERROR_MODEL_LOAD_ERROR = 0xF0000650,
// CPUT_ERROR_MODEL_FILE_NOT_FOUND = CPUT_ERROR_MODEL_LOAD_ERROR+1,
//
// // Shader errors
CPUT_ERROR_VERTEX_LAYOUT_PROBLEM = 0xF0000700,
// CPUT_ERROR_VERTEX_BUFFER_CREATION_PROBLEM = CPUT_ERROR_VERTEX_LAYOUT_PROBLEM+1,
// CPUT_ERROR_INDEX_BUFFER_CREATION_PROBLEM = CPUT_ERROR_VERTEX_LAYOUT_PROBLEM+2,
// CPUT_ERROR_UNSUPPORTED_VERTEX_ELEMENT_TYPE = CPUT_ERROR_VERTEX_LAYOUT_PROBLEM+3,
// CPUT_ERROR_INDEX_BUFFER_LAYOUT_PROBLEM = CPUT_ERROR_VERTEX_LAYOUT_PROBLEM+4,
CPUT_ERROR_SHADER_INPUT_SLOT_NOT_MATCHED = CPUT_ERROR_VERTEX_LAYOUT_PROBLEM+5,
//
//
// // Context creation errors
// CPUT_ERROR_CONTEXT_CREATION_FAILURE = 0xF0000C00,
// CPUT_ERROR_SWAP_CHAIN_CREATION_FAILURE = CPUT_ERROR_CONTEXT_CREATION_FAILURE+1,
// CPUT_ERROR_RENDER_TARGET_VIEW_CREATION_FAILURE = CPUT_ERROR_CONTEXT_CREATION_FAILURE+2,
//
// // Depth buffer errors
// CPUT_ERROR_DEPTH_BUFFER_CREATION_ERROR = 0xF0000800,
// CPUT_ERROR_DEPTH_STENCIL_BUFFER_CREATION_ERROR = CPUT_ERROR_DEPTH_BUFFER_CREATION_ERROR+1,
// CPUT_ERROR_RASTER_STATE_CREATION_ERROR = CPUT_ERROR_DEPTH_BUFFER_CREATION_ERROR+2,
//
// // GUI shaders
CPUT_ERROR_INITIALIZATION_GUI_VERTEX_SHADER_NOT_FOUND = 0xF0000130,
CPUT_ERROR_INITIALIZATION_GUI_PIXEL_SHADER_NOT_FOUND = CPUT_ERROR_INITIALIZATION_GUI_VERTEX_SHADER_NOT_FOUND+1,
CPUT_ERROR_INITIALIZATION_GUI_CONTROL_TEXTURES_NOT_FOUND = CPUT_ERROR_INITIALIZATION_GUI_VERTEX_SHADER_NOT_FOUND+2,
//
// // gfx system errors
// CPUT_ERROR_GFX_SUBSYSTEM_BUSY = 0xF0000B00,
// CPUT_ERROR_GFX_SUBSYSTEM_TO_MANY_OBJECTS = CPUT_ERROR_GFX_SUBSYSTEM_BUSY+1,
//
// // window layer errors
CPUT_ERROR_WINDOW_CANNOT_REGISTER_APP = 0xF0000D00,
CPUT_ERROR_WINDOW_ALREADY_EXISTS = CPUT_ERROR_WINDOW_CANNOT_REGISTER_APP+1,
// CPUT_ERROR_CANNOT_GET_WINDOW_CLASS = CPUT_ERROR_WINDOW_CANNOT_REGISTER_APP+3,
CPUT_ERROR_CANNOT_GET_WINDOW_INSTANCE = CPUT_ERROR_WINDOW_CANNOT_REGISTER_APP+4,
// CPUT_ERROR_WINDOW_OS_PROPERTY_GET_ERROR = CPUT_ERROR_WINDOW_CANNOT_REGISTER_APP+5,
//
// // AssetLibrary/AssetSet errors
CPUT_ERROR_ASSET_LIBRARY_INVALID_LIBRARY = 0xF0000E00,
// CPUT_ERROR_ASSET_SET_INVALID_TYPE = CPUT_ERROR_ASSET_LIBRARY_INVALID_LIBRARY+1,
// CPUT_ERROR_ASSET_LIBRARY_OBJECT_NOT_FOUND,
// CPUT_ERROR_ASSET_ALREADY_EXISTS = CPUT_ERROR_ASSET_LIBRARY_INVALID_LIBRARY+3,
//
// // Paramter block errors.
CPUT_ERROR_PARAMETER_BLOCK_NOT_FOUND = 0xF0000F00,
//
// // misc errors
// CPUT_ERROR_FULLSCREEN_SWITCH_ERROR = 0xF0000F00,
} CPUTResult;
static int gRefCount = 0;
//handy defines
//-----------------------------------------------------------------------------
#define SAFE_RELEASE(p) {if((p)){HEAPCHECK; gRefCount = (p)->Release(); (p)=NULL; HEAPCHECK;} }
#define SAFE_DELETE(p) {if((p)){HEAPCHECK; delete (p); (p)=NULL;HEAPCHECK; }}
#define SAFE_DELETE_ARRAY(p){if((p)){HEAPCHECK; delete[](p); (p)=NULL;HEAPCHECK; }}
#define UNREFERENCED_PARAMETER(P) (P)
// CPUT data types
//-----------------------------------------------------------------------------
#define CPUTSUCCESS(returnCode) ((returnCode) < 0xF0000000)
#define CPUTFAILED(returnCode) ((returnCode) >= 0xF0000000)
//typedef UINT CPUTResult;
typedef unsigned int UINT;
typedef unsigned long DWORD;
// color
struct CPUTColor4
{
float r;
float g;
float b;
float a;
bool operator == (const CPUTColor4& rhs) const
{
return((rhs.r == r) &&
(rhs.g == g) &&
(rhs.b == b) &&
(rhs.a == a));
}
bool operator != (const CPUTColor4& rhs) const
{
return((rhs.r != r) ||
(rhs.g != g) ||
(rhs.b != b) ||
(rhs.a != a));
}
};
// where the loader should start looking from to locate files
enum CPUT_PATH_SEARCH_MODE
{
CPUT_PATH_SEARCH_RESOURCE_DIRECTORY,
CPUT_PATH_SEARCH_NONE,
};
// string size limitations
const UINT CPUT_MAX_PATH = 2048;
const UINT CPUT_MAX_STRING_LENGTH = 1024;
const UINT CPUT_MAX_SHADER_ERROR_STRING_LENGTH = 8192;
const UINT CPUT_MAX_DIGIT_STRING_LENGTH = 5;
// Data format types used in interpreting mesh data
enum CPUT_DATA_FORMAT_TYPE
{
CPUT_UNKNOWN=0,
CPUT_DOUBLE=1,
CPUT_F32=2,
CPUT_U64=3,
CPUT_I64=4,
CPUT_U32=5,
CPUT_I32=6,
CPUT_U16=7,
CPUT_I16=8,
CPUT_U8=9,
CPUT_I8=10,
CPUT_CHAR=11,
CPUT_BOOL=12,
};
// Corresponding sizes (in bytes) that match CPUT_DATA_FORMAT_TYPE
const int CPUT_DATA_FORMAT_SIZE[] =
{
0, //CPUT_UNKNOWN=0,
8, //CPUT_DOUBLE,
4, //CPUT_F32,
8, //CPUT_U64,
8, //CPUT_I64,
4, //CPUT_U32,
4, //CPUT_I32,
2, //CPUT_U16,
2, //CPUT_I16,
1, //CPUT_U8,
1, //CPUT_I8,
1, //CPUT_CHAR
1, //CPUT_BOOL
};
//-----------------------------------------------------------------------------
enum eCPUTMapType
{
CPUT_MAP_UNDEFINED = 0,
CPUT_MAP_READ = 1,
CPUT_MAP_WRITE = 2,
CPUT_MAP_READ_WRITE = 3,
CPUT_MAP_WRITE_DISCARD = 4,
CPUT_MAP_NO_OVERWRITE = 5
};
// routines to support unicode + multibyte
// TODO: Move to string file
//-----------------------------------------------------------------------------
#if defined (UNICODE) || defined(_UNICODE)
// define string and literal types
#define cString std::wstring
#define cStringStream std::wstringstream
#define cFile std::wfstream
#define _L(x) L##x
// convert integer to wide/unicode ascii
//-----------------------------------------------------------------------------
inline std::wstring itoc(const int integer)
{
wchar_t wcstring[CPUT_MAX_STRING_LENGTH];
swprintf_s(&wcstring[0], CPUT_MAX_STRING_LENGTH, _L("%d"),integer);
std::wstring ws(wcstring);
return ws;
}
// convert pointer to wide/unicode ascii
//-----------------------------------------------------------------------------
inline std::wstring ptoc(const void *pPointer)
{
std::wstringstream wstream;
//std::ostringstream os;
wstream << pPointer;
std::wstring address;
address = wstream.str();
return address;
}
// convert char* to wide/unicode string
//-----------------------------------------------------------------------------
inline std::wstring s2ws(const char* stringArg)
{
// compute the size of the buffer I need to allocate
size_t numConvertedChars;
mbstowcs_s(&numConvertedChars, NULL, 0, stringArg, _TRUNCATE);
numConvertedChars++; // +1 for null termination
if(numConvertedChars>CPUT_MAX_STRING_LENGTH)
{
numConvertedChars = CPUT_MAX_STRING_LENGTH;
}
// allocate the converted string and copy
wchar_t *pWString = new wchar_t[numConvertedChars];
mbstowcs_s(&numConvertedChars, pWString, numConvertedChars, stringArg, _TRUNCATE);
std::wstring ws(pWString);
delete [] pWString;
return ws;
/*
// alternate method - less 'safe', but possibly useful for unix
std::string s = stringArg;
std::wstring ws(s.begin(), s.end());
ws.assign(s.begin(), s.end());
return ws;
*/
}
// convert wide/unicode string to char
//-----------------------------------------------------------------------------
inline char* ws2s(std::wstring string)
{
size_t numConverted, finalCount;
// what size of buffer (in bytes) do we need to allocate for conversion?
wcstombs_s(&numConverted, NULL, 0, string.c_str(), CPUT_MAX_STRING_LENGTH);
numConverted+=2; // for null termination
char *pBuffer = new char[numConverted];
// do the actual conversion
wcstombs_s(&finalCount, pBuffer, numConverted, string.c_str(), CPUT_MAX_STRING_LENGTH);
return pBuffer;
}
#else
// define string and literal types
#define cString std::string
#define cStringStream std::stringstream
#define cFile std::fstream
#define _L(x) x
// conversion routine
//-----------------------------------------------------------------------------
inline std::string s2ws(const char* stringArg) { return std::string(stringArg); }
// convert integer to char string
//-----------------------------------------------------------------------------
inline std::string itoc(const int integer)
{
char string[CPUT_MAX_STRING_LENGTH];
sprintf_s(string, CPUT_MAX_STRING_LENGTH, "%d",integer);
std::string s(string);
return s;
}
// convert pointer to wide/unicode ascii
//-----------------------------------------------------------------------------
inline std::string ptoc(const void *pPointer)
{
std::ostringstream stream;
stream << pPointer;
std::string address;
address = stream.str();
return address;
}
// conversion from ws2s
// Doesn't do anything in multibyte version since string is already a char*
//-----------------------------------------------------------------------------
inline char* ws2s(const char* string)
{
return const_cast<char*>(string);
}
#endif
#ifdef CPUT_FOR_DX11
#include "CPUTRenderTarget.h"
#else
#error You must supply a target graphics API (ex: #define CPUT_FOR_DX11), or implement the target API for this file.
#endif
class CPUTCamera;
class CPUTRenderStateBlock;
// CPUT class
//-----------------------------------------------------------------------------
class CPUT:public CPUTEventHandler, public CPUTCallbackHandler
{
protected:
CPUTCamera *mpCamera;
CPUTCamera *mpShadowCamera;
CPUTTimer *mpTimer;
float3 mLightColor; // TODO: Get from light(s)
float3 mAmbientColor;
CPUTBuffer *mpBackBuffer;
CPUTBuffer *mpDepthBuffer;
CPUTTexture *mpBackBufferTexture;
CPUTTexture *mpDepthBufferTexture;
public:
CPUT() :
mpCamera(NULL),
mpShadowCamera(NULL),
mAmbientColor(0.2f, 0.2f, 0.2f),
mLightColor(1.0f, 1.0f, 1.0f),
mpBackBuffer(NULL),
mpDepthBuffer(NULL),
mpBackBufferTexture(NULL),
mpDepthBufferTexture(NULL)
{}
virtual ~CPUT() {}
CPUTCamera *GetCamera() { return mpCamera; }
CPUTCamera *GetShadowCamera() { return mpShadowCamera; } // TODO: Support more than one.
virtual void InnerExecutionLoop() {;}
virtual void ResizeWindowSoft(UINT width, UINT height) {UNREFERENCED_PARAMETER(width);UNREFERENCED_PARAMETER(height);}
virtual void ResizeWindow(UINT width, UINT height) {
CPUTRenderTargetColor::SetActiveWidthHeight( width, height );
CPUTRenderTargetDepth::SetActiveWidthHeight( width, height );
}
virtual void DeviceShutdown(){}
virtual CPUTEventHandledCode CPUTHandleKeyboardEvent(CPUTKey key) {UNREFERENCED_PARAMETER(key);return CPUT_EVENT_UNHANDLED;}
virtual CPUTEventHandledCode CPUTHandleMouseEvent(int x, int y, int wheel, CPUTMouseState state) {UNREFERENCED_PARAMETER(x);UNREFERENCED_PARAMETER(y);UNREFERENCED_PARAMETER(wheel);UNREFERENCED_PARAMETER(state);return CPUT_EVENT_UNHANDLED;}
float3 &GetAmbientColor() { return mAmbientColor; }
void SetAmbientColor( float3 &ambientColor ) { mAmbientColor = ambientColor; }
float3 &GetLightColor() { return mLightColor; }
void SetLightColor( float3 &lightColor ) { mLightColor = lightColor; }
};
// Include this here to make sure ASSERT resolves correctly
#include "CPUTOSServicesWin.h"
void CPUTSetDebugName( void *pResource, cString name );
#endif // #ifndef __CPUTBASE_H__
================================================
FILE: CPUT/CPUT/CPUTAssetLibrary.cpp
================================================
////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
////////////////////////////////////////////////////////////////////////////////
#include <algorithm> // for std::string.transform()
#include "CPUTAssetLibrary.h"
#include "CPUTRenderNode.h"
#include "CPUTAssetSet.h"
#include "CPUTMaterial.h"
#include "CPUTRenderStateBlock.h"
#include "CPUTModel.h"
#include "CPUTCamera.h"
#include "CPUTLight.h"
#include "CPUTFont.h"
#include "CPUTBuffer.h"
// TODO: How do we want to store both DX and OGL assets in the same library?
// Could use API-specific libraries. Could move both platforms to single file. etc.
// CPUTAssetLibrary *CPUTAssetLibrary::mpAssetLibrary = new CPUTAssetLibraryDX11();
CPUTAssetListEntry *CPUTAssetLibrary::mpAssetSetList = NULL;
CPUTAssetListEntry *CPUTAssetLibrary::mpNullNodeList = NULL;
CPUTAssetListEntry *CPUTAssetLibrary::mpModelList = NULL;
CPUTAssetListEntry *CPUTAssetLibrary::mpCameraList = NULL;
CPUTAssetListEntry *CPUTAssetLibrary::mpLightList = NULL;
CPUTAssetListEntry *CPUTAssetLibrary::mpMaterialList = NULL;
CPUTAssetListEntry *CPUTAssetLibrary::mpTextureList = NULL;
CPUTAssetListEntry *CPUTAssetLibrary::mpBufferList = NULL;
CPUTAssetListEntry *CPUTAssetLibrary::mpConstantBufferList = NULL;
CPUTAssetListEntry *CPUTAssetLibrary::mpRenderStateBlockList = NULL;
CPUTAssetListEntry *CPUTAssetLibrary::mpFontList = NULL;
//-----------------------------------------------------------------------------
void CPUTAssetLibrary::ReleaseTexturesAndBuffers()
{
CPUTAssetListEntry *pMaterial = mpMaterialList;
while( pMaterial )
{
((CPUTMaterial*)pMaterial->pData)->ReleaseTexturesAndBuffers();
pMaterial = pMaterial->pNext;
}
}
//-----------------------------------------------------------------------------
void CPUTAssetLibrary::RebindTexturesAndBuffers()
{
CPUTAssetListEntry *pMaterial = mpMaterialList;
while( pMaterial )
{
((CPUTMaterial*)pMaterial->pData)->RebindTexturesAndBuffers();
pMaterial = pMaterial->pNext;
}
}
//-----------------------------------------------------------------------------
void CPUTAssetLibrary::DeleteAssetLibrary()
{
SAFE_DELETE(mpAssetLibrary);
}
//-----------------------------------------------------------------------------
void CPUTAssetLibrary::ReleaseAllLibraryLists()
{
// Release philosophy: Everyone that references releases. If node refers to parent, then it should release parent, etc...
// TODO: Traverse lists. Print names and ref counts (as debug aid)
#undef SAFE_RELEASE_LIST
#define SAFE_RELEASE_LIST(x) {ReleaseList(x); x = NULL;}
SAFE_RELEASE_LIST(mpAssetSetList);
SAFE_RELEASE_LIST(mpMaterialList);
SAFE_RELEASE_LIST(mpModelList);
SAFE_RELEASE_LIST(mpLightList);
SAFE_RELEASE_LIST(mpCameraList);
SAFE_RELEASE_LIST(mpNullNodeList);
SAFE_RELEASE_LIST(mpTextureList );
SAFE_RELEASE_LIST(mpBufferList );
SAFE_RELEASE_LIST(mpConstantBufferList );
SAFE_RELEASE_LIST(mpRenderStateBlockList );
SAFE_RELEASE_LIST(mpFontList);
// The following -specific items are destroyed in the derived class
// TODO. Move their declaration and definition to the derived class too
// SAFE_RELEASE_LIST(mpPixelShaderList);
// SAFE_RELEASE_LIST(mpVertexShaderList);
// SAFE_RELEASE_LIST(mpGeometryShaderList);
}
//-----------------------------------------------------------------------------
void CPUTAssetLibrary::ReleaseList(CPUTAssetListEntry *pLibraryRoot)
{
CPUTAssetListEntry *pNext;
for( CPUTAssetListEntry *pNodeEntry = pLibraryRoot; NULL != pNodeEntry; pNodeEntry = pNext )
{
pNext = pNodeEntry->pNext;
CPUTRefCount *pRefCountedNode = (CPUTRefCount*)pNodeEntry->pData;
pRefCountedNode->Release();
HEAPCHECK;
delete pNodeEntry;
}
}
// Find an asset in a specific library
// ** Does not Addref() returned items **
// Asset library doesn't care if we're using absolute paths for names or not, it
// just adds/finds/deletes the matching string literal.
//-----------------------------------------------------------------------------
void *CPUTAssetLibrary::FindAsset(const cString &name, CPUTAssetListEntry *pList, bool nameIsFullPathAndFilename)
{
cString absolutePathAndFilename;
CPUTOSServices *pServices = CPUTOSServices::GetOSServices();
pServices->ResolveAbsolutePathAndFilename( nameIsFullPathAndFilename ? name : (mAssetSetDirectoryName + name), &absolutePathAndFilename);
absolutePathAndFilename = nameIsFullPathAndFilename ? name : absolutePathAndFilename;
UINT hash = CPUTComputeHash( absolutePathAndFilename );
while(NULL!=pList)
{
if( hash == pList->hash && (0 == _wcsicmp( absolutePathAndFilename.data(), pList->name.data() )) )
{
return (void*)pList->pData;
}
pList = pList->pNext;
}
return NULL;
}
//-----------------------------------------------------------------------------
void CPUTAssetLibrary::AddAsset(const cString &name, void *pAsset, CPUTAssetListEntry **pHead)
{
// convert string to lowercase
cString lowercaseName = name;
std::transform(lowercaseName.begin(), lowercaseName.end(), lowercaseName.begin(), ::tolower);
// Do we already have one by this name?
CPUTAssetListEntry *pTail = *pHead;
// TODO: Save explicit tail pointer instead of iterating to find the null.
for( CPUTAssetListEntry *pCur=*pHead; NULL!=pCur; pCur=pCur->pNext )
{
// Assert that we haven't added one with this name
ASSERT( 0 != _wcsicmp( pCur->name.data(), name.data() ), _L("Warning: asset ")+name+_L(" already exists") );
pTail = pCur;
}
CPUTAssetListEntry **pDest = pTail ? &pTail->pNext : pHead;
*pDest = new CPUTAssetListEntry();
(*pDest)->hash = CPUTComputeHash(name);
(*pDest)->name = name;
(*pDest)->pData = pAsset;
(*pDest)->pNext = NULL;
// TODO: Our assets are not yet all derived from CPUTRenderNode.
// TODO: For now, rely on caller performing the AddRef() as it knows the assets type.
((CPUTRefCount*)pAsset)->AddRef();
}
//-----------------------------------------------------------------------------
CPUTRenderStateBlock *CPUTAssetLibrary::GetRenderStateBlock(const cString &name, bool nameIsFullPathAndFilename )
{
// Resolve name to absolute path before searching
cString finalName;
if( name.at(0) == '$' )
{
finalName = name;
} else
{
// Resolve name to absolute path
CPUTOSServices *pServices = CPUTOSServices::GetOSServices();
pServices->ResolveAbsolutePathAndFilename( nameIsFullPathAndFilename? name : (mShaderDirectoryName + name), &finalName);
}
// see if the render state block is already in the library
CPUTRenderStateBlock *pRenderStateBlock = FindRenderStateBlock(finalName, true);
if(NULL==pRenderStateBlock)
{
return CPUTRenderStateBlock::CreateRenderStateBlock( name, finalName );
}
pRenderStateBlock->AddRef();
return pRenderStateBlock;
}
//-----------------------------------------------------------------------------
CPUTAssetSet *CPUTAssetLibrary::GetAssetSet( const cString &name, bool nameIsFullPathAndFilename )
{
// Resolve the absolute path
cString absolutePathAndFilename;
CPUTOSServices *pServices = CPUTOSServices::GetOSServices();
pServices->ResolveAbsolutePathAndFilename( nameIsFullPathAndFilename ? name
: (mAssetSetDirectoryName + name + _L(".set")), &absolutePathAndFilename );
absolutePathAndFilename = nameIsFullPathAndFilename ? name : absolutePathAndFilename;
CPUTAssetSet *pAssetSet = FindAssetSet(absolutePathAndFilename, true);
if(NULL == pAssetSet)
{
return CPUTAssetSet::CreateAssetSet( name, absolutePathAndFilename );
}
pAssetSet->AddRef();
return pAssetSet;
}
// TODO: All of these Get() functions look very similar.
// Keep them all for their interface, but have them call a common function
//-----------------------------------------------------------------------------
CPUTMaterial *CPUTAssetLibrary::GetMaterial(const cString &name, bool nameIsFullPathAndFilename, const cString &modelSuffix, const cString &meshSuffix)
{
// Resolve name to absolute path before searching
CPUTOSServices *pServices = CPUTOSServices::GetOSServices();
cString absolutePathAndFilename;
pServices->ResolveAbsolutePathAndFilename( nameIsFullPathAndFilename? name : (mMaterialDirectoryName + name + _L(".mtl")), &absolutePathAndFilename);
// If we already have one by this name, then return it
CPUTMaterial *pMaterial = FindMaterial(absolutePathAndFilename, true);
if(NULL==pMaterial)
{
// We don't already have it in the library, so create it.
pMaterial = CPUTMaterial::CreateMaterial( absolutePathAndFilename, modelSuffix, meshSuffix );
return pMaterial;
}
else if( (0==modelSuffix.length()) && !pMaterial->MaterialRequiresPerModelPayload() )
{
// This material doesn't have per-model elements, so we don't need to clone it.
pMaterial->AddRef();
return pMaterial;
}
#ifdef _DEBUG
// We need to clone the material. Do that by loading it again, but with a different name.
// Add the model's suffix (address as string, plus model's material array index as string)
CPUTMaterial *pUniqueMaterial = FindMaterial(absolutePathAndFilename + modelSuffix + meshSuffix, true);
ASSERT( NULL == pUniqueMaterial, _L("Unique material already not unique: ") + absolutePathAndFilename + modelSuffix + meshSuffix );
#endif
CPUTMaterial *pClonedMaterial = pMaterial->CloneMaterial( absolutePathAndFilename, modelSuffix, meshSuffix );
AddMaterial( absolutePathAndFilename + modelSuffix + meshSuffix, pClonedMaterial );
return pClonedMaterial;
}
// Get CPUTModel from asset library
// If the model exists, then the existing model is Addref'ed and returned
//-----------------------------------------------------------------------------
CPUTModel *CPUTAssetLibrary::GetModel(const cString &name, bool nameIsFullPathAndFilename)
{
// Resolve name to absolute path before searching
cString absolutePathAndFilename;
CPUTOSServices *pServices = CPUTOSServices::GetOSServices();
pServices->ResolveAbsolutePathAndFilename( nameIsFullPathAndFilename? name : (mModelDirectoryName + name + _L(".mdl")), &absolutePathAndFilename);
absolutePathAndFilename = nameIsFullPathAndFilename ? name : absolutePathAndFilename;
// If we already have one by this name, then return it
CPUTModel *pModel = FindModel(absolutePathAndFilename, true);
if(NULL!=pModel)
{
pModel->AddRef();
return pModel;
}
// Looks like no one calls GetModel(). Or, they never call it for missing models.
#if TODO // delegate
// Model was not in the library, so create and load a new model
pModel = new CPUTModel();
pModel->LoadModelPayload(absolutePathAndFilename);
AddModel(name, pModel);
return CPUTModel::CreateMode( absolutePathAndFilename, aboslutePathAndFilename );
#endif
return pModel;
}
//-----------------------------------------------------------------------------
CPUTCamera *CPUTAssetLibrary::GetCamera(const cString &name)
{
// TODO: Should we prefix camera names with a path anyway? To keek them unique?
// If we already have one by this name, then return it
CPUTCamera *pCamera = FindCamera(name, true);
if(NULL!=pCamera)
{
pCamera->AddRef();
return pCamera;
}
return NULL;
}
//-----------------------------------------------------------------------------
CPUTLight *CPUTAssetLibrary::GetLight(const cString &name)
{
// If we already have one by this name, then return it
CPUTLight *pLight = FindLight(name, true);
if(NULL!=pLight)
{
pLight->AddRef();
return pLight;
}
return NULL;
}
//-----------------------------------------------------------------------------
CPUTTexture *CPUTAssetLibrary::GetTexture(const cString &name, bool nameIsFullPathAndFilename, bool loadAsSRGB )
{
cString finalName;
if( name.at(0) == '$' )
{
finalName = name;
} else
{
// Resolve name to absolute path
CPUTOSServices *pServices = CPUTOSServices::GetOSServices();
pServices->ResolveAbsolutePathAndFilename( nameIsFullPathAndFilename? name : (mTextureDirectoryName + name), &finalName);
}
// If we already have one by this name, then return it
CPUTTexture *pTexture = FindTexture(finalName, true);
if(NULL==pTexture)
{
return CPUTTexture::CreateTexture( name, finalName, loadAsSRGB);
}
pTexture->AddRef();
return pTexture;
}
//-----------------------------------------------------------------------------
CPUTBuffer *CPUTAssetLibrary::GetBuffer(const cString &name )
{
// If we already have one by this name, then return it
CPUTBuffer *pBuffer = FindBuffer(name, true);
ASSERT( pBuffer, _L("Can't find buffer ") + name );
pBuffer->AddRef();
return pBuffer;
}
//-----------------------------------------------------------------------------
CPUTBuffer *CPUTAssetLibrary::GetConstantBuffer(const cString &name )
{
// If we already have one by this name, then return it
CPUTBuffer *pBuffer = FindConstantBuffer(name, true);
ASSERT( pBuffer, _L("Can't find constant buffer ") + name );
pBuffer->AddRef();
return pBuffer;
}
//-----------------------------------------------------------------------------
CPUTFont *CPUTAssetLibrary::GetFont(const cString &name )
{
// Resolve name to absolute path
CPUTOSServices *pServices = CPUTOSServices::GetOSServices();
cString absolutePathAndFilename;
pServices->ResolveAbsolutePathAndFilename( (mFontDirectoryName + name), &absolutePathAndFilename);
// If we already have one by this name, then return it
CPUTFont *pFont = FindFont(absolutePathAndFilename, true);
if(NULL==pFont)
{
return CPUTFont::CreateFont( name, absolutePathAndFilename);
}
pFont->AddRef();
return pFont;
}
================================================
FILE: CPUT/CPUT/CPUTAssetLibrary.h
================================================
////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
////////////////////////////////////////////////////////////////////////////////
#ifndef __CPUTASSETLIBRARY_H__
#define __CPUTASSETLIBRARY_H__
#include "CPUT.h"
#include "CPUTOSServicesWin.h" // TODO: why is this windows-specific?
// Global Asset Library
//
// The purpose of this library is to keep a copy of all loaded assets and
// provide a one-stop-loading system. All assets that are loaded into the
// system via the Getxxx() operators stays in the library. Further Getxxx()
// operations on an already loaded object will addref and return the previously
// loaded object.
//-----------------------------------------------------------------------------
// node that holds a single library object
struct CPUTAssetListEntry
{
UINT hash;
cString name;
void *pData;
CPUTAssetListEntry *pNext;
};
#define SAFE_RELEASE_LIST(list) ReleaseList(list);(list)=NULL;
class CPUTAssetSet;
class CPUTNullNode;
class CPUTModel;
class CPUTMaterial;
class CPUTLight;
class CPUTCamera;
class CPUTTexture;
class CPUTBuffer;
class CPUTRenderStateBlock;
class CPUTFont;
class CPUTAssetLibrary
{
protected:
static CPUTAssetLibrary *mpAssetLibrary;
// simple linked lists for now, but if we want to optimize or load blocks
// we can change these to dynamically re-sizing arrays and then just do
// memcopies into the structs.
// Note: No camera, light, or NullNode directory names - they don't have payload files (i.e., they are defined completely in the .set file)
cString mAssetSetDirectoryName;
cString mModelDirectoryName;
cString mMaterialDirectoryName;
cString mTextureDirectoryName;
cString mShaderDirectoryName;
cString mFontDirectoryName;
public: // TODO: temporary for debug.
// TODO: Make these lists static. Share assets (e.g., texture) across all requests for this process.
static CPUTAssetListEntry *mpAssetSetList;
static CPUTAssetListEntry *mpNullNodeList;
static CPUTAssetListEntry *mpModelList;
static CPUTAssetListEntry *mpCameraList;
static CPUTAssetListEntry *mpLightList;
static CPUTAssetListEntry *mpMaterialList;
static CPUTAssetListEntry *mpTextureList;
static CPUTAssetListEntry *mpBufferList;
static CPUTAssetListEntry *mpConstantBufferList;
static CPUTAssetListEntry *mpRenderStateBlockList;
static CPUTAssetListEntry *mpFontList;
static void RebindTexturesAndBuffers();
static void ReleaseTexturesAndBuffers();
public:
static CPUTAssetLibrary *GetAssetLibrary(){ return mpAssetLibrary; }
static void DeleteAssetLibrary();
CPUTAssetLibrary() {}
virtual ~CPUTAssetLibrary() {}
// Add/get/delete items to specified library
void *FindAsset(const cString &name, CPUTAssetListEntry *pList, bool nameIsFullPathAndFilename=false);
virtual void ReleaseAllLibraryLists();
void SetMediaDirectoryName( const cString &directoryName)
{
mAssetSetDirectoryName = directoryName + _L("Asset\\");
mModelDirectoryName = directoryName + _L("Asset\\");
mMaterialDirectoryName = directoryName + _L("Material\\");
mTextureDirectoryName = directoryName + _L("Texture\\");
mShaderDirectoryName = directoryName + _L("Shader\\");
// mFontStateBlockDirectoryName = directoryName + _L("Font\\");
}
void SetAssetSetDirectoryName( const cString &directoryName) { mAssetSetDirectoryName = directoryName; }
void SetModelDirectoryName( const cString &directoryName) { mModelDirectoryName = directoryName; }
void SetMaterialDirectoryName( const cString &directoryName) { mMaterialDirectoryName = directoryName; }
void SetTextureDirectoryName( const cString &directoryName) { mTextureDirectoryName = directoryName; }
void SetShaderDirectoryName( const cString &directoryName) { mShaderDirectoryName = directoryName; }
void SetFontDirectoryName( const cString &directoryName) { mFontDirectoryName = directoryName; }
void SetAllAssetDirectoryNames( const cString &directoryName) {
mAssetSetDirectoryName = directoryName;
mModelDirectoryName = directoryName;
mMaterialDirectoryName = directoryName;
mTextureDirectoryName = directoryName;
mShaderDirectoryName = directoryName;
mFontDirectoryName = directoryName;
};
cString &GetAssetSetDirectoryName() { return mAssetSetDirectoryName; }
cString &GetModelDirectory() { return mModelDirectoryName; }
cString &GetMaterialDirectory() { return mMaterialDirectoryName; }
cString &GetTextureDirectory() { return mTextureDirectoryName; }
cString &GetShaderDirectory() { return mShaderDirectoryName; }
cString &GetFontDirectory() { return mFontDirectoryName; }
void AddAssetSet( const cString &name, CPUTAssetSet *pAssetSet) { AddAsset( name, pAssetSet, &mpAssetSetList ); }
void AddNullNode( const cString &name, CPUTNullNode *pNullNode) { AddAsset( name, pNullNode, &mpNullNodeList ); }
void AddModel( const cString &name, CPUTModel *pModel) { AddAsset( name, pModel, &mpModelList ); }
void AddMaterial( const cString &name, CPUTMaterial *pMaterial) { AddAsset( name, pMaterial, &mpMaterialList ); }
void AddLight( const cString &name, CPUTLight *pLight) { AddAsset( name, pLight, &mpLightList ); }
void AddCamera( const cString &name, CPUTCamera *pCamera) { AddAsset( name, pCamera, &mpCameraList ); }
void AddTexture( const cString &name, CPUTTexture *pTexture) { AddAsset( name, pTexture, &mpTextureList ); }
void AddBuffer( const cString &name, CPUTBuffer *pBuffer) { AddAsset( name, pBuffer, &mpBufferList ); }
void AddConstantBuffer( const cString &name, CPUTBuffer *pBuffer) { AddAsset( name, pBuffer, &mpConstantBufferList ); }
void AddRenderStateBlock(const cString &name, CPUTRenderStateBlock *pRenderStateBlock){ AddAsset( name, pRenderStateBlock, &mpRenderStateBlockList ); }
void AddFont( const cString &name, CPUTFont *pFont) { AddAsset( name, pFont, &mpFontList ); }
CPUTAssetSet *FindAssetSet(const cString &name, bool nameIsFullPathAndFilename=false) { return (CPUTAssetSet*)FindAsset( name, mpAssetSetList, nameIsFullPathAndFilename ); }
CPUTNullNode *FindNullNode(const cString &name, bool nameIsFullPathAndFilename=false) { return (CPUTNullNode*)FindAsset( name, mpNullNodeList, nameIsFullPathAndFilename ); }
CPUTModel *FindModel(const cString &name, bool nameIsFullPathAndFilename=false) { return (CPUTModel*)FindAsset( name, mpModelList, nameIsFullPathAndFilename ); }
CPUTMaterial *FindMaterial(const cString &name, bool nameIsFullPathAndFilename=false) { return (CPUTMaterial*)FindAsset( name, mpMaterialList, nameIsFullPathAndFilename ); }
CPUTLight *FindLight(const cString &name, bool nameIsFullPathAndFilename=false) { return (CPUTLight*)FindAsset( name, mpLightList, nameIsFullPathAndFilename ); }
CPUTCamera *FindCamera(const cString &name, bool nameIsFullPathAndFilename=false) { return (CPUTCamera*)FindAsset( name, mpCameraList, nameIsFullPathAndFilename ); }
CPUTTexture *FindTexture(const cString &name, bool nameIsFullPathAndFilename=false) { return (CPUTTexture*)FindAsset( name, mpTextureList, nameIsFullPathAndFilename ); }
CPUTBuffer *FindBuffer(const cString &name, bool nameIsFullPathAndFilename=false) { return (CPUTBuffer*)FindAsset( name, mpBufferList, nameIsFullPathAndFilename ); }
CPUTBuffer *FindConstantBuffer(const cString &name, bool nameIsFullPathAndFilename=false) { return (CPUTBuffer*)FindAsset( name, mpConstantBufferList, nameIsFullPathAndFilename ); }
CPUTRenderStateBlock *FindRenderStateBlock(const cString &name, bool nameIsFullPathAndFilename=false ) { return (CPUTRenderStateBlock*)FindAsset( name, mpRenderStateBlockList, nameIsFullPathAndFilename ); }
CPUTFont *FindFont(const cString &name, bool nameIsFullPathAndFilename=false) { return (CPUTFont*)FindAsset( name, mpFontList, nameIsFullPathAndFilename ); }
// If the asset exists, these 'Get' methods will addref and return it. Otherwise,
// they will create it and return it.
CPUTAssetSet *GetAssetSet( const cString &name, bool nameIsFullPathAndFilename=false );
CPUTTexture *GetTexture( const cString &name, bool nameIsFullPathAndFilename=false, bool loadAsSRGB=true );
CPUTMaterial *GetMaterial( const cString &name, bool nameIsFullPathAndFilename=false, const cString &modelSuffix=_L(""), const cString &meshSuffix=_L("") );
CPUTModel *GetModel( const cString &name, bool nameIsFullPathAndFilename=false );
CPUTRenderStateBlock *GetRenderStateBlock(const cString &name, bool nameIsFullPathAndFilename=false);
CPUTBuffer *GetBuffer( const cString &name );
CPUTBuffer *GetConstantBuffer( const cString &name );
CPUTCamera *GetCamera( const cString &name );
CPUTLight *GetLight( const cString &name );
CPUTFont *GetFont( const cString &name );
protected:
// helper functions
void ReleaseList(CPUTAssetListEntry *pLibraryRoot);
void AddAsset( const cString &name, void *pAsset, CPUTAssetListEntry **pHead );
UINT CPUTComputeHash( const cString &string )
{
size_t length = string.length();
UINT hash = 0;
for( size_t ii=0; ii<length; ii++ )
{
hash += tolower(string[ii]);
}
return hash;
}
};
#endif //#ifndef __CPUTASSETLIBRARY_H__
================================================
FILE: CPUT/CPUT/CPUTAssetLibraryDX11.cpp
================================================
////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
////////////////////////////////////////////////////////////////////////////////
#include "D3dx9tex.h" // super-annoying - must be first or you get new() operator overloading errors during compile b/c of D3DXGetImageInfoFromFile() function
#include "CPUTAssetLibraryDX11.h"
// define the objects we'll need
#include "CPUTModelDX11.h"
#include "CPUTMaterialDX11.h"
#include "CPUTTextureDX11.h"
#include "CPUTRenderStateBlockDX11.h"
#include "CPUTLight.h"
#include "CPUTCamera.h"
#include "CPUTVertexShaderDX11.h"
#include "CPUTPixelShaderDX11.h"
#include "CPUTGeometryShaderDX11.h"
#include "CPUTComputeShaderDX11.h"
#include "CPUTHullShaderDX11.h"
#include "CPUTDomainShaderDX11.h"
// MPF: opengl es - yipe - can't do both at the same time - need to have it bind dynamically/via compile-time
CPUTAssetLibrary *CPUTAssetLibrary::mpAssetLibrary = new CPUTAssetLibraryDX11();
CPUTAssetListEntry *CPUTAssetLibraryDX11::mpPixelShaderList = NULL;
CPUTAssetListEntry *CPUTAssetLibraryDX11::mpComputeShaderList = NULL;
CPUTAssetListEntry *CPUTAssetLibraryDX11::mpVertexShaderList = NULL;
CPUTAssetListEntry *CPUTAssetLibraryDX11::mpGeometryShaderList = NULL;
CPUTAssetListEntry *CPUTAssetLibraryDX11::mpHullShaderList = NULL;
CPUTAssetListEntry *CPUTAssetLibraryDX11::mpDomainShaderList = NULL;
// TODO: Change OS Services to a flat list of CPUT* functions. Avoid calls all over the place like:
// CPUTOSServices::GetOSServices();
// Deletes and properly releases all asset library lists that contain
// unwrapped IUnknown DirectX objects.
//-----------------------------------------------------------------------------
void CPUTAssetLibraryDX11::ReleaseAllLibraryLists()
{
// TODO: we really need to wrap the DX assets so we don't need to distinguish their IUnknown type.
SAFE_RELEASE_LIST(mpPixelShaderList);
SAFE_RELEASE_LIST(mpComputeShaderList);
SAFE_RELEASE_LIST(mpVertexShaderList);
SAFE_RELEASE_LIST(mpGeometryShaderList);
SAFE_RELEASE_LIST(mpHullShaderList);
SAFE_RELEASE_LIST(mpDomainShaderList);
// Call base class implementation to clean up the non-DX object lists
return CPUTAssetLibrary::ReleaseAllLibraryLists();
}
// Erase the specified list, Release()-ing underlying objects
//-----------------------------------------------------------------------------
void CPUTAssetLibraryDX11::ReleaseIunknownList( CPUTAssetListEntry *pList )
{
CPUTAssetListEntry *pNode = pList;
CPUTAssetListEntry *pOldNode = NULL;
while( NULL!=pNode )
{
// release the object using the DirectX IUnknown interface
((IUnknown*)(pNode->pData))->Release();
pOldNode = pNode;
pNode = pNode->pNext;
delete pOldNode;
}
HEAPCHECK;
}
// Retrieve specified pixel shader
//-----------------------------------------------------------------------------
CPUTResult CPUTAssetLibraryDX11::GetPixelShader(
const cString &name,
ID3D11Device *pD3dDevice,
const cString &shaderMain,
const cString &shaderProfile,
CPUTPixelShaderDX11 **ppPixelShader,
bool nameIsFullPathAndFilename
)
{
CPUTResult result = CPUT_SUCCESS;
cString finalName;
if( name.at(0) == '$' )
{
finalName = name;
} else
{
// Resolve name to absolute path
CPUTOSServices *pServices = CPUTOSServices::GetOSServices();
pServices->ResolveAbsolutePathAndFilename( nameIsFullPathAndFilename? name : (mShaderDirectoryName + name), &finalName);
}
// see if the shader is already in the library
void *pShader = FindPixelShader(finalName + shaderMain + shaderProfile, true);
if(NULL!=pShader)
{
*ppPixelShader = (CPUTPixelShaderDX11*) pShader;
(*ppPixelShader)->AddRef();
return result;
}
*ppPixelShader = CPUTPixelShaderDX11::CreatePixelShader( finalName, pD3dDevice, shaderMain, shaderProfile );
return result;
}
// Retrieve specified pixel shader
//-----------------------------------------------------------------------------
CPUTResult CPUTAssetLibraryDX11::GetComputeShader(
const cString &name,
ID3D11Device *pD3dDevice,
const cString &shaderMain,
const cString &shaderProfile,
CPUTComputeShaderDX11 **ppComputeShader,
bool nameIsFullPathAndFilename
)
{
CPUTResult result = CPUT_SUCCESS;
cString finalName;
if( name.at(0) == '$' )
{
finalName = name;
} else
{
// Resolve name to absolute path
CPUTOSServices* pServices = CPUTOSServices::GetOSServices();
pServices->ResolveAbsolutePathAndFilename( nameIsFullPathAndFilename? name : (mShaderDirectoryName + name), &finalName);
}
// see if the shader is already in the library
void *pShader = FindComputeShader(finalName + shaderMain + shaderProfile, true);
if(NULL!=pShader)
{
*ppComputeShader = (CPUTComputeShaderDX11*) pShader;
(*ppComputeShader)->AddRef();
return result;
}
*ppComputeShader = CPUTComputeShaderDX11::CreateComputeShader( finalName, pD3dDevice, shaderMain, shaderProfile );
return result;
}
// Retrieve specified vertex shader
//-----------------------------------------------------------------------------
CPUTResult CPUTAssetLibraryDX11::GetVertexShader(
const cString &name,
ID3D11Device *pD3dDevice,
const cString &shaderMain,
const cString &shaderProfile,
CPUTVertexShaderDX11 **ppVertexShader,
bool nameIsFullPathAndFilename
)
{
CPUTResult result = CPUT_SUCCESS;
cString finalName;
if( name.at(0) == '$' )
{
finalName = name;
} else
{
// Resolve name to absolute path
CPUTOSServices *pServices = CPUTOSServices::GetOSServices();
pServices->ResolveAbsolutePathAndFilename( nameIsFullPathAndFilename? name : (mShaderDirectoryName + name), &finalName);
}
// see if the shader is already in the library
void *pShader = FindVertexShader(finalName + shaderMain + shaderProfile, true);
if(NULL!=pShader)
{
*ppVertexShader = (CPUTVertexShaderDX11*) pShader;
(*ppVertexShader)->AddRef();
return result;
}
*ppVertexShader = CPUTVertexShaderDX11::CreateVertexShader( finalName, pD3dDevice, shaderMain, shaderProfile );
return result;
}
// Retrieve specified geometry shader
//-----------------------------------------------------------------------------
CPUTResult CPUTAssetLibraryDX11::GetGeometryShader(
const cString &name,
ID3D11Device *pD3dDevice,
const cString &shaderMain,
const cString &shaderProfile,
CPUTGeometryShaderDX11 **ppGeometryShader,
bool nameIsFullPathAndFilename
)
{
CPUTResult result = CPUT_SUCCESS;
cString finalName;
if( name.at(0) == '$' )
{
finalName = name;
} else
{
// Resolve name to absolute path
CPUTOSServices *pServices = CPUTOSServices::GetOSServices();
pServices->ResolveAbsolutePathAndFilename( nameIsFullPathAndFilename? name : (mShaderDirectoryName + name), &finalName);
}
// see if the shader is already in the library
void *pShader = FindGeometryShader(finalName + shaderMain + shaderProfile, true);
if(NULL!=pShader)
{
*ppGeometryShader = (CPUTGeometryShaderDX11*) pShader;
(*ppGeometryShader)->AddRef();
return result;
}
*ppGeometryShader = CPUTGeometryShaderDX11::CreateGeometryShader( finalName, pD3dDevice, shaderMain, shaderProfile );
return result;
}
// Retrieve specified hull shader
//-----------------------------------------------------------------------------
CPUTResult CPUTAssetLibraryDX11::GetHullShader(
const cString &name,
ID3D11Device *pD3dDevice,
const cString &shaderMain,
const cString &shaderProfile,
CPUTHullShaderDX11 **ppHullShader,
bool nameIsFullPathAndFilename
)
{
CPUTResult result = CPUT_SUCCESS;
cString finalName;
if( name.at(0) == '$' )
{
finalName = name;
} else
{
// Resolve name to absolute path
CPUTOSServices *pServices = CPUTOSServices::GetOSServices();
pServices->ResolveAbsolutePathAndFilename( nameIsFullPathAndFilename? name : (mShaderDirectoryName + name), &finalName);
}
// see if the shader is already in the library
void *pShader = FindHullShader(finalName + shaderMain + shaderProfile, true);
if(NULL!=pShader)
{
*ppHullShader = (CPUTHullShaderDX11*) pShader;
(*ppHullShader)->AddRef();
return result;
}
*ppHullShader = CPUTHullShaderDX11::CreateHullShader( finalName, pD3dDevice, shaderMain, shaderProfile );
return result;
}
// Retrieve specified domain shader
//-----------------------------------------------------------------------------
CPUTResult CPUTAssetLibraryDX11::GetDomainShader(
const cString &name,
ID3D11Device *pD3dDevice,
const cString &shaderMain,
const cString &shaderProfile,
CPUTDomainShaderDX11 **ppDomainShader,
bool nameIsFullPathAndFilename
)
{
CPUTResult result = CPUT_SUCCESS;
cString finalName;
if( name.at(0) == '$' )
{
finalName = name;
} else
{
// Resolve name to absolute path
CPUTOSServices *pServices = CPUTOSServices::GetOSServices();
pServices->ResolveAbsolutePathAndFilename( nameIsFullPathAndFilename? name : (mShaderDirectoryName + name), &finalName);
}
// see if the shader is already in the library
void *pShader = FindDomainShader(finalName + shaderMain + shaderProfile, true);
if(NULL!=pShader)
{
*ppDomainShader = (CPUTDomainShaderDX11*) pShader;
(*ppDomainShader)->AddRef();
return result;
}
*ppDomainShader = CPUTDomainShaderDX11::CreateDomainShader( finalName, pD3dDevice, shaderMain, shaderProfile );
return result;
}
//-----------------------------------------------------------------------------
CPUTResult CPUTAssetLibraryDX11::CreatePixelShaderFromMemory(
const cString &name,
ID3D11Device *pD3dDevice,
const cString &shaderMain,
const cString &shaderProfile,
CPUTPixelShaderDX11 **ppShader,
char *pShaderSource
)
{
CPUTResult result = CPUT_SUCCESS;
void *pShader = FindPixelShader(name + shaderMain + shaderProfile, true);
ASSERT( NULL == pShader, _L("Shader already exists.") );
*ppShader = CPUTPixelShaderDX11::CreatePixelShaderFromMemory( name, pD3dDevice, shaderMain, shaderProfile, pShaderSource);
return result;
}
//-----------------------------------------------------------------------------
CPUTResult CPUTAssetLibraryDX11::CreateVertexShaderFromMemory(
const cString &name,
ID3D11Device *pD3dDevice,
const cString &shaderMain,
const cString &shaderProfile,
CPUTVertexShaderDX11 **ppShader,
char *pShaderSource
)
{
CPUTResult result = CPUT_SUCCESS;
void *pShader = FindPixelShader(name + shaderMain + shaderProfile, true);
ASSERT( NULL == pShader, _L("Shader already exists.") );
*ppShader = CPUTVertexShaderDX11::CreateVertexShaderFromMemory( name, pD3dDevice, shaderMain, shaderProfile, pShaderSource);
return result;
}
//-----------------------------------------------------------------------------
CPUTResult CPUTAssetLibraryDX11::CreateComputeShaderFromMemory(
const cString &name,
ID3D11Device *pD3dDevice,
const cString &shaderMain,
const cString &shaderProfile,
CPUTComputeShaderDX11 **ppShader,
char *pShaderSource
)
{
CPUTResult result = CPUT_SUCCESS;
void *pShader = FindPixelShader(name + shaderMain + shaderProfile, true);
ASSERT( NULL == pShader, _L("Shader already exists.") );
*ppShader = CPUTComputeShaderDX11::CreateComputeShaderFromMemory( name, pD3dDevice, shaderMain, shaderProfile, pShaderSource);
return result;
}
// Use DX11 compile from file method to do all the heavy lifting
//-----------------------------------------------------------------------------
CPUTResult CPUTAssetLibraryDX11::CompileShaderFromFile(
const cString &fileName,
const cString &shaderMain,
const cString &shaderProfile,
ID3DBlob **ppBlob
)
{
CPUTResult result = CPUT_SUCCESS;
char pShaderMainAsChar[128];
char pShaderProfileAsChar[128];
ASSERT( shaderMain.length() < 128, _L("Shader main name '") + shaderMain + _L("' longer than 128 chars.") );
ASSERT( shaderProfile.length() < 128, _L("Shader profile name '") + shaderProfile + _L("' longer than 128 chars.") );
size_t count;
wcstombs_s( &count, pShaderMainAsChar, shaderMain.c_str(), 128 );
wcstombs_s( &count, pShaderProfileAsChar, shaderProfile.c_str(), 128 );
// use DirectX to compile the shader file
ID3DBlob *pErrorBlob = NULL;
D3D10_SHADER_MACRO pShaderMacros[2] = { "_CPUT", "1", NULL, NULL };
HRESULT hr = D3DX11CompileFromFile(
fileName.c_str(), // fileName
pShaderMacros, // macro define's
NULL, // includes
pShaderMainAsChar, // main function name
pShaderProfileAsChar, // shader profile/feature level
0, // flags 1
0, // flags 2
NULL, // threaded load? (no for right now)
ppBlob, // blob data with compiled code
&pErrorBlob, // any compile errors stored here
NULL
);
ASSERT( SUCCEEDED(hr), _L("Error compiling shader '") + fileName + _L("'.\n") + (pErrorBlob ? s2ws((char*)pErrorBlob->GetBufferPointer()) : _L("no error message") ) );
if(pErrorBlob)
{
pErrorBlob->Release();
}
return result;
}
// Use DX11 compile from file method to do all the heavy lifting
//-----------------------------------------------------------------------------
CPUTResult CPUTAssetLibraryDX11::CompileShaderFromMemory(
const char *pShaderSource,
const cString &shaderMain,
const cString &shaderProfile,
ID3DBlob **ppBlob
)
{
CPUTResult result = CPUT_SUCCESS;
char pShaderMainAsChar[128];
char pShaderProfileAsChar[128];
ASSERT( shaderMain.length() < 128, _L("Shader main name '") + shaderMain + _L("' longer than 128 chars.") );
ASSERT( shaderProfile.length() < 128, _L("Shader profile name '") + shaderProfile + _L("' longer than 128 chars.") );
size_t count;
wcstombs_s( &count, pShaderMainAsChar, shaderMain.c_str(), 128 );
wcstombs_s( &count, pShaderProfileAsChar, shaderProfile.c_str(), 128 );
// use DirectX to compile the shader file
ID3DBlob *pErrorBlob = NULL;
D3D10_SHADER_MACRO pShaderMacros[2] = { "_CPUT", "1", NULL, NULL }; // TODO: Support passed-in, and defined in .mtl file. Perhaps under [Shader Defines], etc
char *pShaderMainAsChars = ws2s(shaderMain.c_str());
HRESULT hr = D3DX11CompileFromMemory(
pShaderSource, // shader as a string
strlen( pShaderSource ), //
pShaderMainAsChars, // Use entrypoint as file name
pShaderMacros, // macro define's
NULL, // includes
pShaderMainAsChar, // main function name
pShaderProfileAsChar, // shader profile/feature level
0, // flags 1
0, // flags 2
NULL, // threaded load? (no for right now)
ppBlob, // blob data with compiled code
&pErrorBlob, // any compile errors stored here
NULL
);
ASSERT( SUCCEEDED(hr), _L("Error compiling shader '") + shaderMain + _L("'.\n") + (pErrorBlob ? s2ws((char*)pErrorBlob->GetBufferPointer()) : _L("no error message") ) );
if(pErrorBlob)
{
pErrorBlob->Release();
}
delete pShaderMainAsChars;
return result;
}
================================================
FILE: CPUT/CPUT/CPUTAssetLibraryDX11.h
================================================
////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
////////////////////////////////////////////////////////////////////////////////
#ifndef __CPUTASSETLIBRARYDX11_H__
#define __CPUTASSETLIBRARYDX11_H__
#include "CPUTAssetLibrary.h"
#include "CPUTConfigBlock.h"
#include <d3d11.h>
#include <D3DX11tex.h> // for D3DX11_IMAGE_LOAD_INFO structs
class CPUTAssetSet;
class CPUTMaterial;
class CPUTModel;
class CPUTNullNode;
class CPUTCamera;
class CPUTRenderStateBlock;
class CPUTLight;
class CPUTTexture;
class CPUTVertexShaderDX11;
class CPUTPixelShaderDX11;
class CPUTComputeShaderDX11;
class CPUTGeometryShaderDX11;
class CPUTHullShaderDX11;
class CPUTDomainShaderDX11;
//-----------------------------------------------------------------------------
struct CPUTSRGBLoadFlags
{
bool bInterpretInputasSRGB;
bool bWritetoSRGBOutput;
};
//-----------------------------------------------------------------------------
class CPUTAssetLibraryDX11:public CPUTAssetLibrary
{
protected:
static CPUTAssetListEntry *mpPixelShaderList;
static CPUTAssetListEntry *mpComputeShaderList;
static CPUTAssetListEntry *mpVertexShaderList;
static CPUTAssetListEntry *mpGeometryShaderList;
static CPUTAssetListEntry *mpHullShaderList;
static CPUTAssetListEntry *mpDomainShaderList;
public:
CPUTAssetLibraryDX11(){}
virtual ~CPUTAssetLibraryDX11()
{
ReleaseAllLibraryLists();
}
virtual void ReleaseAllLibraryLists();
void ReleaseIunknownList( CPUTAssetListEntry *pList );
void AddPixelShader( const cString &name, CPUTPixelShaderDX11 *pShader) { AddAsset( name, pShader, &mpPixelShaderList ); }
void AddComputeShader( const cString &name, CPUTComputeShaderDX11 *pShader) { AddAsset( name, pShader, &mpComputeShaderList ); }
void AddVertexShader( const cString &name, CPUTVertexShaderDX11 *pShader) { AddAsset( name, pShader, &mpVertexShaderList ); }
void AddGeometryShader( const cString &name, CPUTGeometryShaderDX11 *pShader) { AddAsset( name, pShader, &mpGeometryShaderList ); }
void AddHullShader( const cString &name, CPUTHullShaderDX11 *pShader) { AddAsset( name, pShader, &mpHullShaderList ); }
void AddDomainShader( const cString &name, CPUTDomainShaderDX11 *pShader) { AddAsset( name, pShader, &mpDomainShaderList ); }
CPUTPixelShaderDX11 *FindPixelShader( const cString &name, bool nameIsFullPathAndFilename=false ) { return (CPUTPixelShaderDX11*)FindAsset( name, mpPixelShaderList, nameIsFullPathAndFilename ); }
CPUTComputeShaderDX11 *FindComputeShader( const cString &name, bool nameIsFullPathAndFilename=false ) { return (CPUTComputeShaderDX11*)FindAsset( name, mpComputeShaderList, nameIsFullPathAndFilename ); }
CPUTVertexShaderDX11 *FindVertexShader( const cString &name, bool nameIsFullPathAndFilename=false ) { return (CPUTVertexShaderDX11*)FindAsset( name, mpVertexShaderList, nameIsFullPathAndFilename ); }
CPUTGeometryShaderDX11 *FindGeometryShader( const cString &name, bool nameIsFullPathAndFilename=false ) { return (CPUTGeometryShaderDX11*)FindAsset( name, mpGeometryShaderList, nameIsFullPathAndFilename ); }
CPUTHullShaderDX11 *FindHullShader( const cString &name, bool nameIsFullPathAndFilename=false ) { return (CPUTHullShaderDX11*)FindAsset( name, mpHullShaderList, nameIsFullPathAndFilename ); }
CPUTDomainShaderDX11 *FindDomainShader( const cString &name, bool nameIsFullPathAndFilename=false ) { return (CPUTDomainShaderDX11*)FindAsset( name, mpDomainShaderList, nameIsFullPathAndFilename ); }
// shaders - vertex, pixel
CPUTResult GetPixelShader( const cString &name, ID3D11Device *pD3dDevice, const cString &shaderMain, const cString &shaderProfile, CPUTPixelShaderDX11 **ppShader, bool nameIsFullPathAndFilename=false);
CPUTResult GetComputeShader( const cString &name, ID3D11Device *pD3dDevice, const cString &shaderMain, const cString &shaderProfile, CPUTComputeShaderDX11 **ppShader, bool nameIsFullPathAndFilename=false);
CPUTResult GetVertexShader( const cString &name, ID3D11Device *pD3dDevice, const cString &shaderMain, const cString &shaderProfile, CPUTVertexShaderDX11 **ppShader, bool nameIsFullPathAndFilename=false);
CPUTResult GetGeometryShader( const cString &name, ID3D11Device *pD3dDevice, const cString &shaderMain, const cString &shaderProfile, CPUTGeometryShaderDX11 **ppShader, bool nameIsFullPathAndFilename=false);
CPUTResult GetHullShader( const cString &name, ID3D11Device *pD3dDevice, const cString &shaderMain, const cString &shaderProfile, CPUTHullShaderDX11 **ppShader, bool nameIsFullPathAndFilename=false);
CPUTResult GetDomainShader( const cString &name, ID3D11Device *pD3dDevice, const cString &shaderMain, const cString &shaderProfile, CPUTDomainShaderDX11 **ppShader, bool nameIsFullPathAndFilename=false);
// shaders - vertex, pixel
CPUTResult CreatePixelShaderFromMemory( const cString &name, ID3D11Device *pD3dDevice, const cString &shaderMain, const cString &shaderProfile, CPUTPixelShaderDX11 **ppShader, char *pShaderSource );
CPUTResult CreateComputeShaderFromMemory( const cString &name, ID3D11Device *pD3dDevice, const cString &shaderMain, const cString &shaderProfile, CPUTComputeShaderDX11 **ppShader, char *pShaderSource );
CPUTResult CreateVertexShaderFromMemory( const cString &name, ID3D11Device *pD3dDevice, const cString &shaderMain, const cString &shaderProfile, CPUTVertexShaderDX11 **ppShader, char *pShaderSource );
CPUTResult CreateGeometryShaderFromMemory( const cString &name, ID3D11Device *pD3dDevice, const cString &shaderMain, const cString &shaderProfile, CPUTGeometryShaderDX11 **ppShader, char *pShaderSource );
CPUTResult CreateHullShaderFromMemory( const cString &name, ID3D11Device *pD3dDevice, const cString &shaderMain, const cString &shaderProfile, CPUTHullShaderDX11 **ppShader, char *pShaderSource );
CPUTResult CreateDomainShaderFromMemory( const cString &name, ID3D11Device *pD3dDevice, const cString &shaderMain, const cString &shaderProfile, CPUTDomainShaderDX11 **ppShader, char *pShaderSource );
CPUTResult CompileShaderFromFile( const cString &fileName, const cString &shaderMain, const cString &shaderProfile, ID3DBlob **ppBlob);
CPUTResult CompileShaderFromMemory(const char *pShaderSource, const cString &shaderMain, const cString &shaderProfile, ID3DBlob **ppBlob);
};
#endif // #ifndef __CPUTASSETLIBRARYDX11_H__
================================================
FILE: CPUT/CPUT/CPUTAssetSet.cpp
================================================
////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
////////////////////////////////////////////////////////////////////////////////
#include "CPUTAssetSet.h"
#ifdef CPUT_FOR_DX11
#include "CPUTAssetLibraryDX11.h"
#else
#error You must supply a target graphics API (ex: #define CPUT_FOR_DX11), or implement the target API for this file.
#endif
//-----------------------------------------------------------------------------
CPUTAssetSet::CPUTAssetSet() :
mppAssetList(NULL),
mAssetCount(0),
mpRootNode(NULL),
mpFirstCamera(NULL),
mCameraCount(0)
{
}
//-----------------------------------------------------------------------------
CPUTAssetSet::~CPUTAssetSet()
{
SAFE_RELEASE(mpFirstCamera);
// Deleteing the asset set implies recursively releasing all the assets in the hierarchy
if(mpRootNode && !mpRootNode->ReleaseRecursive() )
{
mpRootNode = NULL;
}
}
//-----------------------------------------------------------------------------
void CPUTAssetSet::RenderRecursive(CPUTRenderParameters &renderParams )
{
if(mpRootNode)
{
mpRootNode->RenderRecursive(renderParams);
}
}
//-----------------------------------------------------------------------------
void CPUTAssetSet::RenderShadowRecursive(CPUTRenderParameters &renderParams )
{
if(mpRootNode)
{
mpRootNode->RenderShadowRecursive(renderParams);
}
}
//-----------------------------------------------------------------------------
void CPUTAssetSet::GetBoundingBox(float3 *pCenter, float3 *pHalf)
{
*pCenter = *pHalf = float3(0.0f);
if(mpRootNode)
{
mpRootNode->GetBoundingBoxRecursive(pCenter, pHalf);
}
}
//-----------------------------------------------------------------------------
CPUTResult CPUTAssetSet::GetAssetByIndex(const UINT index, CPUTRenderNode **ppRenderNode)
{
ASSERT( NULL != ppRenderNode, _L("Invalid NULL parameter") );
*ppRenderNode = mppAssetList[index];
mppAssetList[index]->AddRef();
return CPUT_SUCCESS;
}
// Note: We create an object of derived type here. What do we want to do when we also support OGL? Have DX and OGL specific Create functions?
#include "CPUTAssetSetDX11.h"
//-----------------------------------------------------------------------------
CPUTAssetSet *CPUTAssetSet::CreateAssetSet( const cString &name, const cString &absolutePathAndFilename )
{
// TODO: accept DX11/OGL param to control which platform we generate.
// TODO: be sure to support the case where we want to support only one of them
#ifdef CPUT_FOR_DX11
return CPUTAssetSetDX11::CreateAssetSet( name, absolutePathAndFilename );
#else
#error You must supply a target graphics API (ex: #define CPUT_FOR_DX11), or implement the target API for this file.
#endif
}
================================================
FILE: CPUT/CPUT/CPUTAssetSet.h
================================================
////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
////////////////////////////////////////////////////////////////////////////////
#ifndef __CPUTASSETSET_H__
#define __CPUTASSETSET_H__
#include "CPUTRefCount.h"
#include "CPUTNullNode.h"
#include "CPUTCamera.h"
class CPUTRenderNode;
class CPUTNullNode;
class CPUTRenderParameters;
// initial size and growth defines
class CPUTAssetSet : public CPUTRefCount
{
protected:
CPUTRenderNode **mppAssetList;
UINT mAssetCount;
CPUTNullNode *mpRootNode;
CPUTCamera *mpFirstCamera;
UINT mCameraCount;
~CPUTAssetSet(); // Destructor is not public. Must release instead of delete.
public:
static CPUTAssetSet *CreateAssetSet( const cString &name, const cString &absolutePathAndFilename );
CPUTAssetSet::CPUTAssetSet();
UINT GetAssetCount() { return mAssetCount; }
UINT GetCameraCount() { return mCameraCount; }
CPUTResult GetAssetByIndex(const UINT index, CPUTRenderNode **ppRenderNode);
CPUTRenderNode *GetRoot() { if(mpRootNode){mpRootNode->AddRef();} return mpRootNode; }
void SetRoot( CPUTNullNode *pRoot) { SAFE_RELEASE(mpRootNode); mpRootNode = pRoot; }
CPUTCamera *GetFirstCamera() { if(mpFirstCamera){mpFirstCamera->AddRef();} return mpFirstCamera; } // TODO: Consider supporting indexed access to each asset type
void RenderRecursive(CPUTRenderParameters &renderParams);
void RenderShadowRecursive(CPUTRenderParameters &renderParams);
void UpdateRecursive( float deltaSeconds );
virtual CPUTResult LoadAssetSet(cString name) = 0;
void GetBoundingBox(float3 *pCenter, float3 *pHalf);
};
#endif // #ifndef __CPUTASSETSET_H__
================================================
FILE: CPUT/CPUT/CPUTAssetSetDX11.cpp
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#include "CPUTAssetSetDX11.h"
#include "CPUTModelDX11.h"
#include "CPUTAssetLibraryDX11.h"
#include "CPUTCamera.h"
#include "CPUTLight.h"
//-----------------------------------------------------------------------------
CPUTAssetSetDX11::~CPUTAssetSetDX11()
{
// Release all the elements in the asset list. Note that we don't
// recursively delete the hierarchy here.
// We release the entries here because this class is where we add them.
// TODO: Howevere, all derivations will have this, so perhaps it should go in the base.
for( UINT ii=0; ii<mAssetCount; ii++ )
{
SAFE_RELEASE( mppAssetList[ii] );
}
SAFE_DELETE_ARRAY(mppAssetList);
}
//-----------------------------------------------------------------------------
CPUTResult CPUTAssetSetDX11::LoadAssetSet(cString name)
{
CPUTResult result = CPUT_SUCCESS;
// if not found, load the set file
CPUTConfigFile ConfigFile;
result = ConfigFile.LoadFile(name);
if( !CPUTSUCCESS(result) )
{
return result;
}
// ASSERT( CPUTSUCCESS(result), _L("Failed loading set file '") + name + _L("'.") );
mAssetCount = ConfigFile.BlockCount() + 1; // Add one for the implied root node
mppAssetList = new CPUTRenderNode*[mAssetCount];
mppAssetList[0] = mpRootNode;
mpRootNode->AddRef();
CPUTAssetLibraryDX11 *pAssetLibrary = (CPUTAssetLibraryDX11*)CPUTAssetLibrary::GetAssetLibrary();
for(UINT ii=0; ii<mAssetCount-1; ii++) // Note: -1 because we added one for the root node (we don't load it)
{
CPUTConfigBlock *pBlock = ConfigFile.GetBlock(ii);
ASSERT(pBlock != NULL, _L("Cannot find block"));
cString nodeType = pBlock->GetValueByName(_L("type"))->ValueAsString();
CPUTRenderNode *pParentNode = NULL;
// TODO: use Get*() instead of Load*() ?
cString name = pBlock->GetValueByName(_L("name"))->ValueAsString();
int parentIndex;
CPUTRenderNode *pNode = NULL;
if(0==nodeType.compare(_L("null")))
{
pNode = pNode = new CPUTNullNode();
result = ((CPUTNullNode*)pNode)->LoadNullNode(pBlock, &parentIndex);
pParentNode = mppAssetList[parentIndex+1];
cString &parentPrefix = pParentNode->GetPrefix();
pNode->SetPrefix( parentPrefix + _L(".") + name );
pAssetLibrary->AddNullNode(parentPrefix + name, (CPUTNullNode*)pNode);
// Add this null's name to our prefix
// Append this null's name to our parent's prefix
pNode->SetParent( pParentNode );
pParentNode->AddChild( pNode );
}
else if(0==nodeType.compare(_L("model")))
{
CPUTConfigEntry *pValue = pBlock->GetValueByName( _L("instance") );
CPUTModelDX11 *pModel = new CPUTModelDX11();
if( pValue == &CPUTConfigEntry::sNullConfigValue )
{
// Not found. So, not an instance.
pModel->LoadModel(pBlock, &parentIndex, NULL);
}
else
{
int instance = pValue->ValueAsInt();
pModel->LoadModel(pBlock, &parentIndex, (CPUTModel*)mppAssetList[instance+1]);
}
pParentNode = mppAssetList[parentIndex+1];
pModel->SetParent( pParentNode );
pParentNode->AddChild( pModel );
cString &parentPrefix = pParentNode->GetPrefix();
pModel->SetPrefix( parentPrefix );
pAssetLibrary->AddModel(parentPrefix + name, pModel);
pModel->UpdateBoundsWorldSpace();
#ifdef SUPPORT_DRAWING_BOUNDING_BOXES
// Create a mesh for rendering the bounding box
// TODO: There is definitely a better way to do this. But, want to see the bounding boxes!
pModel->CreateBoundingBoxMesh();
#endif
pNode = pModel;
}
else if(0==nodeType.compare(_L("light")))
{
pNode = new CPUTLight();
((CPUTLight*)pNode)->LoadLight(pBlock, &parentIndex);
pParentNode = mppAssetList[parentIndex+1]; // +1 because we added a root node to the start
pNode->SetParent( pParentNode );
pParentNode->AddChild( pNode );
cString &parentPrefix = pParentNode->GetPrefix();
pNode->SetPrefix( parentPrefix );
pAssetLibrary->AddLight(parentPrefix + name, (CPUTLight*)pNode);
}
else if(0==nodeType.compare(_L("camera")))
{
pNode = new CPUTCamera();
((CPUTCamera*)pNode)->LoadCamera(pBlock, &parentIndex);
pParentNode = mppAssetList[parentIndex+1]; // +1 because we added a root node to the start
pNode->SetParent( pParentNode );
pParentNode->AddChild( pNode );
cString &parentPrefix = pParentNode->GetPrefix();
pNode->SetPrefix( parentPrefix );
pAssetLibrary->AddCamera(parentPrefix + name, (CPUTCamera*)pNode);
if( !mpFirstCamera ) { mpFirstCamera = (CPUTCamera*)pNode; mpFirstCamera->AddRef();}
++mCameraCount;
}
else
{
ASSERT(0,_L("Unsupported node type '") + nodeType + _L("'."));
}
// Add the node to our asset list (i.e., the linear list, not the hierarchical)
mppAssetList[ii+1] = pNode;
// Don't AddRef.Creating it set the refcount to 1. We add it to the list, and then we're done with it.
// Net effect is 0 (+1 to add to list, and -1 because we're done with it)
// pNode->AddRef();
}
return result;
}
//-----------------------------------------------------------------------------
CPUTAssetSet *CPUTAssetSetDX11::CreateAssetSet( const cString &name, const cString &absolutePathAndFilename )
{
CPUTAssetLibraryDX11 *pAssetLibrary = ((CPUTAssetLibraryDX11*)CPUTAssetLibrary::GetAssetLibrary());
// Create the root node.
CPUTNullNode *pRootNode = new CPUTNullNode();
pRootNode->SetName(_L("_CPUTAssetSetRootNode_"));
// Create the asset set, set its root, and load it
CPUTAssetSet *pNewAssetSet = new CPUTAssetSetDX11();
pNewAssetSet->SetRoot( pRootNode );
pAssetLibrary->AddNullNode( name + _L("_Root"), pRootNode );
CPUTResult result = pNewAssetSet->LoadAssetSet(absolutePathAndFilename);
if( CPUTSUCCESS(result) )
{
pAssetLibrary->AddAssetSet(name, pNewAssetSet);
return pNewAssetSet;
}
ASSERT( CPUTSUCCESS(result), _L("Error loading AssetSet\n'")+absolutePathAndFilename+_L("'"));
pNewAssetSet->Release();
return NULL;
}
================================================
FILE: CPUT/CPUT/CPUTAssetSetDX11.h
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#ifndef __CPUTASSETSETDX11_H__
#define __CPUTASSETSETDX11_H__
#include "CPUTAssetSet.h"
class CPUTAssetSetDX11 : public CPUTAssetSet
{
public:
static CPUTAssetSet *CreateAssetSet( const cString &name, const cString &absolutePathAndFilename );
CPUTAssetSetDX11() : CPUTAssetSet() {}
virtual ~CPUTAssetSetDX11();
virtual CPUTResult LoadAssetSet(cString name);
};
#endif // #ifndef __CPUTASSETSETDX11_H__
================================================
FILE: CPUT/CPUT/CPUTBuffer.cpp
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#include "CPUTBuffer.h"
#ifdef CPUT_FOR_DX11
#include "CPUTBufferDX11.h"
#else
#error You must supply a target graphics API (ex: #define CPUT_FOR_DX11), or implement the target API for this file.
#endif
================================================
FILE: CPUT/CPUT/CPUTBuffer.h
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#ifndef _CPUTBUFFER_H
#define _CPUTBUFFER_H
#include "CPUT.h"
#include "CPUTRefCount.h"
// TODO: Move to dedicated file
class CPUTBuffer : public CPUTRefCount
{
protected:
cString mName;
eCPUTMapType mMappedType;
~CPUTBuffer(){
mName.clear();
} // Destructor is not public. Must release instead of delete.
public:
CPUTBuffer(){mMappedType = CPUT_MAP_UNDEFINED;}
CPUTBuffer(cString &name) {mName = name; mMappedType = CPUT_MAP_UNDEFINED;}
};
#endif //_CPUTBUFFER_H
================================================
FILE: CPUT/CPUT/CPUTBufferDX11.cpp
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#include "CPUTBufferDX11.h"
//-----------------------------------------------------------------------------
D3D11_MAPPED_SUBRESOURCE CPUTBufferDX11::MapBuffer( CPUTRenderParameters ¶ms, eCPUTMapType type, bool wait )
{
// Mapping for DISCARD requires dynamic buffer. Create dynamic copy?
// Could easily provide input flag. But, where would we specify? Don't like specifying in the .set file
// Because mapping is something the application wants to do - it isn't inherent in the data.
// Could do Clone() and pass dynamic flag to that.
// But, then we have two. Could always delete the other.
// Could support programatic flag - apply to all loaded models in the .set
// Could support programatic flag on model. Load model first, then load set.
// For now, simply support CopyResource mechanism.
HRESULT hr;
ID3D11Device *pD3dDevice = CPUT_DX11::GetDevice();
CPUTRenderParametersDX *pParamsDX11 = (CPUTRenderParametersDX*)¶ms;
ID3D11DeviceContext *pContext = pParamsDX11->mpContext;
if( !mpBufferStaging )
{
D3D11_BUFFER_DESC desc;
mpBuffer->GetDesc( &desc );
desc.Usage = D3D11_USAGE_STAGING;
switch( type )
{
case CPUT_MAP_READ:
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
desc.BindFlags = 0;
break;
case CPUT_MAP_READ_WRITE:
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
desc.BindFlags = 0;
break;
case CPUT_MAP_WRITE:
case CPUT_MAP_WRITE_DISCARD:
case CPUT_MAP_NO_OVERWRITE:
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
desc.BindFlags = 0;
break;
};
hr = pD3dDevice->CreateBuffer( &desc, NULL, &mpBufferStaging );
ASSERT( SUCCEEDED(hr), _L("Failed to create staging buffer") );
CPUTSetDebugName( mpBufferStaging, _L("Staging Buffer"));
}
else
{
ASSERT( mMappedType == type, _L("Mapping with a different CPU access than creation parameter.") );
}
D3D11_MAPPED_SUBRESOURCE info;
switch( type )
{
case CPUT_MAP_READ:
case CPUT_MAP_READ_WRITE:
// TODO: Copying and immediately mapping probably introduces a stall.
// Expose the copy externally?
// TODO: copy only if changed?
// Copy only first time?
// Copy the GPU version before we read from it.
pContext->CopyResource( mpBufferStaging, mpBuffer );
break;
};
hr = pContext->Map( mpBufferStaging, wait ? 0 : D3D11_MAP_FLAG_DO_NOT_WAIT, (D3D11_MAP)type, 0, &info );
mMappedType = type;
return info;
} // CPUTBufferDX11::Map()
//-----------------------------------------------------------------------------
void CPUTBufferDX11::UnmapBuffer( CPUTRenderParameters ¶ms )
{
ASSERT( mMappedType != CPUT_MAP_UNDEFINED, _L("Can't unmap a render target that isn't mapped.") );
CPUTRenderParametersDX *pParamsDX11 = (CPUTRenderParametersDX*)¶ms;
ID3D11DeviceContext *pContext = pParamsDX11->mpContext;
pContext->Unmap( mpBufferStaging, 0 );
// If we were mapped for write, then copy staging buffer to GPU
switch( mMappedType )
{
case CPUT_MAP_READ:
break;
case CPUT_MAP_READ_WRITE:
case CPUT_MAP_WRITE:
case CPUT_MAP_WRITE_DISCARD:
case CPUT_MAP_NO_OVERWRITE:
pContext->CopyResource( mpBuffer, mpBufferStaging );
break;
};
} // CPUTBufferDX11::Unmap()
================================================
FILE: CPUT/CPUT/CPUTBufferDX11.h
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#ifndef _CPUTBUFFERDX11_H
#define _CPUTBUFFERDX11_H
#include "CPUTBuffer.h"
#include "CPUT_DX11.h"
//--------------------------------------------------------------------------------------
// TODO: Move to dedicated file
class CPUTBufferDX11 : public CPUTBuffer
{
private:
// resource view pointer
ID3D11ShaderResourceView *mpShaderResourceView;
ID3D11UnorderedAccessView *mpUnorderedAccessView;
ID3D11Buffer *mpBuffer;
ID3D11Buffer *mpBufferStaging;
// Destructor is not public. Must release instead of delete.
~CPUTBufferDX11() {
SAFE_RELEASE( mpShaderResourceView );
SAFE_RELEASE( mpUnorderedAccessView );
SAFE_RELEASE( mpBuffer );
SAFE_RELEASE( mpBufferStaging );
}
public:
CPUTBufferDX11() :
mpShaderResourceView(NULL),
mpUnorderedAccessView(NULL),
mpBuffer(NULL),
mpBufferStaging(NULL)
{
}
CPUTBufferDX11(cString &name, ID3D11Buffer *pBuffer) :
mpBuffer(pBuffer),
mpBufferStaging(NULL),
mpShaderResourceView(NULL),
mpUnorderedAccessView(NULL),
CPUTBuffer(name)
{
if(pBuffer) pBuffer->AddRef();
}
CPUTBufferDX11(cString &name, ID3D11Buffer *pBuffer, ID3D11ShaderResourceView *pView) :
mpBuffer(pBuffer),
mpBufferStaging(NULL),
mpShaderResourceView(pView),
mpUnorderedAccessView(NULL),
CPUTBuffer(name)
{
if(pBuffer) pBuffer->AddRef();
if(pView) pView->AddRef();
}
CPUTBufferDX11(cString &name, ID3D11Buffer *pBuffer, ID3D11UnorderedAccessView *pView) :
mpBuffer(pBuffer),
mpBufferStaging(NULL),
mpShaderResourceView(NULL),
mpUnorderedAccessView(pView),
CPUTBuffer(name)
{
if(pBuffer) pBuffer->AddRef();
if(pView) pView->AddRef();
}
ID3D11ShaderResourceView *GetShaderResourceView()
{
return mpShaderResourceView;
}
ID3D11UnorderedAccessView *GetUnorderedAccessView()
{
return mpUnorderedAccessView;
}
void SetShaderResourceView(ID3D11ShaderResourceView *pShaderResourceView)
{
// release any resource view we might already be pointing too
SAFE_RELEASE( mpShaderResourceView );
mpShaderResourceView = pShaderResourceView;
mpShaderResourceView->AddRef();
}
void SetUnorderedAccessView(ID3D11UnorderedAccessView *pUnorderedAccessView)
{
// release any resource view we might already be pointing too
SAFE_RELEASE( mpUnorderedAccessView );
mpUnorderedAccessView = pUnorderedAccessView;
mpUnorderedAccessView->AddRef();
}
void SetBufferAndViews(ID3D11Buffer *pBuffer, ID3D11ShaderResourceView *pShaderResourceView, ID3D11UnorderedAccessView *pUnorderedAccessView )
{
SAFE_RELEASE(mpBuffer);
mpBuffer = pBuffer;
if(mpBuffer) mpBuffer->AddRef();
// release any resource view we might already be pointing too
SAFE_RELEASE( mpShaderResourceView );
mpShaderResourceView = pShaderResourceView;
if(mpShaderResourceView) mpShaderResourceView->AddRef();
// release any resource view we might already be pointing too
SAFE_RELEASE( mpUnorderedAccessView );
mpUnorderedAccessView = pUnorderedAccessView;
if(mpUnorderedAccessView) mpUnorderedAccessView->AddRef();
}
ID3D11Buffer *GetNativeBuffer() { return mpBuffer; }
D3D11_MAPPED_SUBRESOURCE MapBuffer( CPUTRenderParameters ¶ms, eCPUTMapType type, bool wait=true );
void UnmapBuffer( CPUTRenderParameters ¶ms );
void ReleaseBuffer()
{
SAFE_RELEASE(mpShaderResourceView);
SAFE_RELEASE(mpUnorderedAccessView);
SAFE_RELEASE(mpBuffer);
SAFE_RELEASE(mpBufferStaging);
}
};
#endif //_CPUTBUFFERDX11_H
================================================
FILE: CPUT/CPUT/CPUTButton.cpp
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#include "CPUTButton.h"
#include "CPUTText.h"
// static initializers
bool CPUTButton::mStaticRegistered = false;
// list of resources sizes
CPUT_SIZE CPUTButton::mpButtonIdleImageSizeList[CPUT_NUM_IMAGES_IN_BUTTON] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
CPUT_SIZE CPUTButton::mpButtonPressedImageSizeList[CPUT_NUM_IMAGES_IN_BUTTON] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
CPUT_SIZE CPUTButton::mpButtonDisabledImageSizeList[CPUT_NUM_IMAGES_IN_BUTTON] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int CPUTButton::mSmallestLeftSizeIdle=0;
int CPUTButton::mSmallestRightSizeIdle=0;
int CPUTButton::mSmallestTopSizeIdle=0;
int CPUTButton::mSmallestBottomSizeIdle=0;
int CPUTButton::mSmallestLeftSizePressed=0;
int CPUTButton::mSmallestRightSizePressed=0;
int CPUTButton::mSmallestTopSizePressed=0;
int CPUTButton::mSmallestBottomSizePressed=0;
int CPUTButton::mSmallestLeftSizeDisabled=0;
int CPUTButton::mSmallestRightSizeDisabled=0;
int CPUTButton::mSmallestTopSizeDisabled=0;
int CPUTButton::mSmallestBottomSizeDisabled=0;
// texture atlas information
float gAtlasWidth = 256.0f;
float gAtlasHeight = 64.0f;
// Texture atlas coordinates of the active-idle button image
int gUVLocations_active[] = {
8,8, 15,31, // lt
8,31, 15,32, // lm
8,32, 15,40, // lb
15,8, 16,31, // mt
15,31, 16,32, // mm
15,32, 16,40, // mb
16,8, 25,31, // rt
16,31, 25,32, // rm
16,32, 25,40 // rb
};
// Texture atlas coordinates of the pressed button image
int gUVLocations_pressed[] = {
63,8, 70,31, // lt
63,31, 70,32, // lm
63,32, 70,40, // lb
70,8, 71,31, // mt
70,31, 71,32, // mm
70,32, 71,40, // mb
71,8, 81,31, // rt
71,31, 81,32, // rm
71,32, 81,40 // rb
};
// Texture atlas coordinates of the disabled button image
int gUVLocations_disabled[] = {
36,8, 43,31, // lt
36,31, 43,32, // lm
36,32, 43,40, // lb
43,8, 45,31, // mt
43,31, 45,32, // mm
43,32, 45,40, // mb
45,8, 55,31, // rt
45,31, 55,32, // rm
45,32, 55,40 // rb
};
float3 mpUVCoords_active[9*2];
float3 mpUVCoords_pressed[9*2];
float3 mpUVCoords_disabled[9*2];
// Constructor
//-----------------------------------------------------------------------------
CPUTButton::CPUTButton(const cString ControlText, CPUTControlID id, CPUTFont *pFont):
mbMouseInside(false),
mbStartedClickInside(false),
mpButtonText(NULL),
mpMirrorBufferActive(NULL),
mpMirrorBufferPressed(NULL),
mpMirrorBufferDisabled(NULL),
mpFont(pFont)
{
// initialize the state variables
InitializeState();
// save the control ID for callbacks
mcontrolID = id;
// save the font to use for text on this button
mpFont = pFont;
// set as enabled
CPUTControl::SetEnable(true);
// initialize the size lists
memset(&mpButtonIdleSizeList, 0, sizeof(CPUT_SIZE) * CPUT_NUM_IMAGES_IN_BUTTON);
memset(&mpButtonPressedSizeList, 0, sizeof(CPUT_SIZE) * CPUT_NUM_IMAGES_IN_BUTTON);
memset(&mpButtonDisabledSizeList, 0, sizeof(CPUT_SIZE) * CPUT_NUM_IMAGES_IN_BUTTON);
// set up the per-instance data
RegisterInstanceResources();
// set the text on the button and resize it accordingly
SetText(ControlText);
// set the default control position
SetPosition( 0, 0 );
}
// Initial state of the control's member variables
//-----------------------------------------------------------------------------
void CPUTButton::InitializeState()
{
mcontrolType = CPUT_BUTTON;
mButtonState = CPUT_BUTTON_NEUTRAL;
// dimensions
mButtonDimensions.x=0;
mButtonDimensions.y=0;
mButtonDimensions.width=0;
mButtonDimensions.height=0;
}
// Destructor
//------------------------------------------------------------------------------
CPUTButton::~CPUTButton()
{
UnRegisterInstanceResources();
}
// Return the upper-left screen coordinate location of this control
//--------------------------------------------------------------------------------
void CPUTButton::GetPosition(int &x, int &y)
{
x = mButtonDimensions.x;
y = mButtonDimensions.y;
}
// Return the width/height of the control
//--------------------------------------------------------------------------------
void CPUTButton::GetDimensions(int &width, int &height)
{
width = mButtonDimensions.width;
height = mButtonDimensions.height;
}
// Returns the number of quads needed to draw this control
//--------------------------------------------------------------------------------
unsigned int CPUTButton::GetOutputVertexCount()
{
// A button is always made of 9 quads.
// Quads 2,4,5,6, and 8 'stretch' in height and/or width to fit the
// static text/content inside the button
//
// ---+-----------+---
// | 1 | 4 | 7 |
// |---+-----------+---|
// | | | |
// | 2 | 5 | 8 |
// | | | |
// |---+-----------+---|
// | 3 | 6 | 9 |
// ---+-----------+---
//
// calculation: 3 verts/triangle * 2 triangle/quad * 9 quads
return (2*3)*9;
}
//CPUTEventHandler
// Handle keyboard events
//--------------------------------------------------------------------------------
CPUTEventHandledCode CPUTButton::HandleKeyboardEvent(CPUTKey key)
{
UNREFERENCED_PARAMETER(key);
return CPUT_EVENT_UNHANDLED;
}
// Handle mouse events
//--------------------------------------------------------------------------------
CPUTEventHandledCode CPUTButton::HandleMouseEvent(int x, int y, int wheel, CPUTMouseState state)
{
UNREFERENCED_PARAMETER(wheel);
CPUTEventHandledCode handledCode = CPUT_EVENT_UNHANDLED;
if((CPUT_CONTROL_INACTIVE == mControlState) || (false == mControlVisible) )
{
mbMouseInside = false;
return handledCode;
}
// if we're continuing to be pressed, move around with the mouse movement
if( (CPUT_BUTTON_PRESSED == mButtonState ) && (CPUT_MOUSE_LEFT_DOWN == state))
{
return CPUT_EVENT_HANDLED;
}
if(ContainsPoint(x,y))
{
// did we start our click inside the button?
if((state & CPUT_MOUSE_LEFT_DOWN) && (true == mbMouseInside))
{
mbStartedClickInside = true;
mButtonState = CPUT_BUTTON_PRESSED;
handledCode = CPUT_EVENT_HANDLED;
// tell gui system this control image is now dirty
// and needs to rebuild it's draw list
mControlGraphicsDirty = true;
}
// did they click inside the button?
if(!(state & CPUT_MOUSE_LEFT_DOWN) && (true == mbStartedClickInside) && (CPUT_BUTTON_PRESSED == mButtonState))
{
// they let up the click - trigger the user's callback
mpCallbackHandler->HandleCallbackEvent(1, mcontrolID, (CPUTControl*) this);
handledCode = CPUT_EVENT_HANDLED;
mButtonState = CPUT_BUTTON_NEUTRAL;
// tell gui system this control image is now dirty
// and needs to rebuild it's draw list
mControlGraphicsDirty = true;
}
if(!(state & CPUT_MOUSE_LEFT_DOWN))
{
mbMouseInside = true;
}
}
else
{
// we left the button
// if we weren't already in neutral state, return to neutral sate
// this handles case of clicking button, exiting button, and releasing button outside control
if(CPUT_BUTTON_NEUTRAL != mButtonState)
{
mButtonState = CPUT_BUTTON_NEUTRAL;
mControlGraphicsDirty = true;
}
mbMouseInside = false;
mButtonState = CPUT_BUTTON_NEUTRAL;
mbStartedClickInside = false;
}
return handledCode;
}
// Returns true if the x,y coordinate is inside the button's control region
//--------------------------------------------------------------------------------
bool CPUTButton::ContainsPoint(int x, int y)
{
if( (x>=mButtonDimensions.x) && (x<=mButtonDimensions.x+mButtonDimensions.width))
{
if( (y>=mButtonDimensions.y) && (y<=mButtonDimensions.y+mButtonDimensions.height))
{
return true;
}
}
return false;
}
// Returns the x,y coordinate inside the button area that should be 'safe' to draw on
//--------------------------------------------------------------------------------
void CPUTButton::GetInsetTextCoordinate(int &x, int &y)
{
// get text size
CPUT_RECT ButtonTextDimensions;
if(mpButtonText)
{
mpButtonText->GetDimensions(ButtonTextDimensions.width, ButtonTextDimensions.height);
}
else
{
ButtonTextDimensions.width=0;
ButtonTextDimensions.height=0;
}
// calculate a good 'center' point
x =(int) ( mButtonDimensions.x + mButtonDimensions.width/2.0f - ButtonTextDimensions.width/2.0f);
y =(int) ( mButtonDimensions.y + mButtonDimensions.height/2.0f - ButtonTextDimensions.height/2.0f);
}
// Sets the text on the control
//--------------------------------------------------------------------------------
void CPUTButton::SetText(const cString String)
{
// Zero out the size and location
InitializeState();
// create the static text object if it doesn't exist
if(NULL == mpButtonText)
{
mpButtonText = new CPUTText(mpFont);
}
// set the Static control's text
mpButtonText->SetText(String);
// get the dimensions of the string in pixels
CPUT_RECT rect;
mpButtonText->GetDimensions(rect.width, rect.height);
// resize this control to fix that string with padding
Resize(rect.width, rect.height);
// move the text to a nice inset location inside the 'safe' area
// of the button image
int x,y;
GetInsetTextCoordinate(x, y);
mpButtonText->SetPosition(x, y);
// position or size may move - force a recalculation of this control's location
// if it is managed by the auto-arrange function
if(this->IsAutoArranged())
{
mControlNeedsArrangmentResizing = true;
}
else
{
// otherwise, we mark this as dirty
mControlGraphicsDirty = true;
}
}
// sets the dimensions of the button
//--------------------------------------------------------------------------------
void CPUTButton::SetDimensions(int width, int height)
{
// Zero out the size and location
InitializeState();
// get the dimensions of the string in pixels
CPUT_RECT rect;
mpButtonText->GetDimensions(rect.width, rect.height);
width = max(rect.width, width);
height = max(rect.height, height);
// resize this control to fix that string with padding
Resize(width, height);
// move the text to a nice inset location inside the 'safe' area
// of the button image
int x,y;
GetInsetTextCoordinate(x, y);
mpButtonText->SetPosition(x, y);
}
// Fills the users buffer with the button text
//--------------------------------------------------------------------------------
void CPUTButton::GetText(cString &String)
{
if(mpButtonText)
{
mpButtonText->GetString(String);
}
}
// Enable/disable the control
//--------------------------------------------------------------------------------
void CPUTButton::SetEnable(bool in_bEnabled)
{
// chain to CPUTControl set enabled
CPUTControl::SetEnable(in_bEnabled);
// set the control's text to match
mpButtonText->SetEnable(in_bEnabled);
// otherwise, we mark this as dirty
mControlGraphicsDirty = true;
}
// Set the upper-left screen coordinate location of this control
//--------------------------------------------------------------------------------
void CPUTButton::SetPosition(int x, int y)
{
// move the button graphics
mButtonDimensions.x = x;
mButtonDimensions.y = y;
// move the static text (if any)
if(mpButtonText)
{
// resize things in the buffers
CPUT_RECT rect;
mpButtonText->GetDimensions(rect.width, rect.height);
Resize(rect.width, rect.height);
int insetX, insetY;
GetInsetTextCoordinate(insetX, insetY);
mpButtonText->SetPosition(insetX, insetY);
}
}
// 'Draw' this control into the supplied vertex buffer object
//--------------------------------------------------------------------------------
void CPUTButton::DrawIntoBuffer(CPUTGUIVertex *pVertexBufferMirror, UINT *pInsertIndex, UINT pMaxBufferSize, CPUTGUIVertex *pTextVertexBufferMirror, UINT *pTextInsertIndex, UINT MaxTextVertexBufferSize)
{
if(!mControlVisible)
{
return;
}
// invalid output buffer pointers?
if((NULL==pVertexBufferMirror) || (NULL==pInsertIndex))
{
return;
}
// invalid buffer pointers?
if(!mpMirrorBufferActive || !mpMirrorBufferPressed || !mpMirrorBufferDisabled)
{
return;
}
// Do we have enough room to put this control into the output buffer?
int VertexCopyCount = GetOutputVertexCount();
ASSERT( (pMaxBufferSize >= *pInsertIndex + VertexCopyCount), _L("Too many CPUT GUI controls for allocated GUI buffer. Allocated GUI vertex buffer is too small.\n\nIncrease CPUT_GUI_BUFFER_SIZE size.") );
switch(mControlState)
{
case CPUT_CONTROL_ACTIVE:
// copy the active+idle button into the stream
if(CPUT_BUTTON_NEUTRAL == mButtonState)
{
memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBufferActive, sizeof(CPUTGUIVertex)*VertexCopyCount);
}
// copy the pressed button into the stream
if(CPUT_BUTTON_PRESSED == mButtonState)
{
memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBufferPressed, sizeof(CPUTGUIVertex)*VertexCopyCount);
}
break;
case CPUT_CONTROL_INACTIVE:
// copy the inactive button into the stream
memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBufferDisabled, sizeof(CPUTGUIVertex)*VertexCopyCount);
break;
default:
// error! unknown state
ASSERT(0,_L("CPUTButton: Control is in unknown state"));
return;
}
// move the index the correct number of floats to account
// for 9 new quads, each quad with 6 verts in it (and each vert with 3+2 floats in it).
*pInsertIndex+= VertexCopyCount;
// now do the text
// draw the text
if(mpButtonText)
{
mpButtonText->DrawIntoBuffer(pTextVertexBufferMirror, pTextInsertIndex, MaxTextVertexBufferSize);
}
// we'll mark the control as no longer being 'dirty'
mControlGraphicsDirty = false;
}
// Allocates/registers resources used by all buttons
//--------------------------------------------------------------------------------
CPUTResult CPUTButton::RegisterStaticResources()
{
// calculate the UV coordinates of each of the 9 images that
// make up a button. Do this for the active, pressed, and disabled states.
for(int ii=0; ii<18; ii++)
{
mpUVCoords_active[ii].x = gUVLocations_active[2*ii]/gAtlasWidth;
mpUVCoords_active[ii].y = gUVLocations_active[2*ii+1]/gAtlasHeight;
mpUVCoords_pressed[ii].x = gUVLocations_pressed[2*ii]/gAtlasWidth;
mpUVCoords_pressed[ii].y = gUVLocations_pressed[2*ii+1]/gAtlasHeight;
mpUVCoords_disabled[ii].x = gUVLocations_disabled[2*ii]/gAtlasWidth;
mpUVCoords_disabled[ii].y = gUVLocations_disabled[2*ii+1]/gAtlasHeight;
}
// calculate the width/height in pixels of each of the 9 image slices
// that makes up the button images
int QuadIndex=0;
for(int ii=0; ii<9*4; ii+=4)
{
mpButtonIdleImageSizeList[QuadIndex].width = gUVLocations_active[ii+2] - gUVLocations_active[ii+0];
mpButtonIdleImageSizeList[QuadIndex].height = gUVLocations_active[ii+3] - gUVLocations_active[ii+1];
mpButtonPressedImageSizeList[QuadIndex].width = gUVLocations_pressed[ii+2] - gUVLocations_pressed[ii+0];
mpButtonPressedImageSizeList[QuadIndex].height = gUVLocations_pressed[ii+3] - gUVLocations_pressed[ii+1];
mpButtonDisabledImageSizeList[QuadIndex].width = gUVLocations_disabled[ii+2] - gUVLocations_disabled[ii+0];
mpButtonDisabledImageSizeList[QuadIndex].height = gUVLocations_disabled[ii+3] - gUVLocations_disabled[ii+1];
QuadIndex++;
}
// find the narrowest (width) left side images
mSmallestLeftSizeIdle = min(min(mpButtonIdleImageSizeList[0].width, mpButtonIdleImageSizeList[1].width), mpButtonIdleImageSizeList[2].width);
mSmallestLeftSizePressed = min(min(mpButtonPressedImageSizeList[0].width, mpButtonPressedImageSizeList[1].width), mpButtonPressedImageSizeList[2].width);
mSmallestLeftSizeDisabled = min(min(mpButtonDisabledImageSizeList[0].width, mpButtonDisabledImageSizeList[1].width), mpButtonDisabledImageSizeList[2].width);
// find the narrowest (width) right side images
mSmallestRightSizeIdle = min(min(mpButtonIdleImageSizeList[6].width, mpButtonIdleImageSizeList[7].width), mpButtonIdleImageSizeList[8].width);
mSmallestRightSizePressed = min(min(mpButtonPressedImageSizeList[6].width, mpButtonPressedImageSizeList[7].width), mpButtonPressedImageSizeList[8].width);
mSmallestRightSizeDisabled = min(min(mpButtonDisabledImageSizeList[6].width, mpButtonDisabledImageSizeList[7].width), mpButtonDisabledImageSizeList[8].width);
// find the shortest (height) of the top row of images
mSmallestTopSizeIdle = min(min( mpButtonIdleImageSizeList[0].height,mpButtonIdleImageSizeList[3].height), mpButtonIdleImageSizeList[6].height);
mSmallestTopSizePressed = min(min( mpButtonPressedImageSizeList[0].height,mpButtonPressedImageSizeList[3].height), mpButtonPressedImageSizeList[6].height);
mSmallestTopSizeDisabled = min( min( mpButtonDisabledImageSizeList[0].height,mpButtonDisabledImageSizeList[3].height), mpButtonDisabledImageSizeList[6].height);
// find the shortest (height) of the bottom row of images
mSmallestBottomSizeIdle = min(min( mpButtonIdleImageSizeList[2].height,mpButtonIdleImageSizeList[5].height), mpButtonIdleImageSizeList[8].height);
mSmallestBottomSizePressed = min(min( mpButtonPressedImageSizeList[2].height,mpButtonPressedImageSizeList[5].height), mpButtonPressedImageSizeList[8].height);
mSmallestBottomSizeDisabled = min(min( mpButtonDisabledImageSizeList[2].height,mpButtonDisabledImageSizeList[5].height), mpButtonDisabledImageSizeList[8].height);
mStaticRegistered = true;
return CPUT_SUCCESS;
}
// Deletes any statically allocated resources used for all buttons
//--------------------------------------------------------------------------------
CPUTResult CPUTButton::UnRegisterStaticResources()
{
return CPUT_SUCCESS;
}
// Allocates an initialize all per-instance resources for this button
//--------------------------------------------------------------------------------
CPUTResult CPUTButton::RegisterInstanceResources()
{
// clear any previously allocated buffers
SAFE_DELETE_ARRAY(mpMirrorBufferActive);
SAFE_DELETE_ARRAY(mpMirrorBufferPressed);
SAFE_DELETE_ARRAY(mpMirrorBufferDisabled);
// allocate the per-instance sizes (each button will have different dimensions)
mpMirrorBufferActive = new CPUTGUIVertex[6 * 9];
mpMirrorBufferPressed = new CPUTGUIVertex[6 * 9];
mpMirrorBufferDisabled = new CPUTGUIVertex[6 * 9];
// store all the default button component quad sizes in instance variables
// Re-sizable parts will get re-calculated during setText and other operations
for(int i=0; i<CPUT_NUM_IMAGES_IN_BUTTON; i++)
{
mpButtonIdleSizeList[i].height = mpButtonIdleImageSizeList[i].height;
mpButtonIdleSizeList[i].width = mpButtonIdleImageSizeList[i].width;
mpButtonPressedSizeList[i].height = mpButtonPressedImageSizeList[i].height;
mpButtonPressedSizeList[i].width = mpButtonPressedImageSizeList[i].width;
mpButtonDisabledSizeList[i].height = mpButtonDisabledImageSizeList[i].height;
mpButtonDisabledSizeList[i].width = mpButtonDisabledImageSizeList[i].width;
}
return CPUT_SUCCESS;
}
// Delete all instance resources alloated for this button
//--------------------------------------------------------------------------------
CPUTResult CPUTButton::UnRegisterInstanceResources()
{
CPUTResult result = CPUT_SUCCESS;
// delete the static text object
SAFE_DELETE(mpButtonText);
// Release the mirrored vertex lists
SAFE_DELETE_ARRAY(mpMirrorBufferActive);
SAFE_DELETE_ARRAY(mpMirrorBufferPressed);
SAFE_DELETE_ARRAY(mpMirrorBufferDisabled);
return result;
}
// Resize the button
// Recalculates the size of the button based on the supplied dimensions and
// generates new vertex buffer lists for each of the 3 states of the control.
//
// It does NOT move the inside text, nor does it base itself on the size of the
// text. You need to do that yourself outside this function and pass it in
//--------------------------------------------------------------------------------
CPUTResult CPUTButton::Resize(int width, int height)
{
// verify that the new dimensions fit the minimal 'safe' dimensions needed to draw the button
// or ugly clipping will occur
int safeWidth=0;
int safeHeight=0;
switch(mControlState)
{
case CPUT_CONTROL_ACTIVE:
if(CPUT_BUTTON_NEUTRAL == mButtonState)
{
safeWidth = mSmallestLeftSizeIdle + mSmallestRightSizeIdle + 1;
safeHeight = mSmallestTopSizeIdle + mSmallestBottomSizeIdle + 1;
}
if(CPUT_BUTTON_PRESSED == mButtonState)
{
safeWidth = mSmallestLeftSizePressed + mSmallestRightSizePressed + 1;
safeHeight = mSmallestTopSizePressed + mSmallestBottomSizePressed + 1;
}
break;
case CPUT_CONTROL_INACTIVE:
safeWidth = mSmallestLeftSizeDisabled + mSmallestRightSizeDisabled + 1;
safeHeight = mSmallestTopSizeDisabled + mSmallestBottomSizeDisabled + 1;
break;
default:
ASSERT(0,_L("")); // todo: error! unknown state - using idle dimensions as a default
safeWidth = mSmallestLeftSizeIdle + mSmallestRightSizeIdle + 1;
safeHeight = mSmallestTopSizeIdle + mSmallestBottomSizeIdle + 1;
}
// if the user's dimensions are smaller than the smallest 'safe' dimensions of the button,
// use the safe ones instead.
if(safeWidth > width)
{
width = safeWidth;
}
if(safeHeight > height)
{
height = safeHeight;
}
// add some padding for nicety
width += CPUT_BUTTON_TEXT_BORDER_PADDING_X;
height += CPUT_BUTTON_TEXT_BORDER_PADDING_Y;
{
// store the new dimensions
mButtonDimensions.width = width;
mButtonDimensions.height = height;
// calculate the pieces we'll need to rebuild
int middleWidth = width - mSmallestLeftSizeIdle - mSmallestRightSizeIdle;
int middleHeight = height - mSmallestTopSizeIdle - mSmallestBottomSizeIdle;
// delete the old button quads for the middle sections
//result = UnRegisterResizableInstanceQuads();
// create a new quads with the correct size
// Idle button quads
// left
AddQuadIntoMirrorBuffer(mpMirrorBufferActive, 0*6, (float)mButtonDimensions.x, (float)mButtonDimensions.y, (float) mpButtonIdleSizeList[0].width, (float) mpButtonIdleSizeList[0].height, mpUVCoords_active[2*0], mpUVCoords_active[2*0+1] );
AddQuadIntoMirrorBuffer(mpMirrorBufferActive, 1*6, (float)mButtonDimensions.x, (float)mButtonDimensions.y+mSmallestTopSizeIdle, (float) mpButtonIdleSizeList[1].width, (float) middleHeight, mpUVCoords_active[2*1], mpUVCoords_active[2*1+1] );
mpButtonIdleSizeList[1].height = middleHeight;
AddQuadIntoMirrorBuffer(mpMirrorBufferActive, 2*6, (float)mButtonDimensions.x, (float)mButtonDimensions.y+mSmallestTopSizeIdle+middleHeight, (float) mpButtonIdleSizeList[2].width, (float) mpButtonIdleSizeList[2].height, mpUVCoords_active[2*2], mpUVCoords_active[2*2+1] );
// middle
AddQuadIntoMirrorBuffer(mpMirrorBufferActive, 3*6, (float)mButtonDimensions.x+mSmallestLeftSizeIdle, (float)mButtonDimensions.y, (float) middleWidth, (float) mpButtonIdleSizeList[3].height, mpUVCoords_active[2*3], mpUVCoords_active[2*3+1] );
mpButtonIdleSizeList[3].width = middleWidth;
AddQuadIntoMirrorBuffer(mpMirrorBufferActive, 4*6, (float)mButtonDimensions.x+mSmallestLeftSizeIdle, (float)mButtonDimensions.y+mSmallestTopSizeIdle, (float) middleWidth, (float) middleHeight, mpUVCoords_active[2*4], mpUVCoords_active[2*4+1] );
mpButtonIdleSizeList[4].width = middleWidth;
mpButtonIdleSizeList[4].height = middleHeight;
AddQuadIntoMirrorBuffer(mpMirrorBufferActive, 5*6, (float)mButtonDimensions.x+mSmallestLeftSizeIdle, (float)mButtonDimensions.y+mSmallestTopSizeIdle+middleHeight, (float) middleWidth, (float) mpButtonIdleSizeList[5].height, mpUVCoords_active[2*5], mpUVCoords_active[2*5+1] );
mpButtonIdleSizeList[5].width = middleWidth;
// right
AddQuadIntoMirrorBuffer(mpMirrorBufferActive, 6*6, (float)mButtonDimensions.x+mSmallestLeftSizeIdle+middleWidth, (float)mButtonDimensions.y, (float) mpButtonIdleSizeList[6].width, (float)mpButtonIdleSizeList[6].height, mpUVCoords_active[2*6], mpUVCoords_active[2*6+1] );
AddQuadIntoMirrorBuffer(mpMirrorBufferActive, 7*6, (float)mButtonDimensions.x+mSmallestLeftSizeIdle+middleWidth, (float)mButtonDimensions.y+mSmallestTopSizeIdle, (float) mpButtonIdleSizeList[7].width, (float)middleHeight, mpUVCoords_active[2*7], mpUVCoords_active[2*7+1] );
mpButtonIdleSizeList[7].height = middleHeight;
AddQuadIntoMirrorBuffer(mpMirrorBufferActive, 8*6, (float)mButtonDimensions.x+mSmallestLeftSizeIdle+middleWidth, (float)mButtonDimensions.y+mSmallestTopSizeIdle+middleHeight, (float) mpButtonIdleSizeList[8].width, (float)mpButtonIdleSizeList[8].height, mpUVCoords_active[2*8], mpUVCoords_active[2*8+1] );
// register uberbuffer
//RegisterUberBuffer(pImmediateContext, &mpUberBufferActive, mpMirrorBufferActive);
// Pressed button quads
// left
AddQuadIntoMirrorBuffer(mpMirrorBufferPressed, 0*6, (float)mButtonDimensions.x, (float)mButtonDimensions.y, (float) mpButtonPressedSizeList[0].width, (float) mpButtonPressedSizeList[0].height, mpUVCoords_pressed[2*0], mpUVCoords_pressed[2*0+1] );
AddQuadIntoMirrorBuffer(mpMirrorBufferPressed, 1*6, (float)mButtonDimensions.x, (float)mButtonDimensions.y+mSmallestTopSizePressed, (float) mpButtonPressedSizeList[1].width, (float) middleHeight, mpUVCoords_pressed[2*1], mpUVCoords_pressed[2*1+1] );
mpButtonPressedSizeList[1].height = middleHeight;
AddQuadIntoMirrorBuffer(mpMirrorBufferPressed, 2*6, (float)mButtonDimensions.x, (float)mButtonDimensions.y+mSmallestTopSizePressed+middleHeight, (float) mpButtonPressedSizeList[2].width, (float) mpButtonPressedSizeList[2].height, mpUVCoords_pressed[2*2], mpUVCoords_pressed[2*2+1] );
// middle
AddQuadIntoMirrorBuffer(mpMirrorBufferPressed, 3*6, (float)mButtonDimensions.x+mSmallestLeftSizePressed, (float)mButtonDimensions.y, (float) middleWidth, (float) mpButtonPressedSizeList[3].height, mpUVCoords_pressed[2*3], mpUVCoords_pressed[2*3+1] );
mpButtonPressedSizeList[3].width = middleWidth;
AddQuadIntoMirrorBuffer(mpMirrorBufferPressed, 4*6, (float)mButtonDimensions.x+mSmallestLeftSizePressed, (float)mButtonDimensions.y+mSmallestTopSizePressed, (float) middleWidth, (float) middleHeight, mpUVCoords_pressed[2*4], mpUVCoords_pressed[2*4+1] );
mpButtonPressedSizeList[4].width = middleWidth;
mpButtonPressedSizeList[4].height = middleHeight;
AddQuadIntoMirrorBuffer(mpMirrorBufferPressed, 5*6, (float)mButtonDimensions.x+mSmallestLeftSizePressed, (float)mButtonDimensions.y+mSmallestTopSizePressed+middleHeight, (float) middleWidth, (float) mpButtonPressedSizeList[5].height, mpUVCoords_pressed[2*5], mpUVCoords_pressed[2*5+1] );
mpButtonPressedSizeList[5].width = middleWidth;
// right
AddQuadIntoMirrorBuffer(mpMirrorBufferPressed, 6*6, (float)mButtonDimensions.x+mSmallestLeftSizePressed+middleWidth, (float)mButtonDimensions.y, (float) mpButtonPressedSizeList[6].width, (float) mpButtonPressedSizeList[6].height, mpUVCoords_pressed[2*6], mpUVCoords_pressed[2*6+1] );
AddQuadIntoMirrorBuffer(mpMirrorBufferPressed, 7*6, (float)mButtonDimensions.x+mSmallestLeftSizePressed+middleWidth, (float)mButtonDimensions.y+mSmallestTopSizePressed, (float) mpButtonPressedSizeList[7].width, (float) middleHeight, mpUVCoords_pressed[2*7], mpUVCoords_pressed[2*7+1] );
mpButtonPressedSizeList[7].height = middleHeight;
AddQuadIntoMirrorBuffer(mpMirrorBufferPressed, 8*6, (float)mButtonDimensions.x+mSmallestLeftSizePressed+middleWidth, (float)mButtonDimensions.y+mSmallestTopSizePressed+middleHeight, (float) mpButtonPressedSizeList[8].width, (float) mpButtonPressedSizeList[8].height, mpUVCoords_pressed[2*8], mpUVCoords_pressed[2*8+1] );
// Disabled button quads
// left
AddQuadIntoMirrorBuffer(mpMirrorBufferDisabled, 0*6, (float)mButtonDimensions.x, (float)mButtonDimensions.y, (float) mpButtonDisabledSizeList[0].width, (float) mpButtonDisabledSizeList[0].height, mpUVCoords_disabled[2*0], mpUVCoords_disabled[2*0+1] );
AddQuadIntoMirrorBuffer(mpMirrorBufferDisabled, 1*6, (float)mButtonDimensions.x, (float)mButtonDimensions.y+mSmallestTopSizePressed, (float) mpButtonDisabledSizeList[1].width, (float) middleHeight, mpUVCoords_disabled[2*1], mpUVCoords_disabled[2*1+1] );
mpButtonDisabledSizeList[1].height = middleHeight;
AddQuadIntoMirrorBuffer(mpMirrorBufferDisabled, 2*6, (float)mButtonDimensions.x, (float)mButtonDimensions.y+mSmallestTopSizePressed+middleHeight, (float) mpButtonDisabledSizeList[2].width, (float) mpButtonDisabledSizeList[2].height, mpUVCoords_disabled[2*2], mpUVCoords_disabled[2*2+1] );
// middle
AddQuadIntoMirrorBuffer(mpMirrorBufferDisabled, 3*6, (float)mButtonDimensions.x+mSmallestLeftSizePressed, (float)mButtonDimensions.y, (float) middleWidth, (float) mpButtonDisabledSizeList[3].height, mpUVCoords_disabled[2*3], mpUVCoords_disabled[2*3+1] );
mpButtonDisabledSizeList[3].width = middleWidth;
AddQuadIntoMirrorBuffer(mpMirrorBufferDisabled, 4*6, (float)mButtonDimensions.x+mSmallestLeftSizePressed, (float)mButtonDimensions.y+mSmallestTopSizePressed, (float) middleWidth, (float) middleHeight, mpUVCoords_disabled[2*4], mpUVCoords_disabled[2*4+1] );
mpButtonDisabledSizeList[4].width = middleWidth;
mpButtonDisabledSizeList[4].height = middleHeight;
AddQuadIntoMirrorBuffer(mpMirrorBufferDisabled, 5*6, (float)mButtonDimensions.x+mSmallestLeftSizePressed, (float)mButtonDimensions.y+mSmallestTopSizePressed+middleHeight, (float) middleWidth, (float) mpButtonDisabledSizeList[5].height, mpUVCoords_disabled[2*5], mpUVCoords_disabled[2*5+1] );
mpButtonDisabledSizeList[5].width = middleWidth;
// right
AddQuadIntoMirrorBuffer(mpMirrorBufferDisabled, 6*6, (float)mButtonDimensions.x+mSmallestLeftSizePressed+middleWidth, (float)mButtonDimensions.y, (float) mpButtonDisabledSizeList[6].width, (float) mpButtonDisabledSizeList[6].height, mpUVCoords_disabled[2*6], mpUVCoords_disabled[2*6+1] );
AddQuadIntoMirrorBuffer(mpMirrorBufferDisabled, 7*6, (float)mButtonDimensions.x+mSmallestLeftSizePressed+middleWidth, (float)mButtonDimensions.y+mSmallestTopSizePressed, (float) mpButtonDisabledSizeList[7].width, (float) middleHeight, mpUVCoords_disabled[2*7], mpUVCoords_disabled[2*7+1] );
mpButtonDisabledSizeList[7].height = middleHeight;
AddQuadIntoMirrorBuffer(mpMirrorBufferDisabled, 8*6, (float)mButtonDimensions.x+mSmallestLeftSizePressed+middleWidth, (float)mButtonDimensions.y+mSmallestTopSizePressed+middleHeight, (float) mpButtonDisabledSizeList[8].width, (float) mpButtonDisabledSizeList[8].height, mpUVCoords_disabled[2*8], mpUVCoords_disabled[2*8+1] );
// Mark this control as 'dirty' for drawing and inform the gui system that
// it needs to re-calculate it's drawing buffer
mControlGraphicsDirty = true;
}
return CPUT_SUCCESS;
}
// This generates a quad with the supplied coordinates/uv's/etc.
//------------------------------------------------------------------------
void CPUTButton::AddQuadIntoMirrorBuffer(CPUTGUIVertex *pMirrorBuffer,
int index,
float x,
float y,
float w,
float h,
float3 uv1,
float3 uv2 )
{
CPUTColor4 color;
color.r = 1.0f;color.g = 1.0f;color.b = 1.0f;color.a = 1.0f;
pMirrorBuffer[index+0].Pos = float3( x + 0.0f, y + 0.0f, 1.0f);
pMirrorBuffer[index+0].UV = float2(uv1.x, uv1.y);
pMirrorBuffer[index+0].Color = color;
pMirrorBuffer[index+1].Pos = float3( x + w, y + 0.0f, 1.0f);
pMirrorBuffer[index+1].UV = float2(uv2.x, uv1.y);
pMirrorBuffer[index+1].Color = color;
pMirrorBuffer[index+2].Pos = float3( x + 0.0f, y + h, 1.0f);
pMirrorBuffer[index+2].UV = float2(uv1.x, uv2.y);
pMirrorBuffer[index+2].Color = color;
pMirrorBuffer[index+3].Pos = float3( x + w, y + 0.0f, 1.0f);
pMirrorBuffer[index+3].UV = float2(uv2.x, uv1.y);
pMirrorBuffer[index+3].Color = color;
pMirrorBuffer[index+4].Pos = float3( x + w, y + h, 1.0f);
pMirrorBuffer[index+4].UV = float2(uv2.x, uv2.y);
pMirrorBuffer[index+4].Color = color;
pMirrorBuffer[index+5].Pos = float3( x + 0.0f, y +h, 1.0f);
pMirrorBuffer[index+5].UV = float2(uv1.x, uv2.y);
pMirrorBuffer[index+5].Color = color;
}
================================================
FILE: CPUT/CPUT/CPUTButton.h
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#ifndef __CPUTBUTTON_H__
#define __CPUTBUTTON_H__
#include "CPUTControl.h"
#include <string.h>
#include "CPUTGuiController.h"
// forward declarations
class CPUTFont;
class CPUTText;
// default padding between controls
#define CPUT_BUTTON_TEXT_BORDER_PADDING_X 15
#define CPUT_BUTTON_TEXT_BORDER_PADDING_Y 5
typedef enum CPUTButtonState
{
CPUT_BUTTON_NEUTRAL,
CPUT_BUTTON_PRESSED,
} CPUTButtonState;
const int CPUT_NUM_IMAGES_IN_BUTTON=9;
const int CPUT_NUM_VERTS_IN_BUTTON_QUAD=6;
// Button base - common functionality for the control
//-----------------------------------------------------------------------------
class CPUTButton:public CPUTControl
{
public:
// constructors
CPUTButton(CPUTButton& copy); // don't allow copy construction
CPUTButton(const cString ControlText, CPUTControlID id, CPUTFont *pFont);
virtual ~CPUTButton();
// CPUTControl
virtual void GetPosition(int &x, int &y);
virtual void GetDimensions(int &width, int &height);
virtual bool ContainsPoint(int x, int y);
virtual void SetPosition(int x, int y);
virtual void SetText(const cString String);
virtual void GetText(cString &String);
virtual unsigned int GetOutputVertexCount();
virtual void SetEnable(bool in_bEnabled);
//CPUTEventHandler
virtual CPUTEventHandledCode HandleKeyboardEvent(CPUTKey key);
virtual CPUTEventHandledCode HandleMouseEvent(int x, int y, int wheel, CPUTMouseState state);
// Register assets
static CPUTResult RegisterStaticResources();
static CPUTResult UnRegisterStaticResources();
CPUTResult RegisterInstanceResources();
CPUTResult UnRegisterInstanceResources();
// draw
virtual void DrawIntoBuffer(CPUTGUIVertex *pVertexBufferMirror, UINT *pInsertIndex, UINT pMaxBufferSize, CPUTGUIVertex *pTextVertexBufferMirror, UINT *pTextInsertIndex, UINT MaxTextVertexBufferSize);
protected:
CPUT_RECT mButtonDimensions;
CPUTButtonState mButtonState;
// helper functions
// control state
bool mbMouseInside;
bool mbStartedClickInside;
CPUTFont *mpFont;
// Static resources
static bool mStaticRegistered;
// sizes of unmodified button graphics
static CPUT_SIZE mpButtonIdleImageSizeList[CPUT_NUM_IMAGES_IN_BUTTON];
static CPUT_SIZE mpButtonPressedImageSizeList[CPUT_NUM_IMAGES_IN_BUTTON];
static CPUT_SIZE mpButtonDisabledImageSizeList[CPUT_NUM_IMAGES_IN_BUTTON];
static int mSmallestLeftSizeIdle;
static int mSmallestRightSizeIdle;
static int mSmallestTopSizeIdle;
static int mSmallestBottomSizeIdle;
static int mSmallestLeftSizePressed;
static int mSmallestRightSizePressed;
static int mSmallestTopSizePressed;
static int mSmallestBottomSizePressed;
static int mSmallestLeftSizeDisabled;
static int mSmallestRightSizeDisabled;
static int mSmallestTopSizeDisabled;
static int mSmallestBottomSizeDisabled;
// per-instance information
CPUTText *mpButtonText;
CPUT_SIZE mpButtonIdleSizeList[CPUT_NUM_IMAGES_IN_BUTTON];
CPUT_SIZE mpButtonPressedSizeList[CPUT_NUM_IMAGES_IN_BUTTON];
CPUT_SIZE mpButtonDisabledSizeList[CPUT_NUM_IMAGES_IN_BUTTON];
CPUTGUIVertex *mpMirrorBufferActive;
CPUTGUIVertex *mpMirrorBufferPressed;
CPUTGUIVertex *mpMirrorBufferDisabled;
// helper functions
void InitializeState();
void SetDimensions(int width, int height);
CPUTResult Resize(int width, int height);
void AddQuadIntoMirrorBuffer(CPUTGUIVertex *pMirrorBuffer, int index, float x, float y, float w, float h, float3 uv1, float3 uv2 );
void GetInsetTextCoordinate(int &x, int &y);
};
#endif //#ifndef __CPUTBUTTON_H__
================================================
FILE: CPUT/CPUT/CPUTCallbackHandler.h
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#ifndef __CPUTCALLBACKHANDLER_H__
#define __CPUTCALLBACKHANDLER_H__
#include "CPUT.h"
#include "CPUTControl.h"
//forward declarations
class CPUTControl;
typedef unsigned int UINT;
typedef UINT CPUTControlID;
typedef UINT CPUTEventID;
#define UNREFERENCED_PARAMETER(P) (P)
class CPUTCallbackHandler
{
public:
virtual void HandleCallbackEvent( CPUTEventID Event, CPUTControlID ControlID, CPUTControl *pControl ) {UNREFERENCED_PARAMETER(Event);UNREFERENCED_PARAMETER(ControlID);UNREFERENCED_PARAMETER(pControl);}
};
#endif // #ifndef __CPUTCALLBACKHANDLER_H__
================================================
FILE: CPUT/CPUT/CPUTCamera.cpp
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#include "CPUTCamera.h"
#include "CPUTFrustum.h"
// Constructor
//-----------------------------------------------------------------------------
CPUTCamera::CPUTCamera() :
mFov(45.0f * 3.14159265f/180.0f),
mNearPlaneDistance(1.0f),
mFarPlaneDistance(100.0f),
mAspectRatio(16.0f/9.0f)
{
// default maya position (roughly)
SetPosition( 1.0f, 0.8f, 1.0f );
}
// Load
//-----------------------------------------------------------------------------
CPUTResult CPUTCamera::LoadCamera(CPUTConfigBlock *pBlock, int *pParentID)
{
// TODO: Have render node load common properties.
CPUTResult result = CPUT_SUCCESS;
mName = pBlock->GetValueByName(_L("name"))->ValueAsString();
*pParentID = pBlock->GetValueByName(_L("parent"))->ValueAsInt();
mFov = pBlock->GetValueByName(_L("FieldOfView"))->ValueAsFloat();
mFov *= (3.14159265f/180.0f);
mNearPlaneDistance = pBlock->GetValueByName(_L("NearPlane"))->ValueAsFloat();
mFarPlaneDistance = pBlock->GetValueByName(_L("FarPlane"))->ValueAsFloat();
LoadParentMatrixFromParameterBlock( pBlock );
return result;
}
//-----------------------------------------------------------------------------
void CPUTCamera::SetAspectRatio(const float aspectRatio)
{
mAspectRatio = aspectRatio;
}
//-----------------------------------------------------------------------------
void CPUTCamera::LookAt( float xx, float yy, float zz )
{
float3 pos;
GetPosition( &pos);
float3 lookPoint(xx, yy, zz);
float3 look = (lookPoint - pos).normalize();
float3 right = cross3(float3(0.0f,1.0f,0.0f), look).normalize(); // TODO: simplicy algebraically
float3 up = cross3(look, right);
mParentMatrix = float4x4(
right.x, right.y, right.z, 0.0f,
up.x, up.y, up.z, 0.0f,
look.x, look.y, look.z, 0.0f,
pos.x, pos.y, pos.z, 1.0f
);
}
//-----------------------------------------------------------------------------
void CPUTCamera::SetFov(const float fov)
{
mFov = fov;
}
#define KEY_DOWN(vk) ((GetAsyncKeyState(vk) & 0x8000)?1:0)
//-----------------------------------------------------------------------------
void CPUTCameraControllerFPS::Update(float deltaSeconds)
{
float speed = mfMoveSpeed * deltaSeconds;
speed *= KEY_DOWN( VK_LSHIFT ) ? 10.0f : KEY_DOWN( VK_LCONTROL) ? 0.1f : 1.0f;
float4x4 *pParentMatrix = mpCamera->GetParentMatrix();
float3 vRight(pParentMatrix->getXAxis());
float3 vUp(pParentMatrix->getYAxis());
float3 vLook(pParentMatrix->getZAxis());
float3 vPositionDelta(0.0f);
if(CPUTOSServices::GetOSServices()->DoesWindowHaveFocus())
{
if(KEY_DOWN('W')) { vPositionDelta += vLook * speed;}
if(KEY_DOWN('A')) { vPositionDelta += vRight * -speed;}
if(KEY_DOWN('S')) { vPositionDelta += vLook * -speed;}
if(KEY_DOWN('D')) { vPositionDelta += vRight * speed;}
if(KEY_DOWN('E')) { vPositionDelta += vUp * speed;}
if(KEY_DOWN('Q')) { vPositionDelta += vUp * -speed;}
}
float x,y,z;
mpCamera->GetPosition( &x, &y, &z );
mpCamera->SetPosition( x+vPositionDelta.x, y+vPositionDelta.y, z+vPositionDelta.z );
mpCamera->Update();
}
//-----------------------------------------------------------------------------
CPUTEventHandledCode CPUTCameraControllerFPS::HandleMouseEvent(
int x,
int y,
int wheel,
CPUTMouseState state
)
{
if(state & CPUT_MOUSE_LEFT_DOWN)
{
float3 position = mpCamera->GetPosition();
if(!(mPrevFrameState & CPUT_MOUSE_LEFT_DOWN)) // Mouse was just clicked
{
mnPrevFrameX = x;
mnPrevFrameY = y;
}
float nDeltaX = (float)(x-mnPrevFrameX);
float nDeltaY = (float)(y-mnPrevFrameY);
float4x4 rotationX = float4x4RotationX(nDeltaY*mfLookSpeed);
float4x4 rotationY = float4x4RotationY(nDeltaX*mfLookSpeed);
mpCamera->SetPosition(0.0f, 0.0f, 0.0f); // Rotate about camera center
float4x4 parent = *mpCamera->GetParentMatrix();
float4x4 orientation = rotationX *parent * rotationY;
orientation.orthonormalize();
mpCamera->SetParentMatrix( orientation );
mpCamera->SetPosition( position.x, position.y, position.z ); // Move back to original position
mpCamera->Update();
mnPrevFrameX = x;
mnPrevFrameY = y;
mPrevFrameState = state;
return CPUT_EVENT_HANDLED;
} else
{
mPrevFrameState = state;
return CPUT_EVENT_UNHANDLED;
}
}
//-----------------------------------------------------------------------------
CPUTEventHandledCode CPUTCameraControllerArcBall::HandleMouseEvent(
int x,
int y,
int wheel,
CPUTMouseState state
)
{
// TODO: We want move-in-x to orbit light in view space, not object space.
if(state & CPUT_MOUSE_RIGHT_DOWN) // TODO: How to make this flexible? Want to choose which mouse button has effect.
{
float4x4 rotationX, rotationY;
if(!(mPrevFrameState & CPUT_MOUSE_RIGHT_DOWN)) // Mouse was just clicked
{
mnPrevFrameX = x;
mnPrevFrameY = y;
}
int nDeltaX = x-mnPrevFrameX;
int nDeltaY = y-mnPrevFrameY;
rotationY = float4x4RotationX(nDeltaY*mfLookSpeed);
rotationX = float4x4RotationY(nDeltaX*mfLookSpeed);
float4x4 orientation = *mpCamera->GetParentMatrix() * rotationY * rotationX;
orientation.orthonormalize();
mpCamera->SetParentMatrix( orientation );
mnPrevFrameX = x;
mnPrevFrameY = y;
mPrevFrameState = state;
return CPUT_EVENT_HANDLED;
} else
{
mPrevFrameState = state;
return CPUT_EVENT_UNHANDLED;
}
}
================================================
FILE: CPUT/CPUT/CPUTCamera.h
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#ifndef __CPUTCamera_H__
#define __CPUTCamera_H__
#include <memory.h>
#include <Windows.h>
#include "CPUT.h"
#include "CPUTRenderNode.h"
#include "CPUTConfigBlock.h"
#include "CPUTFrustum.h"
//-----------------------------------------------------------------------------
class CPUTCamera:public CPUTRenderNode
{
protected:
float mFov; // the field of view in degrees
float mNearPlaneDistance; // near plane distance
float mFarPlaneDistance; // far plane distance
float mAspectRatio; // width/height. TODO: Support separate pixel and viewport aspect ratios
float4x4 mView;
float4x4 mProjection;
public:
CPUTFrustum mFrustum;
CPUTCamera();
~CPUTCamera() {}
void Update( float deltaSeconds=0.0f ) {
// TODO: Do only if required (i.e. if dirty)
mProjection = float4x4PerspectiveFovLH( mFov, mAspectRatio, mFarPlaneDistance, mNearPlaneDistance );
mView = inverse(*GetWorldMatrix());
mFrustum.InitializeFrustum(this);
};
CPUTResult LoadCamera(CPUTConfigBlock *pBlock, int *pParentID);
float4x4 *GetViewMatrix(void)
{
// Update(); We can't afford to do this every time we're asked for the view matrix. Caller needs to make sure camera is updated before entering render loop.
return &mView;
}
const float4x4* GetProjectionMatrix(void) const { return &mProjection; }
void SetProjectionMatrix(const float4x4 &projection) { mProjection = projection; }
float GetAspectRatio() { return mAspectRatio; }
float GetFov() { return mFov; }
void SetAspectRatio(const float aspectRatio);
void SetFov( const float fov );
float GetNearPlaneDistance() { return mNearPlaneDistance; }
float GetFarPlaneDistance() { return mFarPlaneDistance; }
void SetNearPlaneDistance( const float nearPlaneDistance ) { mNearPlaneDistance = nearPlaneDistance; }
void SetFarPlaneDistance( const float farPlaneDistance ) { mFarPlaneDistance = farPlaneDistance; }
void LookAt( float xx, float yy, float zz );
};
//-----------------------------------------------------------------------------
class CPUTCameraController : public CPUTEventHandler
{
protected:
CPUTRenderNode *mpCamera;
float mfMoveSpeed;
float mfLookSpeed;
int mnPrevFrameX;
int mnPrevFrameY;
CPUTMouseState mPrevFrameState;
public:
CPUTCameraController()
: mpCamera(NULL)
, mnPrevFrameX(0)
, mnPrevFrameY(0)
, mfMoveSpeed(1.0f)
, mfLookSpeed(1.0f)
{
}
~CPUTCameraController(){ SAFE_RELEASE(mpCamera);}
void SetCamera(CPUTRenderNode *pCamera) { SAFE_RELEASE(mpCamera); mpCamera = pCamera; pCamera->AddRef(); }
CPUTRenderNode *GetCamera(void) const { return mpCamera; }
void SetMoveSpeed(float speed) { mfMoveSpeed = speed; }
void SetLookSpeed(float speed) { mfLookSpeed = speed; }
virtual void Update(float deltaSeconds=0.0f) = 0;
};
// TODO: Move these implementations to the .cpp file.
//-----------------------------------------------------------------------------
class CPUTCameraControllerFPS : public CPUTCameraController
{
public:
void Update( float deltaSeconds=0.0f);
// TODO: Change to Update(deltaSeconds) and IsKeyDown()
CPUTEventHandledCode HandleKeyboardEvent(CPUTKey key) { return CPUT_EVENT_UNHANDLED; }
CPUTEventHandledCode HandleMouseEvent(int x, int y, int wheel, CPUTMouseState state);
};
//-----------------------------------------------------------------------------
class CPUTCameraControllerArcBall : public CPUTCameraController
{
public:
void Update( float deltaSeconds=0.0f ) {}
CPUTEventHandledCode HandleKeyboardEvent(CPUTKey key) { return CPUT_EVENT_UNHANDLED; }
CPUTEventHandledCode HandleMouseEvent(int x, int y, int wheel, CPUTMouseState state);
};
#endif //#ifndef __CPUTCamera_H__
================================================
FILE: CPUT/CPUT/CPUTCheckbox.cpp
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#include "CPUTCheckbox.h"
#include "CPUTGuiController.h"
#include "CPUTText.h"
CPUT_SIZE CPUTCheckbox::mpCheckboxTextureSizeList[CPUT_CHECKBOX_NUM_IMAGES_IN_CHECKBOX] = { {0,0},{0,0},{0,0} };
// texture atlas information
float gAtlasWidthCheckbox = 256.0f;
float gAtlasHeightCheckbox = 64.0f;
// Pixel coordinates of the active-idle button image within the texture atlas
int gUVLocationsCheckbox_active[] = {
109,3, // tl
124,3, // tr
109,17, // bl
124,17 // br
};
// Pixel coordinates of the pressed button image within the texture atlas
int gUVLocationsCheckbox_pressed[] = {
109,20, // tl
124,20, // tr
109,35, // bl
124,35 // br
};
// Pixel coordinates of the disabled button image within the texture atlas
int gUVLocationsCheckbox_disabled[] = {
109,39, // tl
124,39, // tr
109,54, // bl
124,54 // br
};
// Floating point 0.0f - 1.0f UV coordinates in the texture atlas for each corner of the image
float3 mpUVCoordsCheckbox_active[4];
float3 mpUVCoordsCheckbox_pressed[4];
float3 mpUVCoordsCheckbox_disabled[4];
// Constructor
//-----------------------------------------------------------------------------
CPUTCheckbox::CPUTCheckbox(const cString ControlText, CPUTControlID id, CPUTFont *pFont):
mbMouseInside(false),
mbStartedClickInside(false),
mVertexStride(0),
mVertexOffset(0),
mpCheckboxText(NULL),
mpFont(pFont)
{
// initialize the state variables
InitialStateSet();
// save the control ID for callbacks
mcontrolID = id;
// store the font to be used by this control
mpFont = pFont;
// set as enabled
CPUTControl::SetEnable(true);
// register all the instance resources
RegisterInstanceResources();
// set the control's text string
SetText(ControlText);
}
// Initial state of the control's member variables
//-----------------------------------------------------------------------------
void CPUTCheckbox::InitialStateSet()
{
// state
mcontrolType = CPUT_CHECKBOX;
mControlState = CPUT_CONTROL_ACTIVE;
mCheckboxState = CPUT_CHECKBOX_UNCHECKED;
mCheckboxGuiState = CPUT_CHECKBOX_GUI_NEUTRAL;
// control ID
mcontrolID = 0;
// size
mControlDimensions.x=0;
mControlDimensions.y=0;
mControlDimensions.height=0;
mControlDimensions.width=0;
// default label
SetText(_L("checkbox"));
}
// Destructor
//------------------------------------------------------------------------------
CPUTCheckbox::~CPUTCheckbox()
{
UnRegisterInstanceResources();
}
// Get the x/y window position of this control
//-----------------------------------------------------------------------------
void CPUTCheckbox::GetPosition(int &x, int &y)
{
x = mControlDimensions.x;
y = mControlDimensions.y;
}
// Get checkbox selection state
//-----------------------------------------------------------------------------
CPUTCheckboxState CPUTCheckbox::GetCheckboxState()
{
return mCheckboxState;
}
// Set checkbox selection state
//-----------------------------------------------------------------------------
void CPUTCheckbox::SetCheckboxState(CPUTCheckboxState State)
{
// if state changed, save it, and recalculate the control
if(State != mCheckboxState)
{
mCheckboxState = State;
Recalculate();
}
}
// Returns the number of quads needed to draw this control
//--------------------------------------------------------------------------------
unsigned int CPUTCheckbox::GetOutputVertexCount()
{
// A checkbox is always made of 1 quad.
//
// ---
// | 1 |
// ---
// Calculation: 3 quads/triangle * 2 triangles/quad * 1 quad
return 3*2;
}
// Register assets
//-----------------------------------------------------------------------------
CPUTResult CPUTCheckbox::RegisterStaticResources()
{
// calculate the floating point, 0.0f - 1.0f, UV coordinates of each of the 9 images that
// make up a button. Do this for the active, pressed, and disabled states.
for(int ii=0; ii<4; ii++)
{
mpUVCoordsCheckbox_active[ii].x = gUVLocationsCheckbox_active[2*ii]/gAtlasWidthCheckbox;
mpUVCoordsCheckbox_active[ii].y = gUVLocationsCheckbox_active[2*ii+1]/gAtlasHeightCheckbox;
mpUVCoordsCheckbox_pressed[ii].x = gUVLocationsCheckbox_pressed[2*ii]/gAtlasWidthCheckbox;
mpUVCoordsCheckbox_pressed[ii].y = gUVLocationsCheckbox_pressed[2*ii+1]/gAtlasHeightCheckbox;
mpUVCoordsCheckbox_disabled[ii].x = gUVLocationsCheckbox_disabled[2*ii]/gAtlasWidthCheckbox;
mpUVCoordsCheckbox_disabled[ii].y = gUVLocationsCheckbox_disabled[2*ii+1]/gAtlasHeightCheckbox;
}
// calculate the width/height in pixels of each of the image slices
// that makes up the checkbox images
mpCheckboxTextureSizeList[0].width = gUVLocationsCheckbox_active[2] - gUVLocationsCheckbox_active[0];
mpCheckboxTextureSizeList[0].height = gUVLocationsCheckbox_active[5] - gUVLocationsCheckbox_active[1];
mpCheckboxTextureSizeList[1].width = gUVLocationsCheckbox_pressed[2] - gUVLocationsCheckbox_pressed[0];
mpCheckboxTextureSizeList[1].height = gUVLocationsCheckbox_pressed[5] - gUVLocationsCheckbox_pressed[1];
mpCheckboxTextureSizeList[2].width = gUVLocationsCheckbox_disabled[2] - gUVLocationsCheckbox_disabled[0];
mpCheckboxTextureSizeList[2].height = gUVLocationsCheckbox_disabled[5] - gUVLocationsCheckbox_disabled[1];
return CPUT_SUCCESS;
}
// Release all static resources - only do this if NO more checkbox controls
// are used anywhere on the system
//-----------------------------------------------------------------------------
CPUTResult CPUTCheckbox::UnRegisterStaticResources()
{
return CPUT_SUCCESS;
}
// Register any per-instance resources for this checkbox
//-----------------------------------------------------------------------------
CPUTResult CPUTCheckbox::RegisterInstanceResources()
{
return CPUT_SUCCESS;
}
// Unregister the checkbox's instance resources
//-----------------------------------------------------------------------------
CPUTResult CPUTCheckbox::UnRegisterInstanceResources()
{
// delete the static text object
SAFE_DELETE(mpCheckboxText);
return CPUT_SUCCESS;
}
//CPUTEventHandler
// Handle keyboard events - none for this control
//--------------------------------------------------------------------------------
CPUTEventHandledCode CPUTCheckbox::HandleKeyboardEvent(CPUTKey key)
{
UNREFERENCED_PARAMETER(key);
return CPUT_EVENT_UNHANDLED;
}
// Handle mouse events
//-----------------------------------------------------------------------------
CPUTEventHandledCode CPUTCheckbox::HandleMouseEvent(int x, int y, int wheel, CPUTMouseState state)
{
UNREFERENCED_PARAMETER(wheel);
CPUTEventHandledCode handledCode = CPUT_EVENT_UNHANDLED;
if((CPUT_CONTROL_INACTIVE == mControlState) || (false == mControlVisible) )
{
mbMouseInside = false;
return handledCode;
}
// if we're continuing to be pressed, move around with the mouse movement
//(CPUT_CONTROL_PRESSED == mControlState )
if( (CPUT_CHECKBOX_GUI_PRESSED == mCheckboxGuiState) && (CPUT_MOUSE_LEFT_DOWN == state))
{
return CPUT_EVENT_HANDLED;
}
// handle events occuring in the control
if( ContainsPoint(x,y) )
{
// did we start our click inside the button?
if((state & CPUT_MOUSE_LEFT_DOWN) && (true == mbMouseInside))
{
mbStartedClickInside = true;
mCheckboxGuiState = CPUT_CHECKBOX_GUI_PRESSED;
handledCode = CPUT_EVENT_HANDLED;
// tell gui system this control image is now dirty
// and needs to rebuild it's draw list
mControlGraphicsDirty = true;
}
// did they click inside the button?
if(!(state & CPUT_MOUSE_LEFT_DOWN) && (true == mbStartedClickInside) && (CPUT_CHECKBOX_GUI_PRESSED == mCheckboxGuiState))
{
// set the GUI/mouse controller states
handledCode = CPUT_EVENT_HANDLED;
mCheckboxGuiState = CPUT_CHECKBOX_GUI_NEUTRAL;
// toggle the checkbox state
if(CPUT_CHECKBOX_UNCHECKED == mCheckboxState)
{
mCheckboxState = CPUT_CHECKBOX_CHECKED;
}
else if(CPUT_CHECKBOX_CHECKED == mCheckboxState)
{
mCheckboxState = CPUT_CHECKBOX_UNCHECKED;
}
// trigger the users callback
mpCallbackHandler->HandleCallbackEvent(1, mcontrolID, (CPUTControl*) this);
// tell gui system this control image is now dirty
// and needs to rebuild it's draw list
mControlGraphicsDirty = true;
}
if(!(state & CPUT_MOUSE_LEFT_DOWN))
{
mbMouseInside = true;
}
}
else
{
// we left the button
mbMouseInside = false;
mCheckboxGuiState = CPUT_CHECKBOX_GUI_NEUTRAL;
mbStartedClickInside = false;
}
return handledCode;
}
//CPUTControl
// set the upper-left position of the checkbox control (screen space coords)
//-----------------------------------------------------------------------------
void CPUTCheckbox::SetPosition(int x, int y)
{
// set the new position
mControlDimensions.x = x;
mControlDimensions.y = y;
// recalculate the vertex buffer with new x/y coords
Recalculate();
// move the static text along with the bitmap graphic
int textX, textY;
GetTextPosition(textX, textY);
mpCheckboxText->SetPosition(textX, textY);
}
//-----------------------------------------------------------------------------
void CPUTCheckbox::GetDimensions(int &width, int &height)
{
CalculateBounds();
width = mControlDimensions.width;
height = mControlDimensions.height;
}
// Get the text label on this checkbox
//--------------------------------------------------------------------------------
void CPUTCheckbox::GetText(cString &TextString)
{
if(mpCheckboxText)
{
mpCheckboxText->GetString(TextString);
}
}
// Sets the text label on this checkbox
//--------------------------------------------------------------------------------
void CPUTCheckbox::SetText(const cString String)
{
// create the static text object if it doesn't exist
if(NULL == mpCheckboxText)
{
mpCheckboxText = new CPUTText(mpFont);
}
// set the static control's text
mpCheckboxText->SetText(String);
// move the text to the right spot
int x,y;
GetTextPosition(x,y);
mpCheckboxText->SetPosition(x, y);
// position or size may move - force a recalculation of this control's location
// if it is managed by the auto-arrange function
if(this->IsAutoArranged())
{
mControlNeedsArrangmentResizing = true;
}
else
{
// control graphics have been updated
mControlGraphicsDirty = true;
}
}
// Enable/disable the control
//--------------------------------------------------------------------------------
void CPUTCheckbox::SetEnable(bool in_bEnabled)
{
// chain to CPUTControl
CPUTControl::SetEnable(in_bEnabled);
// set the control's text to match
mpCheckboxText->SetEnable(in_bEnabled);
// recalculate control's quads
Recalculate();
}
// With the given window x/y coordinate, is that point in this control
//-----------------------------------------------------------------------------
bool CPUTCheckbox::ContainsPoint(int x, int y)
{
if( (x>mControlDimensions.x) && (y>mControlDimensions.y) &&
(x< (mControlDimensions.x+mControlDimensions.width)) && (y< (mControlDimensions.y+mControlDimensions.height))
)
{
return true;
}
return false;
}
// Calculate the bounding rectangle for the control
// For the checkbox it includes the checkbox image and the text
//-----------------------------------------------------------------------------
void CPUTCheckbox::CalculateBounds()
{
int textX, textY;
int textWidth, textHeight;
// get the text
GetTextPosition(textX, textY);
mpCheckboxText->GetDimensions(textWidth, textHeight);
mControlDimensions.width = (textX - mControlDimensions.x ) + textWidth;
mControlDimensions.height = textHeight;
if(mpCheckboxTextureSizeList[0].height > textHeight)
{
mControlDimensions.height = mpCheckboxTextureSizeList[0].height;
}
}
// Calculate the correct location to place the text label - usually to the
// right of the image allowing for spacing/image/etc
//--------------------------------------------------------------------------------
void CPUTCheckbox::GetTextPosition(int &x, int &y)
{
// get the dimensions of the string in pixels
CPUT_RECT TextRect;
mpCheckboxText->GetDimensions(TextRect.width, TextRect.height);
// calculate a good spot for the text to be in relation to the checkbox bitmap
x = mControlDimensions.x + mpCheckboxTextureSizeList[0].width + CPUT_CHECKBOX_PADDING; // move right far enough not to overlap the bitmap
y = mControlDimensions.y + mpCheckboxTextureSizeList[0].height - TextRect.height; // try to center text top-to-bottom
}
// 'Draw' this control into the supplied vertex buffer object
//--------------------------------------------------------------------------------
void CPUTCheckbox::DrawIntoBuffer(CPUTGUIVertex *pVertexBufferMirror, UINT *pInsertIndex, UINT pMaxBufferSize, CPUTGUIVertex *pTextVertexBufferMirror, UINT *pTextInsertIndex, UINT MaxTextVertexBufferSize)
{
if(!mControlVisible)
{
return;
}
if((NULL==pVertexBufferMirror) || (NULL==pInsertIndex))
{
return;
}
// Do we have enough room to put this control into the output buffer?
int VertexCopyCount = GetOutputVertexCount();
ASSERT( (pMaxBufferSize >= *pInsertIndex + VertexCopyCount), _L("Too many CPUT GUI controls for allocated GUI buffer. Allocated GUI vertex buffer is too small.\n\nIncrease CPUT_GUI_BUFFER_SIZE size.") );
switch(mControlState)
{
case CPUT_CONTROL_ACTIVE:
// copy the active+idle button into the stream
if(CPUT_CHECKBOX_UNCHECKED == mCheckboxState)
{
memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBufferActive, sizeof(CPUTGUIVertex)*6);
}
// copy the pressed button into the stream
if(CPUT_CHECKBOX_CHECKED == mCheckboxState)
{
memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBufferPressed, sizeof(CPUTGUIVertex)*6);
}
break;
case CPUT_CONTROL_INACTIVE:
// copy the inactive button into the stream
memcpy(&pVertexBufferMirror[*pInsertIndex], mpMirrorBufferDisabled, sizeof(CPUTGUIVertex)*6);
break;
default:
// error! unknown state
ASSERT(0,_L("CPUTCheckbox: Control is in unknown state"));
return;
}
// move the index the correct number of floats to account
// for 1 new quad, each quad with 6 verts in it (and each vert with 3+2 floats in it).
*pInsertIndex+=6;
// now do the text
// draw the text
if(mpCheckboxText)
{
mpCheckboxText->DrawIntoBuffer(pTextVertexBufferMirror, pTextInsertIndex, MaxTextVertexBufferSize);
}
// we'll mark the control as no longer being 'dirty'
mControlGraphicsDirty = false;
}
// Recalculates the the control's image quads
//------------------------------------------------------------------------
void CPUTCheckbox::Recalculate()
{
// active/idle
AddQuadIntoMirrorBuffer(mpMirrorBufferActive,
(float) mControlDimensions.x, (float) mControlDimensions.y,
(float) mpCheckboxTextureSizeList[0].width, (float) mpCheckboxTextureSizeList[0].height,
mpUVCoordsCheckbox_active[0], mpUVCoordsCheckbox_active[3]
);
// pressed
AddQuadIntoMirrorBuffer(mpMirrorBufferPressed,
(float) mControlDimensions.x, (float)mControlDimensions.y,
(float) mpCheckboxTextureSizeList[1].width, (float) mpCheckboxTextureSizeList[1].height,
mpUVCoordsCheckbox_pressed[0], mpUVCoordsCheckbox_pressed[3]
);
// disabled
AddQuadIntoMirrorBuffer(mpMirrorBufferDisabled,
(float) mControlDimensions.x, (float) mControlDimensions.y,
(float) mpCheckboxTextureSizeList[2].width, (float) mpCheckboxTextureSizeList[2].height,
mpUVCoordsCheckbox_disabled[0], mpUVCoordsCheckbox_disabled[3]
);
// re-calculate the bounding box for the control used for hit-testing/sizing
CalculateBounds();
// Mark this control as 'dirty' for drawing and inform the gui system that
// it needs to re-calculate it's drawing buffer
mControlGraphicsDirty = true;
}
// This generates a quad with the supplied coordinates/uv's/etc.
//------------------------------------------------------------------------
void CPUTCheckbox::AddQuadIntoMirrorBuffer(CPUTGUIVertex *pMirrorBuffer,
float x,
float y,
float w,
float h,
float3 uv1,
float3 uv2 )
{
CPUTColor4 color;
color.r = 1.0f;color.g = 1.0f;color.b = 1.0f;color.a = 1.0f;
pMirrorBuffer[0].Pos = float3( x + 0.0f, y + 0.0f, 1.0f);
pMirrorBuffer[0].UV = float2(uv1.x, uv1.y);
pMirrorBuffer[0].Color = color;
pMirrorBuffer[1].Pos = float3( x + w, y + 0.0f, 1.0f);
pMirrorBuffer[1].UV = float2(uv2.x, uv1.y);
pMirrorBuffer[1].Color = color;
pMirrorBuffer[2].Pos = float3( x + 0.0f, y + h, 1.0f);
pMirrorBuffer[2].UV = float2(uv1.x, uv2.y);
pMirrorBuffer[2].Color = color;
pMirrorBuffer[3].Pos = float3( x + w, y + 0.0f, 1.0f);
pMirrorBuffer[3].UV = float2(uv2.x, uv1.y);
pMirrorBuffer[3].Color = color;
pMirrorBuffer[4].Pos = float3( x + w, y + h, 1.0f);
pMirrorBuffer[4].UV = float2(uv2.x, uv2.y);
pMirrorBuffer[4].Color = color;
pMirrorBuffer[5].Pos = float3( x + 0.0f, y +h, 1.0f);
pMirrorBuffer[5].UV = float2(uv1.x, uv2.y);
pMirrorBuffer[5].Color = color;
}
================================================
FILE: CPUT/CPUT/CPUTCheckbox.h
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#ifndef __CPUTCHECKBOX_H__
#define __CPUTCHECKBOX_H__
#include "CPUTControl.h"
#include "CPUTGuiController.h"
// forward declarations
class CPUTFont;
class CPUTText;
typedef enum CPUTCheckboxState
{
CPUT_CHECKBOX_UNCHECKED,
CPUT_CHECKBOX_CHECKED,
} CPUTCheckboxState;
typedef enum CPUTCheckboxGUIState
{
CPUT_CHECKBOX_GUI_NEUTRAL,
CPUT_CHECKBOX_GUI_PRESSED,
} CPUTCheckboxGUIState;
const int CPUT_CHECKBOX_NUM_IMAGES_IN_CHECKBOX=3;
const int CPUT_CHECKBOX_PADDING=5; // padding (in pixels) between checkbox image and the label
// Checkbox
//-----------------------------------------------------------------------------
class CPUTCheckbox:public CPUTControl
{
public:
// button should self-register with the GuiController on create
CPUTCheckbox(CPUTCheckbox& copy);
CPUTCheckbox(const cString ControlText, CPUTControlID id, CPUTFont *pFont);
virtual ~CPUTCheckbox();
// CPUTControl
virtual void GetPosition(int &x, int &y);
virtual unsigned int GetOutputVertexCount();
// CPUTCheckboxDX11
virtual CPUTCheckboxState GetCheckboxState();
void SetCheckboxState(CPUTCheckboxState State);
//CPUTEventHandler
virtual CPUTEventHandledCode HandleKeyboardEvent(CPUTKey key);
virtual CPUTEventHandledCode HandleMouseEvent(int x, int y, int wheel, CPUTMouseState state);
//CPUTControl
virtual bool ContainsPoint(int x, int y);
virtual void SetPosition(int x, int y);
virtual void GetDimensions(int &width, int &height);
virtual void SetText(const cString String);
virtual void GetText(cString &TextString);
virtual void SetEnable(bool bEnabled);
// Register assets
static CPUTResult RegisterStaticResources();
static CPUTResult UnRegisterStaticResources();
CPUTResult RegisterInstanceResources();
CPUTResult UnRegisterInstanceResources();
// CPUTCheckboxDX11
void DrawIntoBuffer(CPUTGUIVertex *pVertexBufferMirror, UINT *pInsertIndex, UINT pMaxBufferSize, CPUTGUIVertex *pTextVertexBufferMirror, UINT *pTextInsertIndex, UINT MaxTextVertexBufferSize);
protected:
CPUT_RECT mControlDimensions;
CPUTCheckboxState mCheckboxState;
CPUTCheckboxGUIState mCheckboxGuiState;
// helper functions
void InitialStateSet();
// new for uber-buffer version
CPUTFont *mpFont;
CPUTGUIVertex mpMirrorBufferActive[6];
CPUTGUIVertex mpMirrorBufferPressed[6];
CPUTGUIVertex mpMirrorBufferDisabled[6];
void Recalculate();
void AddQuadIntoMirrorBuffer(CPUTGUIVertex *pMirrorBuffer, float x, float y, float w, float h, float3 uv1, float3 uv2 );
// static varibles used by ALL checkbox controls
static CPUT_SIZE mpCheckboxTextureSizeList[CPUT_CHECKBOX_NUM_IMAGES_IN_CHECKBOX];
// GUI state
bool mbMouseInside;
bool mbStartedClickInside;
// instance variables for this particular checkbox
UINT mVertexStride;
UINT mVertexOffset;
CPUTText *mpCheckboxText;
// helper functions
void GetTextPosition(int &x, int &y);
void CalculateBounds();
};
#endif //#ifndef __CPUTCHECKBOX_H__
================================================
FILE: CPUT/CPUT/CPUTComputeShaderDX11.cpp
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#include "CPUTComputeShaderDX11.h"
#include "CPUTAssetLibraryDX11.h"
CPUTComputeShaderDX11 *CPUTComputeShaderDX11::CreateComputeShader(
const cString &name,
ID3D11Device *pD3dDevice,
const cString &shaderMain,
const cString &shaderProfile
)
{
ID3DBlob *pCompiledBlob = NULL;
ID3D11ComputeShader *pNewComputeShader = NULL;
CPUTAssetLibraryDX11 *pAssetLibrary = (CPUTAssetLibraryDX11*)CPUTAssetLibrary::GetAssetLibrary();
CPUTResult result = pAssetLibrary->CompileShaderFromFile(name, shaderMain, shaderProfile, &pCompiledBlob);
ASSERT( CPUTSUCCESS(result), _L("Error compiling compute shader:\n\n") );
// Create the compute shader
// TODO: Move to compute shader class
HRESULT hr = pD3dDevice->CreateComputeShader( pCompiledBlob->GetBufferPointer(), pCompiledBlob->GetBufferSize(), NULL, &pNewComputeShader );
ASSERT( SUCCEEDED(hr), _L("Error creating compute shader:\n\n") );
// cString DebugName = _L("CPUTAssetLibraryDX11::GetComputeShader ")+name;
// CPUTSetDebugName(pNewComputeShader, DebugName);
CPUTComputeShaderDX11 *pNewCPUTComputeShader = new CPUTComputeShaderDX11( pNewComputeShader, pCompiledBlob );
// add shader to library
pAssetLibrary->AddComputeShader(name + shaderMain + shaderProfile, pNewCPUTComputeShader);
// return the shader
return pNewCPUTComputeShader;
}
//--------------------------------------------------------------------------------------
CPUTComputeShaderDX11 *CPUTComputeShaderDX11::CreateComputeShaderFromMemory(
const cString &name,
ID3D11Device *pD3dDevice,
const cString &shaderMain,
const cString &shaderProfile,
const char *pShaderSource
)
{
ID3DBlob* pCompiledBlob = NULL;
ID3D11ComputeShader* pNewComputeShader = NULL;
CPUTAssetLibraryDX11 *pAssetLibrary = (CPUTAssetLibraryDX11*)CPUTAssetLibrary::GetAssetLibrary();
CPUTResult result = pAssetLibrary->CompileShaderFromMemory(pShaderSource, shaderMain, shaderProfile, &pCompiledBlob);
ASSERT( CPUTSUCCESS(result), _L("Error compiling Compute shader:\n\n") );
// Create the Compute shader
// TODO: Move to Compute shader class
HRESULT hr = pD3dDevice->CreateComputeShader( pCompiledBlob->GetBufferPointer(), pCompiledBlob->GetBufferSize(), NULL, &pNewComputeShader );
ASSERT( SUCCEEDED(hr), _L("Error creating Compute shader:\n\n") );
// cString DebugName = _L("CPUTAssetLibraryDX11::GetComputeShader ")+name;
// CPUTSetDebugName(pNewComputeShader, DebugName);
CPUTComputeShaderDX11 *pNewCPUTComputeShader = new CPUTComputeShaderDX11( pNewComputeShader, pCompiledBlob );
// add shader to library
pAssetLibrary->AddComputeShader(name + shaderMain + shaderProfile, pNewCPUTComputeShader);
// pNewCPUTComputeShader->Release(); // We've added it to the library, so release our reference
// return the shader (and blob)
return pNewCPUTComputeShader;
}
================================================
FILE: CPUT/CPUT/CPUTComputeShaderDX11.h
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#ifndef _CPUTCOMPUTESHADERDX11_H
#define _CPUTCOMPUTESHADERDX11_H
#include "CPUT.h"
#include "CPUTShaderDX11.h"
class CPUTComputeShaderDX11 : public CPUTShaderDX11
{
protected:
ID3D11ComputeShader *mpComputeShader;
// Destructor is not public. Must release instead of delete.
~CPUTComputeShaderDX11(){ SAFE_RELEASE(mpComputeShader) }
public:
static CPUTComputeShaderDX11 *CreateComputeShader(
const cString &name,
ID3D11Device *pD3dDevice,
const cString &shaderMain,
const cString &shaderProfile
);
static CPUTComputeShaderDX11 *CreateComputeShaderFromMemory(
const cString &name,
ID3D11Device *pD3dDevice,
const cString &shaderMain,
const cString &shaderProfile,
const char *pShaderSource
);
CPUTComputeShaderDX11() : mpComputeShader(NULL), CPUTShaderDX11(NULL) {}
CPUTComputeShaderDX11(ID3D11ComputeShader *pD3D11ComputeShader, ID3DBlob *pBlob) : mpComputeShader(pD3D11ComputeShader), CPUTShaderDX11(pBlob) {}
ID3DBlob *GetBlob() { return mpBlob; }
ID3D11ComputeShader *GetNativeComputeShader() { return mpComputeShader; }
};
#endif //_CPUTCOMPUTESHADER_H
================================================
FILE: CPUT/CPUT/CPUTConfigBlock.cpp
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#include "CPUTConfigBlock.h"
#include "CPUTOSServicesWin.h"
CPUTConfigEntry &CPUTConfigEntry::sNullConfigValue = CPUTConfigEntry(_L(""), _L(""));
//----------------------------------------------------------------
static bool iswhite(char ch)
{
return ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n';
}
template<typename T>
static void RemoveWhitespace(T &start, T &end)
{
while (start < end && iswhite(*start))
{
++start;
}
while (end > start && iswhite(*(end - 1)))
{
--end;
}
}
//----------------------------------------------------------------
static bool ReadLine(const char **ppStart, const char **ppEnd, const char **ppCur)
{
const char *pCur = *ppCur;
if (!*pCur) // check for EOF
{
return false;
}
// We're at the start of a line now, skip leading whitespace
while (*pCur == ' ' || *pCur == '\t')
{
++pCur;
}
*ppStart = pCur;
// Forward to the end of the line and keep track of last non-whitespace char
const char *pEnd = pCur;
for (;;)
{
char ch = *pCur++;
if (!ch)
{
--pCur; // terminating NUL isn't consumed
break;
}
else if (ch == '\n')
{
break;
}
else if (!iswhite(ch))
{
pEnd = pCur;
}
}
*ppEnd = pEnd;
*ppCur = pCur;
return true;
}
//----------------------------------------------------------------
static const char *FindFirst(const char *start, const char *end, char ch)
{
const char *p = start;
while (p < end && *p != ch)
{
++p;
}
return p;
}
static const char *FindLast(const char *start, const char *end, char ch)
{
const char *p = end;
while (--p >= start && *p != ch)
{
}
return p;
}
static void AssignStr(cString &dest, const char *start, const char *end, _locale_t locale)
{
dest.clear();
if (end <= start)
{
return;
}
static const int NBUF = 64;
wchar_t buf[NBUF];
int nb = 0;
size_t len = end - start;
size_t initial = len + 1; // assume most characters are 1-byte
dest.reserve(initial);
const char *p = start;
while (p < end)
{
int len = _mbtowc_l(&buf[nb++], p, end - p, locale);
if (len < 1)
{
break;
}
p += len;
if (p >= end || nb >= NBUF)
{
dest.append(buf, nb);
nb = 0;
}
}
}
//----------------------------------------------------------------
void CPUTConfigEntry::ValueAsFloatArray(float *pFloats, int count)
{
cString valueCopy = szValue;
TCHAR *szOrigValue = (TCHAR*)valueCopy.c_str();
TCHAR *szNewValue = NULL;
TCHAR *szCurrValue = wcstok_s(szOrigValue, _L(" "), &szNewValue);
for(int clear = 0; clear < count; clear++)
{
pFloats[clear] = 0.0f;
}
for(int ii=0;ii<count;++ii)
{
if(szCurrValue == NULL)
{
return;
}
pFloats[ii] = (float) _wtof(szCurrValue);
szCurrValue = wcstok_s(NULL, _L(" "), &szNewValue);
}
}
//----------------------------------------------------------------
CPUTConfigBlock::CPUTConfigBlock()
: mnValueCount(0)
{
}
//----------------------------------------------------------------
CPUTConfigBlock::~CPUTConfigBlock()
{
}
//----------------------------------------------------------------
const cString &CPUTConfigBlock::GetName(void)
{
return mszName;
}
//----------------------------------------------------------------
int CPUTConfigBlock::GetNameValue(void)
{
return mName.ValueAsInt();
}
//----------------------------------------------------------------
CPUTConfigEntry *CPUTConfigBlock::GetValue(int nValueIndex)
{
if(nValueIndex < 0 || nValueIndex >= mnValueCount)
{
return NULL;
}
return &mpValues[nValueIndex];
}
//----------------------------------------------------------------
CPUTConfigEntry *CPUTConfigBlock::AddValue(const cString &szName, const cString &szValue )
{
cString szNameLower = szName;
std::transform(szNameLower.begin(), szNameLower.end(), szNameLower.begin(), ::tolower);
cString szValueLower = szValue;
std::transform(szValueLower.begin(), szValueLower.end(), szValueLower.begin(), ::tolower);
// TODO: What should we do if it already exists?
CPUTConfigEntry *pEntry = &mpValues[mnValueCount++];
pEntry->szName = szNameLower;
pEntry->szValue = szValueLower;
return pEntry;
}
//----------------------------------------------------------------
CPUTConfigEntry *CPUTConfigBlock::GetValueByName(const cString &szName)
{
for(int ii=0; ii<mnValueCount; ++ii)
{
const cString &valName = mpValues[ii].szName;
if(valName.size() != szName.size())
{
continue;
}
size_t j = 0;
while (j < valName.size() && tolower(szName[j]) == valName[j])
{
++j;
}
if (j == valName.size()) // match
{
return &mpValues[ii];
}
}
// not found - return an 'empty' object to avoid crashes/extra error checking
return &CPUTConfigEntry::sNullConfigValue;
}
//----------------------------------------------------------------
int CPUTConfigBlock::ValueCount(void)
{
return mnValueCount;
}
//----------------------------------------------------------------
CPUTConfigFile::CPUTConfigFile()
: mnBlockCount(0)
, mpBlocks(NULL)
{
}
//----------------------------------------------------------------
CPUTConfigFile::~CPUTConfigFile()
{
if(mpBlocks)
{
delete [] mpBlocks;
mpBlocks = 0;
}
mnBlockCount = 0;
}
//----------------------------------------------------------------
CPUTResult CPUTConfigFile::LoadFile(const cString &szFilename)
{
// Load the file
cString szCurrLine;
CPUTConfigBlock *pCurrBlock = NULL;
FILE *pFile = NULL;
int nCurrBlock = 0;
CPUTResult result = CPUTOSServices::GetOSServices()->OpenFile(szFilename, &pFile);
if(CPUTFAILED(result))
{
return result;
}
_locale_t locale = _get_current_locale();
/* Determine file size */
fseek(pFile, 0, SEEK_END);
int nBytes = ftell(pFile); // for text files, this is an overestimate
fseek(pFile, 0, SEEK_SET);
/* Read the whole thing */
char *pFileContents = new char[nBytes + 1];
nBytes = (int)fread(pFileContents, 1, nBytes, pFile);
fclose(pFile);
pFileContents[nBytes] = 0; // add 0-terminator
/* Count the number of blocks */
const char *pCur = pFileContents;
const char *pStart, *pEnd;
while(ReadLine(&pStart, &pEnd, &pCur))
{
const char *pOpen = FindFirst(pStart, pEnd, '[');
const char *pClose = FindLast(pOpen + 1, pEnd, ']');
if (pOpen < pClose)
{
// This line is a valid block header
mnBlockCount++;
}
}
// For files that don't have any blocks, just add the entire file to one block
if(mnBlockCount == 0)
{
mnBlockCount = 1;
}
pCur = pFileContents;
mpBlocks = new CPUTConfigBlock[mnBlockCount];
pCurrBlock = mpBlocks;
/* Find the first block first */
while(ReadLine(&pStart, &pEnd, &pCur))
{
const char *pOpen = FindFirst(pStart, pEnd, '[');
const char *pClose = FindLast(pOpen + 1, pEnd, ']');
if (pOpen < pClose)
{
// This line is a valid block header
pCurrBlock = mpBlocks + nCurrBlock++;
AssignStr(pCurrBlock->mszName, pOpen + 1, pClose, locale);
std::transform(pCurrBlock->mszName.begin(), pCurrBlock->mszName.end(), pCurrBlock->mszName.begin(), ::tolower);
}
else if (pStart < pEnd)
{
// It's a value
if (pCurrBlock == NULL)
{
continue;
}
const char *pEquals = FindFirst(pStart, pEnd, '=');
if (pEquals == pEnd)
{
// No value, just a key, save it anyway
// Optimistically, we assume it's new
cString &name = pCurrBlock->mpValues[pCurrBlock->mnValueCount].szName;
AssignStr(name, pStart, pEnd, locale);
bool dup = false;
for(int ii=0;ii<pCurrBlock->mnValueCount;++ii)
{
if(!pCurrBlock->mpValues[ii].szName.compare(name))
{
dup = true;
break;
}
}
if(!dup)
{
pCurrBlock->mnValueCount++;
}
}
else
{
const char *pNameStart = pStart;
const char *pNameEnd = pEquals;
const char *pValStart = pEquals + 1;
const char *pValEnd = pEnd;
RemoveWhitespace(pNameStart, pNameEnd);
RemoveWhitespace(pValStart, pValEnd);
// Optimistically assume the name is new
cString &name = pCurrBlock->mpValues[pCurrBlock->mnValueCount].szName;
AssignStr(name, pNameStart, pNameEnd, locale);
std::transform(name.begin(), name.end(), name.begin(), ::tolower);
bool dup = false;
for(int ii=0;ii<pCurrBlock->mnValueCount;++ii)
{
if(!pCurrBlock->mpValues[ii].szName.compare(name))
{
dup = true;
break;
}
}
if(!dup)
{
AssignStr(pCurrBlock->mpValues[pCurrBlock->mnValueCount].szValue, pValStart, pValEnd, locale);
pCurrBlock->mnValueCount++;
}
}
}
}
delete[] pFileContents;
return CPUT_SUCCESS;
}
//----------------------------------------------------------------
CPUTConfigBlock *CPUTConfigFile::GetBlock(int nBlockIndex)
{
if(nBlockIndex >= mnBlockCount || nBlockIndex < 0)
{
return NULL;
}
return &mpBlocks[nBlockIndex];
}
//----------------------------------------------------------------
CPUTConfigBlock *CPUTConfigFile::GetBlockByName(const cString &szBlockName)
{
cString szString = szBlockName;
std::transform(szString.begin(), szString.end(), szString.begin(), ::tolower);
for(int ii=0; ii<mnBlockCount; ++ii)
{
if(mpBlocks[ii].mszName.compare(szString) == 0)
{
return &mpBlocks[ii];
}
}
return NULL;
}
//----------------------------------------------------------------
int CPUTConfigFile::BlockCount(void)
{
return mnBlockCount;
}
================================================
FILE: CPUT/CPUT/CPUTConfigBlock.h
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#ifndef __CPUTPARSELIBRARY_H__
#define __CPUTPARSELIBRARY_H__
#include "CPUT.h"
#include <algorithm> // for std::transform
#if !defined(UNICODE) && !defined(_UNICODE)
#define fgetws fgets
#define swscanf_s sscanf_s
#define wcstok_s strtok_s
#define wcsncmp strncmp
#define _wtoi atoi
#define _wtol atol
#endif
typedef UINT UINT;
class CPUTConfigEntry
{
private:
cString szName;
cString szValue;
friend class CPUTConfigBlock;
friend class CPUTConfigFile;
public:
CPUTConfigEntry() {}
CPUTConfigEntry(const cString &name, const cString &value): szName(name), szValue(value){};
static CPUTConfigEntry &sNullConfigValue;
const cString & NameAsString(void){ return szName;};
const cString & ValueAsString(void){ return szValue; }
bool IsValid(void){ return !szName.empty(); }
float ValueAsFloat(void)
{
float fValue=0;
int retVal;
retVal=swscanf_s(szValue.c_str(), _L("%g"), &fValue ); // float (regular float, or E exponentially notated float)
ASSERT(0!=retVal, _L("ValueAsFloat - value specified is not a float"));
return fValue;
}
int ValueAsInt(void)
{
int nValue=0;
int retVal;
retVal=swscanf_s(szValue.c_str(), _L("%d"), &nValue ); // signed int (NON-hex)
ASSERT(0!=retVal, _L("ValueAsInt - value specified is not a signed int"));
return nValue;
}
UINT ValueAsUint(void)
{
UINT nValue=0;
int retVal;
retVal=swscanf_s(szValue.c_str(), _L("%u"), &nValue ); // unsigned int
ASSERT(0!=retVal, _L("ValueAsUint - value specified is not a UINT"));
return nValue;
}
bool ValueAsBool(void)
{
return (szValue.compare(_L("true")) == 0) ||
(szValue.compare(_L("1")) == 0) ||
(szValue.compare(_L("t")) == 0);
}
void ValueAsFloatArray(float *pFloats, int count);
};
class CPUTConfigBlock
{
public:
CPUTConfigBlock();
~CPUTConfigBlock();
CPUTConfigEntry *AddValue(const cString &szName, const cString &szValue);
CPUTConfigEntry *GetValue(int nValueIndex);
CPUTConfigEntry *GetValueByName(const cString &szName);
const cString &GetName(void);
int GetNameValue(void);
int ValueCount(void);
bool IsValid() { return mnValueCount > 0; }
private:
CPUTConfigEntry mpValues[64];
CPUTConfigEntry mName;
cString mszName;
int mnValueCount;
friend class CPUTConfigFile;
};
class CPUTConfigFile
{
public:
CPUTConfigFile();
~CPUTConfigFile();
CPUTResult LoadFile(const cString &szFilename);
CPUTConfigBlock *GetBlock(int nBlockIndex);
CPUTConfigBlock *GetBlockByName(const cString &szBlockName);
int BlockCount(void);
private:
CPUTConfigBlock *mpBlocks;
int mnBlockCount;
};
#endif //#ifndef __CPUTPARSELIBRARY_H__
================================================
FILE: CPUT/CPUT/CPUTControl.cpp
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
#include "CPUTControl.h"
// Constructor
//------------------------------------------------------------------------------
CPUTControl::CPUTControl():mControlVisible(true),
mControlGraphicsDirty(false),
mControlAutoArranged(true),
mControlNeedsArrangmentResizing(true),
mhotkey(KEY_NONE),
mcontrolType(CPUT_CONTROL_UNKNOWN),
mcontrolID(0),
mpCallbackHandler(NULL),
mControlState(CPUT_CONTROL_ACTIVE)
{
}
// Destructor
//------------------------------------------------------------------------------
CPUTControl::~CPUTControl()
{
}
// Control type/identifier routines that have a common implementation for all controls
// Sets the control's ID used for identification purposes (hopefully unique)
//------------------------------------------------------------------------------
void CPUTControl::SetControlID(CPUTControlID id)
{
mcontrolID = id;
}
// Get the ID for this control
//------------------------------------------------------------------------------
CPUTControlID CPUTControl::GetControlID()
{
return mcontrolID;
}
// Get the type of control this is (button/dropdown/etc)
//------------------------------------------------------------------------------
CPUTControlType CPUTControl::GetType()
{
return mcontrolType;
}
// Set callback handler
//------------------------------------------------------------------------------
void CPUTControl::SetControlCallback(CPUTCallbackHandler *pHandler)
{
mpCallbackHandler = pHandler;
}
// set whether controls is visible or not (it is still there, but not visible)
//------------------------------------------------------------------------------
void CPUTControl::SetVisibility(bool bVisible)
{
mControlVisible = bVisible;
}
// visibility state
//------------------------------------------------------------------------------
bool CPUTControl::IsVisible()
{
return mControlVisible;
}
// Set the hot key for keyboard events for this control
//------------------------------------------------------------------------------
void CPUTControl::SetHotkey(CPUTKey hotKey)
{
mhotkey = hotKey;
}
// Get the hot key set for this control
//------------------------------------------------------------------------------
CPUTKey CPUTControl::GetHotkey()
{
return mhotkey;
}
// Should this control be auto-arranged?
//------------------------------------------------------------------------------
void CPUTControl::SetAutoArranged(bool bIsAutoArranged)
{
mControlAutoArranged = bIsAutoArranged;
}
//------------------------------------------------------------------------------
bool CPUTControl::IsAutoArranged()
{
return mControlAutoArranged;
}
// Set the control to enabled or greyed out
//------------------------------------------------------------------------------
void CPUTControl::SetEnable(bool bEnabled)
{
if(!bEnabled)
{
mControlState = CPUT_CONTROL_INACTIVE;
}
else
{
mControlState = CPUT_CONTROL_ACTIVE;
}
}
// Return bool if the control is enabled/greyed out
//------------------------------------------------------------------------------
bool CPUTControl::IsEnabled()
{
if(mControlState == CPUT_CONTROL_INACTIVE)
{
return false;
}
return true;
}
================================================
FILE: CPUT/CPUT/CPUTControl.h
================================================
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, ei
gitextract_u9hxjrts/ ├── .gitattributes ├── .gitignore ├── CPUT/ │ ├── CPUT/ │ │ ├── CPUT.h │ │ ├── CPUTAssetLibrary.cpp │ │ ├── CPUTAssetLibrary.h │ │ ├── CPUTAssetLibraryDX11.cpp │ │ ├── CPUTAssetLibraryDX11.h │ │ ├── CPUTAssetSet.cpp │ │ ├── CPUTAssetSet.h │ │ ├── CPUTAssetSetDX11.cpp │ │ ├── CPUTAssetSetDX11.h │ │ ├── CPUTBuffer.cpp │ │ ├── CPUTBuffer.h │ │ ├── CPUTBufferDX11.cpp │ │ ├── CPUTBufferDX11.h │ │ ├── CPUTButton.cpp │ │ ├── CPUTButton.h │ │ ├── CPUTCallbackHandler.h │ │ ├── CPUTCamera.cpp │ │ ├── CPUTCamera.h │ │ ├── CPUTCheckbox.cpp │ │ ├── CPUTCheckbox.h │ │ ├── CPUTComputeShaderDX11.cpp │ │ ├── CPUTComputeShaderDX11.h │ │ ├── CPUTConfigBlock.cpp │ │ ├── CPUTConfigBlock.h │ │ ├── CPUTControl.cpp │ │ ├── CPUTControl.h │ │ ├── CPUTDomainShaderDX11.cpp │ │ ├── CPUTDomainShaderDX11.h │ │ ├── CPUTDropdown.cpp │ │ ├── CPUTDropdown.h │ │ ├── CPUTEventHandler.h │ │ ├── CPUTFont.cpp │ │ ├── CPUTFont.h │ │ ├── CPUTFontDX11.cpp │ │ ├── CPUTFontDX11.h │ │ ├── CPUTFrustum.cpp │ │ ├── CPUTFrustum.h │ │ ├── CPUTGeometryShaderDX11.cpp │ │ ├── CPUTGeometryShaderDX11.h │ │ ├── CPUTGuiController.cpp │ │ ├── CPUTGuiController.h │ │ ├── CPUTGuiControllerDX11.cpp │ │ ├── CPUTGuiControllerDX11.h │ │ ├── CPUTHullShaderDX11.cpp │ │ ├── CPUTHullShaderDX11.h │ │ ├── CPUTITTTaskMarker.cpp │ │ ├── CPUTITTTaskMarker.h │ │ ├── CPUTInputLayoutCache.h │ │ ├── CPUTInputLayoutCacheDX11.cpp │ │ ├── CPUTInputLayoutCacheDX11.h │ │ ├── CPUTLight.cpp │ │ ├── CPUTLight.h │ │ ├── CPUTMaterial.cpp │ │ ├── CPUTMaterial.h │ │ ├── CPUTMaterialDX11.cpp │ │ ├── CPUTMaterialDX11.h │ │ ├── CPUTMath.h │ │ ├── CPUTMesh.cpp │ │ ├── CPUTMesh.h │ │ ├── CPUTMeshDX11.cpp │ │ ├── CPUTMeshDX11.h │ │ ├── CPUTModel.cpp │ │ ├── CPUTModel.h │ │ ├── CPUTModelDX11.cpp │ │ ├── CPUTModelDX11.h │ │ ├── CPUTNullNode.cpp │ │ ├── CPUTNullNode.h │ │ ├── CPUTOSServicesWin.cpp │ │ ├── CPUTOSServicesWin.h │ │ ├── CPUTPerfTaskMarker.cpp │ │ ├── CPUTPerfTaskMarker.h │ │ ├── CPUTPixelShaderDX11.cpp │ │ ├── CPUTPixelShaderDX11.h │ │ ├── CPUTPostProcess.cpp │ │ ├── CPUTPostProcess.h │ │ ├── CPUTRefCount.h │ │ ├── CPUTRenderNode.cpp │ │ ├── CPUTRenderNode.h │ │ ├── CPUTRenderParams.h │ │ ├── CPUTRenderParamsDX.h │ │ ├── CPUTRenderStateBlock.cpp │ │ ├── CPUTRenderStateBlock.h │ │ ├── CPUTRenderStateBlockDX11.cpp │ │ ├── CPUTRenderStateBlockDX11.h │ │ ├── CPUTRenderStateMapsDX11.h │ │ ├── CPUTRenderTarget.cpp │ │ ├── CPUTRenderTarget.h │ │ ├── CPUTResource.h │ │ ├── CPUTShaderDX11.cpp │ │ ├── CPUTShaderDX11.h │ │ ├── CPUTSlider.cpp │ │ ├── CPUTSlider.h │ │ ├── CPUTSprite.cpp │ │ ├── CPUTSprite.h │ │ ├── CPUTText.cpp │ │ ├── CPUTText.h │ │ ├── CPUTTexture.cpp │ │ ├── CPUTTexture.h │ │ ├── CPUTTextureDX11.cpp │ │ ├── CPUTTextureDX11.h │ │ ├── CPUTTimer.h │ │ ├── CPUTTimerWin.cpp │ │ ├── CPUTTimerWin.h │ │ ├── CPUTVertexShaderDX11.cpp │ │ ├── CPUTVertexShaderDX11.h │ │ ├── CPUTWindowWin.cpp │ │ ├── CPUTWindowWin.h │ │ ├── CPUT_DX11.cpp │ │ └── CPUT_DX11.h │ ├── CPUT-DX11.sln │ ├── CPUT-DX11.vcxproj │ ├── CPUT-DX11.vcxproj.filters │ ├── CPUT-DX11_2012.vcxproj │ ├── CPUT-DX11_2012.vcxproj.filters │ └── resources/ │ ├── controls/ │ │ ├── atlas/ │ │ │ ├── atlas.cmd │ │ │ ├── atlas.set │ │ │ ├── lambert1.mtl │ │ │ └── polySurface1.mdl │ │ └── atlas.dds │ ├── fonts/ │ │ └── font_Arial_12.dds │ └── shaders/ │ ├── GUIRenderState.rs │ ├── GUIShaderDX.ps │ └── GUIShaderDX.vs ├── Default_Config.txt ├── LightSctrPostProcess.cpp ├── LightSctrPostProcess.h ├── OutdoorLightScattering.cpp ├── OutdoorLightScattering.h ├── OutdoorLightScattering_2010.rc ├── OutdoorLightScattering_2010.sln ├── OutdoorLightScattering_2010.vcxproj ├── OutdoorLightScattering_2010.vcxproj.filters ├── OutdoorLightScattering_2012.sln ├── OutdoorLightScattering_2012.vcxproj ├── OutdoorLightScattering_2012.vcxproj.filters ├── RenderTechnique.cpp ├── RenderTechnique.h ├── ShaderMacroHelper.h ├── Terrain/ │ ├── ConfigFile.cpp │ ├── DynamicQuadTreeNode.h │ ├── EarthHemisphere.cpp │ ├── EarthHemisphere.h │ ├── ElevationDataSource.cpp │ ├── ElevationDataSource.h │ ├── Errors.h │ ├── HierarchyArray.h │ └── stdafx.cpp ├── fx/ │ ├── Common.fxh │ ├── LightScattering.fx │ ├── RefineSampleLocations.fx │ ├── Structures.fxh │ ├── Terrain.fx │ └── TerrainStructs.fxh ├── license.txt ├── media/ │ ├── Terrain/ │ │ └── HeightMap.tif │ └── Tiles/ │ ├── cliff_DM.dds │ ├── cliff_NM.dds │ ├── grassDark_DM.dds │ ├── grass_DM.dds │ ├── grass_NM.dds │ ├── gravel_DM.dds │ ├── gravel_NM.dds │ └── snow_DM.dds ├── readme.txt ├── resource.h └── stdafx.h
SYMBOL INDEX (570 symbols across 114 files)
FILE: CPUT/CPUT/CPUT.h
type CPUT_GPA_INSTRUMENTATION_STRINGS (line 41) | enum CPUT_GPA_INSTRUMENTATION_STRINGS{
type CPUTResult (line 81) | typedef enum CPUTResult
type UINT (line 221) | typedef unsigned int UINT;
type DWORD (line 222) | typedef unsigned long DWORD;
type CPUTColor4 (line 225) | struct CPUTColor4
type CPUT_PATH_SEARCH_MODE (line 249) | enum CPUT_PATH_SEARCH_MODE
type CPUT_DATA_FORMAT_TYPE (line 264) | enum CPUT_DATA_FORMAT_TYPE
type eCPUTMapType (line 312) | enum eCPUTMapType
function std (line 335) | inline std::wstring itoc(const int integer)
function std (line 346) | inline std::wstring ptoc(const void *pPointer)
function std (line 360) | inline std::wstring s2ws(const char* stringArg)
function std (line 415) | inline std::string s2ws(const char* stringArg) { return std::string(stri...
function std (line 419) | inline std::string itoc(const int integer)
function std (line 430) | inline std::string ptoc(const void *pPointer)
function CPUTCamera (line 489) | CPUTCamera *GetShadowCamera() { return mpShadowCamera; }
function virtual (line 490) | virtual void InnerExecutionLoop() {;}
function virtual (line 491) | virtual void ResizeWindowSoft(UINT width, UINT height) {UNREFERENCED_PAR...
function virtual (line 492) | virtual void ResizeWindow(UINT width, UINT height) {
function virtual (line 496) | virtual void DeviceShutdown(){}
function virtual (line 498) | virtual CPUTEventHandledCode CPUTHandleKeyboardEvent(CPUTKey key) {UNREF...
function virtual (line 499) | virtual CPUTEventHandledCode CPUTHandleMouseEvent(int x, int y, int whee...
function SetAmbientColor (line 502) | void SetAmbientColor( float3 &ambientColor ) { mAmbientColor = ambie...
function SetLightColor (line 504) | void SetLightColor( float3 &lightColor ) { mLightColor = lightColor; }
FILE: CPUT/CPUT/CPUTAssetLibrary.cpp
function CPUTRenderStateBlock (line 165) | CPUTRenderStateBlock *CPUTAssetLibrary::GetRenderStateBlock(const cStrin...
function CPUTAssetSet (line 190) | CPUTAssetSet *CPUTAssetLibrary::GetAssetSet( const cString &name, bool n...
function CPUTMaterial (line 212) | CPUTMaterial *CPUTAssetLibrary::GetMaterial(const cString &name, bool na...
function CPUTModel (line 250) | CPUTModel *CPUTAssetLibrary::GetModel(const cString &name, bool nameIsFu...
function CPUTCamera (line 280) | CPUTCamera *CPUTAssetLibrary::GetCamera(const cString &name)
function CPUTLight (line 294) | CPUTLight *CPUTAssetLibrary::GetLight(const cString &name)
function CPUTTexture (line 307) | CPUTTexture *CPUTAssetLibrary::GetTexture(const cString &name, bool name...
function CPUTBuffer (line 330) | CPUTBuffer *CPUTAssetLibrary::GetBuffer(const cString &name )
function CPUTBuffer (line 340) | CPUTBuffer *CPUTAssetLibrary::GetConstantBuffer(const cString &name )
function CPUTFont (line 350) | CPUTFont *CPUTAssetLibrary::GetFont(const cString &name )
FILE: CPUT/CPUT/CPUTAssetLibrary.h
type CPUTAssetListEntry (line 31) | struct CPUTAssetListEntry
function class (line 51) | class CPUTAssetLibrary
function virtual (line 89) | virtual ~CPUTAssetLibrary() {}
function SetMediaDirectoryName (line 95) | void SetMediaDirectoryName( const cString &directoryName)
function SetAssetSetDirectoryName (line 104) | void SetAssetSetDirectoryName( const cString &directoryName) { mA...
function SetModelDirectoryName (line 105) | void SetModelDirectoryName( const cString &directoryName) { mM...
function SetMaterialDirectoryName (line 106) | void SetMaterialDirectoryName( const cString &directoryName) { mM...
function SetTextureDirectoryName (line 107) | void SetTextureDirectoryName( const cString &directoryName) { mT...
function SetShaderDirectoryName (line 108) | void SetShaderDirectoryName( const cString &directoryName) { mS...
function SetFontDirectoryName (line 109) | void SetFontDirectoryName( const cString &directoryName) { mF...
function SetAllAssetDirectoryNames (line 110) | void SetAllAssetDirectoryNames( const cString &directoryName) {
function AddAssetSet (line 126) | void AddAssetSet( const cString &name, CPUTAssetSet *pAss...
function AddNullNode (line 127) | void AddNullNode( const cString &name, CPUTNullNode *pNul...
function AddModel (line 128) | void AddModel( const cString &name, CPUTModel *pMod...
function AddMaterial (line 129) | void AddMaterial( const cString &name, CPUTMaterial *pMat...
function AddLight (line 130) | void AddLight( const cString &name, CPUTLight *pLig...
function AddCamera (line 131) | void AddCamera( const cString &name, CPUTCamera *pCam...
function AddTexture (line 132) | void AddTexture( const cString &name, CPUTTexture *pTex...
function AddBuffer (line 133) | void AddBuffer( const cString &name, CPUTBuffer *pBuf...
function AddConstantBuffer (line 134) | void AddConstantBuffer( const cString &name, CPUTBuffer *pBuf...
function AddRenderStateBlock (line 135) | void AddRenderStateBlock(const cString &name, CPUTRenderStateBlock *pRen...
function AddFont (line 136) | void AddFont( const cString &name, CPUTFont *pFon...
function UINT (line 167) | UINT CPUTComputeHash( const cString &string )
FILE: CPUT/CPUT/CPUTAssetLibraryDX11.cpp
function CPUTResult (line 83) | CPUTResult CPUTAssetLibraryDX11::GetPixelShader(
function CPUTResult (line 119) | CPUTResult CPUTAssetLibraryDX11::GetComputeShader(
function CPUTResult (line 155) | CPUTResult CPUTAssetLibraryDX11::GetVertexShader(
function CPUTResult (line 191) | CPUTResult CPUTAssetLibraryDX11::GetGeometryShader(
function CPUTResult (line 227) | CPUTResult CPUTAssetLibraryDX11::GetHullShader(
function CPUTResult (line 264) | CPUTResult CPUTAssetLibraryDX11::GetDomainShader(
function CPUTResult (line 300) | CPUTResult CPUTAssetLibraryDX11::CreatePixelShaderFromMemory(
function CPUTResult (line 317) | CPUTResult CPUTAssetLibraryDX11::CreateVertexShaderFromMemory(
function CPUTResult (line 334) | CPUTResult CPUTAssetLibraryDX11::CreateComputeShaderFromMemory(
function CPUTResult (line 352) | CPUTResult CPUTAssetLibraryDX11::CompileShaderFromFile(
function CPUTResult (line 395) | CPUTResult CPUTAssetLibraryDX11::CompileShaderFromMemory(
FILE: CPUT/CPUT/CPUTAssetLibraryDX11.h
type CPUTSRGBLoadFlags (line 41) | struct CPUTSRGBLoadFlags
function virtual (line 60) | virtual ~CPUTAssetLibraryDX11()
function AddPixelShader (line 68) | void AddPixelShader( const cString &name, CPUTPixelShaderDX11 *pSh...
function AddComputeShader (line 69) | void AddComputeShader( const cString &name, CPUTComputeShaderDX11 *pSh...
function AddVertexShader (line 70) | void AddVertexShader( const cString &name, CPUTVertexShaderDX11 *pSh...
function AddGeometryShader (line 71) | void AddGeometryShader( const cString &name, CPUTGeometryShaderDX11 *pSh...
function AddHullShader (line 72) | void AddHullShader( const cString &name, CPUTHullShaderDX11 *pSh...
function AddDomainShader (line 73) | void AddDomainShader( const cString &name, CPUTDomainShaderDX11 *pSh...
FILE: CPUT/CPUT/CPUTAssetSet.cpp
function CPUTResult (line 75) | CPUTResult CPUTAssetSet::GetAssetByIndex(const UINT index, CPUTRenderNod...
function CPUTAssetSet (line 86) | CPUTAssetSet *CPUTAssetSet::CreateAssetSet( const cString &name, const c...
FILE: CPUT/CPUT/CPUTAssetSet.h
function class (line 28) | class CPUTAssetSet : public CPUTRefCount
FILE: CPUT/CPUT/CPUTAssetSetDX11.cpp
function CPUTResult (line 38) | CPUTResult CPUTAssetSetDX11::LoadAssetSet(cString name)
function CPUTAssetSet (line 153) | CPUTAssetSet *CPUTAssetSetDX11::CreateAssetSet( const cString &name, con...
FILE: CPUT/CPUT/CPUTAssetSetDX11.h
function class (line 21) | class CPUTAssetSetDX11 : public CPUTAssetSet
FILE: CPUT/CPUT/CPUTBuffer.h
function class (line 23) | class CPUTBuffer : public CPUTRefCount
FILE: CPUT/CPUT/CPUTBufferDX11.cpp
function D3D11_MAPPED_SUBRESOURCE (line 20) | D3D11_MAPPED_SUBRESOURCE CPUTBufferDX11::MapBuffer( CPUTRenderParameters...
FILE: CPUT/CPUT/CPUTBufferDX11.h
function class (line 24) | class CPUTBufferDX11 : public CPUTBuffer
function ID3D11ShaderResourceView (line 81) | ID3D11ShaderResourceView *GetShaderResourceView()
function ID3D11UnorderedAccessView (line 86) | ID3D11UnorderedAccessView *GetUnorderedAccessView()
function SetShaderResourceView (line 91) | void SetShaderResourceView(ID3D11ShaderResourceView *pShaderResourceView)
function SetUnorderedAccessView (line 98) | void SetUnorderedAccessView(ID3D11UnorderedAccessView *pUnorderedAccessV...
function SetBufferAndViews (line 105) | void SetBufferAndViews(ID3D11Buffer *pBuffer, ID3D11ShaderResourceView *...
function ID3D11Buffer (line 121) | ID3D11Buffer *GetNativeBuffer() { return mpBuffer; }
function ReleaseBuffer (line 124) | void ReleaseBuffer()
FILE: CPUT/CPUT/CPUTButton.cpp
function CPUTEventHandledCode (line 205) | CPUTEventHandledCode CPUTButton::HandleKeyboardEvent(CPUTKey key)
function CPUTEventHandledCode (line 213) | CPUTEventHandledCode CPUTButton::HandleMouseEvent(int x, int y, int whee...
function CPUTResult (line 497) | CPUTResult CPUTButton::RegisterStaticResources()
function CPUTResult (line 558) | CPUTResult CPUTButton::UnRegisterStaticResources()
function CPUTResult (line 565) | CPUTResult CPUTButton::RegisterInstanceResources()
function CPUTResult (line 597) | CPUTResult CPUTButton::UnRegisterInstanceResources()
function CPUTResult (line 621) | CPUTResult CPUTButton::Resize(int width, int height)
FILE: CPUT/CPUT/CPUTButton.h
type CPUTButtonState (line 31) | typedef enum CPUTButtonState
function class (line 42) | class CPUTButton:public CPUTControl
FILE: CPUT/CPUT/CPUTCallbackHandler.h
type UINT (line 24) | typedef unsigned int UINT;
type UINT (line 25) | typedef UINT CPUTControlID;
type UINT (line 26) | typedef UINT CPUTEventID;
function class (line 29) | class CPUTCallbackHandler
FILE: CPUT/CPUT/CPUTCamera.cpp
function CPUTResult (line 33) | CPUTResult CPUTCamera::LoadCamera(CPUTConfigBlock *pBlock, int *pParentID)
function CPUTEventHandledCode (line 112) | CPUTEventHandledCode CPUTCameraControllerFPS::HandleMouseEvent(
function CPUTEventHandledCode (line 155) | CPUTEventHandledCode CPUTCameraControllerArcBall::HandleMouseEvent(
FILE: CPUT/CPUT/CPUTCamera.h
function class (line 27) | class CPUTCamera:public CPUTRenderNode
function float4x4 (line 53) | float4x4 *GetViewMatrix(void)
function float4x4 (line 59) | const float4x4* GetProjectionMatrix(void) const { return &mProjection; }
function SetProjectionMatrix (line 60) | void SetProjectionMatrix(const float4x4 &projection) { mProje...
function GetAspectRatio (line 61) | float GetAspectRatio() { return mAspectRatio; }
function GetFov (line 62) | float GetFov() { return mFov; }
function GetNearPlaneDistance (line 65) | float GetNearPlaneDistance() { return mNearPlaneDistance; }
function GetFarPlaneDistance (line 66) | float GetFarPlaneDistance() { return mFarPlaneDistance; }
function SetNearPlaneDistance (line 67) | void SetNearPlaneDistance( const float nearPlaneDistance ) { ...
function SetFarPlaneDistance (line 68) | void SetFarPlaneDistance( const float farPlaneDistance ) { m...
function class (line 73) | class CPUTCameraController : public CPUTEventHandler
function class (line 102) | class CPUTCameraControllerFPS : public CPUTCameraController
function class (line 112) | class CPUTCameraControllerArcBall : public CPUTCameraController
FILE: CPUT/CPUT/CPUTCheckbox.cpp
function CPUTCheckboxState (line 127) | CPUTCheckboxState CPUTCheckbox::GetCheckboxState()
function CPUTResult (line 166) | CPUTResult CPUTCheckbox::RegisterStaticResources()
function CPUTResult (line 201) | CPUTResult CPUTCheckbox::UnRegisterStaticResources()
function CPUTResult (line 208) | CPUTResult CPUTCheckbox::RegisterInstanceResources()
function CPUTResult (line 215) | CPUTResult CPUTCheckbox::UnRegisterInstanceResources()
function CPUTEventHandledCode (line 226) | CPUTEventHandledCode CPUTCheckbox::HandleKeyboardEvent(CPUTKey key)
function CPUTEventHandledCode (line 234) | CPUTEventHandledCode CPUTCheckbox::HandleMouseEvent(int x, int y, int wh...
FILE: CPUT/CPUT/CPUTCheckbox.h
type CPUTCheckboxState (line 27) | typedef enum CPUTCheckboxState
type CPUTCheckboxGUIState (line 33) | typedef enum CPUTCheckboxGUIState
function class (line 44) | class CPUTCheckbox:public CPUTControl
FILE: CPUT/CPUT/CPUTComputeShaderDX11.cpp
function CPUTComputeShaderDX11 (line 20) | CPUTComputeShaderDX11 *CPUTComputeShaderDX11::CreateComputeShader(
function CPUTComputeShaderDX11 (line 51) | CPUTComputeShaderDX11 *CPUTComputeShaderDX11::CreateComputeShaderFromMem...
FILE: CPUT/CPUT/CPUTComputeShaderDX11.h
function class (line 22) | class CPUTComputeShaderDX11 : public CPUTShaderDX11
FILE: CPUT/CPUT/CPUTConfigBlock.cpp
function iswhite (line 22) | static bool iswhite(char ch)
function RemoveWhitespace (line 28) | static void RemoveWhitespace(T &start, T &end)
function ReadLine (line 42) | static bool ReadLine(const char **ppStart, const char **ppEnd, const cha...
function AssignStr (line 104) | static void AssignStr(cString &dest, const char *start, const char *end,...
function cString (line 171) | const cString &CPUTConfigBlock::GetName(void)
function CPUTConfigEntry (line 181) | CPUTConfigEntry *CPUTConfigBlock::GetValue(int nValueIndex)
function CPUTConfigEntry (line 190) | CPUTConfigEntry *CPUTConfigBlock::AddValue(const cString &szName, const ...
function CPUTConfigEntry (line 205) | CPUTConfigEntry *CPUTConfigBlock::GetValueByName(const cString &szName)
function CPUTResult (line 252) | CPUTResult CPUTConfigFile::LoadFile(const cString &szFilename)
function CPUTConfigBlock (line 384) | CPUTConfigBlock *CPUTConfigFile::GetBlock(int nBlockIndex)
function CPUTConfigBlock (line 395) | CPUTConfigBlock *CPUTConfigFile::GetBlockByName(const cString &szBlockName)
FILE: CPUT/CPUT/CPUTConfigBlock.h
type UINT (line 34) | typedef UINT UINT;
function class (line 36) | class CPUTConfigEntry
function class (line 88) | class CPUTConfigBlock
function class (line 110) | class CPUTConfigFile
FILE: CPUT/CPUT/CPUTControl.cpp
function CPUTControlID (line 49) | CPUTControlID CPUTControl::GetControlID()
function CPUTControlType (line 56) | CPUTControlType CPUTControl::GetType()
function CPUTKey (line 93) | CPUTKey CPUTControl::GetHotkey()
FILE: CPUT/CPUT/CPUTControl.h
type CPUT_SIZE (line 26) | struct CPUT_SIZE
type CPUT_POINT (line 32) | struct CPUT_POINT
type CPUT_RECT (line 38) | struct CPUT_RECT
type CPUTControlType (line 48) | enum CPUTControlType
type CPUTGUIControlState (line 60) | typedef enum CPUTGUIControlState
type UINT (line 67) | typedef unsigned int UINT;
type UINT (line 68) | typedef UINT CPUTControlID;
type UINT (line 69) | typedef UINT CPUTEventID;
function class (line 78) | class CPUTControl:public CPUTEventHandler
FILE: CPUT/CPUT/CPUTDomainShaderDX11.cpp
function CPUTDomainShaderDX11 (line 21) | CPUTDomainShaderDX11 *CPUTDomainShaderDX11::CreateDomainShader(
function CPUTDomainShaderDX11 (line 53) | CPUTDomainShaderDX11 *CPUTDomainShaderDX11::CreateDomainShaderFromMemory(
FILE: CPUT/CPUT/CPUTDomainShaderDX11.h
function class (line 22) | class CPUTDomainShaderDX11 : public CPUTShaderDX11
FILE: CPUT/CPUT/CPUTDropdown.cpp
function CPUTResult (line 195) | CPUTResult CPUTDropdown::RegisterInstanceResources()
function CPUTResult (line 202) | CPUTResult CPUTDropdown::UnRegisterInstanceResources()
function CPUTResult (line 229) | CPUTResult CPUTDropdown::AddSelectionItem(const cString Item, bool bIsSe...
function CPUTEventHandledCode (line 392) | CPUTEventHandledCode CPUTDropdown::HandleMouseEvent(int x, int y, int wh...
function CPUTResult (line 528) | CPUTResult CPUTDropdown::RegisterStaticResources()
function CPUTResult (line 560) | CPUTResult CPUTDropdown::UnRegisterStaticResources()
FILE: CPUT/CPUT/CPUTDropdown.h
type CPUTDropdownGUIState (line 24) | typedef enum CPUTDropdownGUIState
type CPUTGUIVertex (line 34) | struct CPUTGUIVertex
function class (line 60) | class CPUTDropdown:public CPUTControl
FILE: CPUT/CPUT/CPUTEventHandler.h
type CPUTKey (line 23) | enum CPUTKey
type CPUTMouseState (line 146) | enum CPUTMouseState
type CPUTEventHandledCode (line 157) | enum CPUTEventHandledCode
function class (line 166) | class CPUTEventHandler
FILE: CPUT/CPUT/CPUTFont.cpp
function CPUTFont (line 36) | CPUTFont *CPUTFont::CreateFont( cString FontName, cString AbsolutePathAn...
function CPUT_SIZE (line 50) | CPUT_SIZE CPUTFont::GetGlyphSize(const char c)
FILE: CPUT/CPUT/CPUTFont.h
function class (line 24) | class CPUTFont : public CPUTRefCount
FILE: CPUT/CPUT/CPUTFontDX11.cpp
function CPUTFont (line 41) | CPUTFont *CPUTFontDX11::CreateFont( cString FontName, cString AbsolutePa...
function CPUTTextureDX11 (line 134) | CPUTTextureDX11* CPUTFontDX11::GetAtlasTexture()
function ID3D11ShaderResourceView (line 141) | ID3D11ShaderResourceView* CPUTFontDX11::GetAtlasTextureResourceView()
function CPUTResult (line 152) | CPUTResult CPUTFontDX11::LoadGlyphMappingFile(const cString fileName)
FILE: CPUT/CPUT/CPUTFontDX11.h
function class (line 27) | class CPUTFontDX11 : public CPUTFont
FILE: CPUT/CPUT/CPUTFrustum.h
function class (line 24) | class CPUTFrustum
FILE: CPUT/CPUT/CPUTGeometryShaderDX11.cpp
function CPUTGeometryShaderDX11 (line 21) | CPUTGeometryShaderDX11 *CPUTGeometryShaderDX11::CreateGeometryShader(
function CPUTGeometryShaderDX11 (line 53) | CPUTGeometryShaderDX11 *CPUTGeometryShaderDX11::CreateGeometryShaderFrom...
FILE: CPUT/CPUT/CPUTGeometryShaderDX11.h
function class (line 22) | class CPUTGeometryShaderDX11 : public CPUTShaderDX11
FILE: CPUT/CPUT/CPUTGuiController.cpp
function CPUTEventHandledCode (line 48) | CPUTEventHandledCode CPUTGuiController::HandleMouseEvent(int x, int y, i...
function CPUTResult (line 94) | CPUTResult CPUTGuiController::SetResourceDirectory(const cString Resourc...
function CPUTResult (line 135) | CPUTResult CPUTGuiController::SetActivePanel(CPUTControlID panelID)
function CPUTControlID (line 163) | CPUTControlID CPUTGuiController::GetActivePanelID()
function CPUTResult (line 173) | CPUTResult CPUTGuiController::GetActiveControlList(std::vector<CPUTContr...
function CPUTResult (line 196) | CPUTResult CPUTGuiController::RemoveControlFromPanel(CPUTControlID contr...
function CPUTResult (line 234) | CPUTResult CPUTGuiController::DeletePanel(CPUTControlID panelID)
function UINT (line 276) | UINT CPUTGuiController::FindPanelIDIndex(CPUTControlID panelID)
function CPUTResult (line 341) | CPUTResult CPUTGuiController::AddControl(CPUTControl *pControl, CPUTCont...
function CPUTControl (line 381) | CPUTControl* CPUTGuiController::GetControl(CPUTControlID controlID, CPUT...
function CPUTResult (line 408) | CPUTResult CPUTGuiController::FindControl(CPUTControlID controlID, CPUTC...
FILE: CPUT/CPUT/CPUTGuiController.h
type CPUTGUIVertex (line 30) | struct CPUTGUIVertex
function class (line 37) | class CPUTGuiController:public CPUTEventHandler
FILE: CPUT/CPUT/CPUTGuiControllerDX11.cpp
function CPUTGuiControllerDX11 (line 106) | CPUTGuiControllerDX11* CPUTGuiControllerDX11::GetController()
function CPUTResult (line 116) | CPUTResult CPUTGuiControllerDX11::DeleteController()
function CPUTResult (line 124) | CPUTResult CPUTGuiControllerDX11::ReleaseResources()
function CPUTResult (line 162) | CPUTResult CPUTGuiControllerDX11::Initialize(ID3D11DeviceContext *pImmed...
function CPUTResult (line 182) | CPUTResult CPUTGuiControllerDX11::CreateButton(const cString ButtonText,...
function CPUTResult (line 201) | CPUTResult CPUTGuiControllerDX11::CreateSlider(const cString SliderText,...
function CPUTResult (line 219) | CPUTResult CPUTGuiControllerDX11::CreateCheckbox(const cString CheckboxT...
function CPUTResult (line 237) | CPUTResult CPUTGuiControllerDX11::CreateDropdown(const cString Selection...
function CPUTResult (line 258) | CPUTResult CPUTGuiControllerDX11::CreateText(const cString Text, CPUTCon...
function CPUTResult (line 277) | CPUTResult CPUTGuiControllerDX11::DeleteControl(CPUTControlID controlID)
function CPUTResult (line 578) | CPUTResult CPUTGuiControllerDX11::UpdateUberBuffers(ID3D11DeviceContext ...
function CPUTResult (line 676) | CPUTResult CPUTGuiControllerDX11::RegisterGUIResources(ID3D11DeviceConte...
FILE: CPUT/CPUT/CPUTGuiControllerDX11.h
function class (line 54) | class CPUTGuiControllerDX11:public CPUTGuiController
FILE: CPUT/CPUT/CPUTHullShaderDX11.cpp
function CPUTHullShaderDX11 (line 20) | CPUTHullShaderDX11 *CPUTHullShaderDX11::CreateHullShader(
function CPUTHullShaderDX11 (line 52) | CPUTHullShaderDX11 *CPUTHullShaderDX11::CreateHullShaderFromMemory(
FILE: CPUT/CPUT/CPUTHullShaderDX11.h
function class (line 22) | class CPUTHullShaderDX11 : public CPUTShaderDX11
FILE: CPUT/CPUT/CPUTITTTaskMarker.h
function class (line 28) | class CPUTITTTaskMarker
FILE: CPUT/CPUT/CPUTInputLayoutCache.h
function class (line 21) | class CPUTInputLayoutCache
function virtual (line 25) | virtual ~CPUTInputLayoutCache() {;}
FILE: CPUT/CPUT/CPUTInputLayoutCacheDX11.cpp
function CPUTInputLayoutCacheDX11 (line 38) | CPUTInputLayoutCacheDX11* CPUTInputLayoutCacheDX11::GetInputLayoutCache()
function CPUTResult (line 49) | CPUTResult CPUTInputLayoutCacheDX11::DeleteInputLayoutCache()
function CPUTResult (line 61) | CPUTResult CPUTInputLayoutCacheDX11::GetLayout(
function cString (line 107) | cString CPUTInputLayoutCacheDX11::GenerateLayoutKey(D3D11_INPUT_ELEMENT_...
FILE: CPUT/CPUT/CPUTInputLayoutCacheDX11.h
function class (line 25) | class CPUTInputLayoutCacheDX11:public CPUTInputLayoutCache
FILE: CPUT/CPUT/CPUTLight.cpp
function CPUTResult (line 21) | CPUTResult CPUTLight::LoadLight(CPUTConfigBlock *pBlock, int *pParentID)
FILE: CPUT/CPUT/CPUTLight.h
type LightType (line 23) | enum LightType
type CPUTLightParams (line 30) | struct CPUTLightParams
function class (line 46) | class CPUTLight:public CPUTRenderNode
FILE: CPUT/CPUT/CPUTMaterial.cpp
function CPUTMaterial (line 26) | CPUTMaterial *CPUTMaterial::CreateMaterial( const cString &absolutePathA...
FILE: CPUT/CPUT/CPUTMaterial.h
function class (line 40) | class CPUTMaterial:public CPUTRefCount
function SetMaterialName (line 77) | void SetMaterialName(const cString MaterialName) { mMat...
function GetMaterialName (line 78) | void GetMaterialName(cString &MaterialName) { Mate...
FILE: CPUT/CPUT/CPUTMaterialDX11.cpp
function CPUTResult (line 593) | CPUTResult CPUTMaterialDX11::LoadMaterial(const cString &fileName, const...
function CPUTMaterial (line 730) | CPUTMaterial *CPUTMaterialDX11::CloneMaterial(const cString &fileName, c...
FILE: CPUT/CPUT/CPUTMaterialDX11.h
function class (line 29) | class CPUTShaderParameters
function class (line 126) | class CPUTMaterialDX11 : public CPUTMaterial
FILE: CPUT/CPUT/CPUTMath.h
function DegToRad (line 31) | static inline float DegToRad( float fDeg ) { return fDeg * kDegToRad; }
function RadToDeg (line 32) | static inline float RadToDeg( float fRad ) { return fRad * kRadToDeg; }
function Swap (line 35) | inline void Swap(T &a, T &b)
type float2 (line 41) | struct float2
type float3 (line 42) | struct float3
type float4 (line 43) | struct float4
type float2 (line 48) | struct float2
function float2 (line 121) | float2 operator*(float f) const
function operator (line 146) | bool operator==(const float2 &r) const
function operator (line 150) | bool operator!=(const float2 &r) const
function hadd (line 156) | float hadd(void) const
function lengthSq (line 162) | float lengthSq(void) const
function length (line 166) | float length(void) const
function normalize (line 170) | void normalize(void)
function dot2 (line 176) | inline float dot2(const float2 &l, const float2 &r)
function float2 (line 181) | inline float2 normalize(const float2 &v)
type float3 (line 197) | struct float3
function float3 (line 263) | float3 operator/(const float3 &r) const
function float3 (line 300) | float3 operator*(float f) const
function operator (line 327) | bool operator==(const float3 &r) const
function operator (line 331) | bool operator!=(const float3 &r) const
function hadd (line 337) | float hadd(void) const
function lengthSq (line 343) | float lengthSq(void) const
function length (line 347) | float length(void) const
function float3 (line 351) | float3 normalize(void)
function dot3 (line 357) | inline float dot3(const float3 &l, const float3 &r)
function float3 (line 361) | inline float3 cross3(const float3 &l, const float3 &r)
function float3 (line 367) | inline float3 normalize(const float3 &v)
type float4 (line 377) | struct float4
function float4 (line 448) | float4 operator/(const float4 &r) const
function float4 (line 487) | float4 operator*(float f) const
function operator (line 516) | bool operator==(const float4 &r) const
function operator (line 520) | bool operator!=(const float4 &r) const
function hadd (line 526) | float hadd(void) const
function lengthSq (line 532) | float lengthSq(void) const
function length (line 536) | float length(void) const
function normalize (line 540) | void normalize(void)
function dot4 (line 546) | inline float dot4(const float4 &l, const float4 &r)
function float4 (line 550) | inline float4 normalize(const float4 &v)
type float4x4 (line 562) | struct float4x4
type float3x3 (line 563) | struct float3x3
function float3x3 (line 662) | float3x3 operator*(float f) const
function determinant (line 698) | float determinant() const
function invert (line 714) | void invert(void)
function float3x3 (line 737) | inline float3x3 float3x3Identity(void)
function determinant (line 743) | inline float determinant(const float3x3&m)
function float3x3 (line 748) | inline float3x3 transpose(const float3x3 &m)
function float3x3 (line 755) | inline float3x3 inverse(const float3x3 &m)
function float3x3 (line 762) | inline float3x3 float3x3RotationX(float rad)
function float3x3 (line 771) | inline float3x3 float3x3RotationY(float rad)
function float3x3 (line 780) | inline float3x3 float3x3RotationZ(float rad)
function float4x4 (line 944) | float4x4 operator*(float f) const
function determinant (line 982) | float determinant() const
function invert (line 1024) | void invert(void)
function float3 (line 1145) | float3 getXAxis(void) const
function float3 (line 1149) | float3 getYAxis(void) const
function float3 (line 1153) | float3 getZAxis(void) const
function float3 (line 1157) | float3 getPosition(void) const
function orthonormalize (line 1162) | void orthonormalize(void)
function float4x4 (line 1188) | inline float4x4 float4x4Identity(void)
function float4x4 (line 1195) | inline float4x4 transpose(const float4x4 &m)
function float4x4 (line 1202) | inline float4x4 inverse(const float4x4 &m)
function float4x4 (line 1209) | inline float4x4 float4x4RotationX(float rad)
function float4x4 (line 1219) | inline float4x4 float4x4RotationY(float rad)
function float4x4 (line 1234) | float4x4 m( c, s, 0.0f, 0.0f,
function float4x4 (line 1277) | inline float4x4 float4x4Translation(float x, float y, float z)
function float4x4 (line 1285) | inline float4x4 float4x4Translation(const float3 &v)
function float4x4 (line 1290) | inline float4x4 float4x4PerspectiveFovLH(float fov, float aspect, float ...
function float4x4 (line 1305) | inline float4x4 float4x4PerspectiveFovRH(float fov, float aspect, float ...
function float4x4 (line 1321) | inline float4x4 float4x4PerspectiveLH(float width, float height, float n...
function float4x4 (line 1333) | inline float4x4 float4x4PerspectiveRH(float width, float height, float n...
function float4x4 (line 1345) | inline float4x4 float4x4OrthographicOffCenterLH(float left, float right,...
function float4x4 (line 1360) | inline float4x4 float4x4OrthographicOffCenterRH(float left, float right,...
function float4x4 (line 1374) | inline float4x4 float4x4OrthographicLH(float width, float height, float ...
function float4x4 (line 1381) | inline float4x4 float4x4OrthographicRH(float width, float height, float ...
function float4 (line 1392) | struct quaternion : public float4
function quaternion (line 1479) | inline quaternion quaternionMultiply(const quaternion &l, const quaterni...
function quaternion (line 1488) | inline quaternion quaternionIdentity(void)
function float3 (line 1493) | inline float3 Min( float3 &v0, float3 &v1 )
function float3 (line 1502) | inline float3 Max( float3 &v0, float3 &v1 )
function float4 (line 1511) | inline float4 Min( float4 &v0, float4 &v1 )
function float4 (line 1521) | inline float4 Max( float4 &v0, float4 &v1 )
FILE: CPUT/CPUT/CPUTMesh.h
type eCPUT_VERTEX_ELEMENT_SEMANTIC (line 28) | enum eCPUT_VERTEX_ELEMENT_SEMANTIC
type eCPUT_VERTEX_ELEMENT_TYPE (line 47) | enum eCPUT_VERTEX_ELEMENT_TYPE
function UINT (line 93) | enum eCPUT_MESH_TOPOLOGY : UINT
FILE: CPUT/CPUT/CPUTMeshDX11.cpp
function CPUTResult (line 69) | CPUTResult CPUTMeshDX11::CreateNativeResources(
function DXGI_FORMAT (line 212) | DXGI_FORMAT CPUTMeshDX11::ConvertToDirectXFormat(CPUT_DATA_FORMAT_TYPE d...
function D3D11_MAPPED_SUBRESOURCE (line 282) | D3D11_MAPPED_SUBRESOURCE CPUTMeshDX11::Map(
function D3D11_MAPPED_SUBRESOURCE (line 388) | D3D11_MAPPED_SUBRESOURCE CPUTMeshDX11::MapVertices( CPUTRenderParameters...
function D3D11_MAPPED_SUBRESOURCE (line 403) | D3D11_MAPPED_SUBRESOURCE CPUTMeshDX11::MapIndices( CPUTRenderParameters ...
FILE: CPUT/CPUT/CPUTMeshDX11.h
function class (line 34) | class CPUTMeshDX11 : public CPUTMesh
FILE: CPUT/CPUT/CPUTModel.cpp
function CPUTResult (line 93) | CPUTResult CPUTModel::LoadModelPayload(const cString &File)
FILE: CPUT/CPUT/CPUTModel.h
function class (line 32) | class CPUTModel : public CPUTRenderNode
FILE: CPUT/CPUT/CPUTModelDX11.cpp
function CPUTMeshDX11 (line 25) | CPUTMeshDX11* CPUTModelDX11::GetMesh(const UINT index) const
function CPUTResult (line 182) | CPUTResult CPUTModelDX11::LoadModel(CPUTConfigBlock *pBlock, int *pParen...
FILE: CPUT/CPUT/CPUTModelDX11.h
type CPUTModelConstantBuffer (line 27) | struct CPUTModelConstantBuffer
function class (line 43) | class CPUTModelDX11 : public CPUTModel
FILE: CPUT/CPUT/CPUTNullNode.cpp
function CPUTResult (line 23) | CPUTResult CPUTNullNode::LoadNullNode(CPUTConfigBlock *pBlock, int *pPar...
FILE: CPUT/CPUT/CPUTNullNode.h
function class (line 23) | class CPUTNullNode:public CPUTRenderNode
FILE: CPUT/CPUT/CPUTOSServicesWin.cpp
function CPUTOSServices (line 38) | CPUTOSServices* CPUTOSServices::GetOSServices()
function CPUTResult (line 47) | CPUTResult CPUTOSServices::DeleteOSServices()
function CPUTResult (line 142) | CPUTResult CPUTOSServices::GetWorkingDirectory(cString *pPath)
function CPUTResult (line 153) | CPUTResult CPUTOSServices::SetWorkingDirectory(const cString &path)
function CPUTResult (line 162) | CPUTResult CPUTOSServices::GetExecutableDirectory(cString *pExecutableDir)
function CPUTResult (line 182) | CPUTResult CPUTOSServices::SplitPathAndFilename(const cString &sourceFil...
function CPUTResult (line 209) | CPUTResult CPUTOSServices::ResolveAbsolutePathAndFilename(const cString ...
function CPUTResult (line 221) | CPUTResult CPUTOSServices::DoesFileExist(const cString &pathAndFilename)
function CPUTResult (line 246) | CPUTResult CPUTOSServices::DoesDirectoryExist(const cString &path)
function CPUTResult (line 260) | CPUTResult CPUTOSServices::OpenFile(const cString &fileName, FILE **ppFi...
function CPUTResult (line 273) | CPUTResult CPUTOSServices::ReadFileContents(const cString &fileName, UIN...
function CPUTResult (line 307) | CPUTResult CPUTOSServices::OpenFileDialog(const cString &filter, cString...
function CPUTResult (line 340) | CPUTResult CPUTOSServices::OpenMessageBox(cString title, cString text)
function CPUTResult (line 438) | CPUTResult CPUTOSServices::TranslateFileError(errno_t err)
FILE: CPUT/CPUT/CPUTOSServicesWin.h
function class (line 30) | class CPUTOSServices
FILE: CPUT/CPUT/CPUTPerfTaskMarker.h
function class (line 29) | class CPUTPerfTaskMarker
FILE: CPUT/CPUT/CPUTPixelShaderDX11.cpp
function CPUTPixelShaderDX11 (line 21) | CPUTPixelShaderDX11 *CPUTPixelShaderDX11::CreatePixelShader(
function CPUTPixelShaderDX11 (line 53) | CPUTPixelShaderDX11 *CPUTPixelShaderDX11::CreatePixelShaderFromMemory(
FILE: CPUT/CPUT/CPUTPixelShaderDX11.h
function class (line 22) | class CPUTPixelShaderDX11 : public CPUTShaderDX11
FILE: CPUT/CPUT/CPUTPostProcess.h
function class (line 24) | class CPUTPostProcess
FILE: CPUT/CPUT/CPUTRefCount.h
function class (line 23) | class CPUTRefCount
FILE: CPUT/CPUT/CPUTRenderNode.cpp
function float4x4 (line 138) | float4x4* CPUTRenderNode::GetWorldMatrix()
FILE: CPUT/CPUT/CPUTRenderNode.h
function class (line 27) | class CPUTRenderNode : public CPUTRefCount
function SetParentMatrix (line 133) | void SetParentMatrix(const float4x4 &parentMatrix)
function LoadParentMatrixFromParameterBlock (line 138) | void LoadParentMatrixFromParameterBlock( CPUTConfigBlock *pBlock )
function virtual (line 167) | virtual void GetBoundingBoxRecursive( float3 *pCenter, float3 *pHalf)
FILE: CPUT/CPUT/CPUTRenderParams.h
function class (line 22) | class CPUTRenderParameters
FILE: CPUT/CPUT/CPUTRenderParamsDX.h
function class (line 24) | class CPUTRenderParametersDX : public CPUTRenderParameters
FILE: CPUT/CPUT/CPUTRenderStateBlock.cpp
function CPUTRenderStateBlock (line 27) | CPUTRenderStateBlock *CPUTRenderStateBlock::CreateRenderStateBlock( cons...
FILE: CPUT/CPUT/CPUTRenderStateBlock.h
function class (line 24) | class CPUTRenderStateBlock : public CPUTRefCount
FILE: CPUT/CPUT/CPUTRenderStateBlockDX11.cpp
function CPUTResult (line 66) | CPUTResult CPUTRenderStateBlockDX11::ReadProperties(
function CPUTResult (line 160) | CPUTResult CPUTRenderStateBlockDX11::LoadRenderStateBlock(const cString ...
FILE: CPUT/CPUT/CPUTRenderStateBlockDX11.h
type CPUTRenderStateMapEntry (line 26) | struct CPUTRenderStateMapEntry
function class (line 31) | class CPUTRenderStateDX11
function class (line 47) | class CPUTRenderStateBlockDX11:public CPUTRenderStateBlock
function CPUTRenderStateDX11 (line 96) | CPUTRenderStateDX11 *GetState() {return &mStateDesc;}
type CPUT_PARAM_TYPE (line 100) | enum CPUT_PARAM_TYPE{
type CPUTRenderStateMapEntry (line 122) | struct CPUTRenderStateMapEntry
function class (line 130) | class StringToIntMapEntry
FILE: CPUT/CPUT/CPUTRenderTarget.cpp
function HRESULT (line 59) | HRESULT CPUTRenderTargetColor::CreateRenderTarget(
function HRESULT (line 173) | HRESULT CPUTRenderTargetColor::RecreateRenderTarget(
function HRESULT (line 199) | HRESULT CPUTRenderTargetDepth::CreateRenderTarget(
function HRESULT (line 279) | HRESULT CPUTRenderTargetDepth::RecreateRenderTarget(
function D3D11_MAPPED_SUBRESOURCE (line 467) | D3D11_MAPPED_SUBRESOURCE CPUTRenderTargetColor::MapRenderTarget( CPUTRen...
function D3D11_MAPPED_SUBRESOURCE (line 558) | D3D11_MAPPED_SUBRESOURCE CPUTRenderTargetDepth::MapRenderTarget( CPUTRen...
FILE: CPUT/CPUT/CPUTRenderTarget.h
function class (line 28) | class CPUTRenderTargetColor
function SetActiveRenderTargetView (line 32) | static void SetActiveRenderTargetView(ID3D11RenderTar...
function SetActiveWidthHeight (line 33) | static void SetActiveWidthHeight( UINT width, UINT he...
function UINT (line 34) | static UINT GetActiveWidth() {return sCurrentWidth; }
function UINT (line 35) | static UINT GetActiveHeight() {return sCurrentHeight; }
function CPUTTexture (line 127) | CPUTTexture *GetColorTexture() { return mpColor...
function CPUTBuffer (line 128) | CPUTBuffer *GetColorBuffer() { return mpColor...
function ID3D11ShaderResourceView (line 129) | ID3D11ShaderResourceView *GetColorResourceView() { return mpColor...
function ID3D11UnorderedAccessView (line 130) | ID3D11UnorderedAccessView *GetColorUAV() { return mpColor...
function UINT (line 131) | UINT GetWidth() { return mWidth; }
function UINT (line 132) | UINT GetHeight() { return mHeight; }
function DXGI_FORMAT (line 133) | DXGI_FORMAT GetColorFormat() { return mColorF...
function class (line 140) | class CPUTRenderTargetDepth
function SetActiveDepthStencilView (line 144) | static void SetActiveDepthStencilView(ID3D11DepthSten...
function SetActiveWidthHeight (line 145) | static void SetActiveWidthHeight( UINT width, UINT he...
function UINT (line 146) | static UINT GetActiveWidth() {return sCurrentWidth; }
function UINT (line 147) | static UINT GetActiveHeight() {return sCurrentHeight; }
function ID3D11DepthStencilView (line 221) | ID3D11DepthStencilView *GetDepthBufferView() { return mpDepthStencil...
function ID3D11ShaderResourceView (line 222) | ID3D11ShaderResourceView *GetDepthResourceView() { return mpDepthResourc...
function UINT (line 223) | UINT GetWidth() { return mWidth; }
function UINT (line 224) | UINT GetHeight() { return mHeight; }
FILE: CPUT/CPUT/CPUTShaderDX11.h
function class (line 24) | class CPUTShaderDX11 : public CPUTRefCount
FILE: CPUT/CPUT/CPUTSlider.cpp
function CPUTResult (line 174) | CPUTResult CPUTSlider::RegisterStaticResources()
function CPUTResult (line 213) | CPUTResult CPUTSlider::UnRegisterStaticResources()
function CPUTResult (line 222) | CPUTResult CPUTSlider::RegisterInstanceResources()
function CPUTResult (line 239) | CPUTResult CPUTSlider::UnRegisterInstanceResources()
function CPUTEventHandledCode (line 254) | CPUTEventHandledCode CPUTSlider::HandleMouseEvent(int x, int y, int whee...
function CPUTResult (line 551) | CPUTResult CPUTSlider::SetScale(float StartValue, float EndValue, int Nu...
function CPUTResult (line 580) | CPUTResult CPUTSlider::SetNumberOfTicks(int NumberOfTicks)
function CPUTResult (line 603) | CPUTResult CPUTSlider::GetValue(float & fValue)
function CPUTResult (line 635) | CPUTResult CPUTSlider::SetValue(float fValue)
FILE: CPUT/CPUT/CPUTSlider.h
type CPUTGUIVertex (line 21) | struct CPUTGUIVertex
type CPUTSliderState (line 25) | typedef enum CPUTSliderState
function class (line 37) | class CPUTSlider:public CPUTControl
FILE: CPUT/CPUT/CPUTSprite.cpp
class SpriteVertex (line 23) | class SpriteVertex
function HRESULT (line 39) | HRESULT CPUTSprite::CreateSprite(
FILE: CPUT/CPUT/CPUTSprite.h
function class (line 26) | class CPUTSprite
FILE: CPUT/CPUT/CPUTText.cpp
function CPUTResult (line 152) | CPUTResult CPUTText::RegisterInstanceData()
function CPUTResult (line 170) | CPUTResult CPUTText::RegisterStaticResources()
function CPUTResult (line 177) | CPUTResult CPUTText::UnRegisterStaticResources()
function CPUTResult (line 309) | CPUTResult CPUTText::SetText(const cString String, float depth)
function CPUTResult (line 361) | CPUTResult CPUTText::SetColor(float r, float g, float b, float a)
function CPUTResult (line 373) | CPUTResult CPUTText::SetColor(CPUTColor4 color)
function CPUTColor4 (line 387) | CPUTColor4 CPUTText::GetColor()
FILE: CPUT/CPUT/CPUTText.h
function class (line 26) | class CPUTText:public CPUTControl
FILE: CPUT/CPUT/CPUTTexture.cpp
function CPUTTexture (line 25) | CPUTTexture *CPUTTexture::CreateTexture( const cString &name, const cStr...
FILE: CPUT/CPUT/CPUTTexture.h
function class (line 22) | class CPUTTexture : public CPUTRefCount
FILE: CPUT/CPUT/CPUTTextureDX11.cpp
function CPUTTexture (line 126) | CPUTTexture *CPUTTextureDX11::CreateTexture( const cString &name, const ...
function CPUTResult (line 147) | CPUTResult CPUTTextureDX11::CreateNativeTexture(
function CPUTResult (line 227) | CPUTResult CPUTTextureDX11::GetSRGBEquivalent(DXGI_FORMAT inFormat, DXGI...
function cString (line 262) | const cString &CPUTTextureDX11::GetDXGIFormatString(DXGI_FORMAT format)
function D3D11_MAPPED_SUBRESOURCE (line 282) | D3D11_MAPPED_SUBRESOURCE CPUTTextureDX11::MapTexture( CPUTRenderParamete...
FILE: CPUT/CPUT/CPUTTextureDX11.h
function class (line 24) | class CPUTTextureDX11 : public CPUTTexture
FILE: CPUT/CPUT/CPUTTimer.h
function class (line 19) | class CPUTTimer
FILE: CPUT/CPUT/CPUTTimerWin.h
function class (line 27) | class CPUTTimerWin : CPUTTimer
FILE: CPUT/CPUT/CPUTVertexShaderDX11.cpp
function CPUTVertexShaderDX11 (line 20) | CPUTVertexShaderDX11 *CPUTVertexShaderDX11::CreateVertexShader(
function CPUTVertexShaderDX11 (line 52) | CPUTVertexShaderDX11 *CPUTVertexShaderDX11::CreateVertexShaderFromMemory(
FILE: CPUT/CPUT/CPUTVertexShaderDX11.h
function class (line 22) | class CPUTVertexShaderDX11 : public CPUTShaderDX11
FILE: CPUT/CPUT/CPUTWindowWin.cpp
function _inline (line 21) | _inline void HandleWin32Error()
function _inline (line 37) | _inline void HandleWin32Error() {}
function CPUTResult (line 62) | CPUTResult CPUTWindowWin::Create(CPUT* cput, const cString WindowTitle, ...
function ATOM (line 141) | ATOM CPUTWindowWin::MyRegisterClass(HINSTANCE hInstance)
function BOOL (line 175) | BOOL CPUTWindowWin::InitInstance(int nCmdShow, int windowWidth, int wind...
function LRESULT (line 245) | LRESULT CALLBACK CPUTWindowWin::WndProc(HWND hWnd, UINT message, WPARAM ...
function CPUTKey (line 426) | CPUTKey CPUTWindowWin::ConvertKeyCode(WPARAM wParam, LPARAM lParam)
function CPUTKey (line 607) | CPUTKey CPUTWindowWin::ConvertSpecialKeyCode(WPARAM wParam, LPARAM lParam)
function CPUTMouseState (line 682) | CPUTMouseState CPUTWindowWin::ConvertMouseState(WPARAM wParam)
FILE: CPUT/CPUT/CPUTWindowWin.h
function class (line 33) | class CPUTWindowWin
FILE: CPUT/CPUT/CPUT_DX11.cpp
function CPUTResult (line 59) | CPUTResult CPUT_DX11::CPUTInitialize(const cString pCPUTResourcePath)
function CPUTResult (line 68) | CPUTResult CPUT_DX11::SetCPUTResourceDirectory(const cString ResourceDir...
function CPUTEventHandledCode (line 101) | CPUTEventHandledCode CPUT_DX11::CPUTHandleKeyboardEvent(CPUTKey key)
function CPUTEventHandledCode (line 116) | CPUTEventHandledCode CPUT_DX11::CPUTHandleMouseEvent(int x, int y, int w...
function CPUTResult (line 135) | CPUTResult CPUT_DX11::MakeWindow(const cString WindowTitle, int windowWi...
function CPUTGuiControllerDX11 (line 162) | CPUTGuiControllerDX11* CPUT_DX11::CPUTGetGuiController()
function CPUTResult (line 170) | CPUTResult CPUT_DX11::CreateDXContext(CPUTWindowCreationParams params)
function ID3D11Device (line 354) | ID3D11Device* CPUT_DX11::GetDevice()
function CPUTResult (line 361) | CPUTResult CPUT_DX11::CreateContext()
function CPUTResult (line 401) | CPUTResult CPUT_DX11::DestroyDXContext()
function CPUTResult (line 423) | CPUTResult CPUT_DX11::CPUTToggleFullScreenMode()
function CPUTResult (line 490) | CPUTResult CPUT_DX11::CreateAndBindDepthBuffer(int width, int height)
function CPUTResult (line 809) | CPUTResult CPUT_DX11::CPUTParseCommandLine(cString commandLine, CPUTWind...
function CPUTResult (line 931) | CPUTResult CPUT_DX11::CPUTCreateWindowAndContext(const cString WindowTit...
function CPUTSetDebugName (line 1152) | void CPUTSetDebugName( void *pResource, cString name )
FILE: CPUT/CPUT/CPUT_DX11.h
type CPUTContextCreation (line 45) | struct CPUTContextCreation
type CPUTWindowCreationParams (line 54) | struct CPUTWindowCreationParams
function cString (line 144) | cString GetCPUTResourceDirectory() { return mResourceDirectory; }
function D3D_FEATURE_LEVEL (line 146) | D3D_FEATURE_LEVEL GetFeatureLevel() { return mfeatureLevel; }
function virtual (line 161) | virtual void Update(double deltaSeconds) {}
function virtual (line 162) | virtual void Present() { mpSwapChain->Present( mSyncInterval, 0 ); }
function virtual (line 166) | virtual void FullscreenModeChange(bool bFullscreen) {UNREFERENCED_PARAME...
function virtual (line 167) | virtual void ReleaseSwapChain() {}
FILE: LightSctrPostProcess.cpp
function HRESULT (line 49) | HRESULT CLightSctrPostProcess :: OnCreateDevice(ID3D11Device* in_pd3dDev...
function HRESULT (line 339) | HRESULT CLightSctrPostProcess :: OnResizedSwapChain(ID3D11Device* pd3dDe...
function UnbindResources (line 383) | static void UnbindResources(ID3D11DeviceContext *pDeviceCtx)
function RenderQuad (line 394) | static void RenderQuad(ID3D11DeviceContext *pd3dDeviceCtx,
class CD3DShaderMacroHelper (line 447) | class CD3DShaderMacroHelper
function HRESULT (line 484) | HRESULT CLightSctrPostProcess::CreatePrecomputedOpticalDepthTexture(ID3D...
function HRESULT (line 572) | HRESULT CLightSctrPostProcess :: CreatePrecomputedScatteringLUT(ID3D11De...
function HRESULT (line 1903) | HRESULT CLightSctrPostProcess :: CreateTextures(ID3D11Device* pd3dDevice)
function HRESULT (line 2014) | HRESULT CLightSctrPostProcess :: CreateMinMaxShadowMap(ID3D11Device* pd3...
function D3DXVECTOR2 (line 2055) | D3DXVECTOR2 exp(const D3DXVECTOR2 &fX){ return D3DXVECTOR2(exp(fX.x), ex...
function D3DXVECTOR3 (line 2056) | D3DXVECTOR3 exp(const D3DXVECTOR3 &fX){ return D3DXVECTOR3(exp(fX.x), ex...
function D3DXVECTOR2 (line 2057) | D3DXVECTOR2 operator * (const D3DXVECTOR2 &fX, const D3DXVECTOR2 &fY){ r...
function D3DXVECTOR3 (line 2058) | D3DXVECTOR3 operator * (const D3DXVECTOR3 &fX, const D3DXVECTOR3 &fY){ r...
function D3DXVECTOR2 (line 2059) | D3DXVECTOR2 operator / (const D3DXVECTOR2 &fX, const D3DXVECTOR2 &fY){ r...
function D3DXVECTOR2 (line 2062) | D3DXVECTOR2 ChapmanOrtho(const D3DXVECTOR2 &f2x)
function D3DXVECTOR2 (line 2070) | D3DXVECTOR2 f2ChapmanRising(const D3DXVECTOR2 &f2X, float fCosChi)
function D3DXVECTOR2 (line 2076) | D3DXVECTOR2 GetDensityIntegralFromChapmanFunc(float fHeightAboveSurface,
function ID3D11ShaderResourceView (line 2359) | ID3D11ShaderResourceView* CLightSctrPostProcess :: GetAmbientSkyLightSRV...
FILE: LightSctrPostProcess.h
type SFrameAttribs (line 25) | struct SFrameAttribs
function class (line 51) | class CLightSctrPostProcess
FILE: OutdoorLightScattering.cpp
class CParallelLightCamera (line 27) | class CParallelLightCamera : public CPUTCamera
method Update (line 30) | virtual void Update( float deltaSeconds=0.0f ) {
function CPUTEventHandledCode (line 87) | CPUTEventHandledCode COutdoorLightScatteringSample::HandleKeyboardEvent(...
function CPUTEventHandledCode (line 127) | CPUTEventHandledCode COutdoorLightScatteringSample::HandleMouseEvent(int...
function SelectColor (line 141) | bool SelectColor(D3DXVECTOR4 &f4Color)
function HRESULT (line 608) | HRESULT COutdoorLightScatteringSample::CreateTmpBackBuffAndDepthBuff(ID3...
function HRESULT (line 647) | HRESULT COutdoorLightScatteringSample::CreateShadowMap(ID3D11Device* pd3...
function GetRaySphereIntersection (line 1234) | void GetRaySphereIntersection(D3DXVECTOR3 f3RayOrigin,
function ComputeApproximateNearFarPlaneDist (line 1450) | void ComputeApproximateNearFarPlaneDist(const D3DXVECTOR3 &CameraPos,
function D3DXVECTOR2 (line 1592) | static D3DXVECTOR2 ProjToUV(const D3DXVECTOR2& f2ProjSpaceXY)
function wWinMain (line 1744) | int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWST...
FILE: OutdoorLightScattering.h
type FrameConstantBuffer (line 40) | struct FrameConstantBuffer
type CONTROL_IDS (line 59) | enum CONTROL_IDS
function class (line 112) | class COutdoorLightScatteringSample:public CPUT_DX11
FILE: RenderTechnique.cpp
function HRESULT (line 47) | static
function HRESULT (line 84) | HRESULT CRenderTechnique::CreateVertexShaderFromFile(LPCTSTR strFilePath,
function HRESULT (line 102) | HRESULT CRenderTechnique::CreateGeometryShaderFromFile(LPCTSTR strFilePath,
function HRESULT (line 121) | HRESULT CRenderTechnique::CreatePixelShaderFromFile(LPCTSTR strFilePath,
function HRESULT (line 140) | HRESULT CRenderTechnique::CreateComputeShaderFromFile(LPCTSTR strFilePath,
function HRESULT (line 159) | HRESULT CRenderTechnique::CreateVGPShadersFromFile(LPCTSTR strFilePath,
function HRESULT (line 201) | HRESULT CRenderTechnique::CreateDefaultBlendState()
function HRESULT (line 214) | HRESULT CRenderTechnique::CreateDefaultDepthState(BOOL bEnableDepth,
function HRESULT (line 230) | HRESULT CRenderTechnique::CreateDefaultRasterizerState(D3D11_FILL_MODE F...
function HRESULT (line 247) | HRESULT CRenderTechnique::CreateSampler(ID3D11SamplerState **ppSamplerSt...
FILE: RenderTechnique.h
function class (line 22) | class CRenderTechnique
function SetBS (line 47) | void SetBS(ID3D11BlendState *pBS ){m_pBS = pBS;}
function IsValid (line 56) | bool IsValid(){ return m_pDevice && m_pContext && (m_pPS || m_pCS);}
FILE: ShaderMacroHelper.h
function class (line 21) | class CD3DShaderMacroHelper
function AddShaderMacro (line 36) | void AddShaderMacro( LPCSTR Name, LPCSTR Definition )
function AddShaderMacro (line 48) | void AddShaderMacro( LPCSTR Name, bool Definition )
function Finalize (line 54) | void Finalize()
function operator (line 61) | operator const D3D_SHADER_MACRO* ()
FILE: Terrain/ConfigFile.cpp
function HRESULT (line 21) | HRESULT ParseParameterBool( LPWSTR Value, bool &BoolValue )
function ParseParameterFloat (line 35) | float ParseParameterFloat( LPWSTR Value )
function ParseParameterInt (line 43) | int ParseParameterInt( LPWSTR Value )
function ParseParameterString (line 51) | void ParseParameterString( std::wstring &StringValue, FILE *pFile )
function ParseParameterString (line 66) | void ParseParameterString( LPWSTR StringValue, int MaxLen, FILE *pFile )
function HRESULT (line 78) | HRESULT COutdoorLightScatteringSample :: ParseConfigurationFile( LPCWSTR...
FILE: Terrain/DynamicQuadTreeNode.h
function SQuadTreeNodeLocation (line 22) | struct SQuadTreeNodeLocation
function Next (line 110) | void Next()
function CDynamicQuadTreeNode (line 137) | CDynamicQuadTreeNode *GetAncestor() const { return m_pAncestor; }
function GetDescendants (line 138) | void GetDescendants(const CDynamicQuadTreeNode* &LBDescendant,
function GetDescendants (line 149) | void GetDescendants(CDynamicQuadTreeNode* &LBDescendant,
type std (line 160) | typedef std::auto_ptr<CDynamicQuadTreeNode<NodeDataType> > AutoPtrType;
function SetPos (line 176) | void SetPos(const SQuadTreeNodeLocation& pos){ m_pos = pos; }
FILE: Terrain/EarthHemisphere.cpp
function ExtractViewFrustumPlanesFromMatrix (line 22) | void ExtractViewFrustumPlanesFromMatrix(const D3DXMATRIX &Matrix, SViewF...
function IsBoxVisible (line 65) | bool IsBoxVisible(const SViewFrustum &ViewFrustum, const SBoundingBox &Box)
type SHemisphereVertex (line 89) | struct SHemisphereVertex
method SHemisphereVertex (line 93) | SHemisphereVertex() : f3WorldPos(0,0,0), f2MaskUV0(0,0){}
type QUAD_TRIANGULATION_TYPE (line 96) | enum QUAD_TRIANGULATION_TYPE
class CTriStrip (line 118) | class CTriStrip
method CTriStrip (line 121) | CTriStrip(std::vector<IndexType> &Indices, CIndexGenerator IndexGenera...
method AddStrip (line 128) | void AddStrip(int iBaseIndex,
class CStdIndexGenerator (line 206) | class CStdIndexGenerator
method CStdIndexGenerator (line 209) | CStdIndexGenerator(int iPitch):m_iPitch(iPitch){}
method UINT (line 210) | UINT operator ()(int iCol, int iRow){return iCol + iRow*m_iPitch;}
function ComputeVertexHeight (line 218) | void ComputeVertexHeight(SHemisphereVertex &Vertex,
class CRingMeshBuilder (line 238) | class CRingMeshBuilder
method CRingMeshBuilder (line 241) | CRingMeshBuilder(ID3D11Device *pDevice,
method CreateMesh (line 246) | void CreateMesh(int iBaseIndex,
function GenerateSphereGeometry (line 301) | void GenerateSphereGeometry(ID3D11Device *pDevice,
function HRESULT (line 569) | HRESULT CEarthHemsiphere::CreateRenderStates(ID3D11Device* pd3dDevice)
function HRESULT (line 851) | HRESULT CEarthHemsiphere::OnD3D11CreateDevice( class CElevationDataSourc...
FILE: Terrain/EarthHemisphere.h
type SBoundingBox (line 22) | struct SBoundingBox
type SPlane3D (line 28) | struct SPlane3D
type SViewFrustum (line 35) | struct SViewFrustum
type TEXTURING_MODE (line 52) | enum TEXTURING_MODE
type SRingSectorMesh (line 81) | struct SRingSectorMesh
FILE: Terrain/ElevationDataSource.cpp
function UINT16 (line 144) | UINT16 CElevationDataSource :: GetGlobalMinElevation()const
function UINT16 (line 149) | UINT16 CElevationDataSource :: GetGlobalMaxElevation()const
function MirrorCoord (line 154) | int MirrorCoord(int iCoord, int iDim)
function D3DXVECTOR3 (line 198) | D3DXVECTOR3 CElevationDataSource::ComputeSurfaceNormal(float fCol, float...
FILE: Terrain/ElevationDataSource.h
function class (line 24) | class CElevationDataSource
FILE: Terrain/HierarchyArray.h
function T (line 32) | const T& operator [] (const SQuadTreeNodeLocation &at) const
function Resize (line 37) | void Resize(size_t numLevelsInHierarchy)
FILE: stdafx.h
function UnbindPSResources (line 79) | inline void UnbindPSResources(ID3D11DeviceContext *pCtx)
function UnbindVSResources (line 85) | inline void UnbindVSResources(ID3D11DeviceContext *pCtx)
function UpdateConstantBuffer (line 91) | inline void UpdateConstantBuffer(ID3D11DeviceContext *pDeviceCtx, ID3D11...
Condensed preview — 168 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,529K chars).
[
{
"path": ".gitattributes",
"chars": 483,
"preview": "# Auto detect text files and perform LF normalization\n* text=auto\n\n# Custom for Visual Studio\n*.cs diff=csharp\n*.sln"
},
{
"path": ".gitignore",
"chars": 2643,
"preview": "#################\n## Eclipse\n#################\n\n*.pydevproject\n.project\n.metadata\nbin/\ntmp/\n*.tmp\n*.bak\n*.swp\n*~.nib\nloc"
},
{
"path": "CPUT/CPUT/CPUT.h",
"chars": 18136,
"preview": "////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Corporation\n//\n"
},
{
"path": "CPUT/CPUT/CPUTAssetLibrary.cpp",
"chars": 14734,
"preview": "////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Corporation\n//\n"
},
{
"path": "CPUT/CPUT/CPUTAssetLibrary.h",
"chars": 10883,
"preview": "////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Corporation\n//\n"
},
{
"path": "CPUT/CPUT/CPUTAssetLibraryDX11.cpp",
"chars": 16913,
"preview": "////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Corporation\n//\n"
},
{
"path": "CPUT/CPUT/CPUTAssetLibraryDX11.h",
"chars": 7167,
"preview": "////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Corporation\n//\n"
},
{
"path": "CPUT/CPUT/CPUTAssetSet.cpp",
"chars": 3419,
"preview": "////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Corporation\n//\n"
},
{
"path": "CPUT/CPUT/CPUTAssetSet.h",
"chars": 2427,
"preview": "////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Corporation\n//\n"
},
{
"path": "CPUT/CPUT/CPUTAssetSetDX11.cpp",
"chars": 7380,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTAssetSetDX11.h",
"chars": 1200,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTBuffer.cpp",
"chars": 990,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTBuffer.h",
"chars": 1284,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTBufferDX11.cpp",
"chars": 4294,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTBufferDX11.h",
"chars": 4670,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTButton.cpp",
"chars": 34569,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTButton.h",
"chars": 4490,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTCallbackHandler.h",
"chars": 1344,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTCamera.cpp",
"chars": 6563,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTCamera.h",
"chars": 4859,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTCheckbox.cpp",
"chars": 19041,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTCheckbox.h",
"chars": 3917,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTComputeShaderDX11.cpp",
"chars": 3762,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTComputeShaderDX11.h",
"chars": 2004,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTConfigBlock.cpp",
"chars": 10850,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTConfigBlock.h",
"chars": 3690,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTControl.cpp",
"chars": 4023,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTControl.h",
"chars": 3810,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTDomainShaderDX11.cpp",
"chars": 3819,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTDomainShaderDX11.h",
"chars": 2006,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTDropdown.cpp",
"chars": 45840,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTDropdown.h",
"chars": 5822,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTEventHandler.h",
"chars": 3296,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTFont.cpp",
"chars": 3893,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTFont.h",
"chars": 1983,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTFontDX11.cpp",
"chars": 6949,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTFontDX11.h",
"chars": 1496,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTFrustum.cpp",
"chars": 6530,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTFrustum.h",
"chars": 1477,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTGeometryShaderDX11.cpp",
"chars": 3943,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTGeometryShaderDX11.h",
"chars": 2051,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTGuiController.cpp",
"chars": 19974,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTGuiController.h",
"chars": 4665,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTGuiControllerDX11.cpp",
"chars": 35826,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTGuiControllerDX11.h",
"chars": 6405,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTHullShaderDX11.cpp",
"chars": 3739,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTHullShaderDX11.h",
"chars": 1963,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTITTTaskMarker.cpp",
"chars": 1874,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTITTTaskMarker.h",
"chars": 1397,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTInputLayoutCache.h",
"chars": 1039,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTInputLayoutCacheDX11.cpp",
"chars": 5101,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTInputLayoutCacheDX11.h",
"chars": 1938,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTLight.cpp",
"chars": 3000,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTLight.h",
"chars": 1807,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTMaterial.cpp",
"chars": 2064,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTMaterial.h",
"chars": 4195,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTMaterialDX11.cpp",
"chars": 43515,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTMaterialDX11.h",
"chars": 10239,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTMath.h",
"chars": 36548,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTMesh.cpp",
"chars": 4047,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTMesh.h",
"chars": 8000,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTMeshDX11.cpp",
"chars": 17199,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTMeshDX11.h",
"chars": 4924,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTModel.cpp",
"chars": 12856,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTModel.h",
"chars": 3983,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTModelDX11.cpp",
"chars": 14871,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTModelDX11.h",
"chars": 2373,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTNullNode.cpp",
"chars": 1441,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTNullNode.h",
"chars": 1090,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTOSServicesWin.cpp",
"chars": 16570,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTOSServicesWin.h",
"chars": 3785,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTPerfTaskMarker.cpp",
"chars": 1697,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTPerfTaskMarker.h",
"chars": 1291,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTPixelShaderDX11.cpp",
"chars": 3818,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTPixelShaderDX11.h",
"chars": 1943,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTPostProcess.cpp",
"chars": 5803,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTPostProcess.h",
"chars": 2402,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTRefCount.h",
"chars": 1451,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTRenderNode.cpp",
"chars": 6412,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTRenderNode.h",
"chars": 6727,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTRenderParams.h",
"chars": 1312,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTRenderParamsDX.h",
"chars": 1524,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTRenderStateBlock.cpp",
"chars": 1867,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTRenderStateBlock.h",
"chars": 1814,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTRenderStateBlockDX11.cpp",
"chars": 13798,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTRenderStateBlockDX11.h",
"chars": 5198,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTRenderStateMapsDX11.h",
"chars": 15524,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTRenderTarget.cpp",
"chars": 27347,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTRenderTarget.h",
"chars": 8872,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTResource.h",
"chars": 954,
"preview": "//{{NO_DEPENDENCIES}}\n// Microsoft Visual C++ generated include file.\n// Used by test.rc\n//\n#define IDC_MYICON "
},
{
"path": "CPUT/CPUT/CPUTShaderDX11.cpp",
"chars": 2151,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTShaderDX11.h",
"chars": 1352,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTSlider.cpp",
"chars": 33146,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTSlider.h",
"chars": 4453,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTSprite.cpp",
"chars": 4444,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTSprite.h",
"chars": 1785,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTText.cpp",
"chars": 12007,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTText.h",
"chars": 3502,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTTexture.cpp",
"chars": 1526,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTTexture.h",
"chars": 1629,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTTextureDX11.cpp",
"chars": 18077,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTTextureDX11.h",
"chars": 4018,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTTimer.h",
"chars": 1124,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTTimerWin.cpp",
"chars": 3087,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTTimerWin.h",
"chars": 1417,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTVertexShaderDX11.cpp",
"chars": 3844,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTVertexShaderDX11.h",
"chars": 1958,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTWindowWin.cpp",
"chars": 18717,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUTWindowWin.h",
"chars": 2725,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUT_DX11.cpp",
"chars": 42389,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT/CPUT_DX11.h",
"chars": 7172,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "CPUT/CPUT-DX11.sln",
"chars": 1210,
"preview": "\nMicrosoft Visual Studio Solution File, Format Version 11.00\n# Visual Studio 2010\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A"
},
{
"path": "CPUT/CPUT-DX11.vcxproj",
"chars": 19045,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microso"
},
{
"path": "CPUT/CPUT-DX11.vcxproj.filters",
"chars": 12375,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuil"
},
{
"path": "CPUT/CPUT-DX11_2012.vcxproj",
"chars": 19320,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microso"
},
{
"path": "CPUT/CPUT-DX11_2012.vcxproj.filters",
"chars": 12375,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuil"
},
{
"path": "CPUT/resources/controls/atlas/atlas.cmd",
"chars": 41,
"preview": "-fbx:atlas.fbx -outputdir:../CPRT/atlas/ "
},
{
"path": "CPUT/resources/controls/atlas/atlas.set",
"chars": 260,
"preview": "[node 0]\ntype = model\nname = polySurface1\nparent = -1\nmatrixColumn0 = 1 0 -0 0\nmatrixColumn1 = 0 1 -0 0\nmatrixColumn2 = "
},
{
"path": "CPUT/resources/controls/atlas/lambert1.mtl",
"chars": 457,
"preview": "shadingmodel = lambert\nAmbientColor = 0 0 0 \nAmbientFactor = 1 \nBump = 0 0 0 \nBumpFactor = 1 \nDiffuseColor = 0.5 0.5 0.5"
},
{
"path": "CPUT/resources/shaders/GUIRenderState.rs",
"chars": 1079,
"preview": "[DepthStencilStateDX11]\nDepthEnable = false\n\n[RasterizerStateDX11]\nFillMode = D3D11_FILL_SOLID\nCullMode = D3D11_CULL_BAC"
},
{
"path": "CPUT/resources/shaders/GUIShaderDX.ps",
"chars": 549,
"preview": "//--------------------------------------------------------------------------------------\n// Pixel Shader\n//-------------"
},
{
"path": "CPUT/resources/shaders/GUIShaderDX.vs",
"chars": 878,
"preview": "//--------------------------------------------------------------------------------------\n// Vertex Shader\n//------------"
},
{
"path": "Default_Config.txt",
"chars": 759,
"preview": "RawDEMDataFile = media\\Terrain\\HeightMap.tif\nMaterialMaskFile = media\\Terrain\\Mask.png\nTexturingMode = MaterialMaskNM\nEl"
},
{
"path": "LightSctrPostProcess.cpp",
"chars": 123952,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "LightSctrPostProcess.h",
"chars": 9697,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "OutdoorLightScattering.cpp",
"chars": 77613,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "OutdoorLightScattering.h",
"chars": 6435,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "OutdoorLightScattering_2010.sln",
"chars": 2155,
"preview": "\nMicrosoft Visual Studio Solution File, Format Version 11.00\n# Visual Studio 2010\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A"
},
{
"path": "OutdoorLightScattering_2010.vcxproj",
"chars": 20506,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microso"
},
{
"path": "OutdoorLightScattering_2010.vcxproj.filters",
"chars": 4131,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuil"
},
{
"path": "OutdoorLightScattering_2012.sln",
"chars": 2002,
"preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio 2012\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A"
},
{
"path": "OutdoorLightScattering_2012.vcxproj",
"chars": 12367,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microso"
},
{
"path": "OutdoorLightScattering_2012.vcxproj.filters",
"chars": 4351,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuil"
},
{
"path": "RenderTechnique.cpp",
"chars": 8972,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "RenderTechnique.h",
"chars": 3801,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "ShaderMacroHelper.h",
"chars": 2063,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "Terrain/ConfigFile.cpp",
"chars": 6801,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "Terrain/DynamicQuadTreeNode.h",
"chars": 7874,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "Terrain/EarthHemisphere.cpp",
"chars": 47775,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "Terrain/EarthHemisphere.h",
"chars": 5401,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "Terrain/ElevationDataSource.cpp",
"chars": 9740,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "Terrain/ElevationDataSource.h",
"chars": 2587,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "Terrain/Errors.h",
"chars": 1723,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "Terrain/HierarchyArray.h",
"chars": 1686,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "Terrain/stdafx.cpp",
"chars": 815,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "fx/Common.fxh",
"chars": 6251,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "fx/LightScattering.fx",
"chars": 130003,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "fx/RefineSampleLocations.fx",
"chars": 15742,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "fx/Structures.fxh",
"chars": 9908,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "fx/Terrain.fx",
"chars": 20738,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "fx/TerrainStructs.fxh",
"chars": 2352,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
},
{
"path": "license.txt",
"chars": 10425,
"preview": "\nApache License\n Version 2.0, January 2004\n\n http://www.apache.org/licenses/ \n\nTERMS AND CONDITIONS FOR USE, REPRODUCTIO"
},
{
"path": "readme.txt",
"chars": 1471,
"preview": "Intel Corporation - Outdoor Light Scattering Sample\n\nThis sample shows how high-quality light scattering effects in larg"
},
{
"path": "stdafx.h",
"chars": 2674,
"preview": "/////////////////////////////////////////////////////////////////////////////////////////////\n// Copyright 2017 Intel Co"
}
]
// ... and 14 more files (download for full content)
About this extraction
This page contains the full source code of the GameTechDev/OutdoorLightScattering GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 168 files (15.6 MB), approximately 385.6k tokens, and a symbol index with 570 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.