Browse Source

Remove deprecated DirectX 10 sample

Michael Ragazzon 6 years ago
parent
commit
bbf51558bf

+ 0 - 115
CMake/Modules/FindDirectX.cmake

@@ -1,115 +0,0 @@
-#-------------------------------------------------------------------
-# This file is part of the CMake build system for OGRE
-#     (Object-oriented Graphics Rendering Engine)
-# For the latest info, see http://www.ogre3d.org/
-#
-# The contents of this file are placed in the public domain. Feel
-# free to make use of it in any way you like.
-#-------------------------------------------------------------------
-
-# -----------------------------------------------------------------------------
-# Find DirectX SDK
-# Define:
-# DirectX_FOUND
-# DirectX_INCLUDE_DIR
-# DirectX_LIBRARY
-# DirectX_ROOT_DIR
-
-if(WIN32) # The only platform it makes sense to check for DirectX SDK
-  include(FindPkgMacros)
-  findpkg_begin(DirectX)
-  
-  # Get path, convert backslashes as ${ENV_DXSDK_DIR}
-  getenv_path(DXSDK_DIR)
-  getenv_path(DIRECTX_HOME)
-  getenv_path(DIRECTX_ROOT)
-  getenv_path(DIRECTX_BASE)
-  
-  # construct search paths
-  set(DirectX_PREFIX_PATH 
-    "${DXSDK_DIR}" "${ENV_DXSDK_DIR}"
-    "${DIRECTX_HOME}" "${ENV_DIRECTX_HOME}"
-    "${DIRECTX_ROOT}" "${ENV_DIRECTX_ROOT}"
-    "${DIRECTX_BASE}" "${ENV_DIRECTX_BASE}"
-    "C:/apps_x86/Microsoft DirectX SDK*"
-    "C:/Program Files (x86)/Microsoft DirectX SDK*"
-    "C:/apps/Microsoft DirectX SDK*"
-    "C:/Program Files/Microsoft DirectX SDK*"
-	"$ENV{ProgramFiles}/Microsoft DirectX SDK*"
-  )
-  create_search_paths(DirectX)
-  # redo search if prefix path changed
-  clear_if_changed(DirectX_PREFIX_PATH
-    DirectX_LIBRARY
-	DirectX_INCLUDE_DIR
-	DirectX_ROOT_DIR
-  )
-  
-  find_path(DirectX_INCLUDE_DIR NAMES d3d9.h HINTS ${DirectX_INC_SEARCH_PATH})
-  # dlls are in DirectX_ROOT_DIR/Developer Runtime/x64|x86
-  # lib files are in DirectX_ROOT_DIR/Lib/x64|x86
-  if(CMAKE_CL_64)
-    set(DirectX_LIBPATH_SUFFIX "x64")
-  else(CMAKE_CL_64)
-    set(DirectX_LIBPATH_SUFFIX "x86")
-  endif(CMAKE_CL_64)
-  find_library(DirectX_LIBRARY NAMES d3d9 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
-  find_library(DirectX_D3DX9_LIBRARY NAMES d3dx9 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
-  find_library(DirectX_DXERR9_LIBRARY NAMES dxerr HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
-  find_library(DirectX_DXGUID_LIBRARY NAMES dxguid HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
-  find_library(DirectX_DINPUT8_LIBRARY NAMES dinput8 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
-  find_library(DirectX_XINPUT_LIBRARY NAMES xinput HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
-  find_library(DirectX_DXGI_LIBRARY NAMES dxgi HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
-  find_library(DirectX_D3DCOMPILER_LIBRARY NAMES d3dcompiler HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
-  
-  
-  if(DirectX_INCLUDE_DIR)
-    set(DirectX_ROOT_DIR "${DirectX_INCLUDE_DIR}/..") 
-  endif(DirectX_INCLUDE_DIR)
-
-  findpkg_finish(DirectX)
-  
-  set(DirectX_LIBRARIES 
-	${DirectX_LIBRARIES} 
-    ${DirectX_D3DX9_LIBRARY}
-    ${DirectX_DXERR9_LIBRARY}
-    ${DirectX_DXGUID_LIBRARY}
-    ${DirectX_DINPUT8_LIBRARY}
-    ${DirectX_DXGI_LIBRARY}
-    ${DirectX_D3DCOMPILER_LIBRARY}
-  )
-
-  # look for D3D10.1 components
-
-  if (DirectX_FOUND)
-    find_path(DirectX_D3D10_INCLUDE_DIR NAMES d3d10_1shader.h HINTS ${DirectX_INCLUDE_DIR} NO_DEFAULT_PATH)
-	get_filename_component(DirectX_LIBRARY_DIR "${DirectX_LIBRARY}" PATH)
-	message(STATUS "DX lib dir: ${DirectX_LIBRARY_DIR}")
-
-	find_library(DirectX_D3D10_LIBRARY NAMES d3d10 HINTS ${DirectX_LIBRARY_DIR} NO_DEFAULT_PATH)
-	find_library(DirectX_D3DX10_LIBRARY NAMES d3dx10 HINTS ${DirectX_LIBRARY_DIR} NO_DEFAULT_PATH)
-	
-	
-	if (DirectX_D3D10_INCLUDE_DIR AND DirectX_D3D10_LIBRARY AND DirectX_D3DX10_LIBRARY)
-	  set(DirectX_D3D10_FOUND TRUE)
-	  set(DirectX_D3D10_INCLUDE_DIRS ${DirectX_D3D10_INCLUDE_DIR})
-	  set(DirectX_D3D10_LIBRARIES ${DirectX_D3D10_LIBRARY} ${DirectX_D3DX10_LIBRARY}) 
-	endif ()
-  endif ()
-
-  # look for D3D11 components
-  if (DirectX_FOUND)
-    find_path(DirectX_D3D11_INCLUDE_DIR NAMES D3D11Shader.h HINTS ${DirectX_INCLUDE_DIR} NO_DEFAULT_PATH)
-	get_filename_component(DirectX_LIBRARY_DIR "${DirectX_LIBRARY}" PATH)
-	message(STATUS "DX lib dir: ${DirectX_LIBRARY_DIR}")
-	find_library(DirectX_D3D11_LIBRARY NAMES d3d11 d3d11_beta HINTS ${DirectX_LIBRARY_DIR} NO_DEFAULT_PATH)
-	find_library(DirectX_D3DX11_LIBRARY NAMES d3dx11 HINTS ${DirectX_LIBRARY_DIR} NO_DEFAULT_PATH)
-
-	if (DirectX_D3D11_INCLUDE_DIR AND DirectX_D3D11_LIBRARY AND DirectX_D3DX11_LIBRARY)
-	  set(DirectX_D3D11_FOUND TRUE)
-	  set(DirectX_D3D11_INCLUDE_DIRS ${DirectX_D3D11_INCLUDE_DIR})
-	  set(DirectX_D3D11_LIBRARIES ${DirectX_D3D11_LIBRARY} ${DirectX_D3DX11_LIBRARY})
-	endif ()
-  endif ()
-  
-endif(WIN32)

+ 0 - 11
CMake/SampleFileList.cmake

@@ -117,17 +117,6 @@ set(sfml2_SRC_FILES
     ${PROJECT_SOURCE_DIR}/Samples/basic/sfml2/src/SystemInterfaceSFML.cpp
     ${PROJECT_SOURCE_DIR}/Samples/basic/sfml2/src/SystemInterfaceSFML.cpp
 )
 )
 
 
-set(directx10_HDR_FILES
-    ${PROJECT_SOURCE_DIR}/Samples/basic/directx10/src/D3D10Effect.h
-    ${PROJECT_SOURCE_DIR}/Samples/basic/directx10/src/RenderInterfaceDirectx10.h
-)
-
-set(directx10_SRC_FILES
-    ${PROJECT_SOURCE_DIR}/Samples/basic/directx10/src/main.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/basic/directx10/src/RenderInterfaceDirectx10.cpp
-    ${PROJECT_SOURCE_DIR}/Samples/basic/directx10/src/ShellRenderInterfaceExtensionsDirectX10_Win32.cpp
-)
-
 set(tutorial_template_HDR_FILES
 set(tutorial_template_HDR_FILES
 )
 )
 
 

+ 0 - 1
CMake/gen_samplelists.sh

@@ -9,7 +9,6 @@ srcpath=Samples
 samples=( 'shell'
 samples=( 'shell'
 	'basic/animation' 'basic/benchmark' 'basic/bitmapfont' 'basic/customlog' 'basic/demo' 'basic/drag' 'basic/loaddocument' 'basic/treeview' 'basic/transform'
 	'basic/animation' 'basic/benchmark' 'basic/bitmapfont' 'basic/customlog' 'basic/demo' 'basic/drag' 'basic/loaddocument' 'basic/treeview' 'basic/transform'
 	'basic/sdl2' 'basic/sfml2'
 	'basic/sdl2' 'basic/sfml2'
-	'basic/directx10'
 	'tutorial/template' 'tutorial/datagrid' 'tutorial/datagrid_tree' 'tutorial/drag'
 	'tutorial/template' 'tutorial/datagrid' 'tutorial/datagrid_tree' 'tutorial/drag'
 	'invaders' 'luainvaders'
 	'invaders' 'luainvaders'
 )
 )

+ 2 - 59
CMakeLists.txt

@@ -129,10 +129,6 @@ if(APPLE)
 endif()
 endif()
 
 
 option(BUILD_SAMPLES "Build samples" OFF)
 option(BUILD_SAMPLES "Build samples" OFF)
-if(WIN32)
-	option(SKIP_DIRECTX_SAMPLES "Skip build of all DirectX related samples. Only applies if BUILD_SAMPLES is ON" ON)
-	option(SKIP_DIRECTX10_SAMPLE "Skip build of DirectX 10 related sample. Only applies if BUILD_SAMPLES is ON and SKIP_DIRECTX_SAMPLES is OFF" ON)
-endif()
 
 
 if(APPLE)
 if(APPLE)
 	if(IOS)
 	if(IOS)
@@ -431,46 +427,7 @@ endif(NOT BUILD_FRAMEWORK)
 	endif()
 	endif()
 	
 	
 	# Set up required system libraries
 	# Set up required system libraries
-	if(WIN32)
-		if(SKIP_DIRECTX_SAMPLES)
-			message("-- Skipping all DirectX samples")
-			set(SKIP_DIRECTX10_SAMPLE ON)
-		else()
-			message("-- Determing if DirectX samples can be built")
-			include(FindDirectX)
-			find_package(DirectX)
-			if(DirectX_FOUND)
-				set(DIRECTX_SAMPLE_LIST)
-				set(DIRECTX_SKIPPED_SAMPLE_LIST)
-
-				message("-- Determing if DirectX samples can be built - Yes")
-
-				if(SKIP_DIRECTX10_SAMPLE)
-					message("-- Skipping build of DirectX 10 sample: User disabled")
-					list(APPEND DIRECTX_SKIPPED_SAMPLE_LIST "DirectX10 ")
-				else()
-					if(DirectX_D3D10_FOUND)
-						list(APPEND DIRECTX_SAMPLE_LIST "DirectX10 ")
-					else()
-						set(SKIP_DIRECTX10_SAMPLE ON)
-						message("-- Skipping build of DirectX 10 sample: Missing DirectX_D3D10_INCLUDE_DIR, DirectX_D3D10_LIBRARY or DirectX_D3DX10_LIBRARY")
-						list(APPEND DIRECTX_SKIPPED_SAMPLE_LIST "DirectX10 ")
-					endif()
-				endif()
-
-
-				if(DIRECTX_SAMPLE_LIST)
-					message("-- Enabled DirectX samples: " ${DIRECTX_SAMPLE_LIST})
-				endif()
-				if(DIRECTX_SKIPPED_SAMPLE_LIST)
-					message("-- Disabled DirectX samples: " ${DIRECTX_SKIPPED_SAMPLE_LIST})
-				endif()
-			else()
-				message("-- Determing if DirectX samples can be built - No")
-				set(SKIP_DIRECTX10_SAMPLE ON)
-			endif()
-		endif()
-	elseif(APPLE)
+	if(APPLE)
 		include(FindCarbon)
 		include(FindCarbon)
 		find_package(Carbon REQUIRED)
 		find_package(Carbon REQUIRED)
 		
 		
@@ -518,21 +475,7 @@ endif(NOT BUILD_FRAMEWORK)
 			RUNTIME DESTINATION ${SAMPLES_DIR}/${sample}
 			RUNTIME DESTINATION ${SAMPLES_DIR}/${sample}
 			BUNDLE DESTINATION ${SAMPLES_DIR})
 			BUNDLE DESTINATION ${SAMPLES_DIR})
 	endforeach()
 	endforeach()
-
-	if(WIN32)
-		if(NOT SKIP_DIRECTX10_SAMPLE)
-			include_directories(${DirectX_INCLUDE_DIR} ${DirectX_D3D10_INCLUDE_DIRS})
-
-			bl_sample(directx10 ${sample_LIBRARIES}  ${DirectX_D3D10_LIBRARIES})
-
-			# The samples always set this as their current working directory
-			install(DIRECTORY DESTINATION ${SAMPLES_DIR}/basic/directx10)
-			install(TARGETS directx10 
-				RUNTIME DESTINATION ${SAMPLES_DIR}/directx10
-				BUNDLE DESTINATION ${SAMPLES_DIR})
-		endif()
-	endif()
-
+	
 	message("-- Can SDL2 sample be built")
 	message("-- Can SDL2 sample be built")
 	find_package(SDL2)
 	find_package(SDL2)
 	if(SDL2_FOUND)
 	if(SDL2_FOUND)

+ 0 - 1
Samples/README.TXT

@@ -22,7 +22,6 @@ Directory Overview:
                  * customlog    - setting up custom logging
                  * customlog    - setting up custom logging
                  * demo         - demonstrates a variety of features in RmlUi and
                  * demo         - demonstrates a variety of features in RmlUi and
                                   includes a sandbox for playing with RML/RCSS
                                   includes a sandbox for playing with RML/RCSS
-                 * directx10    - using DirectX 10 as a renderer (deprecated)
                  * drag         - dragging elements between containers
                  * drag         - dragging elements between containers
                  * loaddocument - loading your first document
                  * loaddocument - loading your first document
                  * sdl2         - integrating with SDL2
                  * sdl2         - integrating with SDL2

+ 0 - 56
Samples/basic/directx10/src/D3D10Effect.h

@@ -1,56 +0,0 @@
-#ifndef D3D10EFFECT_H
-#define D3D10EFFECT_H
-
-const char * pEffectData="float4x4 matWorld;" 
-"float4x4 matProjection;" 
-"struct VS_INPUT" 
-"{" 
-	"float4 Pos:POSITION;" 
-	"float4 Colour:COLOR;" 
-	"float2 TexCoord:TEXCOORD;" 
-"};" 
-"struct PS_INPUT" 
-"{" 
-	"float4 Pos:SV_POSITION;" 
-	"float4 Colour:COLOR; "
-	"float2 TexCoord:TEXCOORD;" 
-"};" 
-"Texture2D diffuseMap;" 
-"SamplerState diffuseSampler" 
-"{"
-    "Filter = MIN_MAG_MIP_POINT;" 
-    "AddressU = WRAP;" 
-    "AddressV = WRAP;" 
-"};" 
-"PS_INPUT VS( VS_INPUT input )" 
-"{"
-	"PS_INPUT output=(PS_INPUT)0;"
-	"float4x4 worldViewProjection=mul(matWorld,matProjection);" 	
-	"output.Pos=mul(input.Pos,worldViewProjection);" 
-	"output.TexCoord=input.TexCoord;" 
-	"output.Colour=input.Colour;" 
-    "return output;"
-"}" 
-"float4 PS(PS_INPUT input ) : SV_Target"
-"{"
-	"float4 finalColour=diffuseMap.Sample(diffuseSampler,input.TexCoord)*input.Colour;"
-    "return finalColour;"
-"}"
-"BlendState AlphaBlendingOn"
-"{"
-    "BlendEnable[0] = TRUE;"
-    "DestBlend = INV_SRC_ALPHA;"
-    "SrcBlend = SRC_ALPHA;"
-"};"
-"technique10 Render"
-"{" 
-    "pass P0" 
-    "{" 
-	"SetBlendState(AlphaBlendingOn, float4(0.0f, 0.0f, 0.0f, 0.0f), 0xFFFFFFFF);"
-    "SetVertexShader( CompileShader( vs_4_0, VS() ) );" 
-    "SetGeometryShader( nullptr );" 
-    "SetPixelShader( CompileShader( ps_4_0, PS() ) ); " 
-    "}"
-"}";
-
-#endif

+ 0 - 482
Samples/basic/directx10/src/RenderInterfaceDirectx10.cpp

@@ -1,482 +0,0 @@
-#include "RenderInterfaceDirectX10.h"
-#include <RmlUi/Core.h>
-
-#include "D3D10Effect.h"
-
-//RmlUiD3D10 Texture, this contains the actual texture and the resource view
-//for sending it to the effect
-struct RmlUiD3D10Texture
-{
-	ID3D10ShaderResourceView * textureView;
-	ID3D10Texture2D * texture2D;
-};
-
-// This structure is created for each set of geometry that RmlUi compiles. It stores the vertex and index buffers and
-// the texture associated with the geometry, if one was specified.
-struct RmlUiD310DCompiledGeometry
-{
-	//Vertex Buffer
-	ID3D10Buffer * vertices;
-	DWORD num_vertices;
-
-	//Index buffer
-	ID3D10Buffer * indices;
-	DWORD num_primitives;
-	//Texture
-	RmlUiD3D10Texture * texture;
-};
-
-// The internal format of the vertex we use for rendering RmlUi geometry. We could optimise space by having a second
-// untextured vertex for use when rendering coloured borders and backgrounds.
-struct RmlUiD3D10Vertex
-{
-	FLOAT x, y, z;
-	D3DXCOLOR colour;
-	FLOAT u, v;
-};
-
-//The layout of the vertices
-const D3D10_INPUT_ELEMENT_DESC layout[] =
-{
-    { "POSITION",0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
-	{ "COLOR",0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0},
-	{"TEXCOORD",0,DXGI_FORMAT_R32G32_FLOAT,0,28,D3D10_INPUT_PER_VERTEX_DATA,0},
-};
-
-//The constructor of the render
-RenderInterfaceDirectX10::RenderInterfaceDirectX10(void)
-{
-	m_rmlui_context = nullptr;
-	m_pD3D10Device = nullptr;
-
-	m_pEffect = nullptr;
-	m_pTechnique = nullptr;
-	m_pVertexLayout = nullptr;
-
-	m_pSwapChain = nullptr;
-	m_pRenderTargetView = nullptr;
-
-	m_pProjectionMatrixVariable = nullptr;
-	m_pWorldMatrixVariable = nullptr;
-	m_pDiffuseTextureVariable = nullptr;
-
-	m_pScissorTestDisable = nullptr;
-	m_pScissorTestEnable = nullptr;
-}
-
-//Loads the effect from memory and retrieves initial variables from the effect
-void RenderInterfaceDirectX10::setupEffect()
-{
-	//The pass we are going to use
-	ID3D10EffectPass *pass=nullptr;
-	DWORD dwShaderFlags = 0;
-	#if defined( DEBUG ) || defined( _DEBUG )
-		// Set the D3D10_SHADER_DEBUG flag to embed debug information in the shaders.
-		// Setting this flag improves the shader debugging experience, but still allows 
-		// the shaders to be optimized and to run exactly the way they will run in 
-		// the release configuration of this program. - BMD
-		dwShaderFlags |= D3D10_SHADER_DEBUG;
-
-	#endif
-	//Create our effect from Memory
-	if (FAILED(D3DX10CreateEffectFromMemory((void*)pEffectData,strlen(pEffectData),"DefaultEffect",nullptr,nullptr,"fx_4_0",dwShaderFlags,0,m_pD3D10Device,nullptr,nullptr,&m_pEffect,nullptr,nullptr)))
-	{
-		//Log error
-		Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, "Can't create default effect for rendering, graphics card may not support Shader Model 4");
-		
-	}
-	
-	//Number of elements in the layout - BMD
-	UINT numElements = sizeof(layout)/sizeof(D3D10_INPUT_ELEMENT_DESC);
-	//Get the pass description so we can get some info about the input signature of the vertices
-	D3D10_PASS_DESC passDesc;
-	m_pTechnique=m_pEffect->GetTechniqueByName("Render");
-	pass=m_pTechnique->GetPassByName("P0");
-	pass->GetDesc(&passDesc);
-	//create input layout, to allow us to map our vertex structure to the one held in the effect
-	if (FAILED(m_pD3D10Device->CreateInputLayout(layout, numElements, passDesc.pIAInputSignature, passDesc.IAInputSignatureSize, &m_pVertexLayout)))
-	{
-		Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, "Unable to create input layout");
-	}
-	//grab effect variables
-	m_pWorldMatrixVariable=m_pEffect->GetVariableByName("matWorld")->AsMatrix();
-	m_pProjectionMatrixVariable=m_pEffect->GetVariableByName("matProjection")->AsMatrix();
-
-	//grab texture variable
-	m_pDiffuseTextureVariable=m_pEffect->GetVariableByName("diffuseMap")->AsShaderResource();
-}
-
-RenderInterfaceDirectX10::~RenderInterfaceDirectX10()
-{
-	if (m_pVertexLayout)
-	{
-		m_pVertexLayout->Release();
-		m_pVertexLayout = nullptr;
-	}
-	if (m_pEffect)
-	{
-		m_pEffect->Release();
-		m_pEffect = nullptr;
-	}
-	if (m_pScissorTestDisable){
-		m_pScissorTestDisable->Release();
-		m_pScissorTestDisable = nullptr;
-	}
-	if (m_pScissorTestEnable){
-		m_pScissorTestEnable->Release();
-		m_pScissorTestEnable = nullptr;
-	}
-}
-
-// Called by RmlUi when it wants to render geometry that it does not wish to optimise.
-void RenderInterfaceDirectX10::RenderGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rml::Core::TextureHandle texture, const Rml::Core::Vector2f& translation)
-{
-	// @TODO We've chosen to not support non-compiled geometry in the DirectX renderer. If you wanted to render non-compiled
-	// geometry, for example for very small sections of geometry, you could use DrawIndexedPrimitiveUP or write to a
-	// dynamic vertex buffer which is flushed when either the texture changes or compiled geometry is drawn.
-
-        /// @TODO, HACK, just use the compiled geometry framework for now, this is inefficient but better than absolutely nothing
-        /// for the time being
-	Rml::Core::CompiledGeometryHandle geom = this->CompileGeometry(vertices, num_vertices, indices, num_indices, texture);
-	this->RenderCompiledGeometry(geom, translation);
-	this->ReleaseCompiledGeometry(geom);
-}
-
-// Called by RmlUi when it wants to compile geometry it believes will be static for the forseeable future.
-Rml::Core::CompiledGeometryHandle RenderInterfaceDirectX10::CompileGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture)
-{
-	//Create instance of geometry
-	RmlUiD310DCompiledGeometry * geometry =new RmlUiD310DCompiledGeometry();
-
-	//Vertex Buffer description
-	D3D10_BUFFER_DESC bd;
-	bd.Usage = D3D10_USAGE_DEFAULT;
-	//Set the size of the buffer
-	bd.ByteWidth = sizeof(RmlUiD3D10Vertex) * num_vertices;
-	//This is a vertex buffer
-	bd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
-	bd.CPUAccessFlags = 0;
-	bd.MiscFlags = 0;
-
-	//copy vertices into buffer
-	RmlUiD3D10Vertex * pD3D10Vertices=new RmlUiD3D10Vertex[num_vertices];
-	for (int i=0;i<num_vertices;++i)
-	{
-		pD3D10Vertices[i].x = vertices[i].position.x;
-		pD3D10Vertices[i].y = vertices[i].position.y;
-		pD3D10Vertices[i].z = 0;
-
-		pD3D10Vertices[i].colour=D3DXCOLOR((float)(vertices[i].colour.red/255), (float)(vertices[i].colour.green/255), (float)(vertices[i].colour.blue/255), 
-			(float)(vertices[i].colour.alpha/255));
-		
-		pD3D10Vertices[i].u = vertices[i].tex_coord[0];
-		pD3D10Vertices[i].v = vertices[i].tex_coord[1];
-	}
-	D3D10_SUBRESOURCE_DATA InitData;
-	InitData.pSysMem = pD3D10Vertices;
-
-	//Create VB
-	if (FAILED(m_pD3D10Device->CreateBuffer(
-		&bd,
-		&InitData,
-		&geometry->vertices))){
-		Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, "Undable to create vertex buffer for geometry");
-		return false;
-	}
-
-	delete pD3D10Vertices;
-
-	//Index buffer desc
-	bd.Usage = D3D10_USAGE_DEFAULT;
-	bd.ByteWidth = sizeof( UINT ) * num_indices;
-	bd.BindFlags = D3D10_BIND_INDEX_BUFFER;
-	bd.CPUAccessFlags = 0;
-	bd.MiscFlags = 0;
-
-	//Index values
-	InitData.pSysMem = indices;
-	//Fill and create buffer
-	if (FAILED(m_pD3D10Device->CreateBuffer(
-		&bd,
-		&InitData,
-		&geometry->indices))){
-		Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, "Undable to create index buffer for geometry");
-		return false;
-	}
-
-	//save some info in the instance of the structure
-	geometry->num_vertices = (DWORD) num_vertices;
-	geometry->num_primitives = (DWORD) num_indices / 3;
-
-	geometry->texture = texture == nullptr ? nullptr : (RmlUiD3D10Texture *) texture;
-
-	return (Rml::Core::CompiledGeometryHandle)geometry;
-}
-
-// Called by RmlUi when it wants to render application-compiled geometry.
-void RenderInterfaceDirectX10::RenderCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry, const Rml::Core::Vector2f& translation)
-{
-	//Cast to D3D10 geometry
-	RmlUiD310DCompiledGeometry* d3d10_geometry = (RmlUiD310DCompiledGeometry*) geometry;
-	
-	//if we have a texture then send it, notice we are sending the view(Shader resource) to the 
-	//effect
-	if (d3d10_geometry->texture)
-		m_pDiffuseTextureVariable->SetResource(d3d10_geometry->texture->textureView);
-	else
-		m_pDiffuseTextureVariable->SetResource(nullptr);
-	
-	//build and send the world matrix
-	D3DXMatrixTranslation(&m_matWorld, translation.x, translation.y, 0);
-	m_pWorldMatrixVariable->SetMatrix((float*)m_matWorld);
-	//Set the layout of the vertices that are held in the VB
-	m_pD3D10Device->IASetInputLayout(m_pVertexLayout);
-	//Get the stride(size) of the a vertex, we need this to tell the pipeline the size of one vertex 
-	UINT stride = sizeof(RmlUiD3D10Vertex);
-	//The offset from start of the buffer to where our vertices are located 
-	UINT offset = 0;
-	//Set the VB we are using
-	m_pD3D10Device->IASetVertexBuffers( 
-							0, 
-							1, 
-							&d3d10_geometry->vertices, 
-							&stride, 
-							&offset );
-	//Set the IB we are using
-	m_pD3D10Device->IASetIndexBuffer(d3d10_geometry->indices,DXGI_FORMAT_R32_UINT,0);
-
-
-	D3D10_TECHNIQUE_DESC techDesc;
-	m_pTechnique->GetDesc( &techDesc );
-	//Loop through the passes in the technique
-	for( UINT p = 0; p < techDesc.Passes; ++p )
-	{
-		//Get a pass at current index and apply it
-		m_pTechnique->GetPassByIndex( p )->Apply( 0 );
-		//We are drawing trangle lists
-		m_pD3D10Device->IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST );		
-							
-		//Draw call
-		m_pD3D10Device->DrawIndexed(d3d10_geometry->num_primitives*3,0,0);
-	}
-}
-
-// Called by RmlUi when it wants to release application-compiled geometry.
-void RenderInterfaceDirectX10::ReleaseCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry)
-{
-	//Clean up after ourselves
-	RmlUiD310DCompiledGeometry* d3d10_geometry=(RmlUiD310DCompiledGeometry*)geometry;
-
-	if (d3d10_geometry->vertices){
-		d3d10_geometry->vertices->Release();
-		d3d10_geometry->vertices = nullptr;
-	}
-	if (d3d10_geometry->indices){
-		d3d10_geometry->indices->Release();
-		d3d10_geometry->indices = nullptr;
-	}
-
-	delete d3d10_geometry;
-}
-
-// Called by RmlUi when it wants to enable or disable scissoring to clip content.
-void RenderInterfaceDirectX10::EnableScissorRegion(bool enable)
-{
-	//Is the scissor test enabled?
-	enable ? m_pD3D10Device->RSSetState(m_pScissorTestEnable) : m_pD3D10Device->RSSetState(m_pScissorTestDisable);
-}
-
-// Called by RmlUi when it wants to change the scissor region.
-void RenderInterfaceDirectX10::SetScissorRegion(int x, int y, int width, int height)
-{
-	//The scissor rect
-	D3D10_RECT rect;
-	rect.left=x;
-	rect.right=x+width;
-	rect.top=y;
-	rect.bottom=y+height;
-
-	m_pD3D10Device->RSSetScissorRects(1,&rect);
-}
-
-// Set to byte packing, or the compiler will expand our struct, which means it won't read correctly from file
-#pragma pack(1) 
-struct TGAHeader 
-{
-	char  idLength;
-	char  colourMapType;
-	char  dataType;
-	short int colourMapOrigin;
-	short int colourMapLength;
-	char  colourMapDepth;
-	short int xOrigin;
-	short int yOrigin;
-	short int width;
-	short int height;
-	char  bitsPerPixel;
-	char  imageDescriptor;
-};
-// Restore packing
-#pragma pack()
-
-// Called by RmlUi when a texture is required by the library.
-bool RenderInterfaceDirectX10::LoadTexture(Rml::Core::TextureHandle& texture_handle, Rml::Core::Vector2i& texture_dimensions, const Rml::Core::String& source)
-{
-	Rml::Core::FileInterface* file_interface = Rml::Core::GetFileInterface();
-	Rml::Core::FileHandle file_handle = file_interface->Open(source);
-	if (!file_handle)
-		return false;
-
-	file_interface->Seek(file_handle, 0, SEEK_END);
-	size_t buffer_size = file_interface->Tell(file_handle);
-	file_interface->Seek(file_handle, 0, SEEK_SET);
-	
-	char* buffer = new char[buffer_size];
-	file_interface->Read(buffer, buffer_size, file_handle);
-	file_interface->Close(file_handle);
-
-	TGAHeader header;
-	memcpy(&header, buffer, sizeof(TGAHeader));
-	
-	int color_mode = header.bitsPerPixel / 8;
-	int image_size = header.width * header.height * 4; // We always make 32bit textures 
-	
-	if (header.dataType != 2)
-	{
-		Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, "Only 24/32bit uncompressed TGAs are supported.");
-		return false;
-	}
-	
-	// Ensure we have at least 3 colors
-	if (color_mode < 3)
-	{
-		Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, "Only 24 and 32bit textures are supported");
-		return false;
-	}
-	
-	const char* image_src = buffer + sizeof(TGAHeader);
-	unsigned char* image_dest = new unsigned char[image_size];
-	
-	// Targa is BGR, swap to RGB and flip Y axis
-	for (long y = 0; y < header.height; y++)
-	{
-		long read_index = y * header.width * color_mode;
-		long write_index = ((header.imageDescriptor & 32) != 0) ? read_index : (header.height - y - 1) * header.width * color_mode;
-		for (long x = 0; x < header.width; x++)
-		{
-			image_dest[write_index] = image_src[read_index+2];
-			image_dest[write_index+1] = image_src[read_index+1];
-			image_dest[write_index+2] = image_src[read_index];
-			if (color_mode == 4)
-				image_dest[write_index+3] = image_src[read_index+3];
-			else
-				image_dest[write_index+3] = 255;
-			
-			write_index += 4;
-			read_index += color_mode;
-		}
-	}
-
-	texture_dimensions.x = header.width;
-	texture_dimensions.y = header.height;
-	
-	bool success = GenerateTexture(texture_handle, image_dest, texture_dimensions);
-	
-	delete [] image_dest;
-	delete [] buffer;
-	
-	return success;
-}
-
-// Called by RmlUi when a texture is required to be built from an internally-generated sequence of pixels.
-bool RenderInterfaceDirectX10::GenerateTexture(Rml::Core::TextureHandle& texture_handle, const byte* source, const Rml::Core::Vector2i& source_dimensions)
-{
-	//Create the instance of our texture
-	RmlUiD3D10Texture * pTexture=new RmlUiD3D10Texture();
-
-	//Texture description
-	D3D10_TEXTURE2D_DESC textureDesc;
-	//Width and height of the texture
-	textureDesc.Width=source_dimensions.x;
-	textureDesc.Height=source_dimensions.y;
-	//Mip levels
-	textureDesc.MipLevels=1;
-	textureDesc.ArraySize = 1;
-	//the format of the texture
-	textureDesc.Format=DXGI_FORMAT_R8G8B8A8_UNORM;
-	//The access and usage of the texture
-	textureDesc.CPUAccessFlags=D3D10_CPU_ACCESS_WRITE;
-	textureDesc.Usage=D3D10_USAGE_DYNAMIC;
-	//Our are we going to bind this texture to the pipeline
-	textureDesc.BindFlags= D3D10_BIND_SHADER_RESOURCE;
-	textureDesc.MiscFlags=0;
-	textureDesc.SampleDesc.Count=1;
-	textureDesc.SampleDesc.Quality=0;
-	
-	//create our texture
-	if (FAILED(m_pD3D10Device->CreateTexture2D(&textureDesc,nullptr,&pTexture->texture2D))){
-		Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, "Unable to create texture");
-		return false;
-	}
-
-	//now lets fill it
-	D3D10_MAPPED_TEXTURE2D mappedTex;
-	pTexture->texture2D->Map(D3D10CalcSubresource(0,0,1),D3D10_MAP_WRITE_DISCARD,0,&mappedTex);
-	for (int y = 0; y < source_dimensions.y; ++y)
-	{
-		for (int x = 0; x < source_dimensions.x; ++x)
-		{
-			const byte* source_pixel = source + (source_dimensions.x * 4 * y) + (x * 4);
-			byte* destination_pixel = ((byte*) mappedTex.pData) + mappedTex.RowPitch * y + x * 4;
-			destination_pixel[0] = source_pixel[0];
-			destination_pixel[1] = source_pixel[1];
-			destination_pixel[2] = source_pixel[2];
-			destination_pixel[3] = source_pixel[3];
-		}
-	}
-	pTexture->texture2D->Unmap(D3D10CalcSubresource(0,0,1));
-
-	//Create the shader resoure view for our texture, we need this
-	//to send the texture to the effect
-	D3D10_SHADER_RESOURCE_VIEW_DESC srvDesc;
-	srvDesc.Format=textureDesc.Format;
-	srvDesc.ViewDimension=D3D10_SRV_DIMENSION_TEXTURE2D;
-	srvDesc.Texture2D.MipLevels=textureDesc.MipLevels;
-	srvDesc.Texture2D.MostDetailedMip=0;
-	if (FAILED(m_pD3D10Device->CreateShaderResourceView(pTexture->texture2D, &srvDesc, &pTexture->textureView))){
-		Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, "Unable to create texture view");
-		return false;
-	}
-
-	texture_handle = (Rml::Core::TextureHandle)pTexture;
-	return true;
-}
-
-// Called by RmlUi when a loaded texture is no longer required.
-void RenderInterfaceDirectX10::ReleaseTexture(Rml::Core::TextureHandle texture_handle)
-{
-	//clean up after ourselves
-	RmlUiD3D10Texture * pTexture = (RmlUiD3D10Texture*)texture_handle;
-	if (pTexture->texture2D){
-		pTexture->texture2D->Release();
-		pTexture->texture2D = nullptr;
-	}
-	if (pTexture->textureView){
-		pTexture->textureView->Release();
-		pTexture->textureView = nullptr;
-	}
-	delete pTexture;
-}
-
-// Returns the native horizontal texel offset for the renderer.
-float RenderInterfaceDirectX10::GetHorizontalTexelOffset()
-{
-	return 0.0f;
-}
-
-// Returns the native vertical texel offset for the renderer.
-float RenderInterfaceDirectX10::GetVerticalTexelOffset()
-{
-	return 0.0f;
-}
-

