Skip to content

Commit

Permalink
Start migrating custom HLMS version for Ogre 1.10 (documentation / pb…
Browse files Browse the repository at this point in the history
…s shader / sample will

follow)
Backported a few things from 2.1 which is needed like Threading / Hashing / IdString
  • Loading branch information
msari-ipe-ext-1 committed Mar 30, 2015
1 parent b4336ef commit c4bc172
Show file tree
Hide file tree
Showing 43 changed files with 5,346 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ AndroidBuild/
AndroidDependencies/
Build/
EmscriptenDependencies
EmscriptenBuild
EmscriptenBuild
buildx64
3 changes: 3 additions & 0 deletions CMake/FeatureSummary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ endif ()
if (OGRE_BUILD_COMPONENT_OVERLAY)
set(_components "${_components} + Overlay\n")
endif ()
if (OGRE_BUILD_COMPONENT_HLMS)
set(_components "${_components} + HLMS\n")
endif ()

if (DEFINED _components)
set(_features "${_features}Building components:\n${_components}")
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ cmake_dependent_option(OGRE_BUILD_COMPONENT_VOLUME "Build Volume component" TRUE
cmake_dependent_option(OGRE_BUILD_COMPONENT_PROPERTY "Build Property component" TRUE "Boost_FOUND" FALSE)
cmake_dependent_option(OGRE_BUILD_PLUGIN_CG "Build Cg plugin" TRUE "Cg_FOUND;NOT OGRE_BUILD_PLATFORM_APPLE_IOS;NOT WINDOWS_STORE;NOT WINDOWS_PHONE" FALSE)
cmake_dependent_option(OGRE_BUILD_COMPONENT_OVERLAY "Build Overlay component" TRUE "FREETYPE_FOUND" FALSE)
option(OGRE_BUILD_COMPONENT_HLMS "Build HLMS component" FALSE)
option(OGRE_BUILD_COMPONENT_RTSHADERSYSTEM "Build RTShader System component" TRUE)
cmake_dependent_option(OGRE_BUILD_RTSHADERSYSTEM_CORE_SHADERS "Build RTShader System FFP core shaders" TRUE "OGRE_BUILD_COMPONENT_RTSHADERSYSTEM" FALSE)
cmake_dependent_option(OGRE_BUILD_RTSHADERSYSTEM_EXT_SHADERS "Build RTShader System extensions shaders" TRUE "OGRE_BUILD_COMPONENT_RTSHADERSYSTEM" FALSE)
Expand Down
4 changes: 4 additions & 0 deletions Components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ endif ()
if (OGRE_BUILD_COMPONENT_OVERLAY)
add_subdirectory(Overlay)
endif ()

if (OGRE_BUILD_COMPONENT_HLMS)
add_subdirectory(HLMS)
endif ()
42 changes: 42 additions & 0 deletions Components/HLMS/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#-------------------------------------------------------------------
# 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.
#-------------------------------------------------------------------

############################################################
# HLMS optional component
############################################################

PROJECT(OgreHLMS)

# define header and source files for the library
file(GLOB HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
file(GLOB SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")

# Add needed definitions
add_definitions(-DOGRE_HLMS_EXPORTS -D_MT -D_USRDLL)

# include headers
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${OGRE_SOURCE_DIR}/OgreMain/include)

# setup target
ogre_add_library(OgreHLMS ${OGRE_COMP_LIB_TYPE} ${HEADER_FILES} ${SOURCE_FILES} ${PLATFORM_HEADER_FILES} ${PLATFORM_SOURCE_FILES})
set_target_properties(OgreHLMS PROPERTIES VERSION ${OGRE_SOVERSION} SOVERSION ${OGRE_SOVERSION})
target_link_libraries(OgreHLMS OgreMain)
if (OGRE_CONFIG_THREADS)
target_link_libraries(OgreHLMS ${OGRE_THREAD_LIBRARIES})
endif ()

# install
ogre_config_framework(OgreHLMS)
ogre_config_component(OgreHLMS)

install(FILES ${HEADER_FILES}
DESTINATION include/OGRE/HLMS
)

75 changes: 75 additions & 0 deletions Components/HLMS/include/OgreHlmsDatablock.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2015 Torus Knot Software Ltd
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.
-----------------------------------------------------------------------------
*/

#pragma once

#include "Ogre.h"
#include "OgreHlmsPrerequisites.h"
#include "OgreHlmsPropertyMap.h"
#include "OgreHlmsShaderTemplate.h"

namespace Ogre
{
/** \addtogroup Component
* @{
*/
/** \addtogroup Hlms
* @{
*/
class _OgreHlmsExport HlmsDatablock
{
public:
HlmsDatablock(Ogre::GpuProgramType type, PropertyMap* propertyMap);

PropertyMap* getPropertyMap(){ return mPropertyMap; }

Ogre::GpuProgramType getShaderType(){ return mShaderType; }
const Ogre::String& getLanguarge(){ return mLanguarge; }
ShaderTemplate* getTemplate();
const Ogre::StringVector& getProfileList(){ return mProfilesList; }

void setLanguarge(const Ogre::String& languarge);
void setTemplateName(const Ogre::String& tamplateName);
void addProfile(const Ogre::String& profile);

Ogre::uint32 getHash();

protected:
ShaderTemplate mTemplate;
Ogre::String mTamplateName;
Ogre::String mLanguarge;
Ogre::GpuProgramType mShaderType;
PropertyMap* mPropertyMap;
Ogre::StringVector mProfilesList; // vs_2_0, fs_3_0, ...

Ogre::uint32 mHash;

void reload();
};
}

72 changes: 72 additions & 0 deletions Components/HLMS/include/OgreHlmsManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2015 Torus Knot Software Ltd
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.
-----------------------------------------------------------------------------
*/

#pragma once

#include "Ogre.h"
#include "OgreHlmsPrerequisites.h"
#include "OgreHlmsShaderManager.h"
#include "Threading/OgreThreadHeaders.h"

namespace Ogre
{
class HlmsMaterialBase;

/** \addtogroup Component
* @{
*/
/** \addtogroup Hlms
* @{
*/
class _OgreHlmsExport HlmsManager : public Ogre::RenderObjectListener, public Ogre::Camera::Listener
{
public:
HlmsManager(Ogre::Camera* camera);
virtual ~HlmsManager();

virtual void cameraPreRenderScene(Ogre::Camera* cam);

virtual void notifyRenderSingleObject(
Ogre::Renderable* rend,
const Ogre::Pass* pass,
const Ogre::AutoParamDataSource* source,
const Ogre::LightList* pLightList,
bool suppressRenderStateChanges);

void bind(Ogre::Renderable* rend, HlmsMaterialBase* material);

protected:
Ogre::Camera* mCamera;
Ogre::SceneManager* mSceneManager;

ShaderManager mShaderManager;

std::unordered_map<Ogre::Renderable*, HlmsMaterialBase*> mBindedMaterials;
};
}

65 changes: 65 additions & 0 deletions Components/HLMS/include/OgreHlmsMaterialBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2015 Torus Knot Software Ltd
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.
-----------------------------------------------------------------------------
*/

#pragma once

#include "Ogre.h"
#include "OgreHlmsPrerequisites.h"
#include "OgreHlmsPropertyMap.h"
#include "OgreHlmsDatablock.h"

namespace Ogre
{
/** \addtogroup Component
* @{
*/
/** \addtogroup Hlms
* @{
*/
class _OgreHlmsExport HlmsMaterialBase
{
public:
HlmsMaterialBase();
virtual ~HlmsMaterialBase();

HlmsDatablock* getVertexDatablock(){ return &mVertexDatablock; }
HlmsDatablock* getFragmentDatablock(){ return &mFragmentDatablock; }

PropertyMap& getPropertyMap(){ return mPropertyMap; }

virtual void updatePropertyMap(Ogre::Camera* camera, const Ogre::LightList* pLightList){}
virtual void updateUniforms(Ogre::Camera* camera, Ogre::Pass* pass, const Ogre::AutoParamDataSource* source, const Ogre::LightList* pLightList, bool shaderHasChanged) {}

protected:
HlmsDatablock mVertexDatablock;
HlmsDatablock mFragmentDatablock;

PropertyMap mPropertyMap;
};
}

Loading

0 comments on commit c4bc172

Please sign in to comment.