Merge remote-tracking branch 'upstream/master' into web-entity

Conflicts:
	libraries/entities/src/EntityItemProperties.h
	libraries/entities/src/EntityTypes.h
This commit is contained in:
Brad Davis 2015-05-12 15:56:02 -07:00
commit 8c4f802dbf
19 changed files with 359 additions and 84 deletions

View file

@ -207,7 +207,7 @@ var toolBar = (function () {
});
newWebButton = toolBar.addTool({
imageURL: toolIconUrl + "add-text.svg",
imageURL: "https://s3.amazonaws.com/Oculus/earth17.svg",
subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
width: toolWidth,
height: toolHeight,

View file

@ -13,6 +13,7 @@
var isGrabbing = false;
var grabbedEntity = null;
var lineEntityID = null;
var prevMouse = {};
var deltaMouse = {
z: 0
@ -60,8 +61,13 @@ function vectorIsZero(v) {
return v.x == 0 && v.y == 0 && v.z == 0;
}
function vectorToString(v) {
return "(" + v.x + ", " + v.y + ", " + v.z + ")"
function nearLinePoint(targetPosition) {
// var handPosition = Vec3.sum(MyAvatar.position, {x:0, y:0.2, z:0});
var handPosition = MyAvatar.getRightPalmPosition();
var along = Vec3.subtract(targetPosition, handPosition);
along = Vec3.normalize(along);
along = Vec3.multiply(along, 0.4);
return Vec3.sum(handPosition, along);
}
@ -76,7 +82,6 @@ function mousePressEvent(event) {
var props = Entities.getEntityProperties(grabbedEntity)
isGrabbing = true;
originalGravity = props.gravity;
print("mouse-press setting originalGravity " + originalGravity + " " + vectorToString(originalGravity));
targetPosition = props.position;
currentPosition = props.position;
currentVelocity = props.velocity;
@ -86,6 +91,14 @@ function mousePressEvent(event) {
gravity: {x: 0, y: 0, z: 0}
});
lineEntityID = Entities.addEntity({
type: "Line",
position: nearLinePoint(targetPosition),
dimensions: Vec3.subtract(targetPosition, nearLinePoint(targetPosition)),
color: { red: 255, green: 255, blue: 255 },
lifetime: 300 // if someone crashes while moving something, don't leave the line there forever.
});
Audio.playSound(grabSound, {
position: props.position,
volume: 0.4
@ -121,18 +134,18 @@ function mouseReleaseEvent() {
// 4. interface A releases the entity and puts the original gravity back
// 5. interface B releases the entity and puts the original gravity back (to zero)
if (!vectorIsZero(originalGravity)) {
print("mouse-release restoring originalGravity" + vectorToString(originalGravity));
Entities.editEntity(grabbedEntity, {
gravity: originalGravity
});
} else {
print("mouse-release not restoring originalGravity of zero");
}
Overlays.editOverlay(dropLine, {
visible: false
});
targetPosition = null;
Entities.deleteEntity(lineEntityID);
Audio.playSound(grabSound, {
position: entityProps.position,
volume: 0.25
@ -147,7 +160,6 @@ function mouseMoveEvent(event) {
var props = Entities.getEntityProperties(grabbedEntity);
if (!vectorIsZero(props.gravity)) {
originalGravity = props.gravity;
print("mouse-move adopting originalGravity" + vectorToString(originalGravity));
}
deltaMouse.x = event.x - prevMouse.x;
@ -179,6 +191,11 @@ function mouseMoveEvent(event) {
axisAngle = Quat.axis(dQ);
angularVelocity = Vec3.multiply((theta / dT), axisAngle);
}
Entities.editEntity(lineEntityID, {
position: nearLinePoint(targetPosition),
dimensions: Vec3.subtract(targetPosition, nearLinePoint(targetPosition))
});
}
prevMouse.x = event.x;
prevMouse.y = event.y;

View file

@ -279,6 +279,11 @@
var elModelTextures = document.getElementById("property-model-textures");
var elModelOriginalTextures = document.getElementById("property-model-original-textures");
var elWebSections = document.querySelectorAll(".web-section");
allSections.push(elModelSections);
var elWebSourceURL = document.getElementById("property-web-source-url");
var elTextSections = document.querySelectorAll(".text-section");
allSections.push(elTextSections);
var elTextText = document.getElementById("property-text-text");
@ -470,18 +475,10 @@
elModelOriginalTextures.value = properties.originalTextures;
} else if (properties.type == "Web") {
for (var i = 0; i < elTextSections.length; i++) {
elTextSections[i].style.display = 'block';
elWebSections[i].style.display = 'block';
}
elTextText.value = properties.text;
elTextLineHeight.value = properties.lineHeight.toFixed(4);
elTextTextColor.style.backgroundColor = "rgb(" + properties.textColor.red + "," + properties.textColor.green + "," + properties.textColor.blue + ")";
elTextTextColorRed.value = properties.textColor.red;
elTextTextColorGreen.value = properties.textColor.green;
elTextTextColorBlue.value = properties.textColor.blue;
elTextBackgroundColorRed.value = properties.backgroundColor.red;
elTextBackgroundColorGreen.value = properties.backgroundColor.green;
elTextBackgroundColorBlue.value = properties.backgroundColor.blue;
elWebSourceURL.value = properties.sourceUrl;
} else if (properties.type == "Text") {
for (var i = 0; i < elTextSections.length; i++) {
elTextSections[i].style.display = 'block';

View file

@ -3102,7 +3102,7 @@ ViewFrustum* Application::getViewFrustum() {
#ifdef DEBUG
if (QThread::currentThread() == activeRenderingThread) {
// FIXME, should this be an assert?
qWarning() << "Calling Application::getViewFrustum() from the active rendering thread, did you mean Application::getDisplayViewFrustum()?";
// qWarning() << "Calling Application::getViewFrustum() from the active rendering thread, did you mean Application::getDisplayViewFrustum()?";
}
#endif
return &_viewFrustum;
@ -3112,7 +3112,7 @@ const ViewFrustum* Application::getViewFrustum() const {
#ifdef DEBUG
if (QThread::currentThread() == activeRenderingThread) {
// FIXME, should this be an assert?
qWarning() << "Calling Application::getViewFrustum() from the active rendering thread, did you mean Application::getDisplayViewFrustum()?";
// qWarning() << "Calling Application::getViewFrustum() from the active rendering thread, did you mean Application::getDisplayViewFrustum()?";
}
#endif
return &_viewFrustum;
@ -3122,7 +3122,7 @@ ViewFrustum* Application::getDisplayViewFrustum() {
#ifdef DEBUG
if (QThread::currentThread() != activeRenderingThread) {
// FIXME, should this be an assert?
qWarning() << "Calling Application::getDisplayViewFrustum() from outside the active rendering thread or outside rendering, did you mean Application::getViewFrustum()?";
// qWarning() << "Calling Application::getDisplayViewFrustum() from outside the active rendering thread or outside rendering, did you mean Application::getViewFrustum()?";
}
#endif
return &_displayViewFrustum;

View file

@ -79,7 +79,11 @@ WebWindowClass::WebWindowClass(const QString& title, const QString& url, int wid
}
_webView->setPage(new DataWebPage());
_webView->setUrl(url);
if (!url.startsWith("http")) {
_webView->setUrl(QUrl::fromLocalFile(url));
} else {
_webView->setUrl(url);
}
connect(this, &WebWindowClass::destroyed, _windowWidget, &QWidget::deleteLater);
connect(_webView->page()->mainFrame(), &QWebFrame::javaScriptWindowObjectCleared,

View file

@ -37,6 +37,7 @@
#include "RenderableTextEntityItem.h"
#include "RenderableWebEntityItem.h"
#include "RenderableZoneEntityItem.h"
#include "RenderableLineEntityItem.h"
#include "EntitiesRendererLogging.h"
EntityTreeRenderer::EntityTreeRenderer(bool wantScripts, AbstractViewStateInterface* viewState,
@ -61,6 +62,7 @@ EntityTreeRenderer::EntityTreeRenderer(bool wantScripts, AbstractViewStateInterf
REGISTER_ENTITY_TYPE_WITH_FACTORY(Web, RenderableWebEntityItem::factory)
REGISTER_ENTITY_TYPE_WITH_FACTORY(ParticleEffect, RenderableParticleEffectEntityItem::factory)
REGISTER_ENTITY_TYPE_WITH_FACTORY(Zone, RenderableZoneEntityItem::factory)
REGISTER_ENTITY_TYPE_WITH_FACTORY(Line, RenderableLineEntityItem::factory)
_currentHoverOverEntityID = EntityItemID::createInvalidEntityID(); // makes it the unknown ID
_currentClickingOnEntityID = EntityItemID::createInvalidEntityID(); // makes it the unknown ID

View file

@ -0,0 +1,41 @@
//
// RenderableLineEntityItem.cpp
// libraries/entities-renderer/src/
//
// Created by Seth Alves on 5/11/15.
// Copyright 2015 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 <glm/gtx/quaternion.hpp>
#include <gpu/GPUConfig.h>
#include <DeferredLightingEffect.h>
#include <PerfStat.h>
#include "RenderableLineEntityItem.h"
EntityItem* RenderableLineEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return new RenderableLineEntityItem(entityID, properties);
}
void RenderableLineEntityItem::render(RenderArgs* args) {
PerformanceTimer perfTimer("RenderableLineEntityItem::render");
assert(getType() == EntityTypes::Line);
glm::vec3 position = getPosition();
glm::vec3 dimensions = getDimensions();
glm::quat rotation = getRotation();
glm::vec4 lineColor(toGlm(getXColor()), getLocalRenderAlpha());
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glm::vec3 axis = glm::axis(rotation);
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
glm::vec3 p1 = {0.0f, 0.0f, 0.0f};
glm::vec3& p2 = dimensions;
DependencyManager::get<DeferredLightingEffect>()->renderLine(p1, p2, lineColor, lineColor);
glPopMatrix();
RenderableDebugableEntityItem::render(this, args);
};

View file

@ -0,0 +1,29 @@
//
// RenderableLineEntityItem.h
// libraries/entities-renderer/src/
//
// Created by Seth Alves on 5/11/15.
// Copyright 2015 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
//
#ifndef hifi_RenderableLineEntityItem_h
#define hifi_RenderableLineEntityItem_h
#include <LineEntityItem.h>
#include "RenderableDebugableEntityItem.h"
class RenderableLineEntityItem : public LineEntityItem {
public:
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
RenderableLineEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
LineEntityItem(entityItemID, properties) { }
virtual void render(RenderArgs* args);
};
#endif // hifi_RenderableLineEntityItem_h

View file

@ -32,8 +32,6 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
glm::vec3 dimensions = getDimensions();
glm::vec3 halfDimensions = dimensions / 2.0f;
glm::quat rotation = getRotation();
float leftMargin = 0.1f;
float topMargin = 0.1f;
//qCDebug(entitytree) << "RenderableWebEntityItem::render() id:" << getEntityItemID() << "text:" << getText();

View file

@ -52,7 +52,8 @@ class EntityItemProperties {
friend class TextEntityItem; // TODO: consider removing this friend relationship and use public methods
friend class ParticleEffectEntityItem; // TODO: consider removing this friend relationship and use public methods
friend class ZoneEntityItem; // TODO: consider removing this friend relationship and use public methods
friend class WebEntityItem; // TODO....
friend class WebEntityItem; // TODO: consider removing this friend relationship and use public methods
friend class LineEntityItem; // TODO: consider removing this friend relationship and use public methods
public:
EntityItemProperties();
virtual ~EntityItemProperties();

View file

@ -26,6 +26,7 @@
#include "TextEntityItem.h"
#include "WebEntityItem.h"
#include "ZoneEntityItem.h"
#include "LineEntityItem.h"
QMap<EntityTypes::EntityType, QString> EntityTypes::_typeToNameMap;
QMap<QString, EntityTypes::EntityType> EntityTypes::_nameToTypeMap;
@ -43,6 +44,7 @@ REGISTER_ENTITY_TYPE(Light)
REGISTER_ENTITY_TYPE(Text)
REGISTER_ENTITY_TYPE(ParticleEffect)
REGISTER_ENTITY_TYPE(Zone)
REGISTER_ENTITY_TYPE(Line)
const QString& EntityTypes::getEntityTypeName(EntityType entityType) {
QMap<EntityType, QString>::iterator matchedTypeName = _typeToNameMap.find(entityType);

View file

@ -32,6 +32,7 @@ public:
Unknown,
Box,
Light,
Line,
Model,
ParticleEffect,
Sphere,

View file

@ -0,0 +1,108 @@
//
// LineEntityItem.cpp
// libraries/entities/src
//
// Created by Seth Alves on 5/11/15.
// Copyright 2015 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 <QDebug>
#include <ByteCountCoding.h>
#include "LineEntityItem.h"
#include "EntityTree.h"
#include "EntitiesLogging.h"
#include "EntityTreeElement.h"
EntityItem* LineEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
EntityItem* result = new LineEntityItem(entityID, properties);
return result;
}
LineEntityItem::LineEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
EntityItem(entityItemID)
{
_type = EntityTypes::Line;
_created = properties.getCreated();
setProperties(properties);
}
EntityItemProperties LineEntityItem::getProperties() const {
EntityItemProperties properties = EntityItem::getProperties(); // get the properties from our base class
properties._color = getXColor();
properties._colorChanged = false;
properties._glowLevel = getGlowLevel();
properties._glowLevelChanged = false;
return properties;
}
bool LineEntityItem::setProperties(const EntityItemProperties& properties) {
bool somethingChanged = false;
somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class
SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor);
if (somethingChanged) {
bool wantDebug = false;
if (wantDebug) {
uint64_t now = usecTimestampNow();
int elapsed = now - getLastEdited();
qCDebug(entities) << "LineEntityItem::setProperties() AFTER update... edited AGO=" << elapsed <<
"now=" << now << " getLastEdited()=" << getLastEdited();
}
setLastEdited(properties._lastEdited);
}
return somethingChanged;
}
int LineEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
ReadBitstreamToTreeParams& args,
EntityPropertyFlags& propertyFlags, bool overwriteLocalData) {
int bytesRead = 0;
const unsigned char* dataAt = data;
READ_ENTITY_PROPERTY_COLOR(PROP_COLOR, _color);
return bytesRead;
}
// TODO: eventually only include properties changed since the params.lastViewFrustumSent time
EntityPropertyFlags LineEntityItem::getEntityProperties(EncodeBitstreamParams& params) const {
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
requestedProperties += PROP_COLOR;
return requestedProperties;
}
void LineEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
EntityTreeElementExtraEncodeData* modelTreeElementExtraEncodeData,
EntityPropertyFlags& requestedProperties,
EntityPropertyFlags& propertyFlags,
EntityPropertyFlags& propertiesDidntFit,
int& propertyCount,
OctreeElement::AppendState& appendState) const {
bool successPropertyFits = true;
APPEND_ENTITY_PROPERTY(PROP_COLOR, appendColor, getColor());
}
void LineEntityItem::debugDump() const {
quint64 now = usecTimestampNow();
qCDebug(entities) << " LINE EntityItem id:" << getEntityItemID() << "---------------------------------------------";
qCDebug(entities) << " color:" << _color[0] << "," << _color[1] << "," << _color[2];
qCDebug(entities) << " position:" << debugTreeVector(_position);
qCDebug(entities) << " dimensions:" << debugTreeVector(_dimensions);
qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now);
}

View file

@ -0,0 +1,62 @@
//
// LineEntityItem.h
// libraries/entities/src
//
// Created by Seth Alves on 5/11/15.
// Copyright 2015 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
//
#ifndef hifi_LineEntityItem_h
#define hifi_LineEntityItem_h
#include "EntityItem.h"
class LineEntityItem : public EntityItem {
public:
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
LineEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties);
ALLOW_INSTANTIATION // This class can be instantiated
// methods for getting/setting all properties of an entity
virtual EntityItemProperties getProperties() const;
virtual bool setProperties(const EntityItemProperties& properties);
// TODO: eventually only include properties changed since the params.lastViewFrustumSent time
virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const;
virtual void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
EntityTreeElementExtraEncodeData* modelTreeElementExtraEncodeData,
EntityPropertyFlags& requestedProperties,
EntityPropertyFlags& propertyFlags,
EntityPropertyFlags& propertiesDidntFit,
int& propertyCount,
OctreeElement::AppendState& appendState) const;
virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
ReadBitstreamToTreeParams& args,
EntityPropertyFlags& propertyFlags, bool overwriteLocalData);
const rgbColor& getColor() const { return _color; }
xColor getXColor() const { xColor color = { _color[RED_INDEX], _color[GREEN_INDEX], _color[BLUE_INDEX] }; return color; }
void setColor(const rgbColor& value) { memcpy(_color, value, sizeof(_color)); }
void setColor(const xColor& value) {
_color[RED_INDEX] = value.red;
_color[GREEN_INDEX] = value.green;
_color[BLUE_INDEX] = value.blue;
}
virtual ShapeType getShapeType() const { return SHAPE_TYPE_LINE; }
virtual void debugDump() const;
protected:
rgbColor _color;
};
#endif // hifi_LineEntityItem_h

View file

@ -39,7 +39,7 @@ const float WEB_ENTITY_ITEM_FIXED_DEPTH = 0.01f;
void WebEntityItem::setDimensions(const glm::vec3& value) {
// NOTE: Web Entities always have a "depth" of 1cm.
_dimensions = glm::vec3(value.x, value.y, TEXT_ENTITY_ITEM_FIXED_DEPTH);
_dimensions = glm::vec3(value.x, value.y, WEB_ENTITY_ITEM_FIXED_DEPTH);
}
EntityItemProperties WebEntityItem::getProperties() const {
@ -52,7 +52,7 @@ bool WebEntityItem::setProperties(const EntityItemProperties& properties) {
bool somethingChanged = false;
somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class
SET_ENTITY_PROPERTY_FROM_PROPERTIES(modelURL, setSource);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(modelURL, setSourceUrl);
if (somethingChanged) {
bool wantDebug = false;
@ -75,7 +75,7 @@ int WebEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, i
int bytesRead = 0;
const unsigned char* dataAt = data;
READ_ENTITY_PROPERTY_STRING(PROP_SOURCE_URL, setSource);
READ_ENTITY_PROPERTY_STRING(PROP_SOURCE_URL, setSourceUrl);
return bytesRead;
}
@ -97,7 +97,7 @@ void WebEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitst
OctreeElement::AppendState& appendState) const {
bool successPropertyFits = true;
APPEND_ENTITY_PROPERTY(PROP_SOURCE_URL, appendValue, _source);
APPEND_ENTITY_PROPERTY(PROP_SOURCE_URL, appendValue, _sourceUrl);
}

View file

@ -50,7 +50,7 @@ public:
void** intersectedObject, bool precisionPicking) const;
void setSourceUrl(const QString& value) { _sourceUrl = value; }
const QString& getSource() const { return _sourceUrl; }
const QString& getSourceUrl() const { return _sourceUrl; }
protected:
QString _sourceUrl;

View file

@ -129,6 +129,14 @@ void DeferredLightingEffect::renderWireCube(float size, const glm::vec4& color)
releaseSimpleProgram();
}
void DeferredLightingEffect::renderLine(const glm::vec3& p1, const glm::vec3& p2,
const glm::vec4& color1, const glm::vec4& color2) {
bindSimpleProgram();
DependencyManager::get<GeometryCache>()->renderLine(p1, p2, color1, color2);
releaseSimpleProgram();
}
void DeferredLightingEffect::renderSolidCone(float base, float height, int slices, int stacks) {
bindSimpleProgram();
DependencyManager::get<GeometryCache>()->renderCone(base, height, slices, stacks);
@ -288,21 +296,21 @@ void DeferredLightingEffect::render() {
program->setUniformValue(locations->ambientSphere + i, *(((QVector4D*) &sh) + i));
}
}
if (useSkyboxCubemap) {
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_CUBE_MAP, gpu::GLBackend::getTextureID(_skybox->getCubemap()));
}
if (locations->lightBufferUnit >= 0) {
gpu::Batch batch;
batch.setUniformBuffer(locations->lightBufferUnit, globalLight->getSchemaBuffer());
gpu::GLBackend::renderBatch(batch);
}
if (locations->lightBufferUnit >= 0) {
gpu::Batch batch;
batch.setUniformBuffer(locations->lightBufferUnit, globalLight->getSchemaBuffer());
gpu::GLBackend::renderBatch(batch);
}
if (_atmosphere && (locations->atmosphereBufferUnit >= 0)) {
gpu::Batch batch;
batch.setUniformBuffer(locations->atmosphereBufferUnit, _atmosphere->getDataBuffer());
gpu::Batch batch;
batch.setUniformBuffer(locations->atmosphereBufferUnit, _atmosphere->getDataBuffer());
gpu::GLBackend::renderBatch(batch);
}
glUniformMatrix4fv(locations->invViewMat, 1, false, reinterpret_cast< const GLfloat* >(&invViewMat));
@ -366,11 +374,11 @@ void DeferredLightingEffect::render() {
for (auto lightID : _pointLights) {
auto light = _allocatedLights[lightID];
if (_pointLightLocations.lightBufferUnit >= 0) {
gpu::Batch batch;
batch.setUniformBuffer(_pointLightLocations.lightBufferUnit, light->getSchemaBuffer());
gpu::GLBackend::renderBatch(batch);
if (_pointLightLocations.lightBufferUnit >= 0) {
gpu::Batch batch;
batch.setUniformBuffer(_pointLightLocations.lightBufferUnit, light->getSchemaBuffer());
gpu::GLBackend::renderBatch(batch);
}
glUniformMatrix4fv(_pointLightLocations.invViewMat, 1, false, reinterpret_cast< const GLfloat* >(&invViewMat));
@ -412,10 +420,10 @@ void DeferredLightingEffect::render() {
for (auto lightID : _spotLights) {
auto light = _allocatedLights[lightID];
if (_spotLightLocations.lightBufferUnit >= 0) {
gpu::Batch batch;
batch.setUniformBuffer(_spotLightLocations.lightBufferUnit, light->getSchemaBuffer());
gpu::GLBackend::renderBatch(batch);
if (_spotLightLocations.lightBufferUnit >= 0) {
gpu::Batch batch;
batch.setUniformBuffer(_spotLightLocations.lightBufferUnit, light->getSchemaBuffer());
gpu::GLBackend::renderBatch(batch);
}
glUniformMatrix4fv(_spotLightLocations.invViewMat, 1, false, reinterpret_cast< const GLfloat* >(&invViewMat));
@ -535,42 +543,42 @@ void DeferredLightingEffect::loadLightProgram(const char* fragSource, bool limit
locations.ambientSphere = program.uniformLocation("ambientSphere.L00");
locations.invViewMat = program.uniformLocation("invViewMat");
GLint loc = -1;
#if (GPU_FEATURE_PROFILE == GPU_CORE)
const GLint LIGHT_GPU_SLOT = 3;
loc = glGetUniformBlockIndex(program.programId(), "lightBuffer");
if (loc >= 0) {
glUniformBlockBinding(program.programId(), loc, LIGHT_GPU_SLOT);
locations.lightBufferUnit = LIGHT_GPU_SLOT;
} else {
locations.lightBufferUnit = -1;
}
#else
loc = program.uniformLocation("lightBuffer");
if (loc >= 0) {
locations.lightBufferUnit = loc;
} else {
locations.lightBufferUnit = -1;
}
GLint loc = -1;
#if (GPU_FEATURE_PROFILE == GPU_CORE)
const GLint LIGHT_GPU_SLOT = 3;
loc = glGetUniformBlockIndex(program.programId(), "lightBuffer");
if (loc >= 0) {
glUniformBlockBinding(program.programId(), loc, LIGHT_GPU_SLOT);
locations.lightBufferUnit = LIGHT_GPU_SLOT;
} else {
locations.lightBufferUnit = -1;
}
#else
loc = program.uniformLocation("lightBuffer");
if (loc >= 0) {
locations.lightBufferUnit = loc;
} else {
locations.lightBufferUnit = -1;
}
#endif
#if (GPU_FEATURE_PROFILE == GPU_CORE)
const GLint ATMOSPHERE_GPU_SLOT = 4;
loc = glGetUniformBlockIndex(program.programId(), "atmosphereBufferUnit");
if (loc >= 0) {
glUniformBlockBinding(program.programId(), loc, ATMOSPHERE_GPU_SLOT);
locations.atmosphereBufferUnit = ATMOSPHERE_GPU_SLOT;
} else {
locations.atmosphereBufferUnit = -1;
}
#else
loc = program.uniformLocation("atmosphereBufferUnit");
if (loc >= 0) {
locations.atmosphereBufferUnit = loc;
} else {
locations.atmosphereBufferUnit = -1;
}
#if (GPU_FEATURE_PROFILE == GPU_CORE)
const GLint ATMOSPHERE_GPU_SLOT = 4;
loc = glGetUniformBlockIndex(program.programId(), "atmosphereBufferUnit");
if (loc >= 0) {
glUniformBlockBinding(program.programId(), loc, ATMOSPHERE_GPU_SLOT);
locations.atmosphereBufferUnit = ATMOSPHERE_GPU_SLOT;
} else {
locations.atmosphereBufferUnit = -1;
}
#else
loc = program.uniformLocation("atmosphereBufferUnit");
if (loc >= 0) {
locations.atmosphereBufferUnit = loc;
} else {
locations.atmosphereBufferUnit = -1;
}
#endif
program.release();
@ -597,4 +605,4 @@ void DeferredLightingEffect::setGlobalLight(const glm::vec3& direction, const gl
void DeferredLightingEffect::setGlobalSkybox(const model::SkyboxPointer& skybox) {
_skybox = skybox;
}
}

View file

@ -54,6 +54,10 @@ public:
//// Renders a wireframe cube with the simple program.
void renderWireCube(float size, const glm::vec4& color);
//// Renders a line with the simple program.
void renderLine(const glm::vec3& p1, const glm::vec3& p2,
const glm::vec4& color1, const glm::vec4& color2);
//// Renders a solid cone with the simple program.
void renderSolidCone(float base, float height, int slices, int stacks);

View file

@ -31,7 +31,8 @@ enum ShapeType {
SHAPE_TYPE_CAPSULE_Z,
SHAPE_TYPE_CYLINDER_X,
SHAPE_TYPE_CYLINDER_Y,
SHAPE_TYPE_CYLINDER_Z
SHAPE_TYPE_CYLINDER_Z,
SHAPE_TYPE_LINE
};
class ShapeInfo {