mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 03:13:51 +02:00
Merge branch 'vr_menus' into infoview
Conflicts: tests/ui/src/main.cpp
This commit is contained in:
commit
14b660baf7
67 changed files with 1100 additions and 843 deletions
CMakeLists.txt
domain-server/src
interface
resources/qml
LoginDialog.qmlMessageDialog.qmlVrMenu.qml
controls
Button.qmlCheckBox.qmlDialog.qmlDialogBase.qmlFontAwesome.qmlIconButton.qmlMenuButton.qmlSlider.qmlSpacer.qmlSpinBox.qmlText.qmlTextAndSlider.qmlTextAndSpinBox.qmlTextArea.qmlTextEdit.qmlTextHeader.qmlTextInput.qmlTextInputAndButton.qml
styles
src
libraries
audio/src
entities-renderer/src
entities/src
fbx/src
gpu/src/gpu
GLBackend.cppGLBackendBuffer.cppGLBackendInput.cppGLBackendOutput.cppGLBackendPipeline.cppGLBackendState.cppGLBackendTexture.cppGLBackendTransform.cppState.hStream.hTexture.cppTexture.h
model/src/model
networking/src
octree/src
render-utils/src
shared/src
ui/src
tests/ui/src
|
@ -48,7 +48,7 @@ if (WIN32)
|
|||
elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
||||
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic")
|
||||
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unknown-pragmas")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-strict-aliasing -ggdb")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-strict-aliasing -Wno-unused-parameter -ggdb")
|
||||
endif(WIN32)
|
||||
|
||||
if (NOT MSVC12)
|
||||
|
|
|
@ -33,7 +33,7 @@ DomainServerWebSessionData::DomainServerWebSessionData(const QJsonObject& userOb
|
|||
}
|
||||
}
|
||||
|
||||
DomainServerWebSessionData::DomainServerWebSessionData(const DomainServerWebSessionData& otherSessionData) {
|
||||
DomainServerWebSessionData::DomainServerWebSessionData(const DomainServerWebSessionData& otherSessionData) : QObject() {
|
||||
_username = otherSessionData._username;
|
||||
_roles = otherSessionData._roles;
|
||||
}
|
||||
|
|
|
@ -5,9 +5,8 @@ import "controls"
|
|||
import "styles"
|
||||
|
||||
Dialog {
|
||||
HifiConstants { id: hifi }
|
||||
title: "Login"
|
||||
HifiPalette { id: hifiPalette }
|
||||
SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
|
||||
objectName: "LoginDialog"
|
||||
height: 512
|
||||
width: 384
|
||||
|
@ -117,7 +116,7 @@ Dialog {
|
|||
width: 192
|
||||
height: 64
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
color: hifiPalette.hifiBlue
|
||||
color: hifi.colors.hifiBlue
|
||||
border.width: 0
|
||||
radius: 10
|
||||
|
||||
|
@ -160,7 +159,7 @@ Dialog {
|
|||
text:"Create Account"
|
||||
font.pointSize: 12
|
||||
font.bold: true
|
||||
color: hifiPalette.hifiBlue
|
||||
color: hifi.colors.hifiBlue
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
|
@ -177,7 +176,7 @@ Dialog {
|
|||
verticalAlignment: Text.AlignVCenter
|
||||
font.pointSize: 12
|
||||
text: "Recover Password"
|
||||
color: hifiPalette.hifiBlue
|
||||
color: hifi.colors.hifiBlue
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
|
|
|
@ -18,8 +18,6 @@ Dialog {
|
|||
onImplicitHeightChanged: root.height = implicitHeight
|
||||
onImplicitWidthChanged: root.width = implicitWidth
|
||||
|
||||
SystemPalette { id: palette }
|
||||
|
||||
function calculateImplicitWidth() {
|
||||
if (buttons.visibleChildren.length < 2)
|
||||
return;
|
||||
|
|
|
@ -7,12 +7,19 @@ import "styles"
|
|||
|
||||
Hifi.VrMenu {
|
||||
id: root
|
||||
HifiConstants { id: hifi }
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
objectName: "VrMenu"
|
||||
|
||||
enabled: false
|
||||
opacity: 0.0
|
||||
|
||||
property int animationDuration: 200
|
||||
HifiPalette { id: hifiPalette }
|
||||
property var models: []
|
||||
property var columns: []
|
||||
|
||||
z: 10000
|
||||
|
||||
onEnabledChanged: {
|
||||
|
@ -22,7 +29,7 @@ Hifi.VrMenu {
|
|||
opacity = enabled ? 1.0 : 0.0
|
||||
if (enabled) {
|
||||
forceActiveFocus()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The actual animator
|
||||
|
@ -41,10 +48,6 @@ Hifi.VrMenu {
|
|||
if (!visible) reset();
|
||||
}
|
||||
|
||||
|
||||
property var models: []
|
||||
property var columns: []
|
||||
|
||||
property var menuBuilder: Component {
|
||||
Border {
|
||||
Component.onCompleted: {
|
||||
|
@ -58,10 +61,20 @@ Hifi.VrMenu {
|
|||
y = lastMousePosition.y - height / 2;
|
||||
}
|
||||
}
|
||||
SystemPalette { id: sysPalette; colorGroup: SystemPalette.Active }
|
||||
border.color: hifiPalette.hifiBlue
|
||||
color: sysPalette.window
|
||||
border.color: hifi.colors.hifiBlue
|
||||
color: hifi.colors.window
|
||||
property int menuDepth
|
||||
/*
|
||||
MouseArea {
|
||||
// Rectangle { anchors.fill: parent; color: "#7f0000FF"; visible: enabled }
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
while (parent.menuDepth != root.models.length - 1) {
|
||||
root.popColumn()
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
ListView {
|
||||
spacing: 6
|
||||
|
@ -71,27 +84,29 @@ Hifi.VrMenu {
|
|||
anchors.margins: outerMargin
|
||||
id: listView
|
||||
height: root.height
|
||||
currentIndex: -1
|
||||
|
||||
onCountChanged: {
|
||||
recalculateSize()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function recalculateSize() {
|
||||
var newHeight = 0
|
||||
var newWidth = minWidth;
|
||||
for (var i = 0; i < children.length; ++i) {
|
||||
var item = children[i];
|
||||
if (!item.visible) {
|
||||
continue
|
||||
}
|
||||
newHeight += item.height
|
||||
}
|
||||
parent.height = newHeight + outerMargin * 2;
|
||||
parent.width = newWidth + outerMargin * 2
|
||||
}
|
||||
|
||||
|
||||
highlight: Rectangle {
|
||||
width: listView.minWidth - 32;
|
||||
height: 32
|
||||
color: sysPalette.highlight
|
||||
color: hifi.colors.hifiBlue
|
||||
y: (listView.currentItem) ? listView.currentItem.y : 0;
|
||||
x: 32
|
||||
Behavior on y {
|
||||
|
@ -101,10 +116,8 @@ Hifi.VrMenu {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
property int columnIndex: root.models.length - 1
|
||||
model: root.models[columnIndex]
|
||||
model: root.models[menuDepth]
|
||||
delegate: Loader {
|
||||
id: loader
|
||||
sourceComponent: root.itemBuilder
|
||||
|
@ -120,12 +133,6 @@ Hifi.VrMenu {
|
|||
value: modelData
|
||||
when: loader.status == Loader.Ready
|
||||
}
|
||||
Binding {
|
||||
target: loader.item
|
||||
property: "listViewIndex"
|
||||
value: index
|
||||
when: loader.status == Loader.Ready
|
||||
}
|
||||
Binding {
|
||||
target: loader.item
|
||||
property: "listView"
|
||||
|
@ -133,26 +140,39 @@ Hifi.VrMenu {
|
|||
when: loader.status == Loader.Ready
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
property var itemBuilder: Component {
|
||||
Text {
|
||||
SystemPalette { id: sp; colorGroup: SystemPalette.Active }
|
||||
id: thisText
|
||||
x: 32
|
||||
property var source
|
||||
property var root
|
||||
property var listViewIndex
|
||||
property var listView
|
||||
text: typedText()
|
||||
height: implicitHeight
|
||||
width: implicitWidth
|
||||
color: source.enabled ? "black" : "gray"
|
||||
|
||||
color: source.enabled ? hifi.colors.text : hifi.colors.disabledText
|
||||
enabled: source.enabled && source.visible
|
||||
// FIXME uncommenting this line results in menus that have blank spots
|
||||
// rather than having the correct size
|
||||
// visible: source.visible
|
||||
|
||||
onListViewChanged: {
|
||||
if (listView) {
|
||||
listView.minWidth = Math.max(listView.minWidth, implicitWidth + 64);
|
||||
listView.recalculateSize();
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (listView) {
|
||||
listView.recalculateSize();
|
||||
}
|
||||
}
|
||||
|
||||
onImplicitWidthChanged: {
|
||||
if (listView) {
|
||||
listView.minWidth = Math.max(listView.minWidth, implicitWidth + 64);
|
||||
|
@ -163,15 +183,27 @@ Hifi.VrMenu {
|
|||
FontAwesome {
|
||||
visible: source.type == 1 && source.checkable
|
||||
x: -32
|
||||
text: (source.type == 1 && source.checked) ? "\uF05D" : "\uF10C"
|
||||
text: checkText();
|
||||
color: parent.color
|
||||
function checkText() {
|
||||
if (source.type != 1) {
|
||||
return;
|
||||
}
|
||||
// FIXME this works for native QML menus but I don't think it will
|
||||
// for proxied QML menus
|
||||
if (source.exclusiveGroup) {
|
||||
return source.checked ? "\uF05D" : "\uF10C"
|
||||
}
|
||||
return source.checked ? "\uF046" : "\uF096"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FontAwesome {
|
||||
visible: source.type == 2
|
||||
x: listView.width - 64
|
||||
x: listView.width - 32 - (hifi.layout.spacing * 2)
|
||||
text: "\uF0DA"
|
||||
color: parent.color
|
||||
}
|
||||
|
||||
|
||||
function typedText() {
|
||||
switch(source.type) {
|
||||
|
@ -200,38 +232,53 @@ Hifi.VrMenu {
|
|||
interval: 1000
|
||||
onTriggered: parent.select();
|
||||
}
|
||||
onEntered: {
|
||||
if (source.type == 2 && enabled) {
|
||||
timer.start()
|
||||
}
|
||||
}
|
||||
onExited: {
|
||||
timer.stop()
|
||||
}
|
||||
/*
|
||||
* Uncomment below to have menus auto-popup
|
||||
*
|
||||
* FIXME if we enabled timer based menu popup, either the timer has
|
||||
* to be very very short or after auto popup there has to be a small
|
||||
* amount of time, or a test if the mouse has moved before a click
|
||||
* will be accepted, otherwise it's too easy to accidently click on
|
||||
* something immediately after the auto-popup appears underneath your
|
||||
* cursor
|
||||
*
|
||||
*/
|
||||
//onEntered: {
|
||||
// if (source.type == 2 && enabled) {
|
||||
// timer.start()
|
||||
// }
|
||||
//}
|
||||
//onExited: {
|
||||
// timer.stop()
|
||||
//}
|
||||
onClicked: {
|
||||
select();
|
||||
}
|
||||
function select() {
|
||||
timer.stop();
|
||||
listView.currentIndex = listViewIndex
|
||||
parent.root.selectItem(parent.source);
|
||||
var popped = false;
|
||||
while (columns.length - 1 > listView.parent.menuDepth) {
|
||||
popColumn();
|
||||
popped = true;
|
||||
}
|
||||
|
||||
if (!popped || source.type != 1) {
|
||||
parent.root.selectItem(parent.source);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function lastColumn() {
|
||||
return columns[root.columns.length - 1];
|
||||
}
|
||||
|
||||
|
||||
function pushColumn(items) {
|
||||
models.push(items)
|
||||
if (columns.length) {
|
||||
var oldColumn = lastColumn();
|
||||
oldColumn.enabled = false;
|
||||
oldColumn.opacity = 0.5;
|
||||
//oldColumn.enabled = false
|
||||
}
|
||||
var newColumn = menuBuilder.createObject(root);
|
||||
columns.push(newColumn);
|
||||
|
|
|
@ -5,6 +5,5 @@ import "."
|
|||
import "../styles"
|
||||
|
||||
Original.Button {
|
||||
style: ButtonStyle {
|
||||
}
|
||||
style: ButtonStyle { }
|
||||
}
|
||||
|
|
16
interface/resources/qml/controls/CheckBox.qml
Normal file
16
interface/resources/qml/controls/CheckBox.qml
Normal file
|
@ -0,0 +1,16 @@
|
|||
import QtQuick.Controls 1.3 as Original
|
||||
import QtQuick.Controls.Styles 1.3
|
||||
import "../styles"
|
||||
import "."
|
||||
Original.CheckBox {
|
||||
text: "Check Box"
|
||||
style: CheckBoxStyle {
|
||||
indicator: FontAwesome {
|
||||
text: control.checked ? "\uf046" : "\uf096"
|
||||
}
|
||||
label: Text {
|
||||
text: control.text
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -11,28 +11,21 @@ import "../styles"
|
|||
* Examine the QML ApplicationWindow.qml source for how it does this
|
||||
*
|
||||
*/
|
||||
Item {
|
||||
DialogBase {
|
||||
id: root
|
||||
|
||||
HifiPalette { id: hifiPalette }
|
||||
SystemPalette { id: sysPalette; colorGroup: SystemPalette.Active }
|
||||
HifiConstants { id: hifi }
|
||||
// FIXME better placement via a window manager
|
||||
x: parent ? parent.width / 2 - width / 2 : 0
|
||||
y: parent ? parent.height / 2 - height / 2 : 0
|
||||
|
||||
property int animationDuration: 400
|
||||
property bool destroyOnInvisible: false
|
||||
property bool destroyOnCloseButton: true
|
||||
property bool resizable: false
|
||||
|
||||
property int animationDuration: hifi.effects.fadeInDuration
|
||||
property int minX: 256
|
||||
property int minY: 256
|
||||
property int topMargin: root.height - clientBorder.height + 8
|
||||
property int margins: 8
|
||||
property string title
|
||||
property int titleSize: titleBorder.height + 12
|
||||
property string frameColor: hifiPalette.hifiBlue
|
||||
property string backgroundColor: sysPalette.window
|
||||
property string headerBackgroundColor: sysPalette.dark
|
||||
clip: true
|
||||
readonly property int topMargin: root.height - clientBorder.height + hifi.layout.spacing
|
||||
|
||||
/*
|
||||
* Support for animating the dialog in and out.
|
||||
|
@ -44,7 +37,8 @@ Item {
|
|||
// visibility, so that we can do animations in both directions. Because
|
||||
// visibility and enabled are boolean flags, they cannot be animated. So when
|
||||
// enabled is change, we modify a property that can be animated, like scale or
|
||||
// opacity.
|
||||
// opacity, and then when the target animation value is reached, we can
|
||||
// modify the visibility
|
||||
onEnabledChanged: {
|
||||
scale = enabled ? 1.0 : 0.0
|
||||
}
|
||||
|
@ -57,13 +51,13 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
// We remove any load the dialog might have on the QML by toggling it's
|
||||
// visibility based on the state of the animated property
|
||||
// Once we're scaled to 0, disable the dialog's visibility
|
||||
onScaleChanged: {
|
||||
visible = (scale != 0.0);
|
||||
}
|
||||
|
||||
// Some dialogs should be destroyed when they become invisible, so handle that
|
||||
|
||||
// Some dialogs should be destroyed when they become invisible,
|
||||
// so handle that
|
||||
onVisibleChanged: {
|
||||
if (!visible && destroyOnInvisible) {
|
||||
destroy();
|
||||
|
@ -91,6 +85,7 @@ Item {
|
|||
|
||||
MouseArea {
|
||||
id: sizeDrag
|
||||
enabled: root.resizable
|
||||
property int startX
|
||||
property int startY
|
||||
anchors.right: parent.right
|
||||
|
@ -103,7 +98,7 @@ Item {
|
|||
startY = mouseY
|
||||
}
|
||||
onPositionChanged: {
|
||||
if (pressed && root.resizable) {
|
||||
if (pressed) {
|
||||
root.deltaSize((mouseX - startX), (mouseY - startY))
|
||||
startX = mouseX
|
||||
startY = mouseY
|
||||
|
@ -111,83 +106,41 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Window decorations, with a title bar and frames
|
||||
*/
|
||||
Border {
|
||||
id: windowBorder
|
||||
anchors.fill: parent
|
||||
border.color: root.frameColor
|
||||
color: root.backgroundColor
|
||||
MouseArea {
|
||||
id: titleDrag
|
||||
x: root.titleX
|
||||
y: root.titleY
|
||||
width: root.titleWidth
|
||||
height: root.titleHeight
|
||||
|
||||
Border {
|
||||
id: titleBorder
|
||||
height: 48
|
||||
drag {
|
||||
target: root
|
||||
minimumX: 0
|
||||
minimumY: 0
|
||||
maximumX: root.parent ? root.parent.width - root.width : 0
|
||||
maximumY: root.parent ? root.parent.height - root.height : 0
|
||||
}
|
||||
|
||||
Row {
|
||||
id: windowControls
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 0
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 0
|
||||
border.color: root.frameColor
|
||||
color: root.headerBackgroundColor
|
||||
|
||||
Text {
|
||||
id: titleText
|
||||
// FIXME move all constant colors to our own palette class HifiPalette
|
||||
color: "white"
|
||||
text: root.title
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: titleDrag
|
||||
anchors.right: closeButton.left
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.rightMargin: 4
|
||||
drag {
|
||||
target: root
|
||||
minimumX: 0
|
||||
minimumY: 0
|
||||
maximumX: root.parent ? root.parent.width - root.width : 0
|
||||
maximumY: root.parent ? root.parent.height - root.height : 0
|
||||
}
|
||||
}
|
||||
Image {
|
||||
id: closeButton
|
||||
x: 360
|
||||
height: 16
|
||||
anchors.rightMargin: hifi.layout.spacing
|
||||
FontAwesome {
|
||||
id: icon
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 16
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 12
|
||||
source: "../../styles/close.svg"
|
||||
size: root.titleHeight - hifi.layout.spacing * 2
|
||||
color: "red"
|
||||
text: "\uf00d"
|
||||
MouseArea {
|
||||
anchors.margins: hifi.layout.spacing / 2
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // header border
|
||||
|
||||
Border {
|
||||
id: clientBorder
|
||||
border.color: root.frameColor
|
||||
// FIXME move all constant colors to our own palette class HifiPalette
|
||||
color: "#00000000"
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: 0
|
||||
anchors.top: titleBorder.bottom
|
||||
anchors.topMargin: -titleBorder.border.width
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 0
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 0
|
||||
clip: true
|
||||
} // client border
|
||||
} // window border
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
74
interface/resources/qml/controls/DialogBase.qml
Normal file
74
interface/resources/qml/controls/DialogBase.qml
Normal file
|
@ -0,0 +1,74 @@
|
|||
import QtQuick 2.3
|
||||
import QtQuick.Controls 1.2
|
||||
import "."
|
||||
import "../styles"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
HifiConstants { id: hifi }
|
||||
implicitHeight: 512
|
||||
implicitWidth: 512
|
||||
property string title
|
||||
property int titleSize: titleBorder.height + 12
|
||||
property string frameColor: hifi.colors.hifiBlue
|
||||
property string backgroundColor: hifi.colors.dialogBackground
|
||||
property bool active: false
|
||||
|
||||
property alias titleBorder: titleBorder
|
||||
readonly property alias titleX: titleBorder.x
|
||||
readonly property alias titleY: titleBorder.y
|
||||
readonly property alias titleWidth: titleBorder.width
|
||||
readonly property alias titleHeight: titleBorder.height
|
||||
|
||||
property alias clientBorder: clientBorder
|
||||
readonly property real clientX: clientBorder.x + hifi.styles.borderWidth
|
||||
readonly property real clientY: clientBorder.y + hifi.styles.borderWidth
|
||||
readonly property real clientWidth: clientBorder.width - hifi.styles.borderWidth * 2
|
||||
readonly property real clientHeight: clientBorder.height - hifi.styles.borderWidth * 2
|
||||
|
||||
/*
|
||||
* Window decorations, with a title bar and frames
|
||||
*/
|
||||
Border {
|
||||
id: windowBorder
|
||||
anchors.fill: parent
|
||||
border.color: root.frameColor
|
||||
color: "#00000000"
|
||||
|
||||
Border {
|
||||
id: titleBorder
|
||||
height: hifi.layout.windowTitleHeight
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
border.color: root.frameColor
|
||||
clip: true
|
||||
color: root.active ?
|
||||
hifi.colors.activeWindow.headerBackground :
|
||||
hifi.colors.inactiveWindow.headerBackground
|
||||
|
||||
Text {
|
||||
id: titleText
|
||||
color: root.active ?
|
||||
hifi.colors.activeWindow.headerText :
|
||||
hifi.colors.inactiveWindow.headerText
|
||||
text: root.title
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
anchors.fill: parent
|
||||
}
|
||||
} // header border
|
||||
|
||||
Border {
|
||||
id: clientBorder
|
||||
border.color: root.frameColor
|
||||
color: root.backgroundColor
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.top: titleBorder.bottom
|
||||
anchors.topMargin: -titleBorder.border.width
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
clip: true
|
||||
} // client border
|
||||
} // window border
|
||||
|
||||
}
|
|
@ -8,9 +8,9 @@ Text {
|
|||
property int size: 32
|
||||
width: size
|
||||
height: size
|
||||
font.pixelSize: size
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
font.family: iconFont.name
|
||||
font.pointSize: 18
|
||||
}
|
||||
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
import QtQuick 2.3
|
||||
import QtQuick.Controls 1.3
|
||||
import QtQuick.Window 2.2
|
||||
import QtQuick.Controls.Styles 1.3
|
||||
|
||||
Button {
|
||||
text: "Text"
|
||||
style: ButtonStyle {
|
||||
background: Item { anchors.fill: parent }
|
||||
label: Text {
|
||||
id: icon
|
||||
width: height
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
font.family: iconFont.name
|
||||
font.pointSize: 18
|
||||
property alias unicode: icon.text
|
||||
FontLoader { id: iconFont; source: "/fonts/fontawesome-webfont.ttf"; }
|
||||
text: control.text
|
||||
color: control.enabled ? "white" : "dimgray"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import QtQuick 2.3
|
||||
import QtQuick.Controls 1.3 as Original
|
||||
import "../styles"
|
||||
import "../controls"
|
||||
|
8
interface/resources/qml/controls/Slider.qml
Normal file
8
interface/resources/qml/controls/Slider.qml
Normal file
|
@ -0,0 +1,8 @@
|
|||
import QtQuick.Controls 1.3 as Original
|
||||
import QtQuick.Controls.Styles 1.3
|
||||
|
||||
import "../styles"
|
||||
import "."
|
||||
|
||||
Original.Slider {
|
||||
}
|
11
interface/resources/qml/controls/Spacer.qml
Normal file
11
interface/resources/qml/controls/Spacer.qml
Normal file
|
@ -0,0 +1,11 @@
|
|||
import QtQuick 2.4
|
||||
import "../styles"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
HifiConstants { id: hifi }
|
||||
property real size: hifi.layout.spacing
|
||||
property real multiplier: 1.0
|
||||
height: size * multiplier
|
||||
width: size * multiplier
|
||||
}
|
15
interface/resources/qml/controls/SpinBox.qml
Normal file
15
interface/resources/qml/controls/SpinBox.qml
Normal file
|
@ -0,0 +1,15 @@
|
|||
|
||||
import QtQuick.Controls 1.3 as Original
|
||||
import QtQuick.Controls.Styles 1.3
|
||||
|
||||
import "../styles"
|
||||
import "."
|
||||
|
||||
Original.SpinBox {
|
||||
style: SpinBoxStyle {
|
||||
HifiConstants { id: hifi }
|
||||
font.family: hifi.fonts.fontFamily
|
||||
font.pointSize: hifi.fonts.fontSize
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
import QtQuick 2.3 as Original
|
||||
import "../styles"
|
||||
|
||||
Original.Text {
|
||||
font.family: "Helvetica"
|
||||
font.pointSize: 18
|
||||
HifiConstants { id: hifi }
|
||||
font.family: hifi.fonts.fontFamily
|
||||
font.pointSize: hifi.fonts.fontSize
|
||||
}
|
||||
|
||||
|
|
24
interface/resources/qml/controls/TextAndSlider.qml
Normal file
24
interface/resources/qml/controls/TextAndSlider.qml
Normal file
|
@ -0,0 +1,24 @@
|
|||
import QtQuick 2.3 as Original
|
||||
import "../styles"
|
||||
import "."
|
||||
|
||||
Original.Item {
|
||||
property alias text: label.text
|
||||
property alias value: slider.value
|
||||
|
||||
Text {
|
||||
id: label
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
verticalAlignment: Original.Text.AlignVCenter
|
||||
}
|
||||
|
||||
Slider {
|
||||
id: slider
|
||||
width: 120
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
}
|
||||
}
|
26
interface/resources/qml/controls/TextAndSpinBox.qml
Normal file
26
interface/resources/qml/controls/TextAndSpinBox.qml
Normal file
|
@ -0,0 +1,26 @@
|
|||
import QtQuick 2.3 as Original
|
||||
import "../styles"
|
||||
import "."
|
||||
|
||||
Original.Item {
|
||||
property alias text: label.text
|
||||
property alias value: spinBox.value
|
||||
|
||||
Text {
|
||||
id: label
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
verticalAlignment: Original.Text.AlignVCenter
|
||||
text: "Minimum HMD FPS"
|
||||
}
|
||||
SpinBox {
|
||||
id: spinBox
|
||||
width: 120
|
||||
maximumValue: 240
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
import QtQuick 2.3 as Original
|
||||
import QtQuick.Controls 2.3 as Original
|
||||
import "../styles"
|
||||
|
||||
Original.TextArea {
|
||||
font.family: "Helvetica"
|
||||
font.pointSize: 18
|
||||
HifiConstants { id: hifi }
|
||||
font.family: hifi.fonts.fontFamily
|
||||
font.pointSize: hifi.fonts.fontSize
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import QtQuick 2.3 as Original
|
||||
import "../styles"
|
||||
|
||||
Original.TextEdit {
|
||||
font.family: "Helvetica"
|
||||
font.pointSize: 18
|
||||
HifiConstants { id: hifi }
|
||||
font.family: hifi.fonts.fontFamily
|
||||
font.pointSize: hifi.fonts.fontSize
|
||||
}
|
||||
|
||||
|
|
9
interface/resources/qml/controls/TextHeader.qml
Normal file
9
interface/resources/qml/controls/TextHeader.qml
Normal file
|
@ -0,0 +1,9 @@
|
|||
import "."
|
||||
import "../styles"
|
||||
|
||||
Text {
|
||||
HifiConstants { id: hifi }
|
||||
color: hifi.colors.hifiBlue
|
||||
font.pointSize: hifi.fonts.headerPointSize
|
||||
font.bold: true
|
||||
}
|
|
@ -1,34 +1,36 @@
|
|||
import QtQuick 2.3
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick 2.3 as Original
|
||||
import "../styles"
|
||||
import "."
|
||||
|
||||
TextInput {
|
||||
SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
|
||||
Original.TextInput {
|
||||
id: root
|
||||
HifiConstants { id: hifi }
|
||||
property string helperText
|
||||
font.family: "Helvetica"
|
||||
font.pointSize: 18
|
||||
width: 256
|
||||
height: 64
|
||||
color: myPalette.text
|
||||
height: hifi.layout.rowHeight
|
||||
clip: true
|
||||
verticalAlignment: TextInput.AlignVCenter
|
||||
color: hifi.colors.text
|
||||
verticalAlignment: Original.TextInput.AlignVCenter
|
||||
font.family: hifi.fonts.fontFamily
|
||||
font.pointSize: hifi.fonts.fontSize
|
||||
|
||||
onTextChanged: {
|
||||
if (text == "") {
|
||||
helperText.visible = true;
|
||||
} else {
|
||||
helperText.visible = false;
|
||||
}
|
||||
|
||||
Original.Rectangle {
|
||||
// Render the rectangle as background
|
||||
z: -1
|
||||
anchors.fill: parent
|
||||
color: hifi.colors.inputBackground
|
||||
}
|
||||
|
||||
Text {
|
||||
id: helperText
|
||||
anchors.fill: parent
|
||||
font.pointSize: parent.font.pointSize
|
||||
font.family: parent.font.family
|
||||
verticalAlignment: TextInput.AlignVCenter
|
||||
text: parent.helperText
|
||||
color: myPalette.dark
|
||||
clip: true
|
||||
verticalAlignment: parent.verticalAlignment
|
||||
horizontalAlignment: parent.horizontalAlignment
|
||||
text: root.helperText
|
||||
color: hifi.colors.hintText
|
||||
visible: !root.text
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
40
interface/resources/qml/controls/TextInputAndButton.qml
Normal file
40
interface/resources/qml/controls/TextInputAndButton.qml
Normal file
|
@ -0,0 +1,40 @@
|
|||
import QtQuick 2.3 as Original
|
||||
import "../styles"
|
||||
import "."
|
||||
|
||||
Original.Item {
|
||||
id: root
|
||||
HifiConstants { id: hifi }
|
||||
height: hifi.layout.rowHeight
|
||||
property string text
|
||||
property string helperText
|
||||
property string buttonText
|
||||
property int buttonWidth: 0
|
||||
property alias input: input
|
||||
property alias button: button
|
||||
signal clicked()
|
||||
|
||||
TextInput {
|
||||
id: input
|
||||
text: root.text
|
||||
helperText: root.helperText
|
||||
anchors.left: parent.left
|
||||
anchors.right: button.left
|
||||
anchors.rightMargin: 8
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.top: parent.top
|
||||
}
|
||||
|
||||
Button {
|
||||
id: button
|
||||
clip: true
|
||||
width: root.buttonWidth ? root.buttonWidth : implicitWidth
|
||||
text: root.buttonText
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.top: parent.top
|
||||
onClicked: root.clicked()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
import QtQuick 2.3
|
||||
|
||||
Rectangle {
|
||||
SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
|
||||
property int margin: 5
|
||||
color: myPalette.window
|
||||
border.color: myPalette.dark
|
||||
border.width: 5
|
||||
radius: border.width * 2
|
||||
HifiConstants { id: hifi }
|
||||
implicitHeight: 64
|
||||
implicitWidth: 64
|
||||
color: hifi.colors.window
|
||||
border.color: hifi.colors.hifiBlue
|
||||
border.width: hifi.styles.borderWidth
|
||||
radius: hifi.styles.borderRadius
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import "."
|
|||
import "../controls"
|
||||
|
||||
OriginalStyles.ButtonStyle {
|
||||
Original.SystemPalette { id: myPalette; colorGroup: Original.SystemPalette.Active }
|
||||
HifiConstants { id: hifi }
|
||||
padding {
|
||||
top: 8
|
||||
left: 12
|
||||
|
@ -15,10 +15,9 @@ OriginalStyles.ButtonStyle {
|
|||
anchors.fill: parent
|
||||
}
|
||||
label: Text {
|
||||
renderType: Original.Text.NativeRendering
|
||||
verticalAlignment: Original.Text.AlignVCenter
|
||||
horizontalAlignment: Original.Text.AlignHCenter
|
||||
text: control.text
|
||||
color: control.enabled ? myPalette.text : myPalette.dark
|
||||
color: control.enabled ? hifi.colors.text : hifi.colors.disabledText
|
||||
}
|
||||
}
|
||||
|
|
61
interface/resources/qml/styles/HifiConstants.qml
Normal file
61
interface/resources/qml/styles/HifiConstants.qml
Normal file
|
@ -0,0 +1,61 @@
|
|||
import QtQuick 2.4
|
||||
|
||||
Item {
|
||||
SystemPalette { id: sysPalette; colorGroup: SystemPalette.Active }
|
||||
readonly property alias colors: colors
|
||||
readonly property alias layout: layout
|
||||
readonly property alias fonts: fonts
|
||||
readonly property alias styles: styles
|
||||
readonly property alias effects: effects
|
||||
|
||||
Item {
|
||||
id: colors
|
||||
readonly property color hifiBlue: "#0e7077"
|
||||
readonly property color window: sysPalette.window
|
||||
readonly property color dialogBackground: sysPalette.window
|
||||
//readonly property color dialogBackground: "#00000000"
|
||||
readonly property color inputBackground: "white"
|
||||
readonly property color background: sysPalette.dark
|
||||
readonly property color text: sysPalette.text
|
||||
readonly property color disabledText: "gray"
|
||||
readonly property color hintText: sysPalette.dark
|
||||
readonly property color light: sysPalette.light
|
||||
readonly property alias activeWindow: activeWindow
|
||||
readonly property alias inactiveWindow: inactiveWindow
|
||||
QtObject {
|
||||
id: activeWindow
|
||||
readonly property color headerBackground: "white"
|
||||
readonly property color headerText: "black"
|
||||
}
|
||||
QtObject {
|
||||
id: inactiveWindow
|
||||
readonly property color headerBackground: "gray"
|
||||
readonly property color headerText: "black"
|
||||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: fonts
|
||||
readonly property real headerPointSize: 24
|
||||
readonly property string fontFamily: "Helvetica"
|
||||
readonly property real fontSize: 18
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: layout
|
||||
property int spacing: 8
|
||||
property int rowHeight: 40
|
||||
property int windowTitleHeight: 48
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: styles
|
||||
readonly property int borderWidth: 5
|
||||
readonly property int borderRadius: borderWidth * 2
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: effects
|
||||
readonly property int fadeInDuration: 400
|
||||
}
|
||||
}
|
|
@ -1,5 +1,11 @@
|
|||
import QtQuick 2.4
|
||||
|
||||
QtObject {
|
||||
Item {
|
||||
property string hifiBlue: "#0e7077"
|
||||
}
|
||||
property alias colors: colorsObj
|
||||
|
||||
Item {
|
||||
id: colorsObj
|
||||
property string hifiRed: "red"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
ButtonStyle {
|
||||
background: Item { anchors.fill: parent }
|
||||
label: Text {
|
||||
label: FontAwesome {
|
||||
id: icon
|
||||
width: height
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
font.family: iconFont.name
|
||||
font.pointSize: 18
|
||||
property alias unicode: icon.text
|
||||
FontLoader { id: iconFont; source: "../../fonts/fontawesome-webfont.ttf"; }
|
||||
property alias unicode: text
|
||||
text: control.text
|
||||
color: control.enabled ? "white" : "dimgray"
|
||||
color: control.enabled ? hifi.colors.text : hifi.colors.disabledText
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Controls.Styles 1.3
|
||||
import "../controls"
|
||||
import "."
|
||||
|
||||
ButtonStyle {
|
||||
HifiPalette { id: hifiPalette }
|
||||
padding {
|
||||
top: 2
|
||||
left: 4
|
||||
right: 4
|
||||
bottom: 2
|
||||
}
|
||||
background: Item {}
|
||||
label: Text {
|
||||
renderType: Text.NativeRendering
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: control.text
|
||||
color: control.enabled ? "yellow" : "brown"
|
||||
}
|
||||
}
|
|
@ -63,7 +63,7 @@
|
|||
#include <GlowEffect.h>
|
||||
#include <HFActionEvent.h>
|
||||
#include <HFBackEvent.h>
|
||||
#include <HifiMenu.h>
|
||||
#include <VrMenu.h>
|
||||
#include <LogHandler.h>
|
||||
#include <MainWindow.h>
|
||||
#include <ModelEntityItem.h>
|
||||
|
@ -1326,13 +1326,16 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//#define VR_MENU_ONLY_IN_HMD
|
||||
|
||||
void Application::keyReleaseEvent(QKeyEvent* event) {
|
||||
if (event->key() == Qt::Key_Alt && _altPressed && _window->isActiveWindow()) {
|
||||
#ifndef DEBUG
|
||||
#ifdef VR_MENU_ONLY_IN_HMD
|
||||
if (OculusManager::isConnected()) {
|
||||
#endif
|
||||
VrMenu::toggle();
|
||||
#ifndef DEBUG
|
||||
#ifdef VR_MENU_ONLY_IN_HMD
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <PathUtils.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <UserActivityLogger.h>
|
||||
#include <HifiMenu.h>
|
||||
#include <VrMenu.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "AccountManager.h"
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
TreeNodeScript(const QString& localPath, const QString& fullPath, ScriptOrigin origin);
|
||||
const QString& getLocalPath() { return _localPath; }
|
||||
const QString& getFullPath() { return _fullPath; };
|
||||
const ScriptOrigin getOrigin() { return _origin; };
|
||||
ScriptOrigin getOrigin() { return _origin; };
|
||||
|
||||
private:
|
||||
QString _localPath;
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
FaceModel& getFaceModel() { return _faceModel; }
|
||||
const FaceModel& getFaceModel() const { return _faceModel; }
|
||||
|
||||
const bool getReturnToCenter() const { return _returnHeadToCenter; } // Do you want head to try to return to center (depends on interface detected)
|
||||
bool getReturnToCenter() const { return _returnHeadToCenter; } // Do you want head to try to return to center (depends on interface detected)
|
||||
float getAverageLoudness() const { return _averageLoudness; }
|
||||
/// \return the point about which scaling occurs.
|
||||
glm::vec3 getScalePivot() const;
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
HIFI_QML_DEF(MarketplaceDialog)
|
||||
|
||||
|
||||
MarketplaceDialog::MarketplaceDialog(QQuickItem *parent) : OffscreenQmlDialog(parent) {
|
||||
MarketplaceDialog::MarketplaceDialog(QQuickItem* parent) : OffscreenQmlDialog(parent) {
|
||||
}
|
||||
|
||||
bool MarketplaceDialog::navigationRequested(const QString & url) {
|
||||
bool MarketplaceDialog::navigationRequested(const QString& url) {
|
||||
qDebug() << url;
|
||||
if (Application::getInstance()->canAcceptURL(url)) {
|
||||
if (Application::getInstance()->acceptURL(url)) {
|
||||
|
|
|
@ -20,9 +20,9 @@ class MarketplaceDialog : public OffscreenQmlDialog
|
|||
HIFI_QML_DECL
|
||||
|
||||
public:
|
||||
MarketplaceDialog(QQuickItem *parent = 0);
|
||||
MarketplaceDialog(QQuickItem* parent = nullptr);
|
||||
|
||||
Q_INVOKABLE bool navigationRequested(const QString & url);
|
||||
Q_INVOKABLE bool navigationRequested(const QString& url);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ void Overlays::renderHUD() {
|
|||
lodManager->getOctreeSizeScale(),
|
||||
lodManager->getBoundaryLevelAdjust(),
|
||||
RenderArgs::DEFAULT_RENDER_MODE, RenderArgs::MONO,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
foreach(Overlay* thisOverlay, _overlaysHUD) {
|
||||
if (thisOverlay->is3D()) {
|
||||
|
@ -126,7 +126,7 @@ void Overlays::renderWorld(bool drawFront, RenderArgs::RenderMode renderMode, Re
|
|||
lodManager->getOctreeSizeScale(),
|
||||
lodManager->getBoundaryLevelAdjust(),
|
||||
renderMode, renderSide,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
|
||||
foreach(Overlay* thisOverlay, _overlaysWorld) {
|
||||
|
|
|
@ -64,7 +64,7 @@ AudioEffectOptions::AudioEffectOptions(QScriptValue arguments) :
|
|||
}
|
||||
}
|
||||
|
||||
AudioEffectOptions::AudioEffectOptions(const AudioEffectOptions &other) {
|
||||
AudioEffectOptions::AudioEffectOptions(const AudioEffectOptions &other) : QObject() {
|
||||
*this = other;
|
||||
}
|
||||
|
||||
|
|
|
@ -391,7 +391,7 @@ void EntityTreeRenderer::render(RenderArgs::RenderMode renderMode, RenderArgs::R
|
|||
_viewState->getShadowViewFrustum() : _viewState->getCurrentViewFrustum();
|
||||
|
||||
RenderArgs args = { this, frustum, getSizeScale(), getBoundaryLevelAdjust(), renderMode, renderSide,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
|
||||
_tree->lockForRead();
|
||||
|
|
|
@ -521,7 +521,7 @@ bool EntityTree::findInSphereOperation(OctreeElement* element, void* extraData)
|
|||
|
||||
// NOTE: assumes caller has handled locking
|
||||
void EntityTree::findEntities(const glm::vec3& center, float radius, QVector<const EntityItem*>& foundEntities) {
|
||||
FindAllNearPointArgs args = { center, radius };
|
||||
FindAllNearPointArgs args = { center, radius, QVector<const EntityItem*>() };
|
||||
// NOTE: This should use recursion, since this is a spatial operation
|
||||
recurseTreeWithOperation(findInSphereOperation, &args);
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ bool FBXGeometry::convexHullContains(const glm::vec3& point) const {
|
|||
|
||||
auto checkEachPrimitive = [=](FBXMesh& mesh, QVector<int> indices, int primitiveSize) -> bool {
|
||||
// Check whether the point is "behind" all the primitives.
|
||||
for (unsigned int j = 0; j < indices.size(); j += primitiveSize) {
|
||||
for (int j = 0; j < indices.size(); j += primitiveSize) {
|
||||
if (!isPointBehindTrianglesPlane(point,
|
||||
mesh.vertices[indices[j]],
|
||||
mesh.vertices[indices[j + 1]],
|
||||
|
@ -1469,7 +1469,8 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
bool rotationMinX = false, rotationMinY = false, rotationMinZ = false;
|
||||
bool rotationMaxX = false, rotationMaxY = false, rotationMaxZ = false;
|
||||
glm::vec3 rotationMin, rotationMax;
|
||||
FBXModel model = { name, -1 };
|
||||
FBXModel model = { name, -1, glm::vec3(), glm::mat4(), glm::quat(), glm::quat(), glm::quat(),
|
||||
glm::mat4(), glm::vec3(), glm::vec3()};
|
||||
ExtractedMesh* mesh = NULL;
|
||||
QVector<ExtractedBlendshape> blendshapes;
|
||||
foreach (const FBXNode& subobject, object.children) {
|
||||
|
@ -1685,7 +1686,8 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
textureContent.insert(filename, content);
|
||||
}
|
||||
} else if (object.name == "Material") {
|
||||
Material material = { glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(), 96.0f, 1.0f };
|
||||
Material material = { glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(), 96.0f, 1.0f,
|
||||
QString(""), QSharedPointer<model::Material>(NULL)};
|
||||
foreach (const FBXNode& subobject, object.children) {
|
||||
bool properties = false;
|
||||
QByteArray propertyName;
|
||||
|
|
|
@ -143,7 +143,7 @@ void GLBackend::do_draw(Batch& batch, uint32 paramOffset) {
|
|||
uint32 startVertex = batch._params[paramOffset + 0]._uint;
|
||||
|
||||
glDrawArrays(mode, startVertex, numVertices);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void GLBackend::do_drawIndexed(Batch& batch, uint32 paramOffset) {
|
||||
|
@ -159,15 +159,15 @@ void GLBackend::do_drawIndexed(Batch& batch, uint32 paramOffset) {
|
|||
GLenum glType = _elementTypeToGLType[_input._indexBufferType];
|
||||
|
||||
glDrawElements(mode, numIndices, glType, reinterpret_cast<GLvoid*>(startIndex + _input._indexBufferOffset));
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void GLBackend::do_drawInstanced(Batch& batch, uint32 paramOffset) {
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void GLBackend::do_drawIndexedInstanced(Batch& batch, uint32 paramOffset) {
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
// TODO: As long as we have gl calls explicitely issued from interface
|
||||
|
@ -189,7 +189,7 @@ void Batch::_glEnable(GLenum cap) {
|
|||
}
|
||||
void GLBackend::do_glEnable(Batch& batch, uint32 paramOffset) {
|
||||
glEnable(batch._params[paramOffset]._uint);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glDisable(GLenum cap) {
|
||||
|
@ -201,7 +201,7 @@ void Batch::_glDisable(GLenum cap) {
|
|||
}
|
||||
void GLBackend::do_glDisable(Batch& batch, uint32 paramOffset) {
|
||||
glDisable(batch._params[paramOffset]._uint);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glEnableClientState(GLenum array) {
|
||||
|
@ -213,7 +213,7 @@ void Batch::_glEnableClientState(GLenum array) {
|
|||
}
|
||||
void GLBackend::do_glEnableClientState(Batch& batch, uint32 paramOffset) {
|
||||
glEnableClientState(batch._params[paramOffset]._uint);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glDisableClientState(GLenum array) {
|
||||
|
@ -225,7 +225,7 @@ void Batch::_glDisableClientState(GLenum array) {
|
|||
}
|
||||
void GLBackend::do_glDisableClientState(Batch& batch, uint32 paramOffset) {
|
||||
glDisableClientState(batch._params[paramOffset]._uint);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glCullFace(GLenum mode) {
|
||||
|
@ -237,7 +237,7 @@ void Batch::_glCullFace(GLenum mode) {
|
|||
}
|
||||
void GLBackend::do_glCullFace(Batch& batch, uint32 paramOffset) {
|
||||
glCullFace(batch._params[paramOffset]._uint);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glAlphaFunc(GLenum func, GLclampf ref) {
|
||||
|
@ -252,7 +252,7 @@ void GLBackend::do_glAlphaFunc(Batch& batch, uint32 paramOffset) {
|
|||
glAlphaFunc(
|
||||
batch._params[paramOffset + 1]._uint,
|
||||
batch._params[paramOffset + 0]._float);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glDepthFunc(GLenum func) {
|
||||
|
@ -264,7 +264,7 @@ void Batch::_glDepthFunc(GLenum func) {
|
|||
}
|
||||
void GLBackend::do_glDepthFunc(Batch& batch, uint32 paramOffset) {
|
||||
glDepthFunc(batch._params[paramOffset]._uint);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glDepthMask(GLboolean flag) {
|
||||
|
@ -276,7 +276,7 @@ void Batch::_glDepthMask(GLboolean flag) {
|
|||
}
|
||||
void GLBackend::do_glDepthMask(Batch& batch, uint32 paramOffset) {
|
||||
glDepthMask(batch._params[paramOffset]._uint);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glDepthRange(GLfloat zNear, GLfloat zFar) {
|
||||
|
@ -291,7 +291,7 @@ void GLBackend::do_glDepthRange(Batch& batch, uint32 paramOffset) {
|
|||
glDepthRange(
|
||||
batch._params[paramOffset + 1]._float,
|
||||
batch._params[paramOffset + 0]._float);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glBindBuffer(GLenum target, GLuint buffer) {
|
||||
|
@ -306,7 +306,7 @@ void GLBackend::do_glBindBuffer(Batch& batch, uint32 paramOffset) {
|
|||
glBindBuffer(
|
||||
batch._params[paramOffset + 1]._uint,
|
||||
batch._params[paramOffset + 0]._uint);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glBindTexture(GLenum target, GLuint texture) {
|
||||
|
@ -321,7 +321,7 @@ void GLBackend::do_glBindTexture(Batch& batch, uint32 paramOffset) {
|
|||
glBindTexture(
|
||||
batch._params[paramOffset + 1]._uint,
|
||||
batch._params[paramOffset + 0]._uint);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glActiveTexture(GLenum texture) {
|
||||
|
@ -333,7 +333,7 @@ void Batch::_glActiveTexture(GLenum texture) {
|
|||
}
|
||||
void GLBackend::do_glActiveTexture(Batch& batch, uint32 paramOffset) {
|
||||
glActiveTexture(batch._params[paramOffset]._uint);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glDrawBuffers(GLsizei n, const GLenum* bufs) {
|
||||
|
@ -348,7 +348,7 @@ void GLBackend::do_glDrawBuffers(Batch& batch, uint32 paramOffset) {
|
|||
glDrawBuffers(
|
||||
batch._params[paramOffset + 1]._uint,
|
||||
(const GLenum*)batch.editData(batch._params[paramOffset + 0]._uint));
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glUseProgram(GLuint program) {
|
||||
|
@ -365,7 +365,7 @@ void GLBackend::do_glUseProgram(Batch& batch, uint32 paramOffset) {
|
|||
_pipeline._invalidProgram = false;
|
||||
glUseProgram(_pipeline._program);
|
||||
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glUniform1f(GLint location, GLfloat v0) {
|
||||
|
@ -385,7 +385,7 @@ void GLBackend::do_glUniform1f(Batch& batch, uint32 paramOffset) {
|
|||
glUniform1f(
|
||||
batch._params[paramOffset + 1]._int,
|
||||
batch._params[paramOffset + 0]._float);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glUniform2f(GLint location, GLfloat v0, GLfloat v1) {
|
||||
|
@ -402,7 +402,7 @@ void GLBackend::do_glUniform2f(Batch& batch, uint32 paramOffset) {
|
|||
batch._params[paramOffset + 2]._int,
|
||||
batch._params[paramOffset + 1]._float,
|
||||
batch._params[paramOffset + 0]._float);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glUniform4fv(GLint location, GLsizei count, const GLfloat* value) {
|
||||
|
@ -421,7 +421,7 @@ void GLBackend::do_glUniform4fv(Batch& batch, uint32 paramOffset) {
|
|||
batch._params[paramOffset + 1]._uint,
|
||||
(const GLfloat*)batch.editData(batch._params[paramOffset + 0]._uint));
|
||||
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
|
@ -441,7 +441,7 @@ void GLBackend::do_glUniformMatrix4fv(Batch& batch, uint32 paramOffset) {
|
|||
batch._params[paramOffset + 2]._uint,
|
||||
batch._params[paramOffset + 1]._uint,
|
||||
(const GLfloat*)batch.editData(batch._params[paramOffset + 0]._uint));
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glEnableVertexAttribArray(GLint location) {
|
||||
|
@ -453,7 +453,7 @@ void Batch::_glEnableVertexAttribArray(GLint location) {
|
|||
}
|
||||
void GLBackend::do_glEnableVertexAttribArray(Batch& batch, uint32 paramOffset) {
|
||||
glEnableVertexAttribArray(batch._params[paramOffset]._uint);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glDisableVertexAttribArray(GLint location) {
|
||||
|
@ -465,7 +465,7 @@ void Batch::_glDisableVertexAttribArray(GLint location) {
|
|||
}
|
||||
void GLBackend::do_glDisableVertexAttribArray(Batch& batch, uint32 paramOffset) {
|
||||
glDisableVertexAttribArray(batch._params[paramOffset]._uint);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void Batch::_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {
|
||||
|
@ -484,6 +484,6 @@ void GLBackend::do_glColor4f(Batch& batch, uint32 paramOffset) {
|
|||
batch._params[paramOffset + 2]._float,
|
||||
batch._params[paramOffset + 1]._float,
|
||||
batch._params[paramOffset + 0]._float);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ GLBackend::GLBuffer* GLBackend::syncGPUObject(const Buffer& buffer) {
|
|||
if (!object) {
|
||||
object = new GLBuffer();
|
||||
glGenBuffers(1, &object->_buffer);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
Backend::setGPUObject(buffer, object);
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ GLBackend::GLBuffer* GLBackend::syncGPUObject(const Buffer& buffer) {
|
|||
object->_stamp = buffer.getSysmem().getStamp();
|
||||
object->_size = buffer.getSysmem().getSize();
|
||||
//}
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
|
||||
return object;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ void GLBackend::updateInput() {
|
|||
glDisableVertexAttribArray(i);
|
||||
}
|
||||
}
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
|
||||
_input._attributeActivation.flip(i);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ void GLBackend::updateInput() {
|
|||
if (_input._buffersState.test(bufferNum) || _input._invalidFormat) {
|
||||
GLuint vbo = gpu::GLBackend::getBufferID((*buffers[bufferNum]));
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
_input._buffersState[bufferNum] = false;
|
||||
|
||||
for (unsigned int i = 0; i < channel._slots.size(); i++) {
|
||||
|
@ -142,7 +142,7 @@ void GLBackend::updateInput() {
|
|||
glVertexAttribPointer(slot, count, type, isNormalized, stride,
|
||||
reinterpret_cast<GLvoid*>(pointer));
|
||||
}
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -219,5 +219,5 @@ void GLBackend::do_setIndexBuffer(Batch& batch, uint32 paramOffset) {
|
|||
} else {
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ GLBackend::GLFramebuffer* GLBackend::syncGPUObject(const Framebuffer& framebuffe
|
|||
GLFramebuffer* object = Backend::getGPUObject<GLBackend::GLFramebuffer>(framebuffer);
|
||||
|
||||
// If GPU object already created and in sync
|
||||
bool needUpdate = false;
|
||||
if (object) {
|
||||
return object;
|
||||
} else if (framebuffer.isEmpty()) {
|
||||
|
@ -36,90 +35,90 @@ GLBackend::GLFramebuffer* GLBackend::syncGPUObject(const Framebuffer& framebuffe
|
|||
if (!object) {
|
||||
GLuint fbo;
|
||||
glGenFramebuffers(1, &fbo);
|
||||
CHECK_GL_ERROR();
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
|
||||
unsigned int nbColorBuffers = 0;
|
||||
GLenum colorBuffers[16];
|
||||
if (framebuffer.hasColor()) {
|
||||
static const GLenum colorAttachments[] = {
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
GL_COLOR_ATTACHMENT1,
|
||||
GL_COLOR_ATTACHMENT2,
|
||||
GL_COLOR_ATTACHMENT3,
|
||||
GL_COLOR_ATTACHMENT4,
|
||||
GL_COLOR_ATTACHMENT5,
|
||||
GL_COLOR_ATTACHMENT6,
|
||||
GL_COLOR_ATTACHMENT7,
|
||||
GL_COLOR_ATTACHMENT8,
|
||||
GL_COLOR_ATTACHMENT9,
|
||||
GL_COLOR_ATTACHMENT10,
|
||||
GL_COLOR_ATTACHMENT11,
|
||||
GL_COLOR_ATTACHMENT12,
|
||||
GL_COLOR_ATTACHMENT13,
|
||||
GL_COLOR_ATTACHMENT14,
|
||||
GL_COLOR_ATTACHMENT15 };
|
||||
|
||||
int unit = 0;
|
||||
for (auto& b : framebuffer.getRenderBuffers()) {
|
||||
auto surface = b._texture;
|
||||
if (surface) {
|
||||
auto gltexture = GLBackend::syncGPUObject(*surface);
|
||||
if (gltexture) {
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachments[unit], GL_TEXTURE_2D, gltexture->_texture, 0);
|
||||
}
|
||||
colorBuffers[nbColorBuffers] = colorAttachments[unit];
|
||||
nbColorBuffers++;
|
||||
unit++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (framebuffer.hasDepthStencil()) {
|
||||
auto surface = framebuffer.getDepthStencilBuffer();
|
||||
if (surface) {
|
||||
auto gltexture = GLBackend::syncGPUObject(*surface);
|
||||
if (gltexture) {
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, gltexture->_texture, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Last but not least, define where we draw
|
||||
if (nbColorBuffers > 0) {
|
||||
glDrawBuffers(nbColorBuffers, colorBuffers);
|
||||
} else {
|
||||
glDrawBuffer( GL_NONE );
|
||||
}
|
||||
|
||||
// Now check for completness
|
||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
bool result = false;
|
||||
switch (status) {
|
||||
case GL_FRAMEBUFFER_COMPLETE :
|
||||
// Success !
|
||||
result = true;
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT :
|
||||
qCDebug(gpulogging) << "GLFramebuffer::syncGPUObject : Framebuffer not valid, GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT.";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT :
|
||||
qCDebug(gpulogging) << "GLFramebuffer::syncGPUObject : Framebuffer not valid, GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT.";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER :
|
||||
qCDebug(gpulogging) << "GLFramebuffer::syncGPUObject : Framebuffer not valid, GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER.";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER :
|
||||
qCDebug(gpulogging) << "GLFramebuffer::syncGPUObject : Framebuffer not valid, GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER.";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_UNSUPPORTED :
|
||||
qCDebug(gpulogging) << "GLFramebuffer::syncGPUObject : Framebuffer not valid, GL_FRAMEBUFFER_UNSUPPORTED.";
|
||||
break;
|
||||
}
|
||||
if (!result && fbo) {
|
||||
glDeleteFramebuffers( 1, &fbo );
|
||||
return nullptr;
|
||||
(void) CHECK_GL_ERROR();
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
|
||||
unsigned int nbColorBuffers = 0;
|
||||
GLenum colorBuffers[16];
|
||||
if (framebuffer.hasColor()) {
|
||||
static const GLenum colorAttachments[] = {
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
GL_COLOR_ATTACHMENT1,
|
||||
GL_COLOR_ATTACHMENT2,
|
||||
GL_COLOR_ATTACHMENT3,
|
||||
GL_COLOR_ATTACHMENT4,
|
||||
GL_COLOR_ATTACHMENT5,
|
||||
GL_COLOR_ATTACHMENT6,
|
||||
GL_COLOR_ATTACHMENT7,
|
||||
GL_COLOR_ATTACHMENT8,
|
||||
GL_COLOR_ATTACHMENT9,
|
||||
GL_COLOR_ATTACHMENT10,
|
||||
GL_COLOR_ATTACHMENT11,
|
||||
GL_COLOR_ATTACHMENT12,
|
||||
GL_COLOR_ATTACHMENT13,
|
||||
GL_COLOR_ATTACHMENT14,
|
||||
GL_COLOR_ATTACHMENT15 };
|
||||
|
||||
int unit = 0;
|
||||
for (auto& b : framebuffer.getRenderBuffers()) {
|
||||
auto surface = b._texture;
|
||||
if (surface) {
|
||||
auto gltexture = GLBackend::syncGPUObject(*surface);
|
||||
if (gltexture) {
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachments[unit], GL_TEXTURE_2D, gltexture->_texture, 0);
|
||||
}
|
||||
colorBuffers[nbColorBuffers] = colorAttachments[unit];
|
||||
nbColorBuffers++;
|
||||
unit++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (framebuffer.hasDepthStencil()) {
|
||||
auto surface = framebuffer.getDepthStencilBuffer();
|
||||
if (surface) {
|
||||
auto gltexture = GLBackend::syncGPUObject(*surface);
|
||||
if (gltexture) {
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, gltexture->_texture, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Last but not least, define where we draw
|
||||
if (nbColorBuffers > 0) {
|
||||
glDrawBuffers(nbColorBuffers, colorBuffers);
|
||||
} else {
|
||||
glDrawBuffer( GL_NONE );
|
||||
}
|
||||
|
||||
// Now check for completness
|
||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
bool result = false;
|
||||
switch (status) {
|
||||
case GL_FRAMEBUFFER_COMPLETE :
|
||||
// Success !
|
||||
result = true;
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT :
|
||||
qCDebug(gpulogging) << "GLFramebuffer::syncGPUObject : Framebuffer not valid, GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT.";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT :
|
||||
qCDebug(gpulogging) << "GLFramebuffer::syncGPUObject : Framebuffer not valid, GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT.";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER :
|
||||
qCDebug(gpulogging) << "GLFramebuffer::syncGPUObject : Framebuffer not valid, GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER.";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER :
|
||||
qCDebug(gpulogging) << "GLFramebuffer::syncGPUObject : Framebuffer not valid, GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER.";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_UNSUPPORTED :
|
||||
qCDebug(gpulogging) << "GLFramebuffer::syncGPUObject : Framebuffer not valid, GL_FRAMEBUFFER_UNSUPPORTED.";
|
||||
break;
|
||||
}
|
||||
if (!result && fbo) {
|
||||
glDeleteFramebuffers( 1, &fbo );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -154,4 +153,4 @@ void GLBackend::do_setFramebuffer(Batch& batch, uint32 paramOffset) {
|
|||
_output._framebuffer = framebuffer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ void GLBackend::do_setPipeline(Batch& batch, uint32 paramOffset) {
|
|||
// THis should be done on Pipeline::update...
|
||||
if (_pipeline._invalidProgram) {
|
||||
glUseProgram(_pipeline._program);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
_pipeline._invalidProgram = false;
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ void GLBackend::updatePipeline() {
|
|||
if (_pipeline._invalidProgram) {
|
||||
// doing it here is aproblem for calls to glUniform.... so will do it on assing...
|
||||
glUseProgram(_pipeline._program);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
_pipeline._invalidProgram = false;
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ void GLBackend::do_setUniformBuffer(Batch& batch, uint32 paramOffset) {
|
|||
// GLuint bo = getBufferID(*uniformBuffer);
|
||||
//glUniformBufferEXT(_shader._program, slot, bo);
|
||||
#endif
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void GLBackend::do_setUniformTexture(Batch& batch, uint32 paramOffset) {
|
||||
|
@ -175,6 +175,6 @@ void GLBackend::do_setUniformTexture(Batch& batch, uint32 paramOffset) {
|
|||
glActiveTexture(GL_TEXTURE0 + slot);
|
||||
glBindTexture(GL_TEXTURE_2D, to);
|
||||
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
|
|
|
@ -458,7 +458,7 @@ void GLBackend::getCurrentGLState(State::Data& state) {
|
|||
| (mask[3] ? State::WRITE_ALPHA : 0);
|
||||
}
|
||||
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void GLBackend::syncPipelineStateCache() {
|
||||
|
@ -485,7 +485,7 @@ void GLBackend::do_setStateFillMode(int32 mode) {
|
|||
if (_pipeline._stateCache.fillMode != mode) {
|
||||
static GLenum GL_FILL_MODES[] = { GL_POINT, GL_LINE, GL_FILL };
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL_MODES[mode]);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
|
||||
_pipeline._stateCache.fillMode = State::FillMode(mode);
|
||||
}
|
||||
|
@ -501,7 +501,7 @@ void GLBackend::do_setStateCullMode(int32 mode) {
|
|||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_CULL_MODES[mode]);
|
||||
}
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
|
||||
_pipeline._stateCache.cullMode = State::CullMode(mode);
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ void GLBackend::do_setStateFrontFaceClockwise(bool isClockwise) {
|
|||
if (_pipeline._stateCache.frontFaceClockwise != isClockwise) {
|
||||
static GLenum GL_FRONT_FACES[] = { GL_CCW, GL_CW };
|
||||
glFrontFace(GL_FRONT_FACES[isClockwise]);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
|
||||
_pipeline._stateCache.frontFaceClockwise = isClockwise;
|
||||
}
|
||||
|
@ -524,7 +524,7 @@ void GLBackend::do_setStateDepthClipEnable(bool enable) {
|
|||
} else {
|
||||
glDisable(GL_DEPTH_CLAMP);
|
||||
}
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
|
||||
_pipeline._stateCache.depthClipEnable = enable;
|
||||
}
|
||||
|
@ -537,7 +537,7 @@ void GLBackend::do_setStateScissorEnable(bool enable) {
|
|||
} else {
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
|
||||
_pipeline._stateCache.scissorEnable = enable;
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ void GLBackend::do_setStateMultisampleEnable(bool enable) {
|
|||
} else {
|
||||
glDisable(GL_MULTISAMPLE);
|
||||
}
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
|
||||
_pipeline._stateCache.multisampleEnable = enable;
|
||||
}
|
||||
|
@ -565,7 +565,7 @@ void GLBackend::do_setStateAntialiasedLineEnable(bool enable) {
|
|||
glDisable(GL_POINT_SMOOTH);
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
|
||||
_pipeline._stateCache.antialisedLineEnable = enable;
|
||||
}
|
||||
|
@ -637,7 +637,7 @@ void GLBackend::do_setStateStencil(State::StencilActivation activation, State::S
|
|||
} else {
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
}
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
|
||||
_pipeline._stateCache.stencilActivation = activation;
|
||||
_pipeline._stateCache.stencilTestFront = frontTest;
|
||||
|
@ -652,7 +652,7 @@ void GLBackend::do_setStateAlphaToCoverageEnable(bool enable) {
|
|||
} else {
|
||||
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
|
||||
}
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
_pipeline._stateCache.alphaToCoverageEnable = enable;
|
||||
}
|
||||
}
|
||||
|
@ -684,7 +684,7 @@ void GLBackend::do_setStateBlend(State::BlendFunction function) {
|
|||
GL_MAX };
|
||||
|
||||
glBlendEquationSeparate(GL_BLEND_OPS[function.getOperationColor()], GL_BLEND_OPS[function.getOperationAlpha()]);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
|
||||
static GLenum BLEND_ARGS[] = {
|
||||
GL_ZERO,
|
||||
|
@ -706,7 +706,7 @@ void GLBackend::do_setStateBlend(State::BlendFunction function) {
|
|||
|
||||
glBlendFuncSeparate(BLEND_ARGS[function.getSourceColor()], BLEND_ARGS[function.getDestinationColor()],
|
||||
BLEND_ARGS[function.getSourceAlpha()], BLEND_ARGS[function.getDestinationAlpha()]);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
} else {
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
@ -735,5 +735,5 @@ void GLBackend::do_setStateBlendFactor(Batch& batch, uint32 paramOffset) {
|
|||
batch._params[paramOffset + 3]._float);
|
||||
|
||||
glBlendColor(factor.x, factor.y, factor.z, factor.w);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
|
|
@ -176,9 +176,10 @@ public:
|
|||
texel.internalFormat = GL_DEPTH_COMPONENT24;
|
||||
break;
|
||||
}
|
||||
case gpu::NUM_TYPES:
|
||||
case gpu::NUM_TYPES: { // quiet compiler
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
qCDebug(gpulogging) << "Unknown combination of texel format";
|
||||
|
@ -281,7 +282,7 @@ GLBackend::GLTexture* GLBackend::syncGPUObject(const Texture& texture) {
|
|||
if (!object) {
|
||||
object = new GLTexture();
|
||||
glGenTextures(1, &object->_texture);
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
Backend::setGPUObject(texture, object);
|
||||
}
|
||||
|
||||
|
@ -365,7 +366,7 @@ GLBackend::GLTexture* GLBackend::syncGPUObject(const Texture& texture) {
|
|||
default:
|
||||
qCDebug(gpulogging) << "GLBackend::syncGPUObject(const Texture&) case for Texture Type " << texture.getType() << " not supported";
|
||||
}
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
|
||||
return object;
|
||||
}
|
||||
|
@ -388,42 +389,42 @@ void GLBackend::syncSampler(const Sampler& sampler, Texture::Type type, GLTextur
|
|||
if (!object) return;
|
||||
if (!object->_texture) return;
|
||||
|
||||
class GLFilterMode {
|
||||
public:
|
||||
GLint minFilter;
|
||||
GLint magFilter;
|
||||
};
|
||||
static const GLFilterMode filterModes[] = {
|
||||
{GL_NEAREST, GL_NEAREST}, //FILTER_MIN_MAG_POINT,
|
||||
{GL_NEAREST, GL_LINEAR}, //FILTER_MIN_POINT_MAG_LINEAR,
|
||||
{GL_LINEAR, GL_NEAREST}, //FILTER_MIN_LINEAR_MAG_POINT,
|
||||
{GL_LINEAR, GL_LINEAR}, //FILTER_MIN_MAG_LINEAR,
|
||||
|
||||
{GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST}, //FILTER_MIN_MAG_MIP_POINT,
|
||||
{GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST}, //FILTER_MIN_MAG_MIP_POINT,
|
||||
{GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST}, //FILTER_MIN_MAG_POINT_MIP_LINEAR,
|
||||
{GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR}, //FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT,
|
||||
{GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR}, //FILTER_MIN_POINT_MAG_MIP_LINEAR,
|
||||
{GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST}, //FILTER_MIN_LINEAR_MAG_MIP_POINT,
|
||||
{GL_LINEAR_MIPMAP_LINEAR, GL_NEAREST}, //FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR,
|
||||
{GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR}, //FILTER_MIN_MAG_LINEAR_MIP_POINT,
|
||||
{GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR}, //FILTER_MIN_MAG_MIP_LINEAR,
|
||||
{GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR} //FILTER_ANISOTROPIC,
|
||||
};
|
||||
class GLFilterMode {
|
||||
public:
|
||||
GLint minFilter;
|
||||
GLint magFilter;
|
||||
};
|
||||
static const GLFilterMode filterModes[] = {
|
||||
{GL_NEAREST, GL_NEAREST}, //FILTER_MIN_MAG_POINT,
|
||||
{GL_NEAREST, GL_LINEAR}, //FILTER_MIN_POINT_MAG_LINEAR,
|
||||
{GL_LINEAR, GL_NEAREST}, //FILTER_MIN_LINEAR_MAG_POINT,
|
||||
{GL_LINEAR, GL_LINEAR}, //FILTER_MIN_MAG_LINEAR,
|
||||
|
||||
{GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST}, //FILTER_MIN_MAG_MIP_POINT,
|
||||
{GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST}, //FILTER_MIN_MAG_MIP_POINT,
|
||||
{GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST}, //FILTER_MIN_MAG_POINT_MIP_LINEAR,
|
||||
{GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR}, //FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT,
|
||||
{GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR}, //FILTER_MIN_POINT_MAG_MIP_LINEAR,
|
||||
{GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST}, //FILTER_MIN_LINEAR_MAG_MIP_POINT,
|
||||
{GL_LINEAR_MIPMAP_LINEAR, GL_NEAREST}, //FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR,
|
||||
{GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR}, //FILTER_MIN_MAG_LINEAR_MIP_POINT,
|
||||
{GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR}, //FILTER_MIN_MAG_MIP_LINEAR,
|
||||
{GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR} //FILTER_ANISOTROPIC,
|
||||
};
|
||||
|
||||
auto fm = filterModes[sampler.getFilter()];
|
||||
glTexParameteri(object->_target, GL_TEXTURE_MIN_FILTER, fm.minFilter);
|
||||
glTexParameteri(object->_target, GL_TEXTURE_MAG_FILTER, fm.magFilter);
|
||||
glTexParameteri(object->_target, GL_TEXTURE_MIN_FILTER, fm.minFilter);
|
||||
glTexParameteri(object->_target, GL_TEXTURE_MAG_FILTER, fm.magFilter);
|
||||
|
||||
static const GLenum comparisonFuncs[] = {
|
||||
GL_NEVER,
|
||||
GL_LESS,
|
||||
GL_EQUAL,
|
||||
GL_LEQUAL,
|
||||
GL_GREATER,
|
||||
GL_NOTEQUAL,
|
||||
GL_GEQUAL,
|
||||
GL_ALWAYS };
|
||||
static const GLenum comparisonFuncs[] = {
|
||||
GL_NEVER,
|
||||
GL_LESS,
|
||||
GL_EQUAL,
|
||||
GL_LEQUAL,
|
||||
GL_GREATER,
|
||||
GL_NOTEQUAL,
|
||||
GL_GEQUAL,
|
||||
GL_ALWAYS };
|
||||
|
||||
if (sampler.doComparison()) {
|
||||
glTexParameteri(object->_target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
|
||||
|
@ -432,22 +433,22 @@ void GLBackend::syncSampler(const Sampler& sampler, Texture::Type type, GLTextur
|
|||
glTexParameteri(object->_target, GL_TEXTURE_COMPARE_MODE, GL_NONE);
|
||||
}
|
||||
|
||||
static const GLenum wrapModes[] = {
|
||||
GL_REPEAT, // WRAP_REPEAT,
|
||||
GL_MIRRORED_REPEAT, // WRAP_MIRROR,
|
||||
GL_CLAMP_TO_EDGE, // WRAP_CLAMP,
|
||||
GL_CLAMP_TO_BORDER, // WRAP_BORDER,
|
||||
GL_MIRROR_CLAMP_TO_EDGE_EXT }; // WRAP_MIRROR_ONCE,
|
||||
|
||||
glTexParameteri(object->_target, GL_TEXTURE_WRAP_S, wrapModes[sampler.getWrapModeU()]);
|
||||
glTexParameteri(object->_target, GL_TEXTURE_WRAP_T, wrapModes[sampler.getWrapModeV()]);
|
||||
glTexParameteri(object->_target, GL_TEXTURE_WRAP_R, wrapModes[sampler.getWrapModeW()]);
|
||||
static const GLenum wrapModes[] = {
|
||||
GL_REPEAT, // WRAP_REPEAT,
|
||||
GL_MIRRORED_REPEAT, // WRAP_MIRROR,
|
||||
GL_CLAMP_TO_EDGE, // WRAP_CLAMP,
|
||||
GL_CLAMP_TO_BORDER, // WRAP_BORDER,
|
||||
GL_MIRROR_CLAMP_TO_EDGE_EXT }; // WRAP_MIRROR_ONCE,
|
||||
|
||||
glTexParameteri(object->_target, GL_TEXTURE_WRAP_S, wrapModes[sampler.getWrapModeU()]);
|
||||
glTexParameteri(object->_target, GL_TEXTURE_WRAP_T, wrapModes[sampler.getWrapModeV()]);
|
||||
glTexParameteri(object->_target, GL_TEXTURE_WRAP_R, wrapModes[sampler.getWrapModeW()]);
|
||||
|
||||
glTexParameterfv(object->_target, GL_TEXTURE_BORDER_COLOR, (const float*) &sampler.getBorderColor());
|
||||
glTexParameteri(object->_target, GL_TEXTURE_BASE_LEVEL, sampler.getMipOffset());
|
||||
glTexParameterf(object->_target, GL_TEXTURE_MIN_LOD, (float) sampler.getMinMip());
|
||||
glTexParameterf(object->_target, GL_TEXTURE_MAX_LOD, (sampler.getMaxMip() == Sampler::MAX_MIP_LEVEL ? 1000.f : sampler.getMaxMip()));
|
||||
glTexParameterf(object->_target, GL_TEXTURE_MAX_ANISOTROPY_EXT, sampler.getMaxAnisotropy());
|
||||
(void) CHECK_GL_ERROR();
|
||||
|
||||
glTexParameterfv(object->_target, GL_TEXTURE_BORDER_COLOR, (const float*) &sampler.getBorderColor());
|
||||
glTexParameteri(object->_target, GL_TEXTURE_BASE_LEVEL, sampler.getMipOffset());
|
||||
glTexParameterf(object->_target, GL_TEXTURE_MIN_LOD, (float) sampler.getMinMip());
|
||||
glTexParameterf(object->_target, GL_TEXTURE_MAX_LOD, (sampler.getMaxMip() == Sampler::MAX_MIP_LEVEL ? 1000.f : sampler.getMaxMip()));
|
||||
glTexParameterf(object->_target, GL_TEXTURE_MAX_ANISOTROPY_EXT, sampler.getMaxAnisotropy());
|
||||
CHECK_GL_ERROR();
|
||||
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ void GLBackend::updateTransform() {
|
|||
}
|
||||
glLoadMatrixf(reinterpret_cast< const GLfloat* >(&_transform._projection));
|
||||
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
if (_transform._invalidModel || _transform._invalidView) {
|
||||
|
@ -141,7 +141,7 @@ void GLBackend::updateTransform() {
|
|||
// glLoadIdentity();
|
||||
}
|
||||
}
|
||||
CHECK_GL_ERROR();
|
||||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
State();
|
||||
virtual ~State();
|
||||
|
||||
const Stamp getStamp() const { return _stamp; }
|
||||
Stamp getStamp() const { return _stamp; }
|
||||
|
||||
typedef ::gpu::ComparisonFunction ComparisonFunction;
|
||||
|
||||
|
|
|
@ -101,9 +101,9 @@ public:
|
|||
uint32 getNumAttributes() const { return _attributes.size(); }
|
||||
const AttributeMap& getAttributes() const { return _attributes; }
|
||||
|
||||
uint8 getNumChannels() const { return _channels.size(); }
|
||||
uint8 getNumChannels() const { return _channels.size(); }
|
||||
const ChannelMap& getChannels() const { return _channels; }
|
||||
const Offset getChannelStride(Slot channel) const { return _channels.at(channel)._stride; }
|
||||
Offset getChannelStride(Slot channel) const { return _channels.at(channel)._stride; }
|
||||
|
||||
uint32 getElementTotalSize() const { return _elementTotalSize; }
|
||||
|
||||
|
|
|
@ -1,354 +1,354 @@
|
|||
//
|
||||
// Texture.cpp
|
||||
// libraries/gpu/src/gpu
|
||||
//
|
||||
// Created by Sam Gateau on 1/17/2015.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "Texture.h"
|
||||
#include <math.h>
|
||||
#include <QDebug>
|
||||
|
||||
using namespace gpu;
|
||||
|
||||
Texture::Pixels::Pixels(const Element& format, Size size, const Byte* bytes) :
|
||||
_sysmem(size, bytes),
|
||||
_format(format),
|
||||
_isGPULoaded(false) {
|
||||
}
|
||||
|
||||
Texture::Pixels::~Pixels() {
|
||||
}
|
||||
|
||||
void Texture::Storage::assignTexture(Texture* texture) {
|
||||
_texture = texture;
|
||||
}
|
||||
|
||||
Stamp Texture::Storage::getStamp(uint16 level) const {
|
||||
PixelsPointer mip = getMip(level);
|
||||
if (mip) {
|
||||
return mip->_sysmem.getStamp();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Texture::Storage::reset() {
|
||||
_mips.clear();
|
||||
}
|
||||
|
||||
Texture::PixelsPointer Texture::Storage::editMip(uint16 level) {
|
||||
if (level < _mips.size()) {
|
||||
return _mips[level];
|
||||
}
|
||||
return PixelsPointer();
|
||||
}
|
||||
|
||||
const Texture::PixelsPointer Texture::Storage::getMip(uint16 level) const {
|
||||
if (level < _mips.size()) {
|
||||
return _mips[level];
|
||||
}
|
||||
return PixelsPointer();
|
||||
}
|
||||
|
||||
void Texture::Storage::notifyGPULoaded(uint16 level) const {
|
||||
PixelsPointer mip = getMip(level);
|
||||
if (mip) {
|
||||
mip->_isGPULoaded = true;
|
||||
mip->_sysmem.resize(0);
|
||||
}
|
||||
}
|
||||
|
||||
bool Texture::Storage::isMipAvailable(uint16 level) const {
|
||||
PixelsPointer mip = getMip(level);
|
||||
return (mip && mip->_sysmem.getSize());
|
||||
}
|
||||
|
||||
bool Texture::Storage::allocateMip(uint16 level) {
|
||||
bool changed = false;
|
||||
if (level >= _mips.size()) {
|
||||
_mips.resize(level+1, PixelsPointer());
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!_mips[level]) {
|
||||
_mips[level] = PixelsPointer(new Pixels());
|
||||
changed = true;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool Texture::Storage::assignMipData(uint16 level, const Element& format, Size size, const Byte* bytes) {
|
||||
// Ok we should be able to do that...
|
||||
allocateMip(level);
|
||||
auto mip = _mips[level];
|
||||
mip->_format = format;
|
||||
Size allocated = mip->_sysmem.setData(size, bytes);
|
||||
mip->_isGPULoaded = false;
|
||||
|
||||
return allocated == size;
|
||||
}
|
||||
|
||||
Texture* Texture::create1D(const Element& texelFormat, uint16 width, const Sampler& sampler) {
|
||||
return create(TEX_1D, texelFormat, width, 1, 1, 1, 1, sampler);
|
||||
}
|
||||
|
||||
Texture* Texture::create2D(const Element& texelFormat, uint16 width, uint16 height, const Sampler& sampler) {
|
||||
return create(TEX_2D, texelFormat, width, height, 1, 1, 1, sampler);
|
||||
}
|
||||
|
||||
Texture* Texture::create3D(const Element& texelFormat, uint16 width, uint16 height, uint16 depth, const Sampler& sampler) {
|
||||
return create(TEX_3D, texelFormat, width, height, depth, 1, 1, sampler);
|
||||
}
|
||||
|
||||
Texture* Texture::createCube(const Element& texelFormat, uint16 width, const Sampler& sampler) {
|
||||
return create(TEX_CUBE, texelFormat, width, width, 1, 1, 1, sampler);
|
||||
}
|
||||
|
||||
Texture* Texture::create(Type type, const Element& texelFormat, uint16 width, uint16 height, uint16 depth, uint16 numSamples, uint16 numSlices, const Sampler& sampler)
|
||||
{
|
||||
Texture* tex = new Texture();
|
||||
tex->_storage.reset(new Storage());
|
||||
tex->_storage->_texture = tex;
|
||||
tex->_type = type;
|
||||
tex->_maxMip = 0;
|
||||
tex->resize(type, texelFormat, width, height, depth, numSamples, numSlices);
|
||||
|
||||
tex->_sampler = sampler;
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
Texture* Texture::createFromStorage(Storage* storage) {
|
||||
Texture* tex = new Texture();
|
||||
tex->_storage.reset(storage);
|
||||
storage->assignTexture(tex);
|
||||
return tex;
|
||||
}
|
||||
|
||||
Texture::Texture():
|
||||
Resource(),
|
||||
_storage(),
|
||||
_stamp(0),
|
||||
_size(0),
|
||||
_width(1),
|
||||
_height(1),
|
||||
_depth(1),
|
||||
_numSamples(1),
|
||||
_numSlices(1),
|
||||
_maxMip(0),
|
||||
_type(TEX_1D),
|
||||
_autoGenerateMips(false),
|
||||
_defined(false)
|
||||
{
|
||||
}
|
||||
|
||||
Texture::~Texture()
|
||||
{
|
||||
}
|
||||
|
||||
Texture::Size Texture::resize(Type type, const Element& texelFormat, uint16 width, uint16 height, uint16 depth, uint16 numSamples, uint16 numSlices) {
|
||||
if (width && height && depth && numSamples && numSlices) {
|
||||
bool changed = false;
|
||||
|
||||
if ( _type != type) {
|
||||
_type = type;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (_numSlices != numSlices) {
|
||||
_numSlices = numSlices;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
numSamples = evalNumSamplesUsed(numSamples);
|
||||
if ((_type >= TEX_2D) && (_numSamples != numSamples)) {
|
||||
_numSamples = numSamples;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (_width != width) {
|
||||
_width = width;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if ((_type >= TEX_2D) && (_height != height)) {
|
||||
_height = height;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
|
||||
if ((_type >= TEX_3D) && (_depth != depth)) {
|
||||
_depth = depth;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// Evaluate the new size with the new format
|
||||
const int DIM_SIZE[] = {1, 1, 1, 6};
|
||||
uint32_t size = DIM_SIZE[_type] *_width * _height * _depth * _numSamples * texelFormat.getSize();
|
||||
|
||||
// If size change then we need to reset
|
||||
if (changed || (size != getSize())) {
|
||||
_size = size;
|
||||
_storage->reset();
|
||||
_stamp++;
|
||||
}
|
||||
|
||||
// TexelFormat might have change, but it's mostly interpretation
|
||||
if (texelFormat != _texelFormat) {
|
||||
_texelFormat = texelFormat;
|
||||
_stamp++;
|
||||
}
|
||||
|
||||
// Here the Texture has been fully defined from the gpu point of view (size and format)
|
||||
_defined = true;
|
||||
} else {
|
||||
_stamp++;
|
||||
}
|
||||
|
||||
return _size;
|
||||
}
|
||||
|
||||
Texture::Size Texture::resize1D(uint16 width, uint16 numSamples) {
|
||||
return resize(TEX_1D, getTexelFormat(), width, 1, 1, numSamples, 1);
|
||||
}
|
||||
Texture::Size Texture::resize2D(uint16 width, uint16 height, uint16 numSamples) {
|
||||
return resize(TEX_2D, getTexelFormat(), width, height, 1, numSamples, 1);
|
||||
}
|
||||
Texture::Size Texture::resize3D(uint16 width, uint16 height, uint16 depth, uint16 numSamples) {
|
||||
return resize(TEX_3D, getTexelFormat(), width, height, depth, numSamples, 1);
|
||||
}
|
||||
Texture::Size Texture::resizeCube(uint16 width, uint16 numSamples) {
|
||||
return resize(TEX_CUBE, getTexelFormat(), width, 1, 1, numSamples, 1);
|
||||
}
|
||||
|
||||
Texture::Size Texture::reformat(const Element& texelFormat) {
|
||||
return resize(_type, texelFormat, getWidth(), getHeight(), getDepth(), getNumSamples(), getNumSlices());
|
||||
}
|
||||
|
||||
bool Texture::isColorRenderTarget() const {
|
||||
return (_texelFormat.getSemantic() == gpu::RGBA);
|
||||
}
|
||||
|
||||
bool Texture::isDepthStencilRenderTarget() const {
|
||||
return (_texelFormat.getSemantic() == gpu::DEPTH) || (_texelFormat.getSemantic() == gpu::DEPTH_STENCIL);
|
||||
}
|
||||
|
||||
uint16 Texture::evalDimNumMips(uint16 size) {
|
||||
double largerDim = size;
|
||||
double val = log(largerDim)/log(2.0);
|
||||
return 1 + (uint16) val;
|
||||
}
|
||||
|
||||
// The number mips that the texture could have if all existed
|
||||
// = log2(max(width, height, depth))
|
||||
uint16 Texture::evalNumMips() const {
|
||||
double largerDim = std::max(std::max(_width, _height), _depth);
|
||||
double val = log(largerDim)/log(2.0);
|
||||
return 1 + (uint16) val;
|
||||
}
|
||||
|
||||
uint16 Texture::maxMip() const {
|
||||
return _maxMip;
|
||||
}
|
||||
|
||||
bool Texture::assignStoredMip(uint16 level, const Element& format, Size size, const Byte* bytes) {
|
||||
// Check that level accessed make sense
|
||||
if (level != 0) {
|
||||
if (_autoGenerateMips) {
|
||||
return false;
|
||||
}
|
||||
if (level >= evalNumMips()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// THen check that the mem buffer passed make sense with its format
|
||||
Size expectedSize = evalStoredMipSize(level, format);
|
||||
if (size == expectedSize) {
|
||||
_storage->assignMipData(level, format, size, bytes);
|
||||
_stamp++;
|
||||
return true;
|
||||
} else if (size > expectedSize) {
|
||||
// NOTE: We are facing this case sometime because apparently QImage (from where we get the bits) is generating images
|
||||
// and alligning the line of pixels to 32 bits.
|
||||
// We should probably consider something a bit more smart to get the correct result but for now (UI elements)
|
||||
// it seems to work...
|
||||
_storage->assignMipData(level, format, size, bytes);
|
||||
_stamp++;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
uint16 Texture::autoGenerateMips(uint16 maxMip) {
|
||||
_autoGenerateMips = true;
|
||||
_maxMip = std::min((uint16) (evalNumMips() - 1), maxMip);
|
||||
_stamp++;
|
||||
return _maxMip;
|
||||
}
|
||||
|
||||
uint16 Texture::getStoredMipWidth(uint16 level) const {
|
||||
PixelsPointer mip = accessStoredMip(level);
|
||||
if (mip && mip->_sysmem.getSize()) {
|
||||
return evalMipWidth(level);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16 Texture::getStoredMipHeight(uint16 level) const {
|
||||
PixelsPointer mip = accessStoredMip(level);
|
||||
if (mip && mip->_sysmem.getSize()) {
|
||||
return evalMipHeight(level);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16 Texture::getStoredMipDepth(uint16 level) const {
|
||||
PixelsPointer mip = accessStoredMip(level);
|
||||
if (mip && mip->_sysmem.getSize()) {
|
||||
return evalMipDepth(level);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 Texture::getStoredMipNumTexels(uint16 level) const {
|
||||
PixelsPointer mip = accessStoredMip(level);
|
||||
if (mip && mip->_sysmem.getSize()) {
|
||||
return evalMipWidth(level) * evalMipHeight(level) * evalMipDepth(level);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 Texture::getStoredMipSize(uint16 level) const {
|
||||
PixelsPointer mip = accessStoredMip(level);
|
||||
if (mip && mip->_sysmem.getSize()) {
|
||||
return evalMipWidth(level) * evalMipHeight(level) * evalMipDepth(level) * getTexelFormat().getSize();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16 Texture::evalNumSamplesUsed(uint16 numSamplesTried) {
|
||||
uint16 sample = numSamplesTried;
|
||||
if (numSamplesTried <= 1)
|
||||
sample = 1;
|
||||
else if (numSamplesTried < 4)
|
||||
sample = 2;
|
||||
else if (numSamplesTried < 8)
|
||||
sample = 4;
|
||||
else if (numSamplesTried < 16)
|
||||
sample = 8;
|
||||
else
|
||||
sample = 8;
|
||||
|
||||
return sample;
|
||||
}
|
||||
|
||||
//
|
||||
// Texture.cpp
|
||||
// libraries/gpu/src/gpu
|
||||
//
|
||||
// Created by Sam Gateau on 1/17/2015.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "Texture.h"
|
||||
#include <math.h>
|
||||
#include <QDebug>
|
||||
|
||||
using namespace gpu;
|
||||
|
||||
Texture::Pixels::Pixels(const Element& format, Size size, const Byte* bytes) :
|
||||
_sysmem(size, bytes),
|
||||
_format(format),
|
||||
_isGPULoaded(false) {
|
||||
}
|
||||
|
||||
Texture::Pixels::~Pixels() {
|
||||
}
|
||||
|
||||
void Texture::Storage::assignTexture(Texture* texture) {
|
||||
_texture = texture;
|
||||
}
|
||||
|
||||
Stamp Texture::Storage::getStamp(uint16 level) const {
|
||||
PixelsPointer mip = getMip(level);
|
||||
if (mip) {
|
||||
return mip->_sysmem.getStamp();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Texture::Storage::reset() {
|
||||
_mips.clear();
|
||||
}
|
||||
|
||||
Texture::PixelsPointer Texture::Storage::editMip(uint16 level) {
|
||||
if (level < _mips.size()) {
|
||||
return _mips[level];
|
||||
}
|
||||
return PixelsPointer();
|
||||
}
|
||||
|
||||
const Texture::PixelsPointer Texture::Storage::getMip(uint16 level) const {
|
||||
if (level < _mips.size()) {
|
||||
return _mips[level];
|
||||
}
|
||||
return PixelsPointer();
|
||||
}
|
||||
|
||||
void Texture::Storage::notifyGPULoaded(uint16 level) const {
|
||||
PixelsPointer mip = getMip(level);
|
||||
if (mip) {
|
||||
mip->_isGPULoaded = true;
|
||||
mip->_sysmem.resize(0);
|
||||
}
|
||||
}
|
||||
|
||||
bool Texture::Storage::isMipAvailable(uint16 level) const {
|
||||
PixelsPointer mip = getMip(level);
|
||||
return (mip && mip->_sysmem.getSize());
|
||||
}
|
||||
|
||||
bool Texture::Storage::allocateMip(uint16 level) {
|
||||
bool changed = false;
|
||||
if (level >= _mips.size()) {
|
||||
_mips.resize(level+1, PixelsPointer());
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!_mips[level]) {
|
||||
_mips[level] = PixelsPointer(new Pixels());
|
||||
changed = true;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool Texture::Storage::assignMipData(uint16 level, const Element& format, Size size, const Byte* bytes) {
|
||||
// Ok we should be able to do that...
|
||||
allocateMip(level);
|
||||
auto mip = _mips[level];
|
||||
mip->_format = format;
|
||||
Size allocated = mip->_sysmem.setData(size, bytes);
|
||||
mip->_isGPULoaded = false;
|
||||
|
||||
return allocated == size;
|
||||
}
|
||||
|
||||
Texture* Texture::create1D(const Element& texelFormat, uint16 width, const Sampler& sampler) {
|
||||
return create(TEX_1D, texelFormat, width, 1, 1, 1, 1, sampler);
|
||||
}
|
||||
|
||||
Texture* Texture::create2D(const Element& texelFormat, uint16 width, uint16 height, const Sampler& sampler) {
|
||||
return create(TEX_2D, texelFormat, width, height, 1, 1, 1, sampler);
|
||||
}
|
||||
|
||||
Texture* Texture::create3D(const Element& texelFormat, uint16 width, uint16 height, uint16 depth, const Sampler& sampler) {
|
||||
return create(TEX_3D, texelFormat, width, height, depth, 1, 1, sampler);
|
||||
}
|
||||
|
||||
Texture* Texture::createCube(const Element& texelFormat, uint16 width, const Sampler& sampler) {
|
||||
return create(TEX_CUBE, texelFormat, width, width, 1, 1, 1, sampler);
|
||||
}
|
||||
|
||||
Texture* Texture::create(Type type, const Element& texelFormat, uint16 width, uint16 height, uint16 depth, uint16 numSamples, uint16 numSlices, const Sampler& sampler)
|
||||
{
|
||||
Texture* tex = new Texture();
|
||||
tex->_storage.reset(new Storage());
|
||||
tex->_storage->_texture = tex;
|
||||
tex->_type = type;
|
||||
tex->_maxMip = 0;
|
||||
tex->resize(type, texelFormat, width, height, depth, numSamples, numSlices);
|
||||
|
||||
tex->_sampler = sampler;
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
Texture* Texture::createFromStorage(Storage* storage) {
|
||||
Texture* tex = new Texture();
|
||||
tex->_storage.reset(storage);
|
||||
storage->assignTexture(tex);
|
||||
return tex;
|
||||
}
|
||||
|
||||
Texture::Texture():
|
||||
Resource(),
|
||||
_storage(),
|
||||
_stamp(0),
|
||||
_size(0),
|
||||
_width(1),
|
||||
_height(1),
|
||||
_depth(1),
|
||||
_numSamples(1),
|
||||
_numSlices(1),
|
||||
_maxMip(0),
|
||||
_type(TEX_1D),
|
||||
_autoGenerateMips(false),
|
||||
_defined(false)
|
||||
{
|
||||
}
|
||||
|
||||
Texture::~Texture()
|
||||
{
|
||||
}
|
||||
|
||||
Texture::Size Texture::resize(Type type, const Element& texelFormat, uint16 width, uint16 height, uint16 depth, uint16 numSamples, uint16 numSlices) {
|
||||
if (width && height && depth && numSamples && numSlices) {
|
||||
bool changed = false;
|
||||
|
||||
if ( _type != type) {
|
||||
_type = type;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (_numSlices != numSlices) {
|
||||
_numSlices = numSlices;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
numSamples = evalNumSamplesUsed(numSamples);
|
||||
if ((_type >= TEX_2D) && (_numSamples != numSamples)) {
|
||||
_numSamples = numSamples;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (_width != width) {
|
||||
_width = width;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if ((_type >= TEX_2D) && (_height != height)) {
|
||||
_height = height;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
|
||||
if ((_type >= TEX_3D) && (_depth != depth)) {
|
||||
_depth = depth;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// Evaluate the new size with the new format
|
||||
const int DIM_SIZE[] = {1, 1, 1, 6};
|
||||
uint32_t size = DIM_SIZE[_type] *_width * _height * _depth * _numSamples * texelFormat.getSize();
|
||||
|
||||
// If size change then we need to reset
|
||||
if (changed || (size != getSize())) {
|
||||
_size = size;
|
||||
_storage->reset();
|
||||
_stamp++;
|
||||
}
|
||||
|
||||
// TexelFormat might have change, but it's mostly interpretation
|
||||
if (texelFormat != _texelFormat) {
|
||||
_texelFormat = texelFormat;
|
||||
_stamp++;
|
||||
}
|
||||
|
||||
// Here the Texture has been fully defined from the gpu point of view (size and format)
|
||||
_defined = true;
|
||||
} else {
|
||||
_stamp++;
|
||||
}
|
||||
|
||||
return _size;
|
||||
}
|
||||
|
||||
Texture::Size Texture::resize1D(uint16 width, uint16 numSamples) {
|
||||
return resize(TEX_1D, getTexelFormat(), width, 1, 1, numSamples, 1);
|
||||
}
|
||||
Texture::Size Texture::resize2D(uint16 width, uint16 height, uint16 numSamples) {
|
||||
return resize(TEX_2D, getTexelFormat(), width, height, 1, numSamples, 1);
|
||||
}
|
||||
Texture::Size Texture::resize3D(uint16 width, uint16 height, uint16 depth, uint16 numSamples) {
|
||||
return resize(TEX_3D, getTexelFormat(), width, height, depth, numSamples, 1);
|
||||
}
|
||||
Texture::Size Texture::resizeCube(uint16 width, uint16 numSamples) {
|
||||
return resize(TEX_CUBE, getTexelFormat(), width, 1, 1, numSamples, 1);
|
||||
}
|
||||
|
||||
Texture::Size Texture::reformat(const Element& texelFormat) {
|
||||
return resize(_type, texelFormat, getWidth(), getHeight(), getDepth(), getNumSamples(), getNumSlices());
|
||||
}
|
||||
|
||||
bool Texture::isColorRenderTarget() const {
|
||||
return (_texelFormat.getSemantic() == gpu::RGBA);
|
||||
}
|
||||
|
||||
bool Texture::isDepthStencilRenderTarget() const {
|
||||
return (_texelFormat.getSemantic() == gpu::DEPTH) || (_texelFormat.getSemantic() == gpu::DEPTH_STENCIL);
|
||||
}
|
||||
|
||||
uint16 Texture::evalDimNumMips(uint16 size) {
|
||||
double largerDim = size;
|
||||
double val = log(largerDim)/log(2.0);
|
||||
return 1 + (uint16) val;
|
||||
}
|
||||
|
||||
// The number mips that the texture could have if all existed
|
||||
// = log2(max(width, height, depth))
|
||||
uint16 Texture::evalNumMips() const {
|
||||
double largerDim = std::max(std::max(_width, _height), _depth);
|
||||
double val = log(largerDim)/log(2.0);
|
||||
return 1 + (uint16) val;
|
||||
}
|
||||
|
||||
uint16 Texture::maxMip() const {
|
||||
return _maxMip;
|
||||
}
|
||||
|
||||
bool Texture::assignStoredMip(uint16 level, const Element& format, Size size, const Byte* bytes) {
|
||||
// Check that level accessed make sense
|
||||
if (level != 0) {
|
||||
if (_autoGenerateMips) {
|
||||
return false;
|
||||
}
|
||||
if (level >= evalNumMips()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// THen check that the mem buffer passed make sense with its format
|
||||
Size expectedSize = evalStoredMipSize(level, format);
|
||||
if (size == expectedSize) {
|
||||
_storage->assignMipData(level, format, size, bytes);
|
||||
_stamp++;
|
||||
return true;
|
||||
} else if (size > expectedSize) {
|
||||
// NOTE: We are facing this case sometime because apparently QImage (from where we get the bits) is generating images
|
||||
// and alligning the line of pixels to 32 bits.
|
||||
// We should probably consider something a bit more smart to get the correct result but for now (UI elements)
|
||||
// it seems to work...
|
||||
_storage->assignMipData(level, format, size, bytes);
|
||||
_stamp++;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
uint16 Texture::autoGenerateMips(uint16 maxMip) {
|
||||
_autoGenerateMips = true;
|
||||
_maxMip = std::min((uint16) (evalNumMips() - 1), maxMip);
|
||||
_stamp++;
|
||||
return _maxMip;
|
||||
}
|
||||
|
||||
uint16 Texture::getStoredMipWidth(uint16 level) const {
|
||||
PixelsPointer mip = accessStoredMip(level);
|
||||
if (mip && mip->_sysmem.getSize()) {
|
||||
return evalMipWidth(level);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16 Texture::getStoredMipHeight(uint16 level) const {
|
||||
PixelsPointer mip = accessStoredMip(level);
|
||||
if (mip && mip->_sysmem.getSize()) {
|
||||
return evalMipHeight(level);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16 Texture::getStoredMipDepth(uint16 level) const {
|
||||
PixelsPointer mip = accessStoredMip(level);
|
||||
if (mip && mip->_sysmem.getSize()) {
|
||||
return evalMipDepth(level);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 Texture::getStoredMipNumTexels(uint16 level) const {
|
||||
PixelsPointer mip = accessStoredMip(level);
|
||||
if (mip && mip->_sysmem.getSize()) {
|
||||
return evalMipWidth(level) * evalMipHeight(level) * evalMipDepth(level);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 Texture::getStoredMipSize(uint16 level) const {
|
||||
PixelsPointer mip = accessStoredMip(level);
|
||||
if (mip && mip->_sysmem.getSize()) {
|
||||
return evalMipWidth(level) * evalMipHeight(level) * evalMipDepth(level) * getTexelFormat().getSize();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16 Texture::evalNumSamplesUsed(uint16 numSamplesTried) {
|
||||
uint16 sample = numSamplesTried;
|
||||
if (numSamplesTried <= 1)
|
||||
sample = 1;
|
||||
else if (numSamplesTried < 4)
|
||||
sample = 2;
|
||||
else if (numSamplesTried < 8)
|
||||
sample = 4;
|
||||
else if (numSamplesTried < 16)
|
||||
sample = 8;
|
||||
else
|
||||
sample = 8;
|
||||
|
||||
return sample;
|
||||
}
|
||||
|
||||
void Texture::setSampler(const Sampler& sampler) {
|
||||
_sampler = sampler;
|
||||
_samplerStamp++;
|
||||
|
|
|
@ -151,8 +151,8 @@ public:
|
|||
Texture& operator=(const Texture& buf); // deep copy of the sysmem texture
|
||||
~Texture();
|
||||
|
||||
const Stamp getStamp() const { return _stamp; }
|
||||
const Stamp getDataStamp(uint16 level = 0) const { return _storage->getStamp(level); }
|
||||
Stamp getStamp() const { return _stamp; }
|
||||
Stamp getDataStamp(uint16 level = 0) const { return _storage->getStamp(level); }
|
||||
|
||||
// The size in bytes of data stored in the texture
|
||||
Size getSize() const { return _size; }
|
||||
|
@ -264,7 +264,7 @@ public:
|
|||
// Own sampler
|
||||
void setSampler(const Sampler& sampler);
|
||||
const Sampler& getSampler() const { return _sampler; }
|
||||
const Stamp getSamplerStamp() const { return _samplerStamp; }
|
||||
Stamp getSamplerStamp() const { return _samplerStamp; }
|
||||
|
||||
protected:
|
||||
std::unique_ptr< Storage > _storage;
|
||||
|
|
|
@ -97,7 +97,7 @@ const Box Mesh::evalPartBounds(int partStart, int partEnd, Boxes& bounds) const
|
|||
auto vertices = &_vertexBuffer.get<Vec3>((*part)._baseVertex);
|
||||
for (;index != endIndex; index++) {
|
||||
// skip primitive restart indices
|
||||
if ((*index) != PRIMITIVE_RESTART_INDEX) {
|
||||
if ((*index) != (uint) PRIMITIVE_RESTART_INDEX) {
|
||||
partBound += vertices[(*index)];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
#include "NetworkLogging.h"
|
||||
#include "DataServerAccountInfo.h"
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
DataServerAccountInfo::DataServerAccountInfo() :
|
||||
_accessToken(),
|
||||
|
@ -33,7 +35,7 @@ DataServerAccountInfo::DataServerAccountInfo() :
|
|||
|
||||
}
|
||||
|
||||
DataServerAccountInfo::DataServerAccountInfo(const DataServerAccountInfo& otherInfo) {
|
||||
DataServerAccountInfo::DataServerAccountInfo(const DataServerAccountInfo& otherInfo) : QObject() {
|
||||
_accessToken = otherInfo._accessToken;
|
||||
_username = otherInfo._username;
|
||||
_xmppPassword = otherInfo._xmppPassword;
|
||||
|
|
|
@ -33,6 +33,7 @@ HifiSockAddr::HifiSockAddr(const QHostAddress& address, quint16 port) :
|
|||
}
|
||||
|
||||
HifiSockAddr::HifiSockAddr(const HifiSockAddr& otherSockAddr) :
|
||||
QObject(),
|
||||
_address(otherSockAddr._address),
|
||||
_port(otherSockAddr._port)
|
||||
{
|
||||
|
|
|
@ -39,8 +39,7 @@ NetworkPeer::NetworkPeer(const QUuid& uuid, const HifiSockAddr& publicSocket, co
|
|||
|
||||
}
|
||||
|
||||
NetworkPeer::NetworkPeer(const NetworkPeer& otherPeer) {
|
||||
|
||||
NetworkPeer::NetworkPeer(const NetworkPeer& otherPeer) : QObject() {
|
||||
_uuid = otherPeer._uuid;
|
||||
_publicSocket = otherPeer._publicSocket;
|
||||
_localSocket = otherPeer._localSocket;
|
||||
|
|
|
@ -31,7 +31,7 @@ OAuthAccessToken::OAuthAccessToken(const QJsonObject& jsonObject) :
|
|||
|
||||
}
|
||||
|
||||
OAuthAccessToken::OAuthAccessToken(const OAuthAccessToken& otherToken) {
|
||||
OAuthAccessToken::OAuthAccessToken(const OAuthAccessToken& otherToken) : QObject() {
|
||||
token = otherToken.token;
|
||||
refreshToken = otherToken.refreshToken;
|
||||
expiryTimestamp = otherToken.expiryTimestamp;
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
#include "NetworkLogging.h"
|
||||
|
||||
#include "RSAKeypairGenerator.h"
|
||||
#ifndef __GNUC__
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
RSAKeypairGenerator::RSAKeypairGenerator(QObject* parent) :
|
||||
QObject(parent)
|
||||
|
|
|
@ -166,7 +166,7 @@ bool OctreeRenderer::renderOperation(OctreeElement* element, void* extraData) {
|
|||
|
||||
void OctreeRenderer::render(RenderArgs::RenderMode renderMode, RenderArgs::RenderSide renderSide) {
|
||||
RenderArgs args = { this, _viewFrustum, getSizeScale(), getBoundaryLevelAdjust(), renderMode, renderSide,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
if (_tree) {
|
||||
_tree->lockForRead();
|
||||
_tree->recurseTreeWithOperation(renderOperation, &args);
|
||||
|
|
|
@ -1796,7 +1796,9 @@ NetworkGeometry::NetworkGeometry(const QUrl& url, const QSharedPointer<NetworkGe
|
|||
|
||||
if (url.isEmpty()) {
|
||||
// make the minimal amount of dummy geometry to satisfy Model
|
||||
FBXJoint joint = { false, QVector<int>(), -1 };
|
||||
FBXJoint joint = { false, QVector<int>(), -1, 0.0f, 0.0f, glm::vec3(), glm::mat4(), glm::quat(), glm::quat(),
|
||||
glm::quat(), glm::mat4(), glm::mat4(), glm::vec3(), glm::vec3(), glm::quat(), glm::quat(),
|
||||
glm::mat4(), QString(""), glm::vec3(), glm::quat(), SHAPE_TYPE_NONE, false};
|
||||
_geometry.joints.append(joint);
|
||||
_geometry.leftEyeJointIndex = -1;
|
||||
_geometry.rightEyeJointIndex = -1;
|
||||
|
|
|
@ -256,7 +256,7 @@ void JointState::setVisibleRotationInConstrainedFrame(const glm::quat& targetRot
|
|||
_visibleRotation = parentRotation * _fbxJoint->preRotation * _visibleRotationInConstrainedFrame * _fbxJoint->postRotation;
|
||||
}
|
||||
|
||||
const bool JointState::rotationIsDefault(const glm::quat& rotation, float tolerance) const {
|
||||
bool JointState::rotationIsDefault(const glm::quat& rotation, float tolerance) const {
|
||||
glm::quat defaultRotation = _fbxJoint->rotation;
|
||||
return glm::abs(rotation.x - defaultRotation.x) < tolerance &&
|
||||
glm::abs(rotation.y - defaultRotation.y) < tolerance &&
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
const glm::quat& getRotationInConstrainedFrame() const { return _rotationInConstrainedFrame; }
|
||||
const glm::quat& getVisibleRotationInConstrainedFrame() const { return _visibleRotationInConstrainedFrame; }
|
||||
|
||||
const bool rotationIsDefault(const glm::quat& rotation, float tolerance = EPSILON) const;
|
||||
bool rotationIsDefault(const glm::quat& rotation, float tolerance = EPSILON) const;
|
||||
|
||||
glm::quat getDefaultRotationInParentFrame() const;
|
||||
const glm::vec3& getDefaultTranslationInConstrainedFrame() const;
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
push(glm::mat4());
|
||||
}
|
||||
|
||||
explicit MatrixStack(const MatrixStack& other) {
|
||||
explicit MatrixStack(const MatrixStack& other) : std::stack<glm::mat4>() {
|
||||
*((std::stack<glm::mat4>*)this) = *((std::stack<glm::mat4>*)&other);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
void setConvexHulls(const QVector<QVector<glm::vec3>>& points);
|
||||
void setCapsuleY(float radius, float halfHeight);
|
||||
|
||||
const int getType() const { return _type; }
|
||||
int getType() const { return _type; }
|
||||
|
||||
const glm::vec3& getHalfExtents() const { return _halfExtents; }
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// HifiMenu.cpp
|
||||
// VrMenu.cpp
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2015/04/21
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
|
@ -8,11 +8,15 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "HifiMenu.h"
|
||||
#include "VrMenu.h"
|
||||
#include <QtQml>
|
||||
#include <QMenuBar>
|
||||
|
||||
// Binds together a Qt Action or Menu with the QML Menu or MenuItem
|
||||
//
|
||||
// TODO On reflection, it may be pointless to use the UUID. Perhaps
|
||||
// simply creating the bidirectional link pointing to both the widget
|
||||
// and qml object and inject the pointer into both objects
|
||||
class MenuUserData : public QObjectUserData {
|
||||
static const int USER_DATA_ID;
|
||||
|
||||
|
@ -46,7 +50,7 @@ const int MenuUserData::USER_DATA_ID = QObject::registerUserData();
|
|||
|
||||
HIFI_QML_DEF_LAMBDA(VrMenu, [&](QQmlContext* context, QObject* newItem) {
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
QObject * rootMenu = offscreenUi->getRootItem()->findChild<QObject*>("rootMenu");
|
||||
QObject* rootMenu = offscreenUi->getRootItem()->findChild<QObject*>("rootMenu");
|
||||
Q_ASSERT(rootMenu);
|
||||
static_cast<VrMenu*>(newItem)->setRootMenu(rootMenu);
|
||||
context->setContextProperty("rootMenu", rootMenu);
|
||||
|
@ -69,7 +73,7 @@ VrMenu::VrMenu(QQuickItem* parent) : QQuickItem(parent) {
|
|||
}
|
||||
|
||||
// QML helper functions
|
||||
QObject* addMenu(QObject* parent, const QString & text) {
|
||||
QObject* addMenu(QObject* parent, const QString& text) {
|
||||
// FIXME add more checking here to ensure no name conflicts
|
||||
QVariant returnedValue;
|
||||
QMetaObject::invokeMethod(parent, "addMenu", Qt::DirectConnection,
|
||||
|
@ -94,7 +98,7 @@ QObject* addItem(QObject* parent, const QString& text) {
|
|||
return result;
|
||||
}
|
||||
|
||||
const QObject* VrMenu::findMenuObject(const QString & menuOption) const {
|
||||
const QObject* VrMenu::findMenuObject(const QString& menuOption) const {
|
||||
if (menuOption.isEmpty()) {
|
||||
return _rootMenu;
|
||||
}
|
||||
|
@ -102,7 +106,7 @@ const QObject* VrMenu::findMenuObject(const QString & menuOption) const {
|
|||
return result;
|
||||
}
|
||||
|
||||
QObject* VrMenu::findMenuObject(const QString & menuOption) {
|
||||
QObject* VrMenu::findMenuObject(const QString& menuOption) {
|
||||
if (menuOption.isEmpty()) {
|
||||
return _rootMenu;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// HifiMenu.h
|
||||
// VrMenu.h
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2015/04/21
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
|
@ -9,8 +9,8 @@
|
|||
//
|
||||
|
||||
#pragma once
|
||||
#ifndef hifi_HifiMenu_h
|
||||
#define hifi_HifiMenu_h
|
||||
#ifndef hifi_VrMenu_h
|
||||
#define hifi_VrMenu_h
|
||||
|
||||
#include <QQuickItem>
|
||||
#include <QHash>
|
||||
|
@ -20,7 +20,7 @@
|
|||
#include <QMenu>
|
||||
#include "OffscreenUi.h"
|
||||
|
||||
// FIXME rename the compilation files to VrMenu.h and VrMenu.cpp after upstream pull requests are merged.
|
||||
// FIXME break up the rendering code (VrMenu) and the code for mirroring a Widget based menu in QML
|
||||
class VrMenu : public QQuickItem {
|
||||
Q_OBJECT
|
||||
HIFI_QML_DECL_LAMBDA
|
||||
|
@ -45,4 +45,4 @@ protected:
|
|||
friend class MenuUserData;
|
||||
};
|
||||
|
||||
#endif // hifi_HifiMenu_h
|
||||
#endif // hifi_VrMenu_h
|
|
@ -36,7 +36,7 @@
|
|||
#include <QDir>
|
||||
#include <QXmlResultItems>
|
||||
#include "MessageDialog.h"
|
||||
#include "HifiMenu.h"
|
||||
#include "VrMenu.h"
|
||||
#include "InfoView.h"
|
||||
|
||||
class RateCounter {
|
||||
|
@ -236,12 +236,16 @@ public:
|
|||
};
|
||||
|
||||
public:
|
||||
MenuConstants(QObject * parent = nullptr) : QObject(parent) {
|
||||
MenuConstants(QObject* parent = nullptr) : QObject(parent) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
<<<<<<< HEAD
|
||||
const QString & getResourcesDir() {
|
||||
=======
|
||||
const QString& getQmlDir() {
|
||||
>>>>>>> vr_menus
|
||||
static QString dir;
|
||||
if (dir.isEmpty()) {
|
||||
QDir path(__FILE__);
|
||||
|
@ -261,7 +265,7 @@ const QString & getQmlDir() {
|
|||
return dir;
|
||||
}
|
||||
|
||||
const QString & getTestQmlDir() {
|
||||
const QString& getTestQmlDir() {
|
||||
static QString dir;
|
||||
if (dir.isEmpty()) {
|
||||
QDir path(__FILE__);
|
||||
|
@ -276,7 +280,7 @@ const QString & getTestQmlDir() {
|
|||
class QTestWindow : public QWindow, private QOpenGLFunctions {
|
||||
Q_OBJECT
|
||||
|
||||
QOpenGLContext * _context{ nullptr };
|
||||
QOpenGLContext* _context{ nullptr };
|
||||
QSize _size;
|
||||
bool _altPressed{ false };
|
||||
RateCounter fps;
|
||||
|
@ -284,7 +288,7 @@ class QTestWindow : public QWindow, private QOpenGLFunctions {
|
|||
int testQmlTexture{ 0 };
|
||||
|
||||
public:
|
||||
QObject * rootMenu;
|
||||
QObject* rootMenu;
|
||||
|
||||
QTestWindow() {
|
||||
_timer.setInterval(1);
|
||||
|
@ -315,7 +319,7 @@ public:
|
|||
initializeOpenGLFunctions();
|
||||
|
||||
{
|
||||
QOpenGLDebugLogger *logger = new QOpenGLDebugLogger(this);
|
||||
QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(this);
|
||||
logger->initialize(); // initializes in the current context, i.e. ctx
|
||||
logger->enableMessages();
|
||||
connect(logger, &QOpenGLDebugLogger::messageLogged, this, [&](const QOpenGLDebugMessage & debugMessage) {
|
||||
|
@ -408,12 +412,12 @@ private:
|
|||
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent * ev) override {
|
||||
void resizeEvent(QResizeEvent* ev) override {
|
||||
resizeWindow(ev->size());
|
||||
}
|
||||
|
||||
|
||||
void keyPressEvent(QKeyEvent *event) {
|
||||
void keyPressEvent(QKeyEvent* event) {
|
||||
_altPressed = Qt::Key_Alt == event->key();
|
||||
switch (event->key()) {
|
||||
case Qt::Key_L:
|
||||
|
@ -445,7 +449,7 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
void moveEvent(QMoveEvent *event) {
|
||||
void moveEvent(QMoveEvent* event) {
|
||||
static qreal oldPixelRatio = 0.0;
|
||||
if (devicePixelRatio() != oldPixelRatio) {
|
||||
oldPixelRatio = devicePixelRatio();
|
||||
|
|
Loading…
Reference in a new issue