Merge branch 'master' of github.com:highfidelity/hifi into fix-camera-update

This commit is contained in:
Dante Ruiz 2018-02-09 10:31:43 -08:00
commit b3a3d92131
56 changed files with 719 additions and 874 deletions

View file

@ -13,6 +13,11 @@ include("cmake/init.cmake")
include("cmake/compiler.cmake")
if (BUILD_SCRIBE_ONLY)
add_subdirectory(tools/scribe)
return()
endif()
if (NOT DEFINED SERVER_ONLY)
set(SERVER_ONLY 0)
endif()

View file

@ -18,7 +18,7 @@ android {
'-DANDROID_TOOLCHAIN=clang',
'-DANDROID_STL=c++_shared',
'-DQT_CMAKE_PREFIX_PATH=' + HIFI_ANDROID_PRECOMPILED + '/qt/lib/cmake',
'-DNATIVE_SCRIBE=' + HIFI_ANDROID_PRECOMPILED + '/scribe',
'-DNATIVE_SCRIBE=' + HIFI_ANDROID_PRECOMPILED + '/scribe' + EXEC_SUFFIX,
'-DHIFI_ANDROID_PRECOMPILED=' + HIFI_ANDROID_PRECOMPILED,
'-DRELEASE_NUMBER=' + RELEASE_NUMBER,
'-DRELEASE_TYPE=' + RELEASE_TYPE,

View file

@ -137,16 +137,16 @@ def packages = [
def scribeLocalFile='scribe' + EXEC_SUFFIX
def scribeFile='scribe_linux_x86_64'
def scribeChecksum='c98678d9726bd8bbf1bab792acf3ff6c'
def scribeVersion='onfeBkJWcJiTwiGOyZPVBjlyhoYQ4Axn'
def scribeChecksum='ca4b904f52f4f993c29175ba96798fa6'
def scribeVersion='wgpf4dB2Ltzg4Lb2jJ4nPFsHoDkmK_OO'
if (Os.isFamily(Os.FAMILY_MAC)) {
scribeFile = 'scribe_osx_x86_64'
scribeChecksum='a137ad62c1bf7cca739da219544a9a16'
scribeVersion='kU.Aq512HVe65uRnkFEWQEqeQfaYF2c0'
scribeChecksum='72db9d32d4e1e50add755570ac5eb749'
scribeVersion='o_NbPrktzEYtBkQf3Tn7zc1nZWzM52w6'
} else if (Os.isFamily(Os.FAMILY_WINDOWS)) {
scribeFile = 'scribe_win32_x86_64.exe'
scribeChecksum='75c2ce9ed45d17de375e3988bfaba816'
scribeVersion='24TfWFh1FBY.t6i_LdzAXZYeQOtmQNZp'
scribeChecksum='678e43d290c90fda670c6fefe038a06d'
scribeVersion='GCCJxlmd2irvNOFWfZR0U1UCLHndHQrC'
}
def options = [

View file

@ -39,56 +39,41 @@ function(AUTOSCRIBE_SHADER SHADER_FILE)
get_filename_component(SHADER_TARGET ${SHADER_FILE} NAME_WE)
get_filename_component(SHADER_EXT ${SHADER_FILE} EXT)
if(SHADER_EXT STREQUAL .slv)
set(SHADER_TARGET ${SHADER_TARGET}_vert.h)
set(SHADER_TYPE vert)
elseif(${SHADER_EXT} STREQUAL .slf)
set(SHADER_TARGET ${SHADER_TARGET}_frag.h)
set(SHADER_TYPE frag)
elseif(${SHADER_EXT} STREQUAL .slg)
set(SHADER_TARGET ${SHADER_TARGET}_geom.h)
set(SHADER_TYPE geom)
endif()
set(SHADER_TARGET ${SHADER_TARGET}_${SHADER_TYPE})
set(SHADER_TARGET "${SHADERS_DIR}/${SHADER_TARGET}")
set(SHADER_TARGET_HEADER ${SHADER_TARGET}.h)
set(SHADER_TARGET_SOURCE ${SHADER_TARGET}.cpp)
set(SCRIBE_COMMAND scribe)
# Target dependant Custom rule on the SHADER_FILE
if (APPLE)
set(GLPROFILE MAC_GL)
set(SCRIBE_ARGS -c++ -D GLPROFILE ${GLPROFILE} ${SCRIBE_INCLUDES} -o ${SHADER_TARGET} ${SHADER_FILE})
add_custom_command(OUTPUT ${SHADER_TARGET} COMMAND scribe ${SCRIBE_ARGS} DEPENDS scribe ${SHADER_INCLUDE_FILES} ${SHADER_FILE})
elseif (ANDROID)
set(GLPROFILE LINUX_GL)
set(SCRIBE_ARGS -c++ -D GLPROFILE ${GLPROFILE} ${SCRIBE_INCLUDES} -o ${SHADER_TARGET} ${SHADER_FILE})
# for an android build, we can't use the scribe that cmake would normally produce as a target,
# since it's unrunnable by the cross-compiling build machine
# so, we require the compiling user to point us at a compiled executable version for their native toolchain
if (NOT NATIVE_SCRIBE)
find_program(NATIVE_SCRIBE scribe PATHS ${SCRIBE_PATH} ENV SCRIBE_PATH)
endif()
if (NOT NATIVE_SCRIBE)
message(FATAL_ERROR "The High Fidelity scribe tool is required for shader pre-processing. \
Please compile scribe using your native toolchain and set SCRIBE_PATH to the path containing the scribe executable in your ENV.\
")
endif ()
add_custom_command(OUTPUT ${SHADER_TARGET} COMMAND ${NATIVE_SCRIBE} ${SCRIBE_ARGS} DEPENDS ${SHADER_INCLUDE_FILES} ${SHADER_FILE})
set(SCRIBE_COMMAND ${NATIVE_SCRIBE})
elseif (UNIX)
set(GLPROFILE LINUX_GL)
set(SCRIBE_ARGS -c++ -D GLPROFILE ${GLPROFILE} ${SCRIBE_INCLUDES} -o ${SHADER_TARGET} ${SHADER_FILE})
add_custom_command(OUTPUT ${SHADER_TARGET} COMMAND scribe ${SCRIBE_ARGS} DEPENDS scribe ${SHADER_INCLUDE_FILES} ${SHADER_FILE})
else ()
set(GLPROFILE PC_GL)
set(SCRIBE_ARGS -c++ -D GLPROFILE ${GLPROFILE} ${SCRIBE_INCLUDES} -o ${SHADER_TARGET} ${SHADER_FILE})
add_custom_command(OUTPUT ${SHADER_TARGET} COMMAND scribe ${SCRIBE_ARGS} DEPENDS scribe ${SHADER_INCLUDE_FILES} ${SHADER_FILE})
endif()
set(SCRIBE_ARGS -c++ -T ${SHADER_TYPE} -D GLPROFILE ${GLPROFILE} ${SCRIBE_INCLUDES} -o ${SHADER_TARGET} ${SHADER_FILE})
add_custom_command(
OUTPUT ${SHADER_TARGET_HEADER} ${SHADER_TARGET_SOURCE}
COMMAND ${SCRIBE_COMMAND} ${SCRIBE_ARGS}
DEPENDS ${SCRIBE_COMMAND} ${SHADER_INCLUDE_FILES} ${SHADER_FILE}
)
#output the generated file name
set(AUTOSCRIBE_SHADER_RETURN ${SHADER_TARGET} PARENT_SCOPE)
set(AUTOSCRIBE_SHADER_RETURN ${SHADER_TARGET_HEADER} ${SHADER_TARGET_SOURCE} PARENT_SCOPE)
file(GLOB INCLUDE_FILES ${SHADER_TARGET})
file(GLOB INCLUDE_FILES ${SHADER_TARGET_HEADER})
endfunction()
@ -126,7 +111,7 @@ macro(AUTOSCRIBE_SHADER_LIB)
if (WIN32)
source_group("Shaders" FILES ${SHADER_INCLUDE_FILES})
source_group("Shaders" FILES ${SHADER_SOURCE_FILES})
source_group("Shaders" FILES ${AUTOSCRIBE_SHADER_SRC})
source_group("Shaders\\generated" FILES ${AUTOSCRIBE_SHADER_SRC})
endif()
list(APPEND AUTOSCRIBE_SHADER_LIB_SRC ${SHADER_INCLUDE_FILES})
@ -136,4 +121,7 @@ macro(AUTOSCRIBE_SHADER_LIB)
# Link library shaders, if they exist
include_directories("${SHADERS_DIR}")
# Add search directory to find gpu/Shader.h
include_directories("${HIFI_LIBRARY_DIR}/gpu/src")
endmacro()

View file

@ -1,96 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
x="0px"
y="0px"
viewBox="0 0 50 50"
style="enable-background:new 0 0 50 50;"
xml:space="preserve"
id="svg2"
inkscape:version="0.91 r13725"
sodipodi:docname="bubble-a.svg"><metadata
id="metadata36"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs34" /><sodipodi:namedview
pagecolor="#ff4900"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1149"
inkscape:window-height="801"
id="namedview32"
showgrid="false"
inkscape:zoom="4.72"
inkscape:cx="25"
inkscape:cy="25"
inkscape:window-x="485"
inkscape:window-y="514"
inkscape:window-maximized="0"
inkscape:current-layer="svg2" /><style
type="text/css"
id="style4">
.st0{fill:#FFFFFF;}
</style><g
id="Layer_2" /><g
id="Layer_1"
style="fill:#000000;fill-opacity:1"><g
id="g8"
style="fill:#000000;fill-opacity:1"><path
class="st0"
d="M23.2,24.1c-0.8,0.9-1.5,1.8-2.2,2.6c-0.1,0.2-0.1,0.5-0.1,0.7c0.1,1.7,0.2,3.4,0.2,5.1 c0,0.8-0.4,1.2-1.1,1.3c-0.7,0.1-1.3-0.4-1.4-1.1c-0.2-2.2-0.3-4.3-0.5-6.5c0-0.3,0.1-0.7,0.4-1c1.1-1.5,2.3-3,3.4-4.5 c0.6-0.7,1.6-1.6,2.6-1.6c0.3,0,1.1,0,1.4,0c0.8-0.1,1.3,0.1,1.9,0.9c1,1.2,1.5,2.3,2.4,3.6c0.7,1.1,1.4,1.6,2.9,1.9 c1.1,0.2,2.2,0.5,3.3,0.8c0.3,0.1,0.6,0.2,0.8,0.3c0.5,0.3,0.7,0.8,0.6,1.3c-0.1,0.5-0.5,0.7-1,0.8c-0.4,0-0.9,0-1.3-0.1 c-1.4-0.3-2.7-0.6-4.1-0.9c-0.8-0.2-1.5-0.6-2.1-1.1c-0.3-0.3-0.6-0.5-0.9-0.8c0,0.3,0,0.5,0,0.7c0,1.2,0,2.4,0,3.6 c0,0.4-0.3,12.6-0.1,16.8c0,0.5-0.1,1-0.2,1.5c-0.2,0.7-0.6,1-1.4,1.1c-0.8,0-1.4-0.3-1.7-1c-0.2-0.5-0.3-1.1-0.4-1.6 c-0.4-4.6-0.9-12.9-1.1-13.8c-0.1-0.8-0.2-1.1-0.3-2.1c-0.1-0.5-0.1-0.9-0.1-1.3C23.3,27.9,23.2,26.1,23.2,24.1z"
id="path10"
style="fill:#000000;fill-opacity:1" /><path
class="st0"
d="M28.2,14.6c0,1.4-1.1,2.6-2.6,2.6l0,0c-1.4,0-2.6-1.1-2.6-2.6v-1.6c0-1.4,1.1-2.6,2.6-2.6l0,0 c1.4,0,2.6,1.1,2.6,2.6V14.6z"
id="path12"
style="fill:#000000;fill-opacity:1" /></g><path
class="st0"
d="M8.4,38.9c2.8,3.2,6.4,5.5,10.5,6.7c0.6,0.2,1.3,0.1,1.7-0.3c0.4-0.3,0.6-0.6,0.7-1c0.2-0.5,0.1-1.1-0.2-1.5 c-0.3-0.5-0.7-0.8-1.2-1c-1.6-0.5-3.2-1.2-4.6-2.1c-1.5-0.9-2.8-2.1-4-3.4c-0.4-0.4-0.9-0.7-1.5-0.7c-0.5,0-1,0.2-1.3,0.5 c-0.4,0.4-0.6,0.8-0.7,1.4C7.8,38,8,38.5,8.4,38.9z"
id="path14"
style="fill:#000000;fill-opacity:1" /><path
class="st0"
d="M43.7,36.8c0.3-0.4,0.4-1,0.3-1.5c-0.1-0.5-0.4-1-0.8-1.3c-0.3-0.2-0.7-0.3-1.1-0.3c-0.7,0-1.3,0.3-1.7,0.9 c-1.1,1.6-2.4,3-4,4.2c-1.2,0.9-2.5,1.7-3.9,2.3c-0.5,0.2-0.9,0.6-1.1,1.1c-0.2,0.5-0.2,1,0,1.5c0.4,1,1.6,1.5,2.6,1 c1.7-0.7,3.3-1.7,4.8-2.8C40.7,40.4,42.4,38.7,43.7,36.8z"
id="path16"
style="fill:#000000;fill-opacity:1" /><path
class="st0"
d="M5.1,33.2c0.5,0.4,1.2,0.4,1.8,0.2c0.5-0.2,0.9-0.6,1.1-1.1c0.2-0.5,0.2-1,0-1.5c-0.1-0.4-0.4-0.7-0.7-0.9 c-0.3-0.2-0.7-0.3-1.1-0.3c-0.2,0-0.5,0-0.7,0.1c-1,0.4-1.5,1.6-1.1,2.6C4.5,32.7,4.7,33,5.1,33.2z"
id="path18"
style="fill:#000000;fill-opacity:1" /><path
class="st0"
d="M45.4,27.3c-0.2,0-0.3-0.1-0.5-0.1c-0.9,0-1.7,0.6-1.9,1.5c-0.1,0.5-0.1,1.1,0.2,1.5c0.3,0.5,0.7,0.8,1.2,0.9 c0.2,0,0.3,0.1,0.5,0.1c0.9,0,1.7-0.6,1.9-1.5c0.1-0.5,0.1-1.1-0.2-1.5C46.4,27.8,45.9,27.5,45.4,27.3z"
id="path20"
style="fill:#000000;fill-opacity:1" /><path
class="st0"
d="M8.6,12c-0.3-0.2-0.7-0.3-1-0.3c-0.3,0-0.7,0.1-1,0.3c-0.3,0.2-0.6,0.4-0.7,0.7c-2,3.5-3.1,7.4-3.1,11.4 c0,0.2,0,0.4,0,0.6c0,0.5,0.2,1,0.6,1.4c0.4,0.4,0.9,0.6,1.4,0.6v0.4l0.1-0.4c0.5,0,1-0.2,1.4-0.6c0.4-0.4,0.6-0.9,0.5-1.4 c0-0.2,0-0.4,0-0.5c0-3.3,0.9-6.6,2.6-9.4C9.9,13.8,9.6,12.6,8.6,12z"
id="path22"
style="fill:#000000;fill-opacity:1" /><path
class="st0"
d="M39.3,11.4c-0.1,0.5,0.1,1.1,0.4,1.5c1.1,1.4,2,3,2.6,4.6c0.6,1.6,1,3.2,1.2,4.9c0,0.5,0.3,1,0.6,1.3 c0.4,0.4,1,0.6,1.5,0.5c0.5,0,1-0.3,1.4-0.7c0.3-0.4,0.5-0.9,0.5-1.5c-0.4-4.2-2-8.2-4.6-11.6c-0.4-0.5-1-0.8-1.6-0.8 c-0.4,0-0.9,0.1-1.2,0.4C39.7,10.4,39.4,10.8,39.3,11.4z"
id="path24"
style="fill:#000000;fill-opacity:1" /><path
class="st0"
d="M12.2,6.3c-0.5,0-0.9,0.2-1.3,0.5c-0.4,0.3-0.7,0.8-0.7,1.4c-0.1,0.5,0.1,1.1,0.4,1.5c0.7,0.8,2,1,2.8,0.3 c0.4-0.3,0.7-0.8,0.7-1.3c0.1-0.5-0.1-1.1-0.4-1.5C13.4,6.6,12.8,6.3,12.2,6.3z"
id="path26"
style="fill:#000000;fill-opacity:1" /><path
class="st0"
d="M37.2,5.2c-0.3-0.2-0.7-0.3-1.1-0.3c-0.7,0-1.3,0.3-1.7,0.9c-0.3,0.4-0.4,1-0.3,1.5c0.1,0.5,0.4,1,0.9,1.3 C36,9.2,37.3,8.9,37.9,8C38.4,7.1,38.2,5.8,37.2,5.2z"
id="path28"
style="fill:#000000;fill-opacity:1" /><path
class="st0"
d="M16.5,4c-0.2,0.5-0.3,1-0.1,1.5c0.4,1,1.5,1.6,2.6,1.2c3.3-1.2,6.8-1.4,10.2-0.6c0.6,0.1,1.2,0,1.7-0.4 c0.4-0.3,0.6-0.7,0.7-1.1c0.1-0.5,0-1.1-0.3-1.5c-0.3-0.5-0.7-0.8-1.3-0.9c-1.6-0.4-3.3-0.5-4.9-0.5c-2.6,0-5.1,0.4-7.5,1.3 C17.1,3.2,16.7,3.6,16.5,4z"
id="path30"
style="fill:#000000;fill-opacity:1" /></g></svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
<g>
<ellipse cx="26.1" cy="18.8" rx="4.6" ry="4.5"/>
<path d="M29.6,25.8h-6.7c-2.8,0-5,2.3-5,5v2c2,2.9,7.4,6.8,8.5,6.8c1.3,0,6.3-4,8.1-6.9v-1.9C34.5,28,32.4,25.8,29.6,25.8z"/>
<path d="M25.8,5.4C32.5,8,35.9,8.6,38.9,9.3C40,9.5,41,9.7,42.1,9.9c-0.3,4.9-0.3,9.8-0.3,12.5c0,8.7-3.6,15.3-11.3,20.4
c-1.2,0.8-2.7,1.5-4.2,2.3c-0.1,0.1-0.2,0.1-0.3,0.2c-3.7-1.7-6.8-3.8-9.2-6.3c-2.7-2.8-4.6-6.1-5.7-10.1c-0.5-1.7-0.7-3.6-0.8-6.3
c-0.1-3.6-0.3-7.8-0.7-12.9C11,9.5,12.2,9.3,13.5,9C16.6,8.3,20.1,7.6,25.8,5.4 M25.8,1.5c-0.2,0-0.4,0-0.6,0.1
C15.7,5.4,12.6,4.9,6.6,6.8C6,7,5.8,7.3,5.8,7.9c0.4,5,0.7,10.2,0.8,14.9c0.1,2.4,0.3,4.9,0.9,7.2c2.6,9.4,9,15.4,17.9,19.2
c0.2,0.1,0.4,0.1,0.6,0.1c0.2,0,0.5,0,0.7-0.1c2-1,4-1.9,5.8-3.1c8.4-5.7,13-13.4,12.9-23.6c0-3.8,0.1-9.8,0.5-15.2
c-0.2-0.1-0.3-0.2-0.5-0.2c-6.2-2-8.1-1.1-19.3-5.5C26.1,1.5,26,1.5,25.8,1.5L25.8,1.5z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -1,46 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
<!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;}
</style>
<g id="Layer_2">
</g>
<g id="Layer_1">
<g>
<path class="st0" d="M23.2,24.1c-0.8,0.9-1.5,1.8-2.2,2.6c-0.1,0.2-0.1,0.5-0.1,0.7c0.1,1.7,0.2,3.4,0.2,5.1
c0,0.8-0.4,1.2-1.1,1.3c-0.7,0.1-1.3-0.4-1.4-1.1c-0.2-2.2-0.3-4.3-0.5-6.5c0-0.3,0.1-0.7,0.4-1c1.1-1.5,2.3-3,3.4-4.5
c0.6-0.7,1.6-1.6,2.6-1.6c0.3,0,1.1,0,1.4,0c0.8-0.1,1.3,0.1,1.9,0.9c1,1.2,1.5,2.3,2.4,3.6c0.7,1.1,1.4,1.6,2.9,1.9
c1.1,0.2,2.2,0.5,3.3,0.8c0.3,0.1,0.6,0.2,0.8,0.3c0.5,0.3,0.7,0.8,0.6,1.3c-0.1,0.5-0.5,0.7-1,0.8c-0.4,0-0.9,0-1.3-0.1
c-1.4-0.3-2.7-0.6-4.1-0.9c-0.8-0.2-1.5-0.6-2.1-1.1c-0.3-0.3-0.6-0.5-0.9-0.8c0,0.3,0,0.5,0,0.7c0,1.2,0,2.4,0,3.6
c0,0.4-0.3,12.6-0.1,16.8c0,0.5-0.1,1-0.2,1.5c-0.2,0.7-0.6,1-1.4,1.1c-0.8,0-1.4-0.3-1.7-1c-0.2-0.5-0.3-1.1-0.4-1.6
c-0.4-4.6-0.9-12.9-1.1-13.8c-0.1-0.8-0.2-1.1-0.3-2.1c-0.1-0.5-0.1-0.9-0.1-1.3C23.3,27.9,23.2,26.1,23.2,24.1z"/>
<path class="st0" d="M28.2,14.6c0,1.4-1.1,2.6-2.6,2.6l0,0c-1.4,0-2.6-1.1-2.6-2.6v-1.6c0-1.4,1.1-2.6,2.6-2.6l0,0
c1.4,0,2.6,1.1,2.6,2.6V14.6z"/>
</g>
<path class="st0" d="M8.4,38.9c2.8,3.2,6.4,5.5,10.5,6.7c0.6,0.2,1.3,0.1,1.7-0.3c0.4-0.3,0.6-0.6,0.7-1c0.2-0.5,0.1-1.1-0.2-1.5
c-0.3-0.5-0.7-0.8-1.2-1c-1.6-0.5-3.2-1.2-4.6-2.1c-1.5-0.9-2.8-2.1-4-3.4c-0.4-0.4-0.9-0.7-1.5-0.7c-0.5,0-1,0.2-1.3,0.5
c-0.4,0.4-0.6,0.8-0.7,1.4C7.8,38,8,38.5,8.4,38.9z"/>
<path class="st0" d="M43.7,36.8c0.3-0.4,0.4-1,0.3-1.5c-0.1-0.5-0.4-1-0.8-1.3c-0.3-0.2-0.7-0.3-1.1-0.3c-0.7,0-1.3,0.3-1.7,0.9
c-1.1,1.6-2.4,3-4,4.2c-1.2,0.9-2.5,1.7-3.9,2.3c-0.5,0.2-0.9,0.6-1.1,1.1c-0.2,0.5-0.2,1,0,1.5c0.4,1,1.6,1.5,2.6,1
c1.7-0.7,3.3-1.7,4.8-2.8C40.7,40.4,42.4,38.7,43.7,36.8z"/>
<path class="st0" d="M5.1,33.2c0.5,0.4,1.2,0.4,1.8,0.2c0.5-0.2,0.9-0.6,1.1-1.1c0.2-0.5,0.2-1,0-1.5c-0.1-0.4-0.4-0.7-0.7-0.9
c-0.3-0.2-0.7-0.3-1.1-0.3c-0.2,0-0.5,0-0.7,0.1c-1,0.4-1.5,1.6-1.1,2.6C4.5,32.7,4.7,33,5.1,33.2z"/>
<path class="st0" d="M45.4,27.3c-0.2,0-0.3-0.1-0.5-0.1c-0.9,0-1.7,0.6-1.9,1.5c-0.1,0.5-0.1,1.1,0.2,1.5c0.3,0.5,0.7,0.8,1.2,0.9
c0.2,0,0.3,0.1,0.5,0.1c0.9,0,1.7-0.6,1.9-1.5c0.1-0.5,0.1-1.1-0.2-1.5C46.4,27.8,45.9,27.5,45.4,27.3z"/>
<path class="st0" d="M8.6,12c-0.3-0.2-0.7-0.3-1-0.3c-0.3,0-0.7,0.1-1,0.3c-0.3,0.2-0.6,0.4-0.7,0.7c-2,3.5-3.1,7.4-3.1,11.4
c0,0.2,0,0.4,0,0.6c0,0.5,0.2,1,0.6,1.4c0.4,0.4,0.9,0.6,1.4,0.6v0.4l0.1-0.4c0.5,0,1-0.2,1.4-0.6c0.4-0.4,0.6-0.9,0.5-1.4
c0-0.2,0-0.4,0-0.5c0-3.3,0.9-6.6,2.6-9.4C9.9,13.8,9.6,12.6,8.6,12z"/>
<path class="st0" d="M39.3,11.4c-0.1,0.5,0.1,1.1,0.4,1.5c1.1,1.4,2,3,2.6,4.6c0.6,1.6,1,3.2,1.2,4.9c0,0.5,0.3,1,0.6,1.3
c0.4,0.4,1,0.6,1.5,0.5c0.5,0,1-0.3,1.4-0.7c0.3-0.4,0.5-0.9,0.5-1.5c-0.4-4.2-2-8.2-4.6-11.6c-0.4-0.5-1-0.8-1.6-0.8
c-0.4,0-0.9,0.1-1.2,0.4C39.7,10.4,39.4,10.8,39.3,11.4z"/>
<path class="st0" d="M12.2,6.3c-0.5,0-0.9,0.2-1.3,0.5c-0.4,0.3-0.7,0.8-0.7,1.4c-0.1,0.5,0.1,1.1,0.4,1.5c0.7,0.8,2,1,2.8,0.3
c0.4-0.3,0.7-0.8,0.7-1.3c0.1-0.5-0.1-1.1-0.4-1.5C13.4,6.6,12.8,6.3,12.2,6.3z"/>
<path class="st0" d="M37.2,5.2c-0.3-0.2-0.7-0.3-1.1-0.3c-0.7,0-1.3,0.3-1.7,0.9c-0.3,0.4-0.4,1-0.3,1.5c0.1,0.5,0.4,1,0.9,1.3
C36,9.2,37.3,8.9,37.9,8C38.4,7.1,38.2,5.8,37.2,5.2z"/>
<path class="st0" d="M16.5,4c-0.2,0.5-0.3,1-0.1,1.5c0.4,1,1.5,1.6,2.6,1.2c3.3-1.2,6.8-1.4,10.2-0.6c0.6,0.1,1.2,0,1.7-0.4
c0.4-0.3,0.6-0.7,0.7-1.1c0.1-0.5,0-1.1-0.3-1.5c-0.3-0.5-0.7-0.8-1.3-0.9c-1.6-0.4-3.3-0.5-4.9-0.5c-2.6,0-5.1,0.4-7.5,1.3
C17.1,3.2,16.7,3.6,16.5,4z"/>
<g>
<ellipse class="st0" cx="26.1" cy="18.8" rx="4.6" ry="4.5"/>
<path class="st0" d="M29.6,25.8h-6.7c-2.8,0-5,2.3-5,5v2c2,2.9,7.4,6.8,8.5,6.8c1.3,0,6.3-4,8.1-6.9v-1.9
C34.5,28,32.4,25.8,29.6,25.8z"/>
<path class="st0" d="M25.8,5.4C32.5,8,35.9,8.6,38.9,9.3C40,9.5,41,9.7,42.1,9.9c-0.3,4.9-0.3,9.8-0.3,12.5
c0,8.7-3.6,15.3-11.3,20.4c-1.2,0.8-2.7,1.5-4.2,2.3c-0.1,0.1-0.2,0.1-0.3,0.2c-3.7-1.7-6.8-3.8-9.2-6.3c-2.7-2.8-4.6-6.1-5.7-10.1
c-0.5-1.7-0.7-3.6-0.8-6.3c-0.1-3.6-0.3-7.8-0.7-12.9C11,9.5,12.2,9.3,13.5,9C16.6,8.3,20.1,7.6,25.8,5.4 M25.8,1.5
c-0.2,0-0.4,0-0.6,0.1C15.7,5.4,12.6,4.9,6.6,6.8C6,7,5.8,7.3,5.8,7.9c0.4,5,0.7,10.2,0.8,14.9c0.1,2.4,0.3,4.9,0.9,7.2
c2.6,9.4,9,15.4,17.9,19.2c0.2,0.1,0.4,0.1,0.6,0.1c0.2,0,0.5,0,0.7-0.1c2-1,4-1.9,5.8-3.1c8.4-5.7,13-13.4,12.9-23.6
c0-3.8,0.1-9.8,0.5-15.2c-0.2-0.1-0.3-0.2-0.5-0.2c-6.2-2-8.1-1.1-19.3-5.5C26.1,1.5,26,1.5,25.8,1.5L25.8,1.5z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -19,30 +19,21 @@ import "../../../controls-uit" as HifiControlsUit
import "../../../controls" as HifiControls
import "../wallet" as HifiWallet
// references XXX from root context
Rectangle {
HifiConstants { id: hifi; }
id: root;
property string marketplaceUrl: "";
property string certificateId: "";
property string marketplaceUrl;
property string certificateId;
property string itemName: "--";
property string itemOwner: "--";
property string itemEdition: "--";
property string dateOfPurchase: "--";
property string itemCost: "--";
property string certTitleTextColor: hifi.colors.darkGray;
property string certTextColor: hifi.colors.white;
property string infoTextColor: hifi.colors.blueAccent;
// 0 means replace none
// 4 means replace all but "Item Edition"
// 5 means replace all 5 replaceable fields
property int certInfoReplaceMode: 5;
property bool isLightbox: false;
property bool isMyCert: false;
property bool useGoldCert: true;
property bool certificateInfoPending: true;
property int certificateStatus: 0;
property bool certificateStatusPending: true;
property bool isCertificateInvalid: false;
// Style
color: hifi.colors.faintGray;
Connections {
@ -54,130 +45,71 @@ Rectangle {
} else {
root.marketplaceUrl = result.data.marketplace_item_url;
root.isMyCert = result.isMyCert ? result.isMyCert : false;
if (root.certInfoReplaceMode > 3) {
root.itemName = result.data.marketplace_item_name;
// "\u2022" is the Unicode character 'BULLET' - it's what's used in password fields on the web, etc
root.itemOwner = root.isMyCert ? Account.username :
"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";
root.dateOfPurchase = root.isMyCert ? getFormattedDate(result.data.transfer_created_at * 1000) : "Undisclosed";
root.itemCost = (root.isMyCert && result.data.cost !== undefined) ? result.data.cost : "Undisclosed";
}
if (root.certInfoReplaceMode > 4) {
root.itemEdition = result.data.edition_number + "/" + (result.data.limited_run === -1 ? "\u221e" : result.data.limited_run);
}
if (root.certificateStatus === 4) { // CERTIFICATE_STATUS_OWNER_VERIFICATION_FAILED
if (root.isMyCert) {
errorText.text = "This item is an uncertified copy of an item you purchased.";
} else {
errorText.text = "The person who placed this item doesn't own it.";
}
}
root.itemOwner = root.isCertificateInvalid ? "--" : (root.isMyCert ? Account.username :
"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022");
root.itemEdition = root.isCertificateInvalid ? "Uncertified Copy" :
(result.data.edition_number + "/" + (result.data.limited_run === -1 ? "\u221e" : result.data.limited_run));
root.dateOfPurchase = root.isCertificateInvalid ? "" : getFormattedDate(result.data.transfer_created_at * 1000);
root.itemName = result.data.marketplace_item_name;
if (result.data.invalid_reason || result.data.transfer_status[0] === "failed") {
root.useGoldCert = false;
root.certTitleTextColor = hifi.colors.redHighlight;
root.certTextColor = hifi.colors.redHighlight;
root.infoTextColor = hifi.colors.redHighlight;
titleBarText.text = "Certificate\nNo Longer Valid";
titleBarText.text = "Invalid Certificate";
titleBarText.color = hifi.colors.redHighlight;
popText.text = "";
showInMarketplaceButton.visible = false;
// "Edition" text previously set above in this function
// "Owner" text previously set above in this function
// "Purchase Date" text previously set above in this function
// "Purchase Price" text previously set above in this function
if (result.data.invalid_reason) {
errorText.text = result.data.invalid_reason;
}
} else if (result.data.transfer_status[0] === "pending") {
root.useGoldCert = false;
root.certTitleTextColor = hifi.colors.redHighlight;
root.certTextColor = hifi.colors.redHighlight;
root.infoTextColor = hifi.colors.redHighlight;
titleBarText.text = "Certificate Pending";
popText.text = "";
showInMarketplaceButton.visible = true;
// "Edition" text previously set above in this function
// "Owner" text previously set above in this function
// "Purchase Date" text previously set above in this function
// "Purchase Price" text previously set above in this function
errorText.text = "The status of this item is still pending confirmation. If the purchase is not confirmed, " +
"this entity will be cleaned up by the domain.";
errorText.color = hifi.colors.baseGray;
}
}
root.certificateInfoPending = false;
}
onUpdateCertificateStatus: {
root.certificateStatus = certStatus;
if (root.certificateStatus === 1) { // CERTIFICATE_STATUS_VERIFICATION_SUCCESS
root.useGoldCert = true;
root.certTitleTextColor = hifi.colors.darkGray;
root.certTextColor = hifi.colors.white;
root.infoTextColor = hifi.colors.blueAccent;
titleBarText.text = "Certificate";
popText.text = "PROOF OF PROVENANCE";
showInMarketplaceButton.visible = true;
root.certInfoReplaceMode = 5;
// "Item Name" text will be set in "onCertificateInfoResult()"
// "Edition" text will be set in "onCertificateInfoResult()"
// "Owner" text will be set in "onCertificateInfoResult()"
// "Purchase Date" text will be set in "onCertificateInfoResult()"
// "Purchase Price" text will be set in "onCertificateInfoResult()"
errorText.text = "";
} else if (root.certificateStatus === 2) { // CERTIFICATE_STATUS_VERIFICATION_TIMEOUT
root.useGoldCert = false;
root.certTitleTextColor = hifi.colors.redHighlight;
root.certTextColor = hifi.colors.redHighlight;
root.infoTextColor = hifi.colors.redHighlight;
titleBarText.text = "Request Timed Out";
popText.text = "";
showInMarketplaceButton.visible = false;
root.certInfoReplaceMode = 0;
root.itemName = "";
root.itemEdition = "";
root.itemOwner = "";
root.dateOfPurchase = "";
root.itemCost = "";
errorText.text = "Your request to inspect this item timed out. Please try again later.";
} else if (root.certificateStatus === 3) { // CERTIFICATE_STATUS_STATIC_VERIFICATION_FAILED
root.useGoldCert = false;
root.certTitleTextColor = hifi.colors.redHighlight;
root.certTextColor = hifi.colors.redHighlight;
root.infoTextColor = hifi.colors.redHighlight;
titleBarText.text = "Certificate\nNo Longer Valid";
popText.text = "";
showInMarketplaceButton.visible = true;
root.certInfoReplaceMode = 5;
// "Item Name" text will be set in "onCertificateInfoResult()"
// "Edition" text will be set in "onCertificateInfoResult()"
// "Owner" text will be set in "onCertificateInfoResult()"
// "Purchase Date" text will be set in "onCertificateInfoResult()"
// "Purchase Price" text will be set in "onCertificateInfoResult()"
errorText.text = "The information associated with this item has been modified and it no longer matches the original certified item.";
} else if (root.certificateStatus === 4) { // CERTIFICATE_STATUS_OWNER_VERIFICATION_FAILED
root.useGoldCert = false;
root.certTitleTextColor = hifi.colors.redHighlight;
root.certTextColor = hifi.colors.redHighlight;
root.infoTextColor = hifi.colors.redHighlight;
if (certStatus === 1) { // CERTIFICATE_STATUS_VERIFICATION_SUCCESS
// NOP
} else if (certStatus === 2) { // CERTIFICATE_STATUS_VERIFICATION_TIMEOUT
root.isCertificateInvalid = true;
errorText.text = "Verification of this certificate timed out.";
errorText.color = hifi.colors.redHighlight;
} else if (certStatus === 3) { // CERTIFICATE_STATUS_STATIC_VERIFICATION_FAILED
root.isCertificateInvalid = true;
titleBarText.text = "Invalid Certificate";
titleBarText.color = hifi.colors.redHighlight;
popText.text = "";
showInMarketplaceButton.visible = true;
root.certInfoReplaceMode = 4;
// "Item Name" text will be set in "onCertificateInfoResult()"
root.itemEdition = "Uncertified Copy"
// "Owner" text will be set in "onCertificateInfoResult()"
// "Purchase Date" text will be set in "onCertificateInfoResult()"
// "Purchase Price" text will be set in "onCertificateInfoResult()"
// "Error Text" text will be set in "onCertificateInfoResult()"
root.itemOwner = "";
dateOfPurchaseHeader.text = "";
root.dateOfPurchase = "";
root.itemEdition = "Uncertified Copy";
errorText.text = "The information associated with this item has been modified and it no longer matches the original certified item.";
errorText.color = hifi.colors.baseGray;
} else if (certStatus === 4) { // CERTIFICATE_STATUS_OWNER_VERIFICATION_FAILED
root.isCertificateInvalid = true;
titleBarText.text = "Invalid Certificate";
titleBarText.color = hifi.colors.redHighlight;
popText.text = "";
root.itemOwner = "";
dateOfPurchaseHeader.text = "";
root.dateOfPurchase = "";
root.itemEdition = "Uncertified Copy";
errorText.text = "The avatar who rezzed this item doesn't own it.";
errorText.color = hifi.colors.baseGray;
} else {
console.log("Unknown certificate status received from ledger signal!");
}
root.certificateStatusPending = false;
// We've gotten cert status - we are GO on getting the cert info
Commerce.certificateInfo(root.certificateId);
}
}
onCertificateIdChanged: {
if (certificateId !== "") {
Commerce.certificateInfo(certificateId);
}
}
@ -190,35 +122,9 @@ Rectangle {
hoverEnabled: true;
}
Rectangle {
id: loadingOverlay;
z: 998;
visible: root.certificateInfoPending || root.certificateStatusPending;
anchors.fill: parent;
color: Qt.rgba(0.0, 0.0, 0.0, 0.7);
// This object is always used in a popup or full-screen Wallet section.
// This MouseArea is used to prevent a user from being
// able to click on a button/mouseArea underneath the popup/section.
MouseArea {
anchors.fill: parent;
propagateComposedEvents: false;
}
AnimatedImage {
source: "../common/images/loader.gif"
width: 96;
height: width;
anchors.verticalCenter: parent.verticalCenter;
anchors.horizontalCenter: parent.horizontalCenter;
}
}
Image {
id: backgroundImage;
anchors.fill: parent;
source: root.useGoldCert ? "images/cert-bg-gold-split.png" : "images/nocert-bg-split.png";
source: "images/cert-bg.jpg";
}
// Title text
@ -231,17 +137,16 @@ Rectangle {
anchors.top: parent.top;
anchors.topMargin: 40;
anchors.left: parent.left;
anchors.leftMargin: 36;
anchors.leftMargin: 45;
anchors.right: parent.right;
anchors.rightMargin: 8;
height: paintedHeight;
// Style
color: root.certTitleTextColor;
wrapMode: Text.WordWrap;
color: hifi.colors.darkGray;
}
// Title text
RalewayRegular {
id: popText;
text: "Proof of Provenance";
// Text size
size: 16;
// Anchors
@ -249,38 +154,9 @@ Rectangle {
anchors.topMargin: 4;
anchors.left: titleBarText.left;
anchors.right: titleBarText.right;
height: text === "" ? 0 : paintedHeight;
height: paintedHeight;
// Style
color: root.certTitleTextColor;
}
// "Close" button
HiFiGlyphs {
id: closeGlyphButton;
text: hifi.glyphs.close;
color: hifi.colors.white;
size: 26;
anchors.top: parent.top;
anchors.topMargin: 10;
anchors.right: parent.right;
anchors.rightMargin: 10;
MouseArea {
anchors.fill: parent;
hoverEnabled: true;
onEntered: {
parent.text = hifi.glyphs.closeInverted;
}
onExited: {
parent.text = hifi.glyphs.close;
}
onClicked: {
if (root.isLightbox) {
root.visible = false;
} else {
sendToScript({method: 'inspectionCertificate_closeClicked', closeGoesToPurchases: root.closeGoesToPurchases});
}
}
}
color: hifi.colors.darkGray;
}
//
@ -288,13 +164,11 @@ Rectangle {
//
Item {
id: certificateContainer;
anchors.top: titleBarText.top;
anchors.topMargin: 110;
anchors.bottom: infoContainer.top;
anchors.top: popText.bottom;
anchors.topMargin: 30;
anchors.bottom: buttonsContainer.top;
anchors.left: parent.left;
anchors.leftMargin: titleBarText.anchors.leftMargin;
anchors.right: parent.right;
anchors.rightMargin: 24;
RalewayRegular {
id: itemNameHeader;
@ -304,7 +178,9 @@ Rectangle {
// Anchors
anchors.top: parent.top;
anchors.left: parent.left;
anchors.leftMargin: 45;
anchors.right: parent.right;
anchors.rightMargin: 16;
height: paintedHeight;
// Style
color: hifi.colors.darkGray;
@ -321,30 +197,79 @@ Rectangle {
anchors.right: itemNameHeader.right;
height: paintedHeight;
// Style
color: root.certTextColor;
color: hifi.colors.white;
elide: Text.ElideRight;
MouseArea {
enabled: showInMarketplaceButton.visible;
anchors.fill: parent;
hoverEnabled: enabled;
onClicked: {
sendToScript({method: 'inspectionCertificate_showInMarketplaceClicked', marketplaceUrl: root.marketplaceUrl});
}
onEntered: itemName.color = hifi.colors.blueHighlight;
onExited: itemName.color = root.certTextColor;
onExited: itemName.color = hifi.colors.white;
}
}
RalewayRegular {
id: ownedByHeader;
text: "OWNER";
// Text size
size: 16;
// Anchors
anchors.top: itemName.bottom;
anchors.topMargin: 28;
anchors.left: parent.left;
anchors.leftMargin: 45;
anchors.right: parent.right;
anchors.rightMargin: 16;
height: paintedHeight;
// Style
color: hifi.colors.darkGray;
}
RalewayRegular {
id: ownedBy;
text: root.itemOwner;
// Text size
size: 22;
// Anchors
anchors.top: ownedByHeader.bottom;
anchors.topMargin: 8;
anchors.left: ownedByHeader.left;
height: paintedHeight;
// Style
color: hifi.colors.white;
elide: Text.ElideRight;
}
AnonymousProRegular {
id: isMyCertText;
visible: root.isMyCert && !root.isCertificateInvalid;
text: "(Private)";
size: 18;
// Anchors
anchors.top: ownedBy.top;
anchors.topMargin: 4;
anchors.bottom: ownedBy.bottom;
anchors.left: ownedBy.right;
anchors.leftMargin: 6;
anchors.right: ownedByHeader.right;
// Style
color: hifi.colors.white;
elide: Text.ElideRight;
verticalAlignment: Text.AlignVCenter;
}
RalewayRegular {
id: editionHeader;
text: "EDITION";
// Text size
size: 16;
// Anchors
anchors.top: itemName.bottom;
anchors.top: ownedBy.bottom;
anchors.topMargin: 28;
anchors.left: parent.left;
anchors.leftMargin: 45;
anchors.right: parent.right;
anchors.rightMargin: 16;
height: paintedHeight;
// Style
color: hifi.colors.darkGray;
@ -361,117 +286,21 @@ Rectangle {
anchors.right: editionHeader.right;
height: paintedHeight;
// Style
color: root.certTextColor;
}
// "Show In Marketplace" button
HifiControlsUit.Button {
id: showInMarketplaceButton;
enabled: root.marketplaceUrl;
color: hifi.buttons.blue;
colorScheme: hifi.colorSchemes.light;
anchors.bottom: parent.bottom;
anchors.bottomMargin: 48;
anchors.right: parent.right;
width: 200;
height: 40;
text: "View In Market"
onClicked: {
sendToScript({method: 'inspectionCertificate_showInMarketplaceClicked', marketplaceUrl: root.marketplaceUrl});
}
}
}
//
// "CERTIFICATE" END
//
//
// "INFO CONTAINER" START
//
Item {
id: infoContainer;
anchors.bottom: parent.bottom;
anchors.left: parent.left;
anchors.leftMargin: titleBarText.anchors.leftMargin;
anchors.right: parent.right;
anchors.rightMargin: 24;
height: root.useGoldCert ? 220 : 372;
RalewayRegular {
id: errorText;
visible: !root.useGoldCert;
// Text size
size: 20;
// Anchors
anchors.top: parent.top;
anchors.topMargin: 36;
anchors.left: parent.left;
anchors.right: parent.right;
height: 116;
// Style
wrapMode: Text.WordWrap;
color: hifi.colors.baseGray;
verticalAlignment: Text.AlignTop;
}
RalewayRegular {
id: ownedByHeader;
text: "OWNER";
// Text size
size: 16;
// Anchors
anchors.top: errorText.visible ? errorText.bottom : parent.top;
anchors.topMargin: 28;
anchors.left: parent.left;
anchors.right: parent.right;
height: paintedHeight;
// Style
color: hifi.colors.darkGray;
}
RalewayRegular {
id: ownedBy;
text: root.itemOwner;
// Text size
size: 22;
// Anchors
anchors.top: ownedByHeader.bottom;
anchors.topMargin: 8;
anchors.left: ownedByHeader.left;
height: paintedHeight;
// Style
color: root.infoTextColor;
elide: Text.ElideRight;
}
AnonymousProRegular {
id: isMyCertText;
visible: root.isMyCert && ownedBy.text !== "--" && ownedBy.text !== "";
text: "(Private)";
size: 18;
// Anchors
anchors.top: ownedBy.top;
anchors.topMargin: 4;
anchors.bottom: ownedBy.bottom;
anchors.left: ownedBy.right;
anchors.leftMargin: 6;
anchors.right: ownedByHeader.right;
// Style
color: root.infoTextColor;
elide: Text.ElideRight;
verticalAlignment: Text.AlignVCenter;
color: hifi.colors.white;
}
RalewayRegular {
id: dateOfPurchaseHeader;
text: "PURCHASE DATE";
text: "DATE OF PURCHASE";
// Text size
size: 16;
// Anchors
anchors.top: ownedBy.bottom;
anchors.top: edition.bottom;
anchors.topMargin: 28;
anchors.left: parent.left;
anchors.right: parent.horizontalCenter;
anchors.rightMargin: 8;
anchors.leftMargin: 45;
anchors.right: parent.right;
anchors.rightMargin: 16;
height: paintedHeight;
// Style
color: hifi.colors.darkGray;
@ -488,59 +317,74 @@ Rectangle {
anchors.right: dateOfPurchaseHeader.right;
height: paintedHeight;
// Style
color: root.infoTextColor;
color: hifi.colors.white;
}
RalewayRegular {
id: priceHeader;
text: "PURCHASE PRICE";
id: errorText;
// Text size
size: 16;
size: 20;
// Anchors
anchors.top: ownedBy.bottom;
anchors.topMargin: 28;
anchors.left: parent.horizontalCenter;
anchors.right: parent.right;
height: paintedHeight;
anchors.top: dateOfPurchase.bottom;
anchors.topMargin: 36;
anchors.left: dateOfPurchase.left;
anchors.right: dateOfPurchase.right;
anchors.bottom: parent.bottom;
// Style
color: hifi.colors.darkGray;
}
HiFiGlyphs {
id: hfcGlyph;
visible: priceText.text !== "Undisclosed" && priceText.text !== "";
text: hifi.glyphs.hfc;
// Size
size: 24;
// Anchors
anchors.top: priceHeader.bottom;
anchors.topMargin: 8;
anchors.left: priceHeader.left;
width: visible ? paintedWidth + 6 : 0;
height: 40;
// Style
color: root.infoTextColor;
wrapMode: Text.WordWrap;
color: hifi.colors.redHighlight;
verticalAlignment: Text.AlignTop;
horizontalAlignment: Text.AlignLeft;
}
AnonymousProRegular {
id: priceText;
text: root.itemCost;
// Text size
size: 18;
// Anchors
anchors.top: priceHeader.bottom;
anchors.topMargin: 8;
anchors.left: hfcGlyph.right;
anchors.right: priceHeader.right;
height: paintedHeight;
// Style
color: root.infoTextColor;
}
}
//
// "INFO CONTAINER" END
// "CERTIFICATE" END
//
Item {
id: buttonsContainer;
anchors.bottom: parent.bottom;
anchors.bottomMargin: 30;
anchors.left: parent.left;
anchors.right: parent.right;
height: 50;
// "Cancel" button
HifiControlsUit.Button {
color: hifi.buttons.noneBorderlessWhite;
colorScheme: hifi.colorSchemes.light;
anchors.top: parent.top;
anchors.left: parent.left;
anchors.leftMargin: 30;
width: parent.width/2 - 50;
height: 50;
text: "close";
onClicked: {
if (root.isLightbox) {
root.visible = false;
} else {
sendToScript({method: 'inspectionCertificate_closeClicked', closeGoesToPurchases: root.closeGoesToPurchases});
}
}
}
// "Show In Marketplace" button
HifiControlsUit.Button {
id: showInMarketplaceButton;
enabled: root.marketplaceUrl;
color: hifi.buttons.blue;
colorScheme: hifi.colorSchemes.light;
anchors.top: parent.top;
anchors.right: parent.right;
anchors.rightMargin: 30;
width: parent.width/2 - 50;
height: 50;
text: "View In Market"
onClicked: {
sendToScript({method: 'inspectionCertificate_showInMarketplaceClicked', marketplaceUrl: root.marketplaceUrl});
}
}
}
//
// FUNCTION DEFINITIONS START
//
@ -560,11 +404,19 @@ Rectangle {
function fromScript(message) {
switch (message.method) {
case 'inspectionCertificate_setCertificateId':
resetCert(false);
root.certificateId = message.certificateId;
break;
case 'inspectionCertificate_resetCert':
resetCert(true);
titleBarText.text = "Certificate";
popText.text = "PROOF OF PURCHASE";
root.certificateId = "";
root.itemName = "--";
root.itemOwner = "--";
root.itemEdition = "--";
root.dateOfPurchase = "--";
root.marketplaceUrl = "";
root.isMyCert = false;
errorText.text = "";
break;
default:
console.log('Unrecognized message from marketplaces.js:', JSON.stringify(message));
@ -572,33 +424,7 @@ Rectangle {
}
signal sendToScript(var message);
function resetCert(alsoResetCertID) {
if (alsoResetCertID) {
root.certificateId = "";
}
root.certInfoReplaceMode = 5;
root.certificateInfoPending = true;
root.certificateStatusPending = true;
root.useGoldCert = true;
root.certTitleTextColor = hifi.colors.darkGray;
root.certTextColor = hifi.colors.white;
root.infoTextColor = hifi.colors.blueAccent;
titleBarText.text = "Certificate";
popText.text = "";
root.itemName = "--";
root.itemOwner = "--";
root.itemEdition = "--";
root.dateOfPurchase = "--";
root.marketplaceUrl = "";
root.itemCost = "--";
root.isMyCert = false;
errorText.text = "";
}
function getFormattedDate(timestamp) {
if (timestamp === "--") {
return "--";
}
function addLeadingZero(n) {
return n < 10 ? '0' + n : '' + n;
}
@ -623,7 +449,7 @@ Rectangle {
var min = addLeadingZero(a.getMinutes());
var sec = addLeadingZero(a.getSeconds());
return year + '-' + month + '-' + day + ' ' + drawnHour + ':' + min + amOrPm;
return year + '-' + month + '-' + day + '<br>' + drawnHour + ':' + min + amOrPm;
}
//
// FUNCTION DEFINITIONS END

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

View file

@ -1115,7 +1115,7 @@ Item {
AnimatedImage {
id: sendingMoneyImage;
source: "../../common/images/loader.gif"
source: "./images/loader.gif"
width: 96;
height: width;
anchors.verticalCenter: parent.verticalCenter;

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View file

@ -318,7 +318,7 @@ static QTimer pingTimer;
static bool DISABLE_WATCHDOG = true;
#else
static const QString DISABLE_WATCHDOG_FLAG{ "HIFI_DISABLE_WATCHDOG" };
static bool DISABLE_WATCHDOG = QProcessEnvironment::systemEnvironment().contains(DISABLE_WATCHDOG_FLAG);
static bool DISABLE_WATCHDOG = nsightActive() || QProcessEnvironment::systemEnvironment().contains(DISABLE_WATCHDOG_FLAG);
#endif
#if defined(USE_GLES)
@ -415,20 +415,26 @@ public:
*crashTrigger = 0xDEAD10CC;
}
static void withPause(const std::function<void()>& lambda) {
pause();
lambda();
resume();
}
static void pause() {
_paused = true;
}
static void resume() {
_paused = false;
// Update the heartbeat BEFORE resuming the checks
updateHeartbeat();
_paused = false;
}
void run() override {
while (!_quit) {
QThread::sleep(HEARTBEAT_UPDATE_INTERVAL_SECS);
// Don't do heartbeat detection under nsight
if (nsightActive() || _paused) {
if (_paused) {
continue;
}
uint64_t lastHeartbeat = _heartbeat; // sample atomic _heartbeat, because we could context switch away and have it updated on us
@ -2283,29 +2289,22 @@ void Application::initializeGL() {
initDisplay();
qCDebug(interfaceapp, "Initialized Display.");
#ifdef Q_OS_OSX
// FIXME: on mac os the shaders take up to 1 minute to compile, so we pause the deadlock watchdog thread.
DeadlockWatchdogThread::pause();
#endif
// Set up the render engine
render::CullFunctor cullFunctor = LODManager::shouldRender;
static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD";
_renderEngine->addJob<UpdateSceneTask>("UpdateScene");
// FIXME: on low end systems os the shaders take up to 1 minute to compile, so we pause the deadlock watchdog thread.
DeadlockWatchdogThread::withPause([&] {
// Set up the render engine
render::CullFunctor cullFunctor = LODManager::shouldRender;
static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD";
_renderEngine->addJob<UpdateSceneTask>("UpdateScene");
#ifndef Q_OS_ANDROID
_renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraJob", cullFunctor, !DISABLE_DEFERRED);
_renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraJob", cullFunctor, !DISABLE_DEFERRED);
#endif
_renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, !DISABLE_DEFERRED, render::ItemKey::TAG_BITS_0, render::ItemKey::TAG_BITS_0);
_renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, !DISABLE_DEFERRED, render::ItemKey::TAG_BITS_0, render::ItemKey::TAG_BITS_0);
_renderEngine->load();
_renderEngine->registerScene(_main3DScene);
_renderEngine->load();
_renderEngine->registerScene(_main3DScene);
// Now that OpenGL is initialized, we are sure we have a valid context and can create the various pipeline shaders with success.
DependencyManager::get<GeometryCache>()->initializeShapePipelines();
#ifdef Q_OS_OSX
DeadlockWatchdogThread::resume();
#endif
// Now that OpenGL is initialized, we are sure we have a valid context and can create the various pipeline shaders with success.
DependencyManager::get<GeometryCache>()->initializeShapePipelines();
});
_offscreenContext = new OffscreenGLCanvas();
_offscreenContext->setObjectName("MainThreadContext");
@ -2404,7 +2403,9 @@ void Application::initializeUi() {
tabletScriptingInterface->getTablet(SYSTEM_TABLET);
}
auto offscreenUi = DependencyManager::get<OffscreenUi>();
DeadlockWatchdogThread::pause();
offscreenUi->create();
DeadlockWatchdogThread::resume();
auto surfaceContext = offscreenUi->getSurfaceContext();

View file

@ -55,7 +55,7 @@ void Application::paintGL() {
// If a display plugin loses it's underlying support, it
// needs to be able to signal us to not use it
if (!displayPlugin->beginFrameRender(_renderFrameCount)) {
updateDisplayMode();
QMetaObject::invokeMethod(this, "updateDisplayMode");
return;
}
}

View file

@ -168,7 +168,7 @@ float LODManager::getDesktopLODDecreaseFPS() const {
}
float LODManager::getDesktopLODIncreaseFPS() const {
return glm::max(((float)MSECS_PER_SECOND / _desktopMaxRenderTime) + INCREASE_LOD_GAP_FPS, MAX_LIKELY_DESKTOP_FPS);
return glm::min(((float)MSECS_PER_SECOND / _desktopMaxRenderTime) + INCREASE_LOD_GAP_FPS, MAX_LIKELY_DESKTOP_FPS);
}
void LODManager::setHMDLODDecreaseFPS(float fps) {
@ -184,7 +184,7 @@ float LODManager::getHMDLODDecreaseFPS() const {
}
float LODManager::getHMDLODIncreaseFPS() const {
return glm::max(((float)MSECS_PER_SECOND / _hmdMaxRenderTime) + INCREASE_LOD_GAP_FPS, MAX_LIKELY_HMD_FPS);
return glm::min(((float)MSECS_PER_SECOND / _hmdMaxRenderTime) + INCREASE_LOD_GAP_FPS, MAX_LIKELY_HMD_FPS);
}
QString LODManager::getLODFeedbackText() {

View file

@ -25,7 +25,7 @@ const float DEFAULT_DESKTOP_MAX_RENDER_TIME = (float)MSECS_PER_SECOND / DEFAULT_
const float DEFAULT_HMD_MAX_RENDER_TIME = (float)MSECS_PER_SECOND / DEFAULT_HMD_LOD_DOWN_FPS; // msec
const float MAX_LIKELY_DESKTOP_FPS = 59.0f; // this is essentially, V-synch - 1 fps
const float MAX_LIKELY_HMD_FPS = 74.0f; // this is essentially, V-synch - 1 fps
const float INCREASE_LOD_GAP_FPS = 15.0f; // fps
const float INCREASE_LOD_GAP_FPS = 10.0f; // fps
// The default value DEFAULT_OCTREE_SIZE_SCALE means you can be 400 meters away from a 1 meter object in order to see it (which is ~20:20 vision).
const float ADJUST_LOD_MAX_SIZE_SCALE = DEFAULT_OCTREE_SIZE_SCALE;

View file

@ -31,6 +31,9 @@ AvatarActionHold::AvatarActionHold(const QUuid& id, EntityItemPointer ownerEntit
myAvatar->addHoldAction(this);
}
_positionalTargetSet = true;
_rotationalTargetSet = true;
#if WANT_DEBUG
qDebug() << "AvatarActionHold::AvatarActionHold" << (void*)this;
#endif

View file

@ -80,7 +80,6 @@ Web3DOverlay::Web3DOverlay() {
_webSurface->getSurfaceContext()->setContextProperty("GlobalServices", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
_webSurface->getSurfaceContext()->setContextProperty("AccountServices", AccountServicesScriptingInterface::getInstance());
_webSurface->getSurfaceContext()->setContextProperty("AddressManager", DependencyManager::get<AddressManager>().data());
}
Web3DOverlay::Web3DOverlay(const Web3DOverlay* Web3DOverlay) :
@ -201,6 +200,11 @@ void Web3DOverlay::setupQmlSurface() {
_webSurface->getSurfaceContext()->setContextProperty("offscreenFlags", flags);
_webSurface->getSurfaceContext()->setContextProperty("AddressManager", DependencyManager::get<AddressManager>().data());
_webSurface->getSurfaceContext()->setContextProperty("Account", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
_webSurface->getSurfaceContext()->setContextProperty("GlobalServices", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
_webSurface->getSurfaceContext()->setContextProperty("AccountServices", AccountServicesScriptingInterface::getInstance());
// in Qt 5.10.0 there is already an "Audio" object in the QML context
// though I failed to find it (from QtMultimedia??). So.. let it be "AudioScriptingInterface"
_webSurface->getSurfaceContext()->setContextProperty("AudioScriptingInterface", DependencyManager::get<AudioScriptingInterface>().data());

View file

@ -395,8 +395,8 @@ void HmdDisplayPlugin::HUDRenderer::build() {
void HmdDisplayPlugin::HUDRenderer::updatePipeline() {
if (!pipeline) {
auto vs = gpu::Shader::createVertex(std::string(hmd_ui_vert));
auto ps = gpu::Shader::createPixel(std::string(hmd_ui_frag));
auto vs = hmd_ui_vert::getShader();
auto ps = hmd_ui_frag::getShader();
auto program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::makeProgram(*program, gpu::Shader::BindingSet());
uniformsLocation = program->getUniformBuffers().findLocation("hudBuffer");

View file

@ -36,8 +36,8 @@ static ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, co
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
PrepareStencil::testMask(*state);
auto vertShader = gpu::Shader::createVertex(std::string(textured_particle_vert));
auto fragShader = gpu::Shader::createPixel(std::string(textured_particle_frag));
auto vertShader = textured_particle_vert::getShader();
auto fragShader = textured_particle_frag::getShader();
auto program = gpu::Shader::createProgram(vertShader, fragShader);
_texturedPipeline = texturedPipeline = gpu::Pipeline::create(program, state);

View file

@ -48,8 +48,8 @@ struct PolyLineUniforms {
static render::ShapePipelinePointer shapePipelineFactory(const render::ShapePlumber& plumber, const render::ShapeKey& key, gpu::Batch& batch) {
if (!polylinePipeline) {
auto VS = gpu::Shader::createVertex(std::string(paintStroke_vert));
auto PS = gpu::Shader::createPixel(std::string(paintStroke_frag));
auto VS = paintStroke_vert::getShader();
auto PS = paintStroke_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(VS, PS);
#ifdef POLYLINE_ENTITY_USE_FADE_EFFECT
auto fadeVS = gpu::Shader::createVertex(std::string(paintStroke_fade_vert));

View file

@ -27,6 +27,7 @@
#include <StencilMaskPass.h>
#include "EntityTreeRenderer.h"
#include "polyvox_vert.h"
#include "polyvox_frag.h"
#include "polyvox_fade_vert.h"
@ -70,6 +71,7 @@
#include "StencilMaskPass.h"
#include "EntityTreeRenderer.h"
#include "polyvox_vert.h"
#include "polyvox_frag.h"
#include "polyvox_fade_vert.h"
@ -1459,8 +1461,8 @@ static gpu::Stream::FormatPointer _vertexFormat;
ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, gpu::Batch& batch) {
if (!_pipelines[0]) {
gpu::ShaderPointer vertexShaders[2] = { gpu::Shader::createVertex(std::string(polyvox_vert)), gpu::Shader::createVertex(std::string(polyvox_fade_vert)) };
gpu::ShaderPointer pixelShaders[2] = { gpu::Shader::createPixel(std::string(polyvox_frag)), gpu::Shader::createPixel(std::string(polyvox_fade_frag)) };
gpu::ShaderPointer vertexShaders[2] = { polyvox_vert::getShader(), polyvox_fade_vert::getShader() };
gpu::ShaderPointer pixelShaders[2] = { polyvox_frag::getShader(), polyvox_fade_frag::getShader() };
gpu::Shader::BindingSet slotBindings;
slotBindings.insert(gpu::Shader::Binding(std::string("materialBuffer"), MATERIAL_GPU_SLOT));

View file

@ -16,8 +16,8 @@
#include <GeometryCache.h>
#include <PerfStat.h>
#include <render-utils/simple_vert.h>
#include <render-utils/simple_frag.h>
#include "render-utils/simple_vert.h"
#include "render-utils/simple_frag.h"
//#define SHAPE_ENTITY_USE_FADE_EFFECT
#ifdef SHAPE_ENTITY_USE_FADE_EFFECT
@ -32,8 +32,8 @@ static const float SPHERE_ENTITY_SCALE = 0.5f;
ShapeEntityRenderer::ShapeEntityRenderer(const EntityItemPointer& entity) : Parent(entity) {
_procedural._vertexSource = simple_vert;
_procedural._fragmentSource = simple_frag;
_procedural._vertexSource = simple_vert::getSource();
_procedural._fragmentSource = simple_frag::getSource();
_procedural._opaqueState->setCullMode(gpu::State::CULL_NONE);
_procedural._opaqueState->setDepthTest(true, true, gpu::LESS_EQUAL);
PrepareStencil::testMaskDrawShape(*_procedural._opaqueState);

View file

@ -73,42 +73,42 @@ ShaderPointer StandardShaderLib::getProgram(GetShader getVS, GetShader getPS) {
ShaderPointer StandardShaderLib::getDrawUnitQuadTexcoordVS() {
if (!_drawUnitQuadTexcoordVS) {
_drawUnitQuadTexcoordVS = gpu::Shader::createVertex(std::string(DrawUnitQuadTexcoord_vert));
_drawUnitQuadTexcoordVS = DrawUnitQuadTexcoord_vert::getShader();
}
return _drawUnitQuadTexcoordVS;
}
ShaderPointer StandardShaderLib::getDrawTransformUnitQuadVS() {
if (!_drawTransformUnitQuadVS) {
_drawTransformUnitQuadVS = gpu::Shader::createVertex(std::string(DrawTransformUnitQuad_vert));
_drawTransformUnitQuadVS = DrawTransformUnitQuad_vert::getShader();
}
return _drawTransformUnitQuadVS;
}
ShaderPointer StandardShaderLib::getDrawTexcoordRectTransformUnitQuadVS() {
if (!_drawTexcoordRectTransformUnitQuadVS) {
_drawTexcoordRectTransformUnitQuadVS = gpu::Shader::createVertex(std::string(DrawTexcoordRectTransformUnitQuad_vert));
_drawTexcoordRectTransformUnitQuadVS = DrawTexcoordRectTransformUnitQuad_vert::getShader();
}
return _drawTexcoordRectTransformUnitQuadVS;
}
ShaderPointer StandardShaderLib::getDrawViewportQuadTransformTexcoordVS() {
if (!_drawViewportQuadTransformTexcoordVS) {
_drawViewportQuadTransformTexcoordVS = gpu::Shader::createVertex(std::string(DrawViewportQuadTransformTexcoord_vert));
_drawViewportQuadTransformTexcoordVS = DrawViewportQuadTransformTexcoord_vert::getShader();
}
return _drawViewportQuadTransformTexcoordVS;
}
ShaderPointer StandardShaderLib::getDrawVertexPositionVS() {
if (!_drawVertexPositionVS) {
_drawVertexPositionVS = gpu::Shader::createVertex(std::string(DrawVertexPosition_vert));
_drawVertexPositionVS = DrawVertexPosition_vert::getShader();
}
return _drawVertexPositionVS;
}
ShaderPointer StandardShaderLib::getDrawTransformVertexPositionVS() {
if (!_drawTransformVertexPositionVS) {
_drawTransformVertexPositionVS = gpu::Shader::createVertex(std::string(DrawTransformVertexPosition_vert));
_drawTransformVertexPositionVS = DrawTransformVertexPosition_vert::getShader();
}
return _drawTransformVertexPositionVS;
}
@ -122,42 +122,42 @@ ShaderPointer StandardShaderLib::getDrawNadaPS() {
ShaderPointer StandardShaderLib::getDrawWhitePS() {
if (!_drawWhitePS) {
_drawWhitePS = gpu::Shader::createPixel(std::string(DrawWhite_frag));
_drawWhitePS = DrawWhite_frag::getShader();
}
return _drawWhitePS;
}
ShaderPointer StandardShaderLib::getDrawColorPS() {
if (!_drawColorPS) {
_drawColorPS = gpu::Shader::createPixel(std::string(DrawColor_frag));
_drawColorPS = DrawColor_frag::getShader();
}
return _drawColorPS;
}
ShaderPointer StandardShaderLib::getDrawTexturePS() {
if (!_drawTexturePS) {
_drawTexturePS = gpu::Shader::createPixel(std::string(DrawTexture_frag));
_drawTexturePS = DrawTexture_frag::getShader();
}
return _drawTexturePS;
}
ShaderPointer StandardShaderLib::getDrawTextureMirroredXPS() {
if (!_drawTextureMirroredXPS) {
_drawTextureMirroredXPS = gpu::Shader::createPixel(std::string(DrawTextureMirroredX_frag));
_drawTextureMirroredXPS = DrawTextureMirroredX_frag::getShader();
}
return _drawTextureMirroredXPS;
}
ShaderPointer StandardShaderLib::getDrawTextureOpaquePS() {
if (!_drawTextureOpaquePS) {
_drawTextureOpaquePS = gpu::Shader::createPixel(std::string(DrawTextureOpaque_frag));
_drawTextureOpaquePS = DrawTextureOpaque_frag::getShader();
}
return _drawTextureOpaquePS;
}
ShaderPointer StandardShaderLib::getDrawColoredTexturePS() {
if (!_drawColoredTexturePS) {
_drawColoredTexturePS = gpu::Shader::createPixel(std::string(DrawColoredTexture_frag));
_drawColoredTexturePS = DrawColoredTexture_frag::getShader();
}
return _drawColoredTexturePS;
}

View file

@ -91,8 +91,8 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky
static std::once_flag once;
std::call_once(once, [&] {
{
auto skyVS = gpu::Shader::createVertex(std::string(skybox_vert));
auto skyFS = gpu::Shader::createPixel(std::string(skybox_frag));
auto skyVS = skybox_vert::getShader();
auto skyFS = skybox_frag::getShader();
auto skyShader = gpu::Shader::createProgram(skyVS, skyFS);
batch.runLambda([skyShader] {

View file

@ -77,13 +77,18 @@ bool ObjectActionTractor::prepareForTractorUpdate(btScalar deltaTimeStep) {
return false;
}
bool doLinearTraction = _positionalTargetSet && (_linearTimeScale < MAX_TRACTOR_TIMESCALE);
bool doAngularTraction = _rotationalTargetSet && (_angularTimeScale < MAX_TRACTOR_TIMESCALE);
if (!doLinearTraction && !doAngularTraction) {
// nothing to do
return false;
}
glm::quat rotation;
glm::vec3 position;
glm::vec3 angularVelocity;
bool linearValid = false;
int linearTractorCount = 0;
bool angularValid = false;
int angularTractorCount = 0;
QList<EntityDynamicPointer> tractorDerivedActions;
@ -105,7 +110,6 @@ bool ObjectActionTractor::prepareForTractorUpdate(btScalar deltaTimeStep) {
linearTimeScale, angularTimeScale);
if (success) {
if (angularTimeScale < MAX_TRACTOR_TIMESCALE) {
angularValid = true;
angularTractorCount++;
angularVelocity += angularVelocityForAction;
if (tractorAction.get() == this) {
@ -115,41 +119,40 @@ bool ObjectActionTractor::prepareForTractorUpdate(btScalar deltaTimeStep) {
}
if (linearTimeScale < MAX_TRACTOR_TIMESCALE) {
linearValid = true;
linearTractorCount++;
position += positionForAction;
}
}
}
if ((angularValid && angularTractorCount > 0) || (linearValid && linearTractorCount > 0)) {
if (angularTractorCount > 0 || linearTractorCount > 0) {
withWriteLock([&]{
if (linearValid && linearTractorCount > 0) {
if (doLinearTraction && linearTractorCount > 0) {
position /= linearTractorCount;
if (_positionalTargetSet) {
_lastPositionTarget = _positionalTarget;
_positionalTarget = position;
if (deltaTimeStep > EPSILON) {
_lastPositionTarget = _positionalTarget;
_positionalTarget = position;
if (deltaTimeStep > EPSILON) {
if (_havePositionTargetHistory) {
// blend the new velocity with the old (low-pass filter)
glm::vec3 newVelocity = (1.0f / deltaTimeStep) * (_positionalTarget - _lastPositionTarget);
const float blend = 0.25f;
_linearVelocityTarget = (1.0f - blend) * _linearVelocityTarget + blend * newVelocity;
} else {
_havePositionTargetHistory = true;
}
}
_positionalTargetSet = true;
_active = true;
}
if (angularValid && angularTractorCount > 0) {
if (doAngularTraction && angularTractorCount > 0) {
angularVelocity /= angularTractorCount;
_rotationalTarget = rotation;
_angularVelocityTarget = angularVelocity;
_rotationalTargetSet = true;
_active = true;
}
});
}
return linearValid || angularValid;
return true;
}
@ -239,7 +242,9 @@ bool ObjectActionTractor::updateArguments(QVariantMap arguments) {
// targets are required, tractor-constants are optional
bool ok = true;
positionalTarget = EntityDynamicInterface::extractVec3Argument("tractor action", arguments, "targetPosition", ok, false);
if (!ok) {
if (ok) {
_positionalTargetSet = true;
} else {
positionalTarget = _desiredPositionalTarget;
}
ok = true;
@ -250,7 +255,9 @@ bool ObjectActionTractor::updateArguments(QVariantMap arguments) {
ok = true;
rotationalTarget = EntityDynamicInterface::extractQuatArgument("tractor action", arguments, "targetRotation", ok, false);
if (!ok) {
if (ok) {
_rotationalTargetSet = true;
} else {
rotationalTarget = _desiredRotationalTarget;
}

View file

@ -39,6 +39,7 @@ protected:
glm::vec3 _lastPositionTarget;
float _linearTimeScale;
bool _positionalTargetSet;
bool _havePositionTargetHistory { false };
glm::quat _rotationalTarget;
glm::quat _desiredRotationalTarget;

View file

@ -241,7 +241,7 @@ void Procedural::prepare(gpu::Batch& batch, const glm::vec3& position, const glm
std::string fragmentShaderSource = _fragmentSource;
size_t replaceIndex = fragmentShaderSource.find(PROCEDURAL_COMMON_BLOCK);
if (replaceIndex != std::string::npos) {
fragmentShaderSource.replace(replaceIndex, PROCEDURAL_COMMON_BLOCK.size(), ProceduralCommon_frag);
fragmentShaderSource.replace(replaceIndex, PROCEDURAL_COMMON_BLOCK.size(), ProceduralCommon_frag::getSource());
}
replaceIndex = fragmentShaderSource.find(PROCEDURAL_VERSION);

View file

@ -19,8 +19,8 @@
#include <graphics/skybox_frag.h>
ProceduralSkybox::ProceduralSkybox() : graphics::Skybox() {
_procedural._vertexSource = skybox_vert;
_procedural._fragmentSource = skybox_frag;
_procedural._vertexSource = skybox_vert::getSource();
_procedural._fragmentSource = skybox_frag::getSource();
// Adjust the pipeline state for background using the stencil test
_procedural.setDoesFade(false);
// Must match PrepareStencil::STENCIL_BACKGROUND

View file

@ -263,7 +263,7 @@ void AmbientOcclusionEffect::configure(const Config& config) {
const gpu::PipelinePointer& AmbientOcclusionEffect::getOcclusionPipeline() {
if (!_occlusionPipeline) {
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(ssao_makeOcclusion_frag));
auto ps = ssao_makeOcclusion_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -288,7 +288,7 @@ const gpu::PipelinePointer& AmbientOcclusionEffect::getOcclusionPipeline() {
const gpu::PipelinePointer& AmbientOcclusionEffect::getHBlurPipeline() {
if (!_hBlurPipeline) {
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(ssao_makeHorizontalBlur_frag));
auto ps = ssao_makeHorizontalBlur_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -311,7 +311,7 @@ const gpu::PipelinePointer& AmbientOcclusionEffect::getHBlurPipeline() {
const gpu::PipelinePointer& AmbientOcclusionEffect::getVBlurPipeline() {
if (!_vBlurPipeline) {
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(ssao_makeVerticalBlur_frag));
auto ps = ssao_makeVerticalBlur_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -458,7 +458,7 @@ void DebugAmbientOcclusion::configure(const Config& config) {
const gpu::PipelinePointer& DebugAmbientOcclusion::getDebugPipeline() {
if (!_debugPipeline) {
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(ssao_debugOcclusion_frag));
auto ps = ssao_debugOcclusion_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;

View file

@ -9,8 +9,6 @@
#include <qmath.h>
#include "animdebugdraw_vert.h"
#include "animdebugdraw_frag.h"
#include <gpu/Batch.h>
#include "AbstractViewStateInterface.h"
#include "RenderUtilsLogging.h"
@ -19,6 +17,9 @@
#include "AnimDebugDraw.h"
#include "animdebugdraw_vert.h"
#include "animdebugdraw_frag.h"
class AnimDebugDrawData {
public:
@ -101,8 +102,8 @@ AnimDebugDraw::AnimDebugDraw() :
state->setBlendFunction(false, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD,
gpu::State::INV_SRC_ALPHA, gpu::State::FACTOR_ALPHA,
gpu::State::BLEND_OP_ADD, gpu::State::ONE);
auto vertShader = gpu::Shader::createVertex(std::string(animdebugdraw_vert));
auto fragShader = gpu::Shader::createPixel(std::string(animdebugdraw_frag));
auto vertShader = animdebugdraw_vert::getShader();
auto fragShader = animdebugdraw_frag::getShader();
auto program = gpu::Shader::createProgram(vertShader, fragShader);
_pipeline = gpu::Pipeline::create(program, state);

View file

@ -57,8 +57,8 @@ const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline(RenderArgs* ar
}
if (!_antialiasingPipeline) {
auto vs = gpu::Shader::createVertex(std::string(fxaa_vert));
auto ps = gpu::Shader::createPixel(std::string(fxaa_frag));
auto vs = fxaa_vert::getShader();
auto ps = fxaa_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -82,8 +82,8 @@ const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline(RenderArgs* ar
const gpu::PipelinePointer& Antialiasing::getBlendPipeline() {
if (!_blendPipeline) {
auto vs = gpu::Shader::createVertex(std::string(fxaa_vert));
auto ps = gpu::Shader::createPixel(std::string(fxaa_blend_frag));
auto vs = fxaa_vert::getShader();
auto ps = fxaa_blend_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;

View file

@ -61,7 +61,7 @@ void BloomThreshold::run(const render::RenderContextPointer& renderContext, cons
if (!_pipeline) {
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
auto ps = gpu::Shader::createPixel(std::string(BloomThreshold_frag));
auto ps = BloomThreshold_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -113,7 +113,7 @@ void BloomApply::run(const render::RenderContextPointer& renderContext, const In
if (!_pipeline) {
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
auto ps = gpu::Shader::createPixel(std::string(BloomApply_frag));
auto ps = BloomApply_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;

View file

@ -369,8 +369,7 @@ bool DebugDeferredBuffer::pipelineNeedsUpdate(Mode mode, std::string customFile)
const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::string customFile) {
if (pipelineNeedsUpdate(mode, customFile)) {
static const std::string VERTEX_SHADER { debug_deferred_buffer_vert };
static const std::string FRAGMENT_SHADER { debug_deferred_buffer_frag };
static const std::string FRAGMENT_SHADER { debug_deferred_buffer_frag::getSource() };
static const std::string SOURCE_PLACEHOLDER { "//SOURCE_PLACEHOLDER" };
static const auto SOURCE_PLACEHOLDER_INDEX = FRAGMENT_SHADER.find(SOURCE_PLACEHOLDER);
Q_ASSERT_X(SOURCE_PLACEHOLDER_INDEX != std::string::npos, Q_FUNC_INFO,
@ -380,7 +379,7 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str
bakedFragmentShader.replace(SOURCE_PLACEHOLDER_INDEX, SOURCE_PLACEHOLDER.size(),
getShaderSourceCode(mode, customFile));
static const auto vs = gpu::Shader::createVertex(VERTEX_SHADER);
const auto vs = debug_deferred_buffer_vert::getShader();
const auto ps = gpu::Shader::createPixel(bakedFragmentShader);
const auto program = gpu::Shader::createProgram(vs, ps);

View file

@ -83,7 +83,7 @@ enum DeferredShader_BufferSlot {
LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT,
};
static void loadLightProgram(const char* vertSource, const char* fragSource, bool lightVolume, gpu::PipelinePointer& program, LightLocationsPtr& locations);
static void loadLightProgram(const gpu::ShaderPointer& vertShader, const gpu::ShaderPointer& fragShader, bool lightVolume, gpu::PipelinePointer& program, LightLocationsPtr& locations);
void DeferredLightingEffect::init() {
_directionalAmbientSphereLightLocations = std::make_shared<LightLocations>();
@ -95,14 +95,14 @@ void DeferredLightingEffect::init() {
_localLightLocations = std::make_shared<LightLocations>();
_localLightOutlineLocations = std::make_shared<LightLocations>();
loadLightProgram(deferred_light_vert, directional_ambient_light_frag, false, _directionalAmbientSphereLight, _directionalAmbientSphereLightLocations);
loadLightProgram(deferred_light_vert, directional_skybox_light_frag, false, _directionalSkyboxLight, _directionalSkyboxLightLocations);
loadLightProgram(deferred_light_vert::getShader(), directional_ambient_light_frag::getShader(), false, _directionalAmbientSphereLight, _directionalAmbientSphereLightLocations);
loadLightProgram(deferred_light_vert::getShader(), directional_skybox_light_frag::getShader(), false, _directionalSkyboxLight, _directionalSkyboxLightLocations);
loadLightProgram(deferred_light_vert, directional_ambient_light_shadow_frag, false, _directionalAmbientSphereLightShadow, _directionalAmbientSphereLightShadowLocations);
loadLightProgram(deferred_light_vert, directional_skybox_light_shadow_frag, false, _directionalSkyboxLightShadow, _directionalSkyboxLightShadowLocations);
loadLightProgram(deferred_light_vert::getShader(), directional_ambient_light_shadow_frag::getShader(), false, _directionalAmbientSphereLightShadow, _directionalAmbientSphereLightShadowLocations);
loadLightProgram(deferred_light_vert::getShader(), directional_skybox_light_shadow_frag::getShader(), false, _directionalSkyboxLightShadow, _directionalSkyboxLightShadowLocations);
loadLightProgram(deferred_light_vert, local_lights_shading_frag, true, _localLight, _localLightLocations);
loadLightProgram(deferred_light_vert, local_lights_drawOutline_frag, true, _localLightOutline, _localLightOutlineLocations);
loadLightProgram(deferred_light_vert::getShader(), local_lights_shading_frag::getShader(), true, _localLight, _localLightLocations);
loadLightProgram(deferred_light_vert::getShader(), local_lights_drawOutline_frag::getShader(), true, _localLightOutline, _localLightOutlineLocations);
}
void DeferredLightingEffect::setupKeyLightBatch(const RenderArgs* args, gpu::Batch& batch, int lightBufferUnit, int ambientBufferUnit, int skyboxCubemapUnit) {
@ -171,12 +171,8 @@ void DeferredLightingEffect::unsetLocalLightsBatch(gpu::Batch& batch, int cluste
}
}
static gpu::ShaderPointer makeLightProgram(const char* vertSource, const char* fragSource, LightLocationsPtr& locations) {
auto VS = gpu::Shader::createVertex(std::string(vertSource));
auto PS = gpu::Shader::createPixel(std::string(fragSource));
gpu::ShaderPointer program = gpu::Shader::createProgram(VS, PS);
static gpu::ShaderPointer makeLightProgram(const gpu::ShaderPointer& vertShader, const gpu::ShaderPointer& fragShader, LightLocationsPtr& locations) {
gpu::ShaderPointer program = gpu::Shader::createProgram(vertShader, fragShader);
gpu::Shader::BindingSet slotBindings;
slotBindings.insert(gpu::Shader::Binding(std::string("colorMap"), DEFERRED_BUFFER_COLOR_UNIT));
slotBindings.insert(gpu::Shader::Binding(std::string("normalMap"), DEFERRED_BUFFER_NORMAL_UNIT));
@ -224,9 +220,9 @@ static gpu::ShaderPointer makeLightProgram(const char* vertSource, const char* f
return program;
}
static void loadLightProgram(const char* vertSource, const char* fragSource, bool lightVolume, gpu::PipelinePointer& pipeline, LightLocationsPtr& locations) {
static void loadLightProgram(const gpu::ShaderPointer& vertShader, const gpu::ShaderPointer& fragShader, bool lightVolume, gpu::PipelinePointer& pipeline, LightLocationsPtr& locations) {
gpu::ShaderPointer program = makeLightProgram(vertSource, fragSource, locations);
gpu::ShaderPointer program = makeLightProgram(vertShader, fragShader, locations);
auto state = std::make_shared<gpu::State>();
state->setColorWriteMask(true, true, true, false);

View file

@ -133,7 +133,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu
RenderArgs* args = renderContext->args;
if (!_hazePipeline) {
gpu::ShaderPointer ps = gpu::Shader::createPixel(std::string(Haze_frag));
gpu::ShaderPointer ps = Haze_frag::getShader();
gpu::ShaderPointer vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);

View file

@ -1946,8 +1946,8 @@ void GeometryCache::renderGlowLine(gpu::Batch& batch, const glm::vec3& p1, const
static std::once_flag once;
std::call_once(once, [&] {
auto state = std::make_shared<gpu::State>();
auto VS = gpu::Shader::createVertex(std::string(glowLine_vert));
auto PS = gpu::Shader::createPixel(std::string(glowLine_frag));
auto VS = glowLine_vert::getShader();
auto PS = glowLine_frag::getShader();
auto program = gpu::Shader::createProgram(VS, PS);
state->setCullMode(gpu::State::CULL_NONE);
state->setDepthTest(true, false, gpu::LESS_EQUAL);
@ -2003,8 +2003,8 @@ void GeometryCache::renderGlowLine(gpu::Batch& batch, const glm::vec3& p1, const
void GeometryCache::useSimpleDrawPipeline(gpu::Batch& batch, bool noBlend) {
static std::once_flag once;
std::call_once(once, [&]() {
auto vs = gpu::Shader::createVertex(std::string(standardTransformPNTC_vert));
auto ps = gpu::Shader::createPixel(std::string(standardDrawTexture_frag));
auto vs = standardTransformPNTC_vert::getShader();
auto ps = standardDrawTexture_frag::getShader();
auto program = gpu::Shader::createProgram(vs, ps);
auto state = std::make_shared<gpu::State>();
@ -2039,8 +2039,8 @@ void GeometryCache::useSimpleDrawPipeline(gpu::Batch& batch, bool noBlend) {
void GeometryCache::useGridPipeline(gpu::Batch& batch, GridBuffer gridBuffer, bool isLayered) {
if (!_gridPipeline) {
auto vs = gpu::Shader::createVertex(std::string(standardTransformPNTC_vert));
auto ps = gpu::Shader::createPixel(std::string(grid_frag));
auto vs = standardTransformPNTC_vert::getShader();
auto ps = grid_frag::getShader();
auto program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::makeProgram((*program));
_gridSlot = program->getUniformBuffers().findLocation("gridBuffer");
@ -2123,12 +2123,9 @@ inline bool operator==(const SimpleProgramKey& a, const SimpleProgramKey& b) {
return a.getRaw() == b.getRaw();
}
static void buildWebShader(const std::string& vertShaderText, const std::string& fragShaderText, bool blendEnable,
static void buildWebShader(const gpu::ShaderPointer& vertShader, const gpu::ShaderPointer& fragShader, bool blendEnable,
gpu::ShaderPointer& shaderPointerOut, gpu::PipelinePointer& pipelinePointerOut) {
auto VS = gpu::Shader::createVertex(vertShaderText);
auto PS = gpu::Shader::createPixel(fragShaderText);
shaderPointerOut = gpu::Shader::createProgram(VS, PS);
shaderPointerOut = gpu::Shader::createProgram(vertShader, fragShader);
gpu::Shader::BindingSet slotBindings;
gpu::Shader::makeProgram(*shaderPointerOut, slotBindings);
@ -2151,8 +2148,8 @@ void GeometryCache::bindWebBrowserProgram(gpu::Batch& batch, bool transparent) {
gpu::PipelinePointer GeometryCache::getWebBrowserProgram(bool transparent) {
static std::once_flag once;
std::call_once(once, [&]() {
buildWebShader(simple_vert, simple_opaque_web_browser_frag, false, _simpleOpaqueWebBrowserShader, _simpleOpaqueWebBrowserPipelineNoAA);
buildWebShader(simple_vert, simple_transparent_web_browser_frag, true, _simpleTransparentWebBrowserShader, _simpleTransparentWebBrowserPipelineNoAA);
buildWebShader(simple_vert::getShader(), simple_opaque_web_browser_frag::getShader(), false, _simpleOpaqueWebBrowserShader, _simpleOpaqueWebBrowserPipelineNoAA);
buildWebShader(simple_vert::getShader(), simple_transparent_web_browser_frag::getShader(), true, _simpleTransparentWebBrowserShader, _simpleTransparentWebBrowserPipelineNoAA);
});
return transparent ? _simpleTransparentWebBrowserPipelineNoAA : _simpleOpaqueWebBrowserPipelineNoAA;
@ -2181,9 +2178,9 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transp
if (!fading) {
static std::once_flag once;
std::call_once(once, [&]() {
auto VS = gpu::Shader::createVertex(std::string(simple_vert));
auto PS = gpu::Shader::createPixel(std::string(simple_textured_frag));
auto PSUnlit = gpu::Shader::createPixel(std::string(simple_textured_unlit_frag));
auto VS = simple_vert::getShader();
auto PS = simple_textured_frag::getShader();
auto PSUnlit = simple_textured_unlit_frag::getShader();
_simpleShader = gpu::Shader::createProgram(VS, PS);
_unlitShader = gpu::Shader::createProgram(VS, PSUnlit);
@ -2196,9 +2193,9 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transp
} else {
static std::once_flag once;
std::call_once(once, [&]() {
auto VS = gpu::Shader::createVertex(std::string(simple_fade_vert));
auto PS = gpu::Shader::createPixel(std::string(simple_textured_fade_frag));
auto PSUnlit = gpu::Shader::createPixel(std::string(simple_textured_unlit_fade_frag));
auto VS = simple_fade_vert::getShader();
auto PS = simple_textured_fade_frag::getShader();
auto PSUnlit = simple_textured_unlit_fade_frag::getShader();
_simpleFadeShader = gpu::Shader::createProgram(VS, PS);
_unlitFadeShader = gpu::Shader::createProgram(VS, PSUnlit);

View file

@ -130,8 +130,8 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c
fillState->setColorWriteMask(false, false, false, false);
fillState->setCullMode(gpu::State::CULL_FRONT);
auto vs = gpu::Shader::createVertex(std::string(Highlight_aabox_vert));
auto ps = gpu::Shader::createPixel(std::string(nop_frag));
auto vs = Highlight_aabox_vert::getShader();
auto ps = nop_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -313,7 +313,7 @@ const gpu::PipelinePointer& DrawHighlight::getPipeline(const render::HighlightSt
state->setStencilTest(true, 0, gpu::State::StencilTest(OUTLINE_STENCIL_MASK, 0xFF, gpu::EQUAL));
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(Highlight_frag));
auto ps = Highlight_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -325,7 +325,7 @@ const gpu::PipelinePointer& DrawHighlight::getPipeline(const render::HighlightSt
_pipeline = gpu::Pipeline::create(program, state);
ps = gpu::Shader::createPixel(std::string(Highlight_filled_frag));
ps = Highlight_filled_frag::getShader();
program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::makeProgram(*program, slotBindings);
_pipelineFilled = gpu::Pipeline::create(program, state);
@ -385,8 +385,7 @@ void DebugHighlight::run(const render::RenderContextPointer& renderContext, cons
}
void DebugHighlight::initializePipelines() {
static const std::string VERTEX_SHADER{ debug_deferred_buffer_vert };
static const std::string FRAGMENT_SHADER{ debug_deferred_buffer_frag };
static const std::string FRAGMENT_SHADER{ debug_deferred_buffer_frag::getSource() };
static const std::string SOURCE_PLACEHOLDER{ "//SOURCE_PLACEHOLDER" };
static const auto SOURCE_PLACEHOLDER_INDEX = FRAGMENT_SHADER.find(SOURCE_PLACEHOLDER);
Q_ASSERT_X(SOURCE_PLACEHOLDER_INDEX != std::string::npos, Q_FUNC_INFO,
@ -396,7 +395,7 @@ void DebugHighlight::initializePipelines() {
state->setDepthTest(gpu::State::DepthTest(false, false));
state->setStencilTest(true, 0, gpu::State::StencilTest(OUTLINE_STENCIL_MASK, 0xFF, gpu::EQUAL));
const auto vs = gpu::Shader::createVertex(VERTEX_SHADER);
const auto vs = debug_deferred_buffer_vert::getShader();
// Depth shader
{
@ -553,14 +552,14 @@ const render::Varying DrawHighlightTask::addSelectItemJobs(JobModel& task, const
#include "model_shadow_frag.h"
void DrawHighlightTask::initMaskPipelines(render::ShapePlumber& shapePlumber, gpu::StatePointer state) {
auto modelVertex = gpu::Shader::createVertex(std::string(model_shadow_vert));
auto modelPixel = gpu::Shader::createPixel(std::string(model_shadow_frag));
auto modelVertex = model_shadow_vert::getShader();
auto modelPixel = model_shadow_frag::getShader();
gpu::ShaderPointer modelProgram = gpu::Shader::createProgram(modelVertex, modelPixel);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withoutSkinned(),
modelProgram, state);
auto skinVertex = gpu::Shader::createVertex(std::string(skin_model_shadow_vert));
auto skinVertex = skin_model_shadow_vert::getShader();
gpu::ShaderPointer skinProgram = gpu::Shader::createProgram(skinVertex, modelPixel);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withSkinned(),

View file

@ -605,8 +605,8 @@ void DebugLightClusters::configure(const Config& config) {
const gpu::PipelinePointer DebugLightClusters::getDrawClusterGridPipeline() {
if (!_drawClusterGrid) {
auto vs = gpu::Shader::createVertex(std::string(lightClusters_drawGrid_vert));
auto ps = gpu::Shader::createPixel(std::string(lightClusters_drawGrid_frag));
auto vs = lightClusters_drawGrid_vert::getShader();
auto ps = lightClusters_drawGrid_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -635,7 +635,7 @@ const gpu::PipelinePointer DebugLightClusters::getDrawClusterFromDepthPipeline()
if (!_drawClusterFromDepth) {
// auto vs = gpu::Shader::createVertex(std::string(lightClusters_drawGrid_vert));
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(lightClusters_drawClusterFromDepth_frag));
auto ps = lightClusters_drawClusterFromDepth_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -665,7 +665,7 @@ const gpu::PipelinePointer DebugLightClusters::getDrawClusterContentPipeline() {
if (!_drawClusterContent) {
// auto vs = gpu::Shader::createVertex(std::string(lightClusters_drawClusterContent_vert));
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(lightClusters_drawClusterContent_frag));
auto ps = lightClusters_drawClusterContent_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;

View file

@ -121,16 +121,16 @@ void batchSetter(const ShapePipeline& pipeline, gpu::Batch& batch, RenderArgs* a
void lightBatchSetter(const ShapePipeline& pipeline, gpu::Batch& batch, RenderArgs* args);
void initOverlay3DPipelines(ShapePlumber& plumber, bool depthTest) {
auto vertex = gpu::Shader::createVertex(std::string(overlay3D_vert));
auto vertexModel = gpu::Shader::createVertex(std::string(model_vert));
auto pixel = gpu::Shader::createPixel(std::string(overlay3D_frag));
auto pixelTranslucent = gpu::Shader::createPixel(std::string(overlay3D_translucent_frag));
auto pixelUnlit = gpu::Shader::createPixel(std::string(overlay3D_unlit_frag));
auto pixelTranslucentUnlit = gpu::Shader::createPixel(std::string(overlay3D_translucent_unlit_frag));
auto pixelModel = gpu::Shader::createPixel(std::string(overlay3D_model_frag));
auto pixelModelTranslucent = gpu::Shader::createPixel(std::string(overlay3D_model_translucent_frag));
auto pixelModelUnlit = gpu::Shader::createPixel(std::string(overlay3D_model_unlit_frag));
auto pixelModelTranslucentUnlit = gpu::Shader::createPixel(std::string(overlay3D_model_translucent_unlit_frag));
auto vertex = overlay3D_vert::getShader();
auto vertexModel = model_vert::getShader();
auto pixel = overlay3D_frag::getShader();
auto pixelTranslucent = overlay3D_translucent_frag::getShader();
auto pixelUnlit = overlay3D_unlit_frag::getShader();
auto pixelTranslucentUnlit = overlay3D_translucent_unlit_frag::getShader();
auto pixelModel = overlay3D_model_frag::getShader();
auto pixelModelTranslucent = overlay3D_model_translucent_frag::getShader();
auto pixelModelUnlit = overlay3D_model_unlit_frag::getShader();
auto pixelModelTranslucentUnlit = overlay3D_model_translucent_unlit_frag::getShader();
auto opaqueProgram = gpu::Shader::createProgram(vertex, pixel);
auto translucentProgram = gpu::Shader::createProgram(vertex, pixelTranslucent);
@ -187,66 +187,66 @@ void initOverlay3DPipelines(ShapePlumber& plumber, bool depthTest) {
void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter) {
// Vertex shaders
auto simpleVertex = gpu::Shader::createVertex(std::string(simple_vert));
auto modelVertex = gpu::Shader::createVertex(std::string(model_vert));
auto modelNormalMapVertex = gpu::Shader::createVertex(std::string(model_normal_map_vert));
auto modelLightmapVertex = gpu::Shader::createVertex(std::string(model_lightmap_vert));
auto modelLightmapNormalMapVertex = gpu::Shader::createVertex(std::string(model_lightmap_normal_map_vert));
auto modelTranslucentVertex = gpu::Shader::createVertex(std::string(model_translucent_vert));
auto modelTranslucentNormalMapVertex = gpu::Shader::createVertex(std::string(model_translucent_normal_map_vert));
auto modelShadowVertex = gpu::Shader::createVertex(std::string(model_shadow_vert));
auto skinModelVertex = gpu::Shader::createVertex(std::string(skin_model_vert));
auto skinModelNormalMapVertex = gpu::Shader::createVertex(std::string(skin_model_normal_map_vert));
auto skinModelShadowVertex = gpu::Shader::createVertex(std::string(skin_model_shadow_vert));
auto modelLightmapFadeVertex = gpu::Shader::createVertex(std::string(model_lightmap_fade_vert));
auto modelLightmapNormalMapFadeVertex = gpu::Shader::createVertex(std::string(model_lightmap_normal_map_fade_vert));
auto skinModelFadeVertex = gpu::Shader::createVertex(std::string(skin_model_fade_vert));
auto skinModelNormalMapFadeVertex = gpu::Shader::createVertex(std::string(skin_model_normal_map_fade_vert));
auto simpleVertex = simple_vert::getShader();
auto modelVertex = model_vert::getShader();
auto modelNormalMapVertex = model_normal_map_vert::getShader();
auto modelLightmapVertex = model_lightmap_vert::getShader();
auto modelLightmapNormalMapVertex = model_lightmap_normal_map_vert::getShader();
auto modelTranslucentVertex = model_translucent_vert::getShader();
auto modelTranslucentNormalMapVertex = model_translucent_normal_map_vert::getShader();
auto modelShadowVertex = model_shadow_vert::getShader();
auto skinModelVertex = skin_model_vert::getShader();
auto skinModelNormalMapVertex = skin_model_normal_map_vert::getShader();
auto skinModelShadowVertex = skin_model_shadow_vert::getShader();
auto modelLightmapFadeVertex = model_lightmap_fade_vert::getShader();
auto modelLightmapNormalMapFadeVertex = model_lightmap_normal_map_fade_vert::getShader();
auto skinModelFadeVertex = skin_model_fade_vert::getShader();
auto skinModelNormalMapFadeVertex = skin_model_normal_map_fade_vert::getShader();
auto skinModelTranslucentVertex = skinModelFadeVertex; // We use the same because it ouputs world position per vertex
auto skinModelNormalMapTranslucentVertex = skinModelNormalMapFadeVertex; // We use the same because it ouputs world position per vertex
auto modelFadeVertex = gpu::Shader::createVertex(std::string(model_fade_vert));
auto modelNormalMapFadeVertex = gpu::Shader::createVertex(std::string(model_normal_map_fade_vert));
auto simpleFadeVertex = gpu::Shader::createVertex(std::string(simple_fade_vert));
auto modelShadowFadeVertex = gpu::Shader::createVertex(std::string(model_shadow_fade_vert));
auto skinModelShadowFadeVertex = gpu::Shader::createVertex(std::string(skin_model_shadow_fade_vert));
auto modelFadeVertex = model_fade_vert::getShader();
auto modelNormalMapFadeVertex = model_normal_map_fade_vert::getShader();
auto simpleFadeVertex = simple_fade_vert::getShader();
auto modelShadowFadeVertex = model_shadow_fade_vert::getShader();
auto skinModelShadowFadeVertex = skin_model_shadow_fade_vert::getShader();
// Pixel shaders
auto simplePixel = gpu::Shader::createPixel(std::string(simple_textured_frag));
auto simpleUnlitPixel = gpu::Shader::createPixel(std::string(simple_textured_unlit_frag));
auto simpleTranslucentPixel = gpu::Shader::createPixel(std::string(simple_transparent_textured_frag));
auto simpleTranslucentUnlitPixel = gpu::Shader::createPixel(std::string(simple_transparent_textured_unlit_frag));
auto modelPixel = gpu::Shader::createPixel(std::string(model_frag));
auto modelUnlitPixel = gpu::Shader::createPixel(std::string(model_unlit_frag));
auto modelNormalMapPixel = gpu::Shader::createPixel(std::string(model_normal_map_frag));
auto modelSpecularMapPixel = gpu::Shader::createPixel(std::string(model_specular_map_frag));
auto modelNormalSpecularMapPixel = gpu::Shader::createPixel(std::string(model_normal_specular_map_frag));
auto modelTranslucentPixel = gpu::Shader::createPixel(std::string(model_translucent_frag));
auto modelTranslucentNormalMapPixel = gpu::Shader::createPixel(std::string(model_translucent_normal_map_frag));
auto modelTranslucentUnlitPixel = gpu::Shader::createPixel(std::string(model_translucent_unlit_frag));
auto modelShadowPixel = gpu::Shader::createPixel(std::string(model_shadow_frag));
auto modelLightmapPixel = gpu::Shader::createPixel(std::string(model_lightmap_frag));
auto modelLightmapNormalMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_map_frag));
auto modelLightmapSpecularMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_specular_map_frag));
auto modelLightmapNormalSpecularMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_specular_map_frag));
auto modelLightmapFadePixel = gpu::Shader::createPixel(std::string(model_lightmap_fade_frag));
auto modelLightmapNormalMapFadePixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_map_fade_frag));
auto modelLightmapSpecularMapFadePixel = gpu::Shader::createPixel(std::string(model_lightmap_specular_map_fade_frag));
auto modelLightmapNormalSpecularMapFadePixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_specular_map_fade_frag));
auto simplePixel = simple_textured_frag::getShader();
auto simpleUnlitPixel = simple_textured_unlit_frag::getShader();
auto simpleTranslucentPixel = simple_transparent_textured_frag::getShader();
auto simpleTranslucentUnlitPixel = simple_transparent_textured_unlit_frag::getShader();
auto modelPixel = model_frag::getShader();
auto modelUnlitPixel = model_unlit_frag::getShader();
auto modelNormalMapPixel = model_normal_map_frag::getShader();
auto modelSpecularMapPixel = model_specular_map_frag::getShader();
auto modelNormalSpecularMapPixel = model_normal_specular_map_frag::getShader();
auto modelTranslucentPixel = model_translucent_frag::getShader();
auto modelTranslucentNormalMapPixel = model_translucent_normal_map_frag::getShader();
auto modelTranslucentUnlitPixel = model_translucent_unlit_frag::getShader();
auto modelShadowPixel = model_shadow_frag::getShader();
auto modelLightmapPixel = model_lightmap_frag::getShader();
auto modelLightmapNormalMapPixel = model_lightmap_normal_map_frag::getShader();
auto modelLightmapSpecularMapPixel = model_lightmap_specular_map_frag::getShader();
auto modelLightmapNormalSpecularMapPixel = model_lightmap_normal_specular_map_frag::getShader();
auto modelLightmapFadePixel = model_lightmap_fade_frag::getShader();
auto modelLightmapNormalMapFadePixel = model_lightmap_normal_map_fade_frag::getShader();
auto modelLightmapSpecularMapFadePixel = model_lightmap_specular_map_fade_frag::getShader();
auto modelLightmapNormalSpecularMapFadePixel = model_lightmap_normal_specular_map_fade_frag::getShader();
auto modelFadePixel = gpu::Shader::createPixel(std::string(model_fade_frag));
auto modelUnlitFadePixel = gpu::Shader::createPixel(std::string(model_unlit_fade_frag));
auto modelNormalMapFadePixel = gpu::Shader::createPixel(std::string(model_normal_map_fade_frag));
auto modelSpecularMapFadePixel = gpu::Shader::createPixel(std::string(model_specular_map_fade_frag));
auto modelNormalSpecularMapFadePixel = gpu::Shader::createPixel(std::string(model_normal_specular_map_fade_frag));
auto modelShadowFadePixel = gpu::Shader::createPixel(std::string(model_shadow_fade_frag));
auto modelTranslucentFadePixel = gpu::Shader::createPixel(std::string(model_translucent_fade_frag));
auto modelTranslucentNormalMapFadePixel = gpu::Shader::createPixel(std::string(model_translucent_normal_map_fade_frag));
auto modelTranslucentUnlitFadePixel = gpu::Shader::createPixel(std::string(model_translucent_unlit_fade_frag));
auto simpleFadePixel = gpu::Shader::createPixel(std::string(simple_textured_fade_frag));
auto simpleUnlitFadePixel = gpu::Shader::createPixel(std::string(simple_textured_unlit_fade_frag));
auto simpleTranslucentFadePixel = gpu::Shader::createPixel(std::string(simple_transparent_textured_fade_frag));
auto simpleTranslucentUnlitFadePixel = gpu::Shader::createPixel(std::string(simple_transparent_textured_unlit_fade_frag));
auto modelFadePixel = model_fade_frag::getShader();
auto modelUnlitFadePixel = model_unlit_fade_frag::getShader();
auto modelNormalMapFadePixel = model_normal_map_fade_frag::getShader();
auto modelSpecularMapFadePixel = model_specular_map_fade_frag::getShader();
auto modelNormalSpecularMapFadePixel = model_normal_specular_map_fade_frag::getShader();
auto modelShadowFadePixel = model_shadow_fade_frag::getShader();
auto modelTranslucentFadePixel = model_translucent_fade_frag::getShader();
auto modelTranslucentNormalMapFadePixel = model_translucent_normal_map_fade_frag::getShader();
auto modelTranslucentUnlitFadePixel = model_translucent_unlit_fade_frag::getShader();
auto simpleFadePixel = simple_textured_fade_frag::getShader();
auto simpleUnlitFadePixel = simple_textured_unlit_fade_frag::getShader();
auto simpleTranslucentFadePixel = simple_transparent_textured_fade_frag::getShader();
auto simpleTranslucentUnlitFadePixel = simple_transparent_textured_unlit_fade_frag::getShader();
using Key = render::ShapeKey;
auto addPipeline = std::bind(&addPlumberPipeline, std::ref(plumber), _1, _2, _3, _4, _5);
@ -448,19 +448,19 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
void initForwardPipelines(ShapePlumber& plumber, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter) {
// Vertex shaders
auto modelVertex = gpu::Shader::createVertex(std::string(model_vert));
auto modelNormalMapVertex = gpu::Shader::createVertex(std::string(model_normal_map_vert));
auto skinModelVertex = gpu::Shader::createVertex(std::string(skin_model_vert));
auto skinModelNormalMapVertex = gpu::Shader::createVertex(std::string(skin_model_normal_map_vert));
auto skinModelNormalMapFadeVertex = gpu::Shader::createVertex(std::string(skin_model_normal_map_fade_vert));
auto modelVertex = model_vert::getShader();
auto modelNormalMapVertex = model_normal_map_vert::getShader();
auto skinModelVertex = skin_model_vert::getShader();
auto skinModelNormalMapVertex = skin_model_normal_map_vert::getShader();
auto skinModelNormalMapFadeVertex = skin_model_normal_map_fade_vert::getShader();
// Pixel shaders
auto modelPixel = gpu::Shader::createPixel(std::string(forward_model_frag));
auto modelUnlitPixel = gpu::Shader::createPixel(std::string(forward_model_unlit_frag));
auto modelNormalMapPixel = gpu::Shader::createPixel(std::string(forward_model_normal_map_frag));
auto modelSpecularMapPixel = gpu::Shader::createPixel(std::string(forward_model_specular_map_frag));
auto modelNormalSpecularMapPixel = gpu::Shader::createPixel(std::string(forward_model_normal_specular_map_frag));
auto modelNormalMapFadePixel = gpu::Shader::createPixel(std::string(model_normal_map_fade_frag));
auto modelPixel = forward_model_frag::getShader();
auto modelUnlitPixel = forward_model_unlit_frag::getShader();
auto modelNormalMapPixel = forward_model_normal_map_frag::getShader();
auto modelSpecularMapPixel = forward_model_specular_map_frag::getShader();
auto modelNormalSpecularMapPixel = forward_model_normal_specular_map_frag::getShader();
auto modelNormalMapFadePixel = model_normal_map_fade_frag::getShader();
using Key = render::ShapeKey;
auto addPipeline = std::bind(&addPlumberPipeline, std::ref(plumber), _1, _2, _3, _4, _5);
@ -590,29 +590,29 @@ void lightBatchSetter(const ShapePipeline& pipeline, gpu::Batch& batch, RenderAr
}
void initZPassPipelines(ShapePlumber& shapePlumber, gpu::StatePointer state) {
auto modelVertex = gpu::Shader::createVertex(std::string(model_shadow_vert));
auto modelPixel = gpu::Shader::createPixel(std::string(model_shadow_frag));
auto modelVertex = model_shadow_vert::getShader();
auto modelPixel = model_shadow_frag::getShader();
gpu::ShaderPointer modelProgram = gpu::Shader::createProgram(modelVertex, modelPixel);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withoutSkinned().withoutFade(),
modelProgram, state);
auto skinVertex = gpu::Shader::createVertex(std::string(skin_model_shadow_vert));
auto skinPixel = gpu::Shader::createPixel(std::string(skin_model_shadow_frag));
auto skinVertex = skin_model_shadow_vert::getShader();
auto skinPixel = skin_model_shadow_frag::getShader();
gpu::ShaderPointer skinProgram = gpu::Shader::createProgram(skinVertex, skinPixel);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withSkinned().withoutFade(),
skinProgram, state);
auto modelFadeVertex = gpu::Shader::createVertex(std::string(model_shadow_fade_vert));
auto modelFadePixel = gpu::Shader::createPixel(std::string(model_shadow_fade_frag));
auto modelFadeVertex = model_shadow_fade_vert::getShader();
auto modelFadePixel = model_shadow_fade_frag::getShader();
gpu::ShaderPointer modelFadeProgram = gpu::Shader::createProgram(modelFadeVertex, modelFadePixel);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withoutSkinned().withFade(),
modelFadeProgram, state);
auto skinFadeVertex = gpu::Shader::createVertex(std::string(skin_model_shadow_fade_vert));
auto skinFadePixel = gpu::Shader::createPixel(std::string(skin_model_shadow_fade_frag));
auto skinFadeVertex = skin_model_shadow_fade_vert::getShader();
auto skinFadePixel = skin_model_shadow_fade_frag::getShader();
gpu::ShaderPointer skinFadeProgram = gpu::Shader::createProgram(skinFadeVertex, skinFadePixel);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withSkinned().withFade(),

View file

@ -60,7 +60,7 @@ gpu::PipelinePointer PrepareStencil::getMeshStencilPipeline() {
gpu::PipelinePointer PrepareStencil::getPaintStencilPipeline() {
if (!_paintStencilPipeline) {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(stencil_drawMask_frag));
auto ps = stencil_drawMask_frag::getShader();
auto program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::makeProgram((*program));

View file

@ -308,7 +308,7 @@ void diffuseProfileGPU(gpu::TexturePointer& profileMap, RenderArgs* args) {
gpu::PipelinePointer makePipeline;
{
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(subsurfaceScattering_makeProfile_frag));
auto ps = subsurfaceScattering_makeProfile_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -344,7 +344,7 @@ void diffuseScatterGPU(const gpu::TexturePointer& profileMap, gpu::TexturePointe
gpu::PipelinePointer makePipeline;
{
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(subsurfaceScattering_makeLUT_frag));
auto ps = subsurfaceScattering_makeLUT_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -382,7 +382,7 @@ void computeSpecularBeckmannGPU(gpu::TexturePointer& beckmannMap, RenderArgs* ar
gpu::PipelinePointer makePipeline;
{
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(subsurfaceScattering_makeSpecularBeckmann_frag));
auto ps = subsurfaceScattering_makeSpecularBeckmann_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -457,7 +457,7 @@ void DebugSubsurfaceScattering::configure(const Config& config) {
gpu::PipelinePointer DebugSubsurfaceScattering::getScatteringPipeline() {
if (!_scatteringPipeline) {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(subsurfaceScattering_drawScattering_frag));
auto ps = subsurfaceScattering_drawScattering_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;

View file

@ -212,7 +212,7 @@ void LinearDepthPass::run(const render::RenderContextPointer& renderContext, con
const gpu::PipelinePointer& LinearDepthPass::getLinearDepthPipeline() {
if (!_linearDepthPipeline) {
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(surfaceGeometry_makeLinearDepth_frag));
auto ps = surfaceGeometry_makeLinearDepth_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -239,7 +239,7 @@ const gpu::PipelinePointer& LinearDepthPass::getLinearDepthPipeline() {
const gpu::PipelinePointer& LinearDepthPass::getDownsamplePipeline() {
if (!_downsamplePipeline) {
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(surfaceGeometry_downsampleDepthNormal_frag));
auto ps = surfaceGeometry_downsampleDepthNormal_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -540,7 +540,7 @@ void SurfaceGeometryPass::run(const render::RenderContextPointer& renderContext,
const gpu::PipelinePointer& SurfaceGeometryPass::getCurvaturePipeline() {
if (!_curvaturePipeline) {
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(surfaceGeometry_makeCurvature_frag));
auto ps = surfaceGeometry_makeCurvature_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;

View file

@ -28,7 +28,7 @@ ToneMappingEffect::ToneMappingEffect() {
}
void ToneMappingEffect::init() {
auto blitPS = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(toneMapping_frag)));
auto blitPS = toneMapping_frag::getShader();
auto blitVS = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto blitProgram = gpu::ShaderPointer(gpu::Shader::createProgram(blitVS, blitPS));

View file

@ -78,7 +78,7 @@ void SetupZones::run(const RenderContextPointer& context, const Inputs& inputs)
const gpu::PipelinePointer& DebugZoneLighting::getKeyLightPipeline() {
if (!_keyLightPipeline) {
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
auto ps = gpu::Shader::createPixel(std::string(zone_drawKeyLight_frag));
auto ps = zone_drawKeyLight_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -99,7 +99,7 @@ const gpu::PipelinePointer& DebugZoneLighting::getKeyLightPipeline() {
const gpu::PipelinePointer& DebugZoneLighting::getAmbientPipeline() {
if (!_ambientPipeline) {
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
auto ps = gpu::Shader::createPixel(std::string(zone_drawAmbient_frag));
auto ps = zone_drawAmbient_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -120,7 +120,7 @@ const gpu::PipelinePointer& DebugZoneLighting::getAmbientPipeline() {
const gpu::PipelinePointer& DebugZoneLighting::getBackgroundPipeline() {
if (!_backgroundPipeline) {
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
auto ps = gpu::Shader::createPixel(std::string(zone_drawSkybox_frag));
auto ps = zone_drawSkybox_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;

View file

@ -223,9 +223,9 @@ void Font::setupGPU() {
// Setup render pipeline
{
auto vertexShader = gpu::Shader::createVertex(std::string(sdf_text3D_vert));
auto pixelShader = gpu::Shader::createPixel(std::string(sdf_text3D_frag));
auto pixelShaderTransparent = gpu::Shader::createPixel(std::string(sdf_text3D_transparent_frag));
auto vertexShader = sdf_text3D_vert::getShader();
auto pixelShader = sdf_text3D_frag::getShader();
auto pixelShaderTransparent = sdf_text3D_transparent_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vertexShader, pixelShader);
gpu::ShaderPointer programTransparent = gpu::Shader::createProgram(vertexShader, pixelShaderTransparent);

View file

@ -210,7 +210,7 @@ BlurGaussian::BlurGaussian(bool generateOutputFramebuffer, unsigned int downsamp
gpu::PipelinePointer BlurGaussian::getBlurVPipeline() {
if (!_blurVPipeline) {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(blurGaussianV_frag));
auto ps = blurGaussianV_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -232,7 +232,7 @@ gpu::PipelinePointer BlurGaussian::getBlurVPipeline() {
gpu::PipelinePointer BlurGaussian::getBlurHPipeline() {
if (!_blurHPipeline) {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(blurGaussianH_frag));
auto ps = blurGaussianH_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -324,7 +324,7 @@ BlurGaussianDepthAware::BlurGaussianDepthAware(bool generateOutputFramebuffer, c
gpu::PipelinePointer BlurGaussianDepthAware::getBlurVPipeline() {
if (!_blurVPipeline) {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(blurGaussianDepthAwareV_frag));
auto ps = blurGaussianDepthAwareV_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -347,7 +347,7 @@ gpu::PipelinePointer BlurGaussianDepthAware::getBlurVPipeline() {
gpu::PipelinePointer BlurGaussianDepthAware::getBlurHPipeline() {
if (!_blurHPipeline) {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(blurGaussianDepthAwareH_frag));
auto ps = blurGaussianDepthAwareH_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;

View file

@ -34,8 +34,8 @@ using namespace render;
const gpu::PipelinePointer DrawSceneOctree::getDrawCellBoundsPipeline() {
if (!_drawCellBoundsPipeline) {
auto vs = gpu::Shader::createVertex(std::string(drawCellBounds_vert));
auto ps = gpu::Shader::createPixel(std::string(drawCellBounds_frag));
auto vs = drawCellBounds_vert::getShader();
auto ps = drawCellBounds_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -59,7 +59,7 @@ const gpu::PipelinePointer DrawSceneOctree::getDrawCellBoundsPipeline() {
const gpu::PipelinePointer DrawSceneOctree::getDrawLODReticlePipeline() {
if (!_drawLODReticlePipeline) {
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
auto ps = gpu::Shader::createPixel(std::string(drawLODReticle_frag));
auto ps = drawLODReticle_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -162,8 +162,8 @@ void DrawSceneOctree::run(const RenderContextPointer& renderContext, const ItemS
const gpu::PipelinePointer DrawItemSelection::getDrawItemBoundPipeline() {
if (!_drawItemBoundPipeline) {
auto vs = gpu::Shader::createVertex(std::string(drawItemBounds_vert));
auto ps = gpu::Shader::createPixel(std::string(drawItemBounds_frag));
auto vs = drawItemBounds_vert::getShader();
auto ps = drawItemBounds_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;

View file

@ -35,8 +35,8 @@ void DrawStatusConfig::dirtyHelper() {
const gpu::PipelinePointer DrawStatus::getDrawItemBoundsPipeline() {
if (!_drawItemBoundsPipeline) {
auto vs = gpu::Shader::createVertex(std::string(drawItemBounds_vert));
auto ps = gpu::Shader::createPixel(std::string(drawItemBounds_frag));
auto vs = drawItemBounds_vert::getShader();
auto ps = drawItemBounds_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;
@ -63,8 +63,8 @@ const gpu::PipelinePointer DrawStatus::getDrawItemBoundsPipeline() {
const gpu::PipelinePointer DrawStatus::getDrawItemStatusPipeline() {
if (!_drawItemStatusPipeline) {
auto vs = gpu::Shader::createVertex(std::string(drawItemStatus_vert));
auto ps = gpu::Shader::createPixel(std::string(drawItemStatus_frag));
auto vs = drawItemStatus_vert::getShader();
auto ps = drawItemStatus_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;

View file

@ -22,8 +22,8 @@
#include <gpu/Context.h>
#include <gpu/StandardShaderLib.h>
#include <drawItemBounds_vert.h>
#include <drawItemBounds_frag.h>
#include "drawItemBounds_vert.h"
#include "drawItemBounds_frag.h"
using namespace render;
@ -155,8 +155,8 @@ void DrawLight::run(const RenderContextPointer& renderContext, const ItemBounds&
const gpu::PipelinePointer DrawBounds::getPipeline() {
if (!_boundsPipeline) {
auto vs = gpu::Shader::createVertex(std::string(drawItemBounds_vert));
auto ps = gpu::Shader::createPixel(std::string(drawItemBounds_frag));
auto vs = drawItemBounds_vert::getShader();
auto ps = drawItemBounds_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings;

View file

@ -15,7 +15,6 @@ in vec4 varColor;
in vec2 varTexcoord;
out vec4 outFragColor;
void main(void) {
float var = step(fract(varTexcoord.x * varTexcoord.y * 1.0), 0.5);

View file

@ -636,14 +636,9 @@
openLoginWindow();
break;
case 'disableHmdPreview':
isHmdPreviewDisabled = Menu.isOptionChecked("Disable Preview");
DesktopPreviewProvider.setPreviewDisabledReason("SECURE_SCREEN");
Menu.setIsOptionChecked("Disable Preview", true);
break;
break; // do nothing here, handled in marketplaces.js
case 'maybeEnableHmdPreview':
DesktopPreviewProvider.setPreviewDisabledReason("USER");
Menu.setIsOptionChecked("Disable Preview", isHmdPreviewDisabled);
break;
break; // do nothing here, handled in marketplaces.js
case 'passphraseReset':
onButtonClicked();
onButtonClicked();
@ -731,11 +726,7 @@
// -Called when the TabletScriptingInterface::screenChanged() signal is emitted. The "type" argument can be either the string
// value of "Home", "Web", "Menu", "QML", or "Closed". The "url" argument is only valid for Web and QML.
function onTabletScreenChanged(type, url) {
var onWalletScreenNow = (type === "QML" && url === WALLET_QML_SOURCE);
if (!onWalletScreenNow && onWalletScreen) {
DesktopPreviewProvider.setPreviewDisabledReason("USER");
}
onWalletScreen = onWalletScreenNow;
onWalletScreen = (type === "QML" && url === WALLET_QML_SOURCE);
wireEventBridge(onWalletScreen);
// Change button to active when window is first openend, false otherwise.
if (button) {

View file

@ -112,11 +112,23 @@ var selectionDisplay = null; // for gridTool.js to ignore
var referrerURL; // Used for updating Purchases QML
var filterText; // Used for updating Purchases QML
var onWalletScreen = false;
function onScreenChanged(type, url) {
onMarketplaceScreen = type === "Web" && url.indexOf(MARKETPLACE_URL) !== -1;
onWalletScreen = url.indexOf(MARKETPLACE_WALLET_QML_PATH) !== -1;
var onWalletScreenNow = url.indexOf(MARKETPLACE_WALLET_QML_PATH) !== -1;
onCommerceScreen = type === "QML" && (url.indexOf(MARKETPLACE_CHECKOUT_QML_PATH) !== -1 || url === MARKETPLACE_PURCHASES_QML_PATH
|| url.indexOf(MARKETPLACE_INSPECTIONCERTIFICATE_QML_PATH) !== -1);
if (!onWalletScreenNow && onWalletScreen) { // exiting wallet screen
if (isHmdPreviewDisabledBySecurity) {
DesktopPreviewProvider.setPreviewDisabledReason("USER");
Menu.setIsOptionChecked("Disable Preview", false);
isHmdPreviewDisabledBySecurity = false;
}
}
onWalletScreen = onWalletScreenNow;
wireEventBridge(onMarketplaceScreen || onCommerceScreen || onWalletScreen);
if (url === MARKETPLACE_PURCHASES_QML_PATH) {
@ -480,7 +492,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
// Description:
// -Called when a message is received from Checkout.qml. The "message" argument is what is sent from the Checkout QML
// in the format "{method, params}", like json-rpc.
var isHmdPreviewDisabled = true;
var isHmdPreviewDisabledBySecurity = false;
function fromQml(message) {
switch (message.method) {
case 'purchases_openWallet':
@ -548,11 +560,19 @@ var selectionDisplay = null; // for gridTool.js to ignore
openLoginWindow();
break;
case 'disableHmdPreview':
isHmdPreviewDisabled = Menu.isOptionChecked("Disable Preview");
Menu.setIsOptionChecked("Disable Preview", true);
var isHmdPreviewDisabled = Menu.isOptionChecked("Disable Preview");
if (!isHmdPreviewDisabled) {
DesktopPreviewProvider.setPreviewDisabledReason("SECURE_SCREEN");
Menu.setIsOptionChecked("Disable Preview", true);
isHmdPreviewDisabledBySecurity = true;
}
break;
case 'maybeEnableHmdPreview':
Menu.setIsOptionChecked("Disable Preview", isHmdPreviewDisabled);
if (isHmdPreviewDisabledBySecurity) {
DesktopPreviewProvider.setPreviewDisabledReason("USER");
Menu.setIsOptionChecked("Disable Preview", false);
isHmdPreviewDisabledBySecurity = false;
}
break;
case 'purchases_openGoTo':
tablet.loadQMLSource("hifi/tablet/TabletAddressDialog.qml");

View file

@ -101,6 +101,7 @@ public:
show();
makeCurrent();
gl::initModuleGl();
gpu::Context::init<gpu::gl::GLBackend>();
makeCurrent();
resize(QSize(800, 600));
@ -135,7 +136,7 @@ const std::string PIXEL_SHADER_DEFINES{ R"GLSL(
#define GPU_TRANSFORM_STEREO_SPLIT_SCREEN
)GLSL" };
void testShaderBuild(const char* vs_src, const char * fs_src) {
void testShaderBuild(const std::string& vs_src, const std::string& fs_src) {
std::string error;
std::vector<char> binary;
GLuint vs, fs;
@ -160,54 +161,54 @@ void QTestWindow::draw() {
static std::once_flag once;
std::call_once(once, [&]{
testShaderBuild(sdf_text3D_vert, sdf_text3D_frag);
testShaderBuild(sdf_text3D_vert::getSource(), sdf_text3D_frag::getSource());
testShaderBuild(DrawTransformUnitQuad_vert, DrawTexture_frag);
testShaderBuild(DrawTexcoordRectTransformUnitQuad_vert, DrawTexture_frag);
testShaderBuild(DrawViewportQuadTransformTexcoord_vert, DrawTexture_frag);
testShaderBuild(DrawTransformUnitQuad_vert, DrawTextureOpaque_frag);
testShaderBuild(DrawTransformUnitQuad_vert, DrawColoredTexture_frag);
testShaderBuild(DrawTransformUnitQuad_vert::getSource(), DrawTexture_frag::getSource());
testShaderBuild(DrawTexcoordRectTransformUnitQuad_vert::getSource(), DrawTexture_frag::getSource());
testShaderBuild(DrawViewportQuadTransformTexcoord_vert::getSource(), DrawTexture_frag::getSource());
testShaderBuild(DrawTransformUnitQuad_vert::getSource(), DrawTextureOpaque_frag::getSource());
testShaderBuild(DrawTransformUnitQuad_vert::getSource(), DrawColoredTexture_frag::getSource());
testShaderBuild(skybox_vert, skybox_frag);
testShaderBuild(simple_vert, simple_frag);
testShaderBuild(simple_vert, simple_textured_frag);
testShaderBuild(simple_vert, simple_textured_unlit_frag);
testShaderBuild(deferred_light_vert, directional_ambient_light_frag);
testShaderBuild(deferred_light_vert, directional_skybox_light_frag);
testShaderBuild(standardTransformPNTC_vert, standardDrawTexture_frag);
testShaderBuild(standardTransformPNTC_vert, DrawTextureOpaque_frag);
testShaderBuild(skybox_vert::getSource(), skybox_frag::getSource());
testShaderBuild(simple_vert::getSource(), simple_frag::getSource());
testShaderBuild(simple_vert::getSource(), simple_textured_frag::getSource());
testShaderBuild(simple_vert::getSource(), simple_textured_unlit_frag::getSource());
testShaderBuild(deferred_light_vert::getSource(), directional_ambient_light_frag::getSource());
testShaderBuild(deferred_light_vert::getSource(), directional_skybox_light_frag::getSource());
testShaderBuild(standardTransformPNTC_vert::getSource(), standardDrawTexture_frag::getSource());
testShaderBuild(standardTransformPNTC_vert::getSource(), DrawTextureOpaque_frag::getSource());
testShaderBuild(model_vert, model_frag);
testShaderBuild(model_normal_map_vert, model_normal_map_frag);
testShaderBuild(model_vert, model_specular_map_frag);
testShaderBuild(model_normal_map_vert, model_normal_specular_map_frag);
testShaderBuild(model_vert, model_translucent_frag);
testShaderBuild(model_normal_map_vert, model_translucent_frag);
testShaderBuild(model_lightmap_vert, model_lightmap_frag);
testShaderBuild(model_lightmap_normal_map_vert, model_lightmap_normal_map_frag);
testShaderBuild(model_lightmap_vert, model_lightmap_specular_map_frag);
testShaderBuild(model_lightmap_normal_map_vert, model_lightmap_normal_specular_map_frag);
testShaderBuild(model_vert::getSource(), model_frag::getSource());
testShaderBuild(model_normal_map_vert::getSource(), model_normal_map_frag::getSource());
testShaderBuild(model_vert::getSource(), model_specular_map_frag::getSource());
testShaderBuild(model_normal_map_vert::getSource(), model_normal_specular_map_frag::getSource());
testShaderBuild(model_vert::getSource(), model_translucent_frag::getSource());
testShaderBuild(model_normal_map_vert::getSource(), model_translucent_frag::getSource());
testShaderBuild(model_lightmap_vert::getSource(), model_lightmap_frag::getSource());
testShaderBuild(model_lightmap_normal_map_vert::getSource(), model_lightmap_normal_map_frag::getSource());
testShaderBuild(model_lightmap_vert::getSource(), model_lightmap_specular_map_frag::getSource());
testShaderBuild(model_lightmap_normal_map_vert::getSource(), model_lightmap_normal_specular_map_frag::getSource());
testShaderBuild(skin_model_vert, model_frag);
testShaderBuild(skin_model_normal_map_vert, model_normal_map_frag);
testShaderBuild(skin_model_vert, model_specular_map_frag);
testShaderBuild(skin_model_normal_map_vert, model_normal_specular_map_frag);
testShaderBuild(skin_model_vert, model_translucent_frag);
testShaderBuild(skin_model_normal_map_vert, model_translucent_frag);
testShaderBuild(skin_model_vert::getSource(), model_frag::getSource());
testShaderBuild(skin_model_normal_map_vert::getSource(), model_normal_map_frag::getSource());
testShaderBuild(skin_model_vert::getSource(), model_specular_map_frag::getSource());
testShaderBuild(skin_model_normal_map_vert::getSource(), model_normal_specular_map_frag::getSource());
testShaderBuild(skin_model_vert::getSource(), model_translucent_frag::getSource());
testShaderBuild(skin_model_normal_map_vert::getSource(), model_translucent_frag::getSource());
testShaderBuild(model_shadow_vert, model_shadow_frag);
testShaderBuild(textured_particle_vert, textured_particle_frag);
testShaderBuild(model_shadow_vert::getSource(), model_shadow_frag::getSource());
testShaderBuild(textured_particle_vert::getSource(), textured_particle_frag::getSource());
/* FIXME: Bring back the ssao shader tests
testShaderBuild(gaussian_blur_vertical_vert, gaussian_blur_frag);
testShaderBuild(gaussian_blur_horizontal_vert, gaussian_blur_frag);
testShaderBuild(ambient_occlusion_vert, ambient_occlusion_frag);
testShaderBuild(ambient_occlusion_vert, occlusion_blend_frag);
testShaderBuild(gaussian_blur_vert::getSource()ical_vert::getSource(), gaussian_blur_frag::getSource());
testShaderBuild(gaussian_blur_horizontal_vert::getSource(), gaussian_blur_frag::getSource());
testShaderBuild(ambient_occlusion_vert::getSource(), ambient_occlusion_frag::getSource());
testShaderBuild(ambient_occlusion_vert::getSource(), occlusion_blend_frag::getSource());
*/
testShaderBuild(overlay3D_vert, overlay3D_frag);
testShaderBuild(overlay3D_vert::getSource(), overlay3D_frag::getSource());
testShaderBuild(paintStroke_vert,paintStroke_frag);
testShaderBuild(polyvox_vert, polyvox_frag);
testShaderBuild(paintStroke_vert::getSource(),paintStroke_frag::getSource());
testShaderBuild(polyvox_vert::getSource(), polyvox_frag::getSource());
});
_context.swapBuffers(this);

View file

@ -1,3 +1,8 @@
set(TARGET_NAME scribe)
setup_hifi_project()
# don't use the setup_hifi_project macro as we don't want Qt or GLM dependencies
file(GLOB TARGET_SRCS src/*)
add_executable(${TARGET_NAME} ${TARGET_SRCS})
if (WIN32)
set_property(TARGET ${TARGET_NAME} APPEND_STRING PROPERTY LINK_FLAGS_DEBUG "/OPT:NOREF /OPT:NOICF")
endif()

View file

@ -41,9 +41,23 @@ int main (int argc, char** argv) {
GRAB_VAR_VALUE,
GRAB_INCLUDE_PATH,
GRAB_TARGET_NAME,
GRAB_SHADER_TYPE,
EXIT,
} mode = READY;
enum Type {
VERTEX = 0,
FRAGMENT,
GEOMETRY,
} type = VERTEX;
static const char* shaderTypeString[] = {
"VERTEX", "PIXEL", "GEOMETRY"
};
static const char* shaderCreateString[] = {
"Vertex", "Pixel", "Geometry"
};
std::string shaderStage{ "vert" };
for (int ii = 1; (mode != EXIT) && (ii < argc); ii++) {
inputs.push_back(argv[ii]);
@ -66,6 +80,8 @@ int main (int argc, char** argv) {
} else if (inputs.back() == "-c++") {
makeCPlusPlus = true;
mode = READY;
} else if (inputs.back() == "-T") {
mode = GRAB_SHADER_TYPE;
} else {
// just grabbed the source filename, stop parameter parsing
srcFilename = inputs.back();
@ -106,6 +122,24 @@ int main (int argc, char** argv) {
}
break;
case GRAB_SHADER_TYPE:
{
if (inputs.back() == "frag") {
shaderStage = inputs.back();
type = FRAGMENT;
} else if (inputs.back() == "geom") {
shaderStage = inputs.back();
type = GEOMETRY;
} else if (inputs.back() == "vert") {
shaderStage = inputs.back();
type = VERTEX;
} else {
cerr << "Unrecognized shader type. Supported is vert, frag or geom" << endl;
}
mode = READY;
}
break;
case EXIT: {
// THis shouldn't happen
}
@ -123,11 +157,13 @@ int main (int argc, char** argv) {
cerr << " varname and varvalue must be made of alpha numerical characters with no spaces." << endl;
cerr << " -listVars : Will list the vars name and value in the standard output." << endl;
cerr << " -showParseTree : Draw the tree obtained while parsing the source" << endl;
cerr << " -c++ : Generate a c++ header file containing the output file stream stored as a char[] variable" << endl;
cerr << " -c++ : Generate a c++ source file containing the output file stream stored as a char[] variable" << endl;
cerr << " -T vert/frag/geom : define the type of the shader. Defaults to VERTEX if not specified." << endl;
cerr << " This is necessary if the -c++ option is used." << endl;
return 0;
}
// Define targetName: if none, get destFilenmae, if none get srcFilename
// Define targetName: if none, get destFilename, if none get srcFilename
if (targetName.empty()) {
if (destFilename.empty()) {
targetName = srcFilename;
@ -163,7 +199,7 @@ int main (int argc, char** argv) {
srcStream.open(srcFilename, std::fstream::in);
if (!srcStream.is_open()) {
cerr << "Failed to open source file <" << srcFilename << ">" << endl;
return 0;
return 1;
}
auto scribe = std::make_shared<TextTemplate>(srcFilename, config);
@ -173,7 +209,7 @@ int main (int argc, char** argv) {
int numErrors = scribe->scribe(destStringStream, srcStream, vars);
if (numErrors) {
cerr << "Scribe " << srcFilename << "> failed: " << numErrors << " errors." << endl;
return 0;
return 1;
};
@ -186,7 +222,6 @@ int main (int argc, char** argv) {
scribe->displayTree(cerr, level);
}
std::ostringstream targetStringStream;
if (makeCPlusPlus) {
// Because there is a maximum size for literal strings declared in source we need to partition the
// full source string stream into pages that seems to be around that value...
@ -208,35 +243,108 @@ int main (int argc, char** argv) {
pageSize += lineSize;
}
targetStringStream << "// File generated by Scribe " << vars["_SCRIBE_DATE"] << std::endl;
targetStringStream << "#ifndef scribe_" << targetName << "_h" << std::endl;
targetStringStream << "#define scribe_" << targetName << "_h" << std::endl << std::endl;
std::stringstream headerStringStream;
std::stringstream sourceStringStream;
std::string headerFileName = destFilename + ".h";
std::string sourceFileName = destFilename + ".cpp";
targetStringStream << "const char " << targetName << "[] = \n";
sourceStringStream << "// File generated by Scribe " << vars["_SCRIBE_DATE"] << std::endl;
// Write header file
headerStringStream << "#ifndef " << targetName << "_h" << std::endl;
headerStringStream << "#define " << targetName << "_h\n" << std::endl;
headerStringStream << "#include <gpu/Shader.h>\n" << std::endl;
headerStringStream << "class " << targetName << " {" << std::endl;
headerStringStream << "public:" << std::endl;
headerStringStream << "\tstatic gpu::Shader::Type getType() { return gpu::Shader::" << shaderTypeString[type] << "; }" << std::endl;
headerStringStream << "\tstatic const std::string& getSource() { return _source; }" << std::endl;
headerStringStream << "\tstatic gpu::ShaderPointer getShader();" << std::endl;
headerStringStream << "private:" << std::endl;
headerStringStream << "\tstatic const std::string _source;" << std::endl;
headerStringStream << "\tstatic gpu::ShaderPointer _shader;" << std::endl;
headerStringStream << "};\n" << std::endl;
headerStringStream << "#endif // " << targetName << "_h" << std::endl;
bool mustOutputHeader = destFilename.empty();
// Compare with existing file
{
std::fstream headerFile;
headerFile.open(headerFileName, std::fstream::in);
if (headerFile.is_open()) {
// Skip first line
std::string line;
std::stringstream previousHeaderStringStream;
std::getline(headerFile, line);
previousHeaderStringStream << headerFile.rdbuf();
mustOutputHeader = mustOutputHeader || previousHeaderStringStream.str() != headerStringStream.str();
} else {
mustOutputHeader = true;
}
}
if (mustOutputHeader) {
if (!destFilename.empty()) {
// File content has changed so write it
std::fstream headerFile;
headerFile.open(headerFileName, std::fstream::out);
if (headerFile.is_open()) {
// First line contains the date of modification
headerFile << sourceStringStream.str();
headerFile << headerStringStream.str();
} else {
cerr << "Scribe output file <" << headerFileName << "> failed to open." << endl;
return 1;
}
} else {
cerr << sourceStringStream.str();
cerr << headerStringStream.str();
}
}
// Write source file
sourceStringStream << "#include \"" << targetName << ".h\"\n" << std::endl;
sourceStringStream << "gpu::ShaderPointer " << targetName << "::_shader;" << std::endl;
sourceStringStream << "const std::string " << targetName << "::_source = std::string()";
// Write the pages content
for (auto page : pages) {
targetStringStream << "R\"SCRIBE(\n" << page->str() << "\n)SCRIBE\"\n";
sourceStringStream << "+ std::string(R\"SCRIBE(\n" << page->str() << "\n)SCRIBE\")\n";
}
targetStringStream << ";\n" << std::endl << std::endl;
sourceStringStream << ";\n" << std::endl << std::endl;
targetStringStream << "#endif" << std::endl;
} else {
targetStringStream << destStringStream.str();
}
sourceStringStream << "gpu::ShaderPointer " << targetName << "::getShader() {" << std::endl;
sourceStringStream << "\tif (_shader==nullptr) {" << std::endl;
sourceStringStream << "\t\t_shader = gpu::Shader::create" << shaderCreateString[type] << "(std::string(_source));" << std::endl;
sourceStringStream << "\t}" << std::endl;
sourceStringStream << "\treturn _shader;" << std::endl;
sourceStringStream << "}\n" << std::endl;
// Destination stream
if (!destFilename.empty()) {
std::fstream destFileStream;
destFileStream.open(destFilename, std::fstream::out);
if (!destFileStream.is_open()) {
cerr << "Scribe output file " << destFilename << "> failed to open." << endl;
return 0;
// Destination stream
if (!destFilename.empty()) {
std::fstream sourceFile;
sourceFile.open(sourceFileName, std::fstream::out);
if (!sourceFile.is_open()) {
cerr << "Scribe output file <" << sourceFileName << "> failed to open." << endl;
return 1;
}
sourceFile << sourceStringStream.str();
} else {
cerr << sourceStringStream.str();
}
destFileStream << targetStringStream.str();
} else {
cerr << targetStringStream.str();
// Destination stream
if (!destFilename.empty()) {
std::fstream destFileStream;
destFileStream.open(destFilename, std::fstream::out);
if (!destFileStream.is_open()) {
cerr << "Scribe output file <" << destFilename << "> failed to open." << endl;
return 1;
}
destFileStream << destStringStream.str();
} else {
cerr << destStringStream.str();
}
}
return 0;