+ 0 - 97
Samples/basic/directx10/src/RenderInterfaceDirectx10.h

@@ -1,97 +0,0 @@
-#ifndef RENDERINTERFACEDIRECTX_H
-#define RENDERINTERFACEDIRECTX_H
-
-#include <RmlUi/Core/RenderInterface.h>
-#include "../../../shell/include/ShellRenderInterfaceExtensions.h"
-#include <d3d10.h>
-#include <d3dx10.h>
-
-/**
-	A sample render interface for RmlUi into DirectX 10.
-
-	TODO: 
-	1) Constant Buffers for variables
-
-	@author Brian McDonald
- */
-
-class RenderInterfaceDirectX10 : public Rml::Core::RenderInterface, public ShellRenderInterfaceExtensions
-{
-public:
-	RenderInterfaceDirectX10();
-	virtual ~RenderInterfaceDirectX10(void);
-
-	/// Called by RmlUi when it wants to render geometry that it does not wish to optimise.
-	virtual void RenderGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture, const Rml::Core::Vector2f& translation);
-
-	/// Called by RmlUi when it wants to compile geometry it believes will be static for the forseeable future.
-	virtual Rml::Core::CompiledGeometryHandle CompileGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture);
-
-	/// Called by RmlUi when it wants to render application-compiled geometry.
-	virtual void RenderCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry, const Rml::Core::Vector2f& translation);
-	/// Called by RmlUi when it wants to release application-compiled geometry.
-	virtual void ReleaseCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry);
-
-	/// Called by RmlUi when it wants to enable or disable scissoring to clip content.
-	virtual void EnableScissorRegion(bool enable);
-	/// Called by RmlUi when it wants to change the scissor region.
-	virtual void SetScissorRegion(int x, int y, int width, int height);
-
-	/// Called by RmlUi when a texture is required by the library.
-	virtual bool LoadTexture(Rml::Core::TextureHandle& texture_handle, Rml::Core::Vector2i& texture_dimensions, const Rml::Core::String& source);
-	/// Called by RmlUi when a texture is required to be built from an internally-generated sequence of pixels.
-	virtual bool GenerateTexture(Rml::Core::TextureHandle& texture_handle, const byte* source, const Rml::Core::Vector2i& source_dimensions);
-	/// Called by RmlUi when a loaded texture is no longer required.
-	virtual void ReleaseTexture(Rml::Core::TextureHandle texture_handle);
-
-	/// Returns the native horizontal texel offset for the renderer.
-	float GetHorizontalTexelOffset();
-	/// Returns the native vertical texel offset for the renderer.
-	float GetVerticalTexelOffset();
-
-	//loads the effect from memory
-	void setupEffect();
-
-	// ShellRenderInterfaceExtensions
-	virtual void SetViewport(int width, int height);
-	virtual void SetContext(void *context);
-	virtual bool AttachToNative(void *nativeWindow);
-	virtual void DetachFromNative(void);
-	virtual void PrepareRenderBuffer(void);
-	virtual void PresentRenderBuffer(void);
-
-private:
-	// RmlUi Context, needed for when the shell window is resized so we can update the Rml::Core::Context
-	// dimensions
-	void *m_rmlui_context;
-
-	//The D3D 10 Device
-	ID3D10Device * m_pD3D10Device;
-	//The Effect we are using to render GUI
-	ID3D10Effect * m_pEffect;
-	//The Current technique
-	ID3D10EffectTechnique*  m_pTechnique;
-	//The Vertex Layout
-	ID3D10InputLayout*      m_pVertexLayout;
-
-	//Swap Chain
-	IDXGISwapChain* m_pSwapChain;
-	//Render Target
-	ID3D10RenderTargetView* m_pRenderTargetView;
-
-	//Effect variables, used to send variables to the effect
-	ID3D10EffectMatrixVariable * m_pProjectionMatrixVariable;
-	ID3D10EffectMatrixVariable * m_pWorldMatrixVariable;
-	ID3D10EffectShaderResourceVariable *m_pDiffuseTextureVariable;
-
-	//Matrices
-	D3DXMATRIX m_matProjection;
-	D3DXMATRIX m_matWorld;
-
-	//Renderstate Blocks
-	ID3D10RasterizerState *m_pScissorTestEnable;
-	ID3D10RasterizerState *m_pScissorTestDisable;
-
-};
-
-#endif

+ 0 - 244
Samples/basic/directx10/src/ShellRenderInterfaceExtensionsDirectX10_Win32.cpp

@@ -1,244 +0,0 @@
-/*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2014 David Wimsey
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#include "RenderInterfaceDirectX10.h"
-#include <RmlUi/Core.h>
-#include <d3d10.h>
-#include <d3dx10.h>
-
-// For _T unicode/mbcs macro
-#include <tchar.h>
-
-void RenderInterfaceDirectX10::SetContext(void *context)
-{
-	m_rmlui_context = context;
-}
-
-void RenderInterfaceDirectX10::SetViewport(int width, int height)
-{
-	if(this->m_pD3D10Device != nullptr)
-	{
-		if(width == 0 || height == 0)
-		{
-			// Windows with no client area cause crashes
-			return;
-		}
-
-		if(this->m_pRenderTargetView)
-		{
-			// Release the existing render target
-			this->m_pRenderTargetView->Release();
-			this->m_pRenderTargetView = nullptr;
-		}
-
-		// Resize the swap chain's buffer to the given dimensions
-		m_pSwapChain->ResizeBuffers(2, width, height, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH);
-
-		// Recreate Render Target
-		ID3D10Texture2D *pBackBuffer;
-		if(FAILED(this->m_pSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*) &pBackBuffer)))
-		{
-			MessageBox(nullptr, _T("SwapChain->GetBuffer failed."), _T("Could not resize DirectX 10 surface"), MB_OK|MB_ICONERROR);
-			return;
-		}
-		if(FAILED(this->m_pD3D10Device->CreateRenderTargetView(pBackBuffer, nullptr, &this->m_pRenderTargetView)))
-		{
-				pBackBuffer->Release();
-				MessageBox(nullptr, _T("D3D10Device->CreateRenderTargetView failed."), _T("Could not resize DirectX 10 surface"), MB_OK|MB_ICONERROR);
-				return;
-		}
-		pBackBuffer->Release();
-	
-		this->m_pD3D10Device->OMSetRenderTargets(1, &this->m_pRenderTargetView, nullptr);
-
-		D3D10_VIEWPORT vp;
-		vp.Width = width;
-		vp.Height = height;
-		vp.MinDepth = 0.0f;
-		vp.MaxDepth = 1.0f;
-		vp.TopLeftX = 0;
-		vp.TopLeftY = 0;
-		this->m_pD3D10Device->RSSetViewports(1, &vp);
-
-		// Recreate our view and projection matrix
-		D3DXMatrixOrthoOffCenterLH(&this->m_matProjection, 0, width, height, 0, -1, 1);
-		m_pProjectionMatrixVariable->SetMatrix((float*)this->m_matProjection);
-
-		if(m_rmlui_context != nullptr)
-		{
-			((Rml::Core::Context*)m_rmlui_context)->SetDimensions(Rml::Core::Vector2i(width, height));
-		}
-	}
-}
-
-bool RenderInterfaceDirectX10::AttachToNative(void *nativeWindow)
-{
-	RECT clientRect;
-	if(!GetClientRect((HWND) nativeWindow, &clientRect))
-	{
-		// if we can't lookup the client rect, abort, something is seriously wrong
-		return false;
-	}
-	int width = clientRect.right - clientRect.left;
-	int height = clientRect.bottom - clientRect.top;
-
-	//put the device into debug if we are in a debug build
-	UINT createDeviceFlags=0;
-#ifdef _DEBUG
-	createDeviceFlags|=D3D10_CREATE_DEVICE_DEBUG;
-#endif
-
-	//Setup swap chain
-	DXGI_SWAP_CHAIN_DESC sd;
-	ZeroMemory(&sd, sizeof(sd));
-	sd.BufferCount=1;
-	sd.OutputWindow = (HWND) nativeWindow;
-	sd.Windowed = TRUE;
-	sd.SampleDesc.Count = 1;
-	sd.SampleDesc.Quality = 0;
-	sd.BufferDesc.Width = width;
-	sd.BufferDesc.Height = height;
-	sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
-	sd.BufferDesc.RefreshRate.Numerator = 60;
-	sd.BufferDesc.RefreshRate.Denominator = 1;
-	sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
-
-	//Create device and swapchain
-	if(FAILED(D3D10CreateDeviceAndSwapChain(nullptr, D3D10_DRIVER_TYPE_HARDWARE, nullptr, createDeviceFlags,	D3D10_SDK_VERSION, &sd, &this->m_pSwapChain, &this->m_pD3D10Device)))
-	{
-		if(MessageBox(nullptr, _T("D3D10CreateDeviceAndSwapChain failed for D3D10_DRIVER_TYPE_HARDWARE.\r\n\r\nWould you like to try the reference renderer, this will be very slow!"), _T("Could not intialized DirectX 10"), MB_OKCANCEL|MB_ICONERROR) == IDOK)
-		{
-			if(FAILED(D3D10CreateDeviceAndSwapChain(nullptr, D3D10_DRIVER_TYPE_REFERENCE, nullptr, createDeviceFlags,	D3D10_SDK_VERSION, &sd, &this->m_pSwapChain, &this->m_pD3D10Device)))
-			{
-				MessageBox(nullptr, _T("D3D10CreateDeviceAndSwapChain failed for D3D10_DRIVER_TYPE_REFERENCE, giving up."), _T("Could not intialized DirectX 10"), MB_OK|MB_ICONERROR);
-				return false;
-			}
-		}
-		else
-		{
-			return false;
-		}
-	}
-	
-	//Create Render Target
-	ID3D10Texture2D *pBackBuffer;
-	if(FAILED (this->m_pSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D),(void**)&pBackBuffer)))
-	{
-		MessageBox(nullptr, _T("SwapChain->GetBuffer failed."), _T("Could not intialized DirectX 10"), MB_OK|MB_ICONERROR);
-		return false;
-	}
-	if(FAILED(this->m_pD3D10Device->CreateRenderTargetView(pBackBuffer, nullptr, &this->m_pRenderTargetView)))
-	{
-			pBackBuffer->Release();
-			MessageBox(nullptr, _T("D3D10Device->CreateRenderTargetView failed."), _T("Could not intialized DirectX 10"), MB_OK|MB_ICONERROR);
-			return false;
-	}
-	pBackBuffer->Release();
-	
-	this->m_pD3D10Device->OMSetRenderTargets(1, &this->m_pRenderTargetView, nullptr);
-
-	D3D10_VIEWPORT vp;
-	vp.Width = width;
-	vp.Height = height;
-	vp.MinDepth = 0.0f;
-	vp.MaxDepth = 1.0f;
-	vp.TopLeftX = 0;
-	vp.TopLeftY = 0;
-	this->m_pD3D10Device->RSSetViewports(1, &vp);
-
-	setupEffect();
-
-	//Create our view and projection matrix
-	D3DXMatrixOrthoOffCenterLH(&this->m_matProjection, 0, width, height, 0, -1, 1);
-	m_pProjectionMatrixVariable->SetMatrix((float*)this->m_matProjection);
-
-	//Create scissor raster states
-	D3D10_RASTERIZER_DESC rasterDesc;
-	rasterDesc.FillMode=D3D10_FILL_SOLID;
-	rasterDesc.CullMode=D3D10_CULL_NONE;
-	rasterDesc.ScissorEnable=TRUE;
-	rasterDesc.FrontCounterClockwise=TRUE;
-	if(FAILED(this->m_pD3D10Device->CreateRasterizerState(&rasterDesc, &this->m_pScissorTestEnable)))
-	{
-		Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, "Can't create Raster State - ScissorEnable");
-	}
-
-	rasterDesc.ScissorEnable=FALSE;
-	if(FAILED(this->m_pD3D10Device->CreateRasterizerState(&rasterDesc, &this->m_pScissorTestDisable)))
-	{
-		Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, "Can't create Raster State - ScissorDisable");
-	}
-
-	return true;
-}
-
-void RenderInterfaceDirectX10::DetachFromNative()
-{
-	if(this->m_pD3D10Device != nullptr)
-	{
-		this->m_pD3D10Device->ClearState();
-		this->m_pD3D10Device = nullptr;
-	}
-	if(this->m_pRenderTargetView != nullptr)
-	{
-		this->m_pRenderTargetView->Release();
-		this->m_pRenderTargetView = nullptr;
-	}
-	if(this->m_pSwapChain != nullptr)
-	{
-		this->m_pSwapChain->Release();
-		this->m_pSwapChain = nullptr;
-	}
-	if(this->m_pD3D10Device != nullptr)
-	{
-		this->m_pD3D10Device->Release();
-		this->m_pD3D10Device = nullptr;
-	}
-
-}
-
-void RenderInterfaceDirectX10::PrepareRenderBuffer()
-{
-	if(this->m_pD3D10Device == nullptr)
-	{
-		return;
-	}
-
-	float ClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f };
-	this->m_pD3D10Device->ClearRenderTargetView(this->m_pRenderTargetView, ClearColor);
-}
-
-void RenderInterfaceDirectX10::PresentRenderBuffer()
-{
-	if(this->m_pSwapChain == nullptr)
-	{
-		return;
-	}
-
-	this->m_pSwapChain->Present(0, 0);
-}

+ 0 - 88
Samples/basic/directx10/src/main.cpp

@@ -1,88 +0,0 @@
-#include <RmlUi/Core.h>
-#include <RmlUi/Debugger.h>
-#include <Input.h>
-#include <Shell.h>
-#include "RenderInterfaceDirectX10.h"
-
-// Because we're a windows app
-#include <windows.h>
-
-// For _T unicode/mbcs macro
-#include <tchar.h>
-
-static Rml::Core::Context* context = nullptr;
-
-ShellRenderInterfaceExtensions *shell_renderer;
-
-void GameLoop()
-{
-	context->Update();
-
-	shell_renderer->PrepareRenderBuffer();
-	context->Render();
-	shell_renderer->PresentRenderBuffer();
-}
-
-int APIENTRY WinMain(HINSTANCE RMLUI_UNUSED_PARAMETER(instance_handle), HINSTANCE RMLUI_UNUSED_PARAMETER(previous_instance_handle), char* RMLUI_UNUSED_PARAMETER(command_line), int RMLUI_UNUSED_PARAMETER(command_show))
-{
-	RMLUI_UNUSED(instance_handle);
-	RMLUI_UNUSED(previous_instance_handle);
-	RMLUI_UNUSED(command_line);
-	RMLUI_UNUSED(command_show);
-
-	int window_width = 1024;
-	int window_height = 768;
-
-	RenderInterfaceDirectX10 directx_renderer;
-	shell_renderer = &directx_renderer;
-
-	// Generic OS initialisation, creates a window and does not attach OpenGL.
-	if (!Shell::Initialise() ||
-		!Shell::OpenWindow("DirectX 10 Sample", shell_renderer, window_width, window_height, true))
-	{
-		Shell::Shutdown();
-		return -1;
-	}
-
-	// Install our DirectX render interface into RmlUi.
-	Rml::Core::SetRenderInterface(&directx_renderer);
-
-	ShellSystemInterface system_interface;
-	Rml::Core::SetSystemInterface(&system_interface);
-
-	Rml::Core::Initialise();
-
-	// Create the main RmlUi context and set it on the shell's input layer.
-	context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(window_width, window_height));
-	if (context == nullptr)
-	{
-		Rml::Core::Shutdown();
-		Shell::Shutdown();
-		return -1;
-	}
-
-	Rml::Debugger::Initialise(context);
-	Input::SetContext(context);
-	shell_renderer->SetContext(context);
-
-	Shell::LoadFonts("assets/");
-
-	// Load and show the tutorial document.
-	Rml::Core::ElementDocument* document = context->LoadDocument("assets/demo.rml");
-	if (document != nullptr)
-	{
-		document->Show();
-		document->RemoveReference();
-	}
-
-	Shell::EventLoop(GameLoop);
-
-	// Shutdown RmlUi.
-	context->RemoveReference();
-	Rml::Core::Shutdown();
-
-	Shell::CloseWindow();
-	Shell::Shutdown();
-
-	return 0;
-}