Use make_shared/create to make shared pointers

This commit is contained in:
Atlante45 2015-07-01 19:46:06 -07:00
parent ee13407066
commit 7b5a5a339a
53 changed files with 233 additions and 237 deletions

View file

@ -110,7 +110,7 @@ SharedNetworkPeer IceServer::addOrUpdateHeartbeatingPeer(const QByteArray& incom
if (!matchingPeer) { if (!matchingPeer) {
// if we don't have this sender we need to create them now // if we don't have this sender we need to create them now
matchingPeer = SharedNetworkPeer(new NetworkPeer(senderUUID, publicSocket, localSocket)); matchingPeer = QSharedPointer<NetworkPeer>::create(senderUUID, publicSocket, localSocket);
_activePeers.insert(senderUUID, matchingPeer); _activePeers.insert(senderUUID, matchingPeer);
qDebug() << "Added a new network peer" << *matchingPeer; qDebug() << "Added a new network peer" << *matchingPeer;

View file

@ -374,7 +374,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_bookmarks = new Bookmarks(); // Before setting up the menu _bookmarks = new Bookmarks(); // Before setting up the menu
_runningScriptsWidget = new RunningScriptsWidget(_window); _runningScriptsWidget = new RunningScriptsWidget(_window);
_renderEngine->addTask(render::TaskPointer(new RenderDeferredTask())); _renderEngine->addTask(make_shared<RenderDeferredTask>());
_renderEngine->registerScene(_main3DScene); _renderEngine->registerScene(_main3DScene);
// start the nodeThread so its event loop is running // start the nodeThread so its event loop is running
@ -3426,8 +3426,8 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
// Background rendering decision // Background rendering decision
if (BackgroundRenderData::_item == 0) { if (BackgroundRenderData::_item == 0) {
auto backgroundRenderData = BackgroundRenderData::Pointer(new BackgroundRenderData(&_environment)); auto backgroundRenderData = make_shared<BackgroundRenderData>(&_environment);
auto backgroundRenderPayload = render::PayloadPointer(new BackgroundRenderData::Payload(backgroundRenderData)); auto backgroundRenderPayload = make_shared<BackgroundRenderData::Payload>(backgroundRenderData);
BackgroundRenderData::_item = _main3DScene->allocateID(); BackgroundRenderData::_item = _main3DScene->allocateID();
pendingChanges.resetItem(WorldBoxRenderData::_item, backgroundRenderPayload); pendingChanges.resetItem(WorldBoxRenderData::_item, backgroundRenderPayload);
} else { } else {
@ -3475,8 +3475,8 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
// Make sure the WorldBox is in the scene // Make sure the WorldBox is in the scene
if (WorldBoxRenderData::_item == 0) { if (WorldBoxRenderData::_item == 0) {
auto worldBoxRenderData = WorldBoxRenderData::Pointer(new WorldBoxRenderData()); auto worldBoxRenderData = make_shared<WorldBoxRenderData>();
auto worldBoxRenderPayload = render::PayloadPointer(new WorldBoxRenderData::Payload(worldBoxRenderData)); auto worldBoxRenderPayload = make_shared<WorldBoxRenderData::Payload>(worldBoxRenderData);
WorldBoxRenderData::_item = _main3DScene->allocateID(); WorldBoxRenderData::_item = _main3DScene->allocateID();

View file

@ -434,7 +434,7 @@ void MyAvatar::startRecording() {
return; return;
} }
if (!_recorder) { if (!_recorder) {
_recorder = RecorderPointer(new Recorder(this)); _recorder = QSharedPointer<Recorder>::create(this);
} }
// connect to AudioClient's signal so we get input audio // connect to AudioClient's signal so we get input audio
auto audioClient = DependencyManager::get<AudioClient>(); auto audioClient = DependencyManager::get<AudioClient>();
@ -486,7 +486,7 @@ void MyAvatar::loadLastRecording() {
return; return;
} }
if (!_player) { if (!_player) {
_player = PlayerPointer(new Player(this)); _player = QSharedPointer<Player>::create(this);
} }
_player->loadRecording(_recorder->getRecording()); _player->loadRecording(_recorder->getRecording());

View file

@ -103,7 +103,7 @@ void Joystick::registerToUserInputMapper(UserInputMapper& mapper) {
// Grab the current free device ID // Grab the current free device ID
_deviceID = mapper.getFreeDeviceID(); _deviceID = mapper.getFreeDeviceID();
auto proxy = UserInputMapper::DeviceProxy::Pointer(new UserInputMapper::DeviceProxy(_name)); auto proxy = std::make_shared<UserInputMapper::DeviceProxy>(_name);
proxy->getButton = [this] (const UserInputMapper::Input& input, int timestamp) -> bool { return this->getButton(input.getChannel()); }; proxy->getButton = [this] (const UserInputMapper::Input& input, int timestamp) -> bool { return this->getButton(input.getChannel()); };
proxy->getAxis = [this] (const UserInputMapper::Input& input, int timestamp) -> float { return this->getAxis(input.getChannel()); }; proxy->getAxis = [this] (const UserInputMapper::Input& input, int timestamp) -> float { return this->getAxis(input.getChannel()); };
proxy->getAvailabeInputs = [this] () -> QVector<UserInputMapper::InputPair> { proxy->getAvailabeInputs = [this] () -> QVector<UserInputMapper::InputPair> {

View file

@ -159,7 +159,7 @@ void KeyboardMouseDevice::registerToUserInputMapper(UserInputMapper& mapper) {
// Grab the current free device ID // Grab the current free device ID
_deviceID = mapper.getFreeDeviceID(); _deviceID = mapper.getFreeDeviceID();
auto proxy = UserInputMapper::DeviceProxy::Pointer(new UserInputMapper::DeviceProxy("Keyboard")); auto proxy = std::make_shared<UserInputMapper::DeviceProxy>("Keyboard");
proxy->getButton = [this] (const UserInputMapper::Input& input, int timestamp) -> bool { return this->getButton(input.getChannel()); }; proxy->getButton = [this] (const UserInputMapper::Input& input, int timestamp) -> bool { return this->getButton(input.getChannel()); };
proxy->getAxis = [this] (const UserInputMapper::Input& input, int timestamp) -> float { return this->getAxis(input.getChannel()); }; proxy->getAxis = [this] (const UserInputMapper::Input& input, int timestamp) -> float { return this->getAxis(input.getChannel()); };
proxy->getAvailabeInputs = [this] () -> QVector<UserInputMapper::InputPair> { proxy->getAvailabeInputs = [this] () -> QVector<UserInputMapper::InputPair> {

View file

@ -662,7 +662,7 @@ void SixenseManager::registerToUserInputMapper(UserInputMapper& mapper) {
// Grab the current free device ID // Grab the current free device ID
_deviceID = mapper.getFreeDeviceID(); _deviceID = mapper.getFreeDeviceID();
auto proxy = UserInputMapper::DeviceProxy::Pointer(new UserInputMapper::DeviceProxy("Hydra")); auto proxy = std::make_shared<UserInputMapper::DeviceProxy>("Hydra");
proxy->getButton = [this] (const UserInputMapper::Input& input, int timestamp) -> bool { return this->getButton(input.getChannel()); }; proxy->getButton = [this] (const UserInputMapper::Input& input, int timestamp) -> bool { return this->getButton(input.getChannel()); };
proxy->getAxis = [this] (const UserInputMapper::Input& input, int timestamp) -> float { return this->getAxis(input.getChannel()); }; proxy->getAxis = [this] (const UserInputMapper::Input& input, int timestamp) -> float { return this->getAxis(input.getChannel()); };
proxy->getAvailabeInputs = [this] () -> QVector<UserInputMapper::InputPair> { proxy->getAvailabeInputs = [this] () -> QVector<UserInputMapper::InputPair> {

View file

@ -620,8 +620,8 @@ void ApplicationCompositor::buildHemiVertices(
auto geometryCache = DependencyManager::get<GeometryCache>(); auto geometryCache = DependencyManager::get<GeometryCache>();
_hemiVertices = gpu::BufferPointer(new gpu::Buffer()); _hemiVertices = std::make_shared<gpu::Buffer>();
_hemiIndices = gpu::BufferPointer(new gpu::Buffer()); _hemiIndices = std::make_shared<gpu::Buffer>();
if (fov >= PI) { if (fov >= PI) {
@ -683,7 +683,7 @@ void ApplicationCompositor::drawSphereSection(gpu::Batch& batch) {
static const int VERTEX_DATA_SLOT = 0; static const int VERTEX_DATA_SLOT = 0;
static const int TEXTURE_DATA_SLOT = 1; static const int TEXTURE_DATA_SLOT = 1;
static const int COLOR_DATA_SLOT = 2; static const int COLOR_DATA_SLOT = 2;
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); // 1 for everyone auto streamFormat = std::make_shared<gpu::Stream::Format>(); // 1 for everyone
streamFormat->setAttribute(gpu::Stream::POSITION, VERTEX_DATA_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); streamFormat->setAttribute(gpu::Stream::POSITION, VERTEX_DATA_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0);
streamFormat->setAttribute(gpu::Stream::TEXCOORD, TEXTURE_DATA_SLOT, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV)); streamFormat->setAttribute(gpu::Stream::TEXCOORD, TEXTURE_DATA_SLOT, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV));
streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_DATA_SLOT, gpu::Element(gpu::VEC4, gpu::FLOAT, gpu::RGBA)); streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_DATA_SLOT, gpu::Element(gpu::VEC4, gpu::FLOAT, gpu::RGBA));

View file

@ -617,7 +617,7 @@ void AvatarData::loadRecording(QString filename) {
return; return;
} }
if (!_player) { if (!_player) {
_player = PlayerPointer(new Player(this)); _player = QSharedPointer<Player>::create(this);
} }
_player->loadFromFile(filename); _player->loadFromFile(filename);
@ -629,7 +629,7 @@ void AvatarData::startPlaying() {
return; return;
} }
if (!_player) { if (!_player) {
_player = PlayerPointer(new Player(this)); _player = QSharedPointer<Player>::create(this);
} }
_player->startPlaying(); _player->startPlaying();
} }
@ -731,7 +731,7 @@ void AvatarData::stopPlaying() {
} }
} }
void AvatarData::changeReferential(Referential *ref) { void AvatarData::changeReferential(Referential* ref) {
delete _referential; delete _referential;
_referential = ref; _referential = ref;
} }

View file

@ -51,7 +51,7 @@ bool AvatarHashMap::isAvatarInRange(const glm::vec3& position, const float range
} }
AvatarSharedPointer AvatarHashMap::newSharedAvatar() { AvatarSharedPointer AvatarHashMap::newSharedAvatar() {
return AvatarSharedPointer(new AvatarData()); return std::make_shared<AvatarData>();
} }
AvatarSharedPointer AvatarHashMap::addAvatar(const QUuid& sessionUUID, const QWeakPointer<Node>& mixerWeakPointer) { AvatarSharedPointer AvatarHashMap::addAvatar(const QUuid& sessionUUID, const QWeakPointer<Node>& mixerWeakPointer) {

View file

@ -202,7 +202,7 @@ void Player::loadFromFile(const QString& file) {
if (_recording) { if (_recording) {
_recording->clear(); _recording->clear();
} else { } else {
_recording = RecordingPointer(new Recording()); _recording = QSharedPointer<Recording>();
} }
readRecordingFromFile(_recording, file); readRecordingFromFile(_recording, file);

View file

@ -417,7 +417,7 @@ RecordingPointer readRecordingFromFile(RecordingPointer recording, const QString
// Reset the recording passed in the arguments // Reset the recording passed in the arguments
if (!recording) { if (!recording) {
recording.reset(new Recording()); recording = QSharedPointer<Recording>::create();
} }
QDataStream fileStream(byteArray); QDataStream fileStream(byteArray);
@ -652,7 +652,7 @@ RecordingPointer readRecordingFromRecFile(RecordingPointer recording, const QStr
timer.start(); timer.start();
if (!recording) { if (!recording) {
recording.reset(new Recording()); recording = QSharedPointer<Recording>::create();
} }
QDataStream fileStream(byteArray); QDataStream fileStream(byteArray);

View file

@ -23,7 +23,7 @@
#include "RenderableDebugableEntityItem.h" #include "RenderableDebugableEntityItem.h"
EntityItemPointer RenderableBoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer RenderableBoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return EntityItemPointer(new RenderableBoxEntityItem(entityID, properties)); return std::make_shared<RenderableBoxEntityItem>(entityID, properties);
} }
void RenderableBoxEntityItem::render(RenderArgs* args) { void RenderableBoxEntityItem::render(RenderArgs* args) {

View file

@ -37,8 +37,8 @@ public:
bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) { bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) {
_myItem = scene->allocateID(); _myItem = scene->allocateID();
auto renderData = RenderableEntityItemProxy::Pointer(new RenderableEntityItemProxy(self)); auto renderData = std::make_shared<RenderableEntityItemProxy>(self);
auto renderPayload = render::PayloadPointer(new RenderableEntityItemProxy::Payload(renderData)); auto renderPayload = std::make_shared<RenderableEntityItemProxy::Payload>(renderData);
pendingChanges.resetItem(_myItem, renderPayload); pendingChanges.resetItem(_myItem, renderPayload);

View file

@ -21,7 +21,7 @@
#include "RenderableLightEntityItem.h" #include "RenderableLightEntityItem.h"
EntityItemPointer RenderableLightEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer RenderableLightEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return EntityItemPointer(new RenderableLightEntityItem(entityID, properties)); return std::make_shared<RenderableLightEntityItem>(entityID, properties);
} }
void RenderableLightEntityItem::render(RenderArgs* args) { void RenderableLightEntityItem::render(RenderArgs* args) {

View file

@ -21,7 +21,7 @@
#include "RenderableLineEntityItem.h" #include "RenderableLineEntityItem.h"
EntityItemPointer RenderableLineEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer RenderableLineEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return EntityItemPointer(new RenderableLineEntityItem(entityID, properties)); return std::make_shared<RenderableLineEntityItem>(entityID, properties);
} }
void RenderableLineEntityItem::updateGeometry() { void RenderableLineEntityItem::updateGeometry() {

View file

@ -26,7 +26,7 @@
#include "RenderableModelEntityItem.h" #include "RenderableModelEntityItem.h"
EntityItemPointer RenderableModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer RenderableModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return EntityItemPointer(new RenderableModelEntityItem(entityID, properties)); return std::make_shared<RenderableModelEntityItem>(entityID, properties);
} }
RenderableModelEntityItem::~RenderableModelEntityItem() { RenderableModelEntityItem::~RenderableModelEntityItem() {
@ -171,8 +171,8 @@ bool RenderableModelEntityItem::addToScene(EntityItemPointer self, std::shared_p
render::PendingChanges& pendingChanges) { render::PendingChanges& pendingChanges) {
_myMetaItem = scene->allocateID(); _myMetaItem = scene->allocateID();
auto renderData = RenderableModelEntityItemMeta::Pointer(new RenderableModelEntityItemMeta(self)); auto renderData = std::make_shared<RenderableModelEntityItemMeta>(self);
auto renderPayload = render::PayloadPointer(new RenderableModelEntityItemMeta::Payload(renderData)); auto renderPayload = std::make_shared<RenderableModelEntityItemMeta::Payload>(renderData);
pendingChanges.resetItem(_myMetaItem, renderPayload); pendingChanges.resetItem(_myMetaItem, renderPayload);

View file

@ -21,7 +21,7 @@
#include "RenderableParticleEffectEntityItem.h" #include "RenderableParticleEffectEntityItem.h"
EntityItemPointer RenderableParticleEffectEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer RenderableParticleEffectEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return EntityItemPointer(new RenderableParticleEffectEntityItem(entityID, properties)); return std::make_shared<RenderableParticleEffectEntityItem>(entityID, properties);
} }
RenderableParticleEffectEntityItem::RenderableParticleEffectEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) : RenderableParticleEffectEntityItem::RenderableParticleEffectEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :

View file

@ -42,7 +42,7 @@
#include "RenderablePolyVoxEntityItem.h" #include "RenderablePolyVoxEntityItem.h"
EntityItemPointer RenderablePolyVoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer RenderablePolyVoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return EntityItemPointer(new RenderablePolyVoxEntityItem(entityID, properties)); return std::make_shared<RenderablePolyVoxEntityItem>(entityID, properties);
} }
RenderablePolyVoxEntityItem::RenderablePolyVoxEntityItem(const EntityItemID& entityItemID, RenderablePolyVoxEntityItem::RenderablePolyVoxEntityItem(const EntityItemID& entityItemID,
@ -351,14 +351,15 @@ void RenderablePolyVoxEntityItem::getModel() {
auto mesh = _modelGeometry.getMesh(); auto mesh = _modelGeometry.getMesh();
const std::vector<uint32_t>& vecIndices = polyVoxMesh.getIndices(); const std::vector<uint32_t>& vecIndices = polyVoxMesh.getIndices();
auto indexBuffer = new gpu::Buffer(vecIndices.size() * sizeof(uint32_t), (gpu::Byte*)vecIndices.data()); auto indexBuffer = std::make_shared<gpu::Buffer>(vecIndices.size() * sizeof(uint32_t),
(gpu::Byte*)vecIndices.data());
auto indexBufferPtr = gpu::BufferPointer(indexBuffer); auto indexBufferPtr = gpu::BufferPointer(indexBuffer);
auto indexBufferView = new gpu::BufferView(indexBufferPtr, gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::RAW)); auto indexBufferView = new gpu::BufferView(indexBufferPtr, gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::RAW));
mesh->setIndexBuffer(*indexBufferView); mesh->setIndexBuffer(*indexBufferView);
const std::vector<PolyVox::PositionMaterialNormal>& vecVertices = polyVoxMesh.getVertices(); const std::vector<PolyVox::PositionMaterialNormal>& vecVertices = polyVoxMesh.getVertices();
auto vertexBuffer = new gpu::Buffer(vecVertices.size() * sizeof(PolyVox::PositionMaterialNormal), auto vertexBuffer = std::make_shared<gpu::Buffer>(vecVertices.size() * sizeof(PolyVox::PositionMaterialNormal),
(gpu::Byte*)vecVertices.data()); (gpu::Byte*)vecVertices.data());
auto vertexBufferPtr = gpu::BufferPointer(vertexBuffer); auto vertexBufferPtr = gpu::BufferPointer(vertexBuffer);
auto vertexBufferView = new gpu::BufferView(vertexBufferPtr, auto vertexBufferView = new gpu::BufferView(vertexBufferPtr,

View file

@ -23,7 +23,7 @@
#include "RenderableDebugableEntityItem.h" #include "RenderableDebugableEntityItem.h"
EntityItemPointer RenderableSphereEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer RenderableSphereEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return EntityItemPointer(new RenderableSphereEntityItem(entityID, properties)); return std::make_shared<RenderableSphereEntityItem>(entityID, properties);
} }
void RenderableSphereEntityItem::render(RenderArgs* args) { void RenderableSphereEntityItem::render(RenderArgs* args) {

View file

@ -24,7 +24,7 @@
#include "GLMHelpers.h" #include "GLMHelpers.h"
EntityItemPointer RenderableTextEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer RenderableTextEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return EntityItemPointer(new RenderableTextEntityItem(entityID, properties)); return std::make_shared<RenderableTextEntityItem>(entityID, properties);
} }
void RenderableTextEntityItem::render(RenderArgs* args) { void RenderableTextEntityItem::render(RenderArgs* args) {

View file

@ -32,7 +32,7 @@ const float DPI = 30.47f;
const float METERS_TO_INCHES = 39.3701f; const float METERS_TO_INCHES = 39.3701f;
EntityItemPointer RenderableWebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer RenderableWebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return EntityItemPointer(new RenderableWebEntityItem(entityID, properties)); return std::make_shared<RenderableWebEntityItem>(entityID, properties);
} }
RenderableWebEntityItem::RenderableWebEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) : RenderableWebEntityItem::RenderableWebEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :

View file

@ -21,7 +21,7 @@
#include <PerfStat.h> #include <PerfStat.h>
EntityItemPointer RenderableZoneEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer RenderableZoneEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return EntityItemPointer(new RenderableZoneEntityItem(entityID, properties)); return std::make_shared<RenderableZoneEntityItem>(entityID, properties);
} }
template<typename Lambda> template<typename Lambda>
@ -196,8 +196,8 @@ bool RenderableZoneEntityItem::addToScene(EntityItemPointer self, std::shared_pt
render::PendingChanges& pendingChanges) { render::PendingChanges& pendingChanges) {
_myMetaItem = scene->allocateID(); _myMetaItem = scene->allocateID();
auto renderData = RenderableZoneEntityItemMeta::Pointer(new RenderableZoneEntityItemMeta(self)); auto renderData = std::make_shared<RenderableZoneEntityItemMeta>(self);
auto renderPayload = render::PayloadPointer(new RenderableZoneEntityItemMeta::Payload(renderData)); auto renderPayload = std::make_shared<RenderableZoneEntityItemMeta::Payload>(renderData);
pendingChanges.resetItem(_myMetaItem, renderPayload); pendingChanges.resetItem(_myMetaItem, renderPayload);
return true; return true;

View file

@ -29,7 +29,7 @@ const float ModelEntityItem::DEFAULT_ANIMATION_FPS = 30.0f;
EntityItemPointer ModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer ModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return EntityItemPointer(new ModelEntityItem(entityID, properties)); return std::make_shared<ModelEntityItem>(entityID, properties);
} }
ModelEntityItem::ModelEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) : ModelEntityItem::ModelEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :

View file

@ -56,7 +56,7 @@ const QString ParticleEffectEntityItem::DEFAULT_TEXTURES = "";
EntityItemPointer ParticleEffectEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer ParticleEffectEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return EntityItemPointer(new ParticleEffectEntityItem(entityID, properties)); return std::make_shared<ParticleEffectEntityItem>(entityID, properties);
} }
// our non-pure virtual subclass for now... // our non-pure virtual subclass for now...

View file

@ -28,12 +28,9 @@ const PolyVoxEntityItem::PolyVoxSurfaceStyle PolyVoxEntityItem::DEFAULT_VOXEL_SU
PolyVoxEntityItem::SURFACE_MARCHING_CUBES; PolyVoxEntityItem::SURFACE_MARCHING_CUBES;
EntityItemPointer PolyVoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer PolyVoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return EntityItemPointer(new PolyVoxEntityItem(entityID, properties)); return std::make_shared<PolyVoxEntityItem>(entityID, properties);
} }
QByteArray PolyVoxEntityItem::makeEmptyVoxelData(quint16 voxelXSize, quint16 voxelYSize, quint16 voxelZSize) { QByteArray PolyVoxEntityItem::makeEmptyVoxelData(quint16 voxelXSize, quint16 voxelYSize, quint16 voxelZSize) {
int rawSize = voxelXSize * voxelYSize * voxelZSize; int rawSize = voxelXSize * voxelYSize * voxelZSize;
@ -48,8 +45,6 @@ QByteArray PolyVoxEntityItem::makeEmptyVoxelData(quint16 voxelXSize, quint16 vox
return newVoxelData; return newVoxelData;
} }
PolyVoxEntityItem::PolyVoxEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) : PolyVoxEntityItem::PolyVoxEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
EntityItem(entityItemID), EntityItem(entityItemID),
_voxelVolumeSize(PolyVoxEntityItem::DEFAULT_VOXEL_VOLUME_SIZE), _voxelVolumeSize(PolyVoxEntityItem::DEFAULT_VOXEL_VOLUME_SIZE),

View file

@ -30,7 +30,7 @@ const xColor TextEntityItem::DEFAULT_BACKGROUND_COLOR = { 0, 0, 0};
const bool TextEntityItem::DEFAULT_FACE_CAMERA = false; const bool TextEntityItem::DEFAULT_FACE_CAMERA = false;
EntityItemPointer TextEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer TextEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return EntityItemPointer(new TextEntityItem(entityID, properties)); return std::make_shared<TextEntityItem>(entityID, properties);
} }
TextEntityItem::TextEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) : TextEntityItem::TextEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :

View file

@ -23,7 +23,7 @@
const QString WebEntityItem::DEFAULT_SOURCE_URL("http://www.google.com"); const QString WebEntityItem::DEFAULT_SOURCE_URL("http://www.google.com");
EntityItemPointer WebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer WebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return EntityItemPointer(new WebEntityItem(entityID, properties)); return std::make_shared<WebEntityItem>(entityID, properties);
} }
WebEntityItem::WebEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) : WebEntityItem::WebEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :

View file

@ -30,7 +30,7 @@ const ShapeType ZoneEntityItem::DEFAULT_SHAPE_TYPE = SHAPE_TYPE_BOX;
const QString ZoneEntityItem::DEFAULT_COMPOUND_SHAPE_URL = ""; const QString ZoneEntityItem::DEFAULT_COMPOUND_SHAPE_URL = "";
EntityItemPointer ZoneEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer ZoneEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return EntityItemPointer(new ZoneEntityItem(entityID, properties)); return std::make_shared<ZoneEntityItem>(entityID, properties);
} }
ZoneEntityItem::ZoneEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) : ZoneEntityItem::ZoneEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :

View file

@ -1323,7 +1323,7 @@ void buildModelMesh(ExtractedMesh& extracted) {
model::Mesh mesh; model::Mesh mesh;
// Grab the vertices in a buffer // Grab the vertices in a buffer
gpu::BufferPointer vb(new gpu::Buffer()); auto vb = make_shared<gpu::Buffer>();
vb->setData(extracted.mesh.vertices.size() * sizeof(glm::vec3), vb->setData(extracted.mesh.vertices.size() * sizeof(glm::vec3),
(const gpu::Byte*) extracted.mesh.vertices.data()); (const gpu::Byte*) extracted.mesh.vertices.data());
gpu::BufferView vbv(vb, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); gpu::BufferView vbv(vb, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ));
@ -1348,7 +1348,7 @@ void buildModelMesh(ExtractedMesh& extracted) {
int totalAttributeSize = clusterWeightsOffset + clusterWeightsSize; int totalAttributeSize = clusterWeightsOffset + clusterWeightsSize;
// Copy all attribute data in a single attribute buffer // Copy all attribute data in a single attribute buffer
gpu::BufferPointer attribBuffer(new gpu::Buffer()); auto attribBuffer = make_shared<gpu::Buffer>();
attribBuffer->resize(totalAttributeSize); attribBuffer->resize(totalAttributeSize);
attribBuffer->setSubData(normalsOffset, normalsSize, (gpu::Byte*) fbxMesh.normals.constData()); attribBuffer->setSubData(normalsOffset, normalsSize, (gpu::Byte*) fbxMesh.normals.constData());
attribBuffer->setSubData(tangentsOffset, tangentsSize, (gpu::Byte*) fbxMesh.tangents.constData()); attribBuffer->setSubData(tangentsOffset, tangentsSize, (gpu::Byte*) fbxMesh.tangents.constData());
@ -1407,7 +1407,7 @@ void buildModelMesh(ExtractedMesh& extracted) {
return; return;
} }
gpu::BufferPointer ib(new gpu::Buffer()); auto ib = make_shared<gpu::Buffer>();
ib->resize(totalIndices * sizeof(int)); ib->resize(totalIndices * sizeof(int));
int indexNum = 0; int indexNum = 0;
@ -1437,7 +1437,7 @@ void buildModelMesh(ExtractedMesh& extracted) {
mesh.setIndexBuffer(ibv); mesh.setIndexBuffer(ibv);
if (parts.size()) { if (parts.size()) {
gpu::BufferPointer pb(new gpu::Buffer()); auto pb = make_shared<gpu::Buffer>();
pb->setData(parts.size() * sizeof(model::Mesh::Part), (const gpu::Byte*) parts.data()); pb->setData(parts.size() * sizeof(model::Mesh::Part), (const gpu::Byte*) parts.data());
gpu::BufferView pbv(pb, gpu::Element(gpu::VEC4, gpu::UINT32, gpu::XYZW)); gpu::BufferView pbv(pb, gpu::Element(gpu::VEC4, gpu::UINT32, gpu::XYZW));
mesh.setPartBuffer(pbv); mesh.setPartBuffer(pbv);
@ -1926,7 +1926,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
} }
material.id = getID(object.properties); material.id = getID(object.properties);
material._material = model::MaterialPointer(new model::Material()); material._material = make_shared<model::Material>();
material._material->setEmissive(material.emissive); material._material->setEmissive(material.emissive);
if (glm::all(glm::equal(material.diffuse, glm::vec3(0.0f)))) { if (glm::all(glm::equal(material.diffuse, glm::vec3(0.0f)))) {
material._material->setDiffuse(material.diffuse); material._material->setDiffuse(material.diffuse);

View file

@ -131,7 +131,7 @@ void setMeshPartDefaults(FBXMeshPart& meshPart, QString materialID) {
meshPart.materialID = materialID; meshPart.materialID = materialID;
meshPart.opacity = 1.0; meshPart.opacity = 1.0;
meshPart._material = model::MaterialPointer(new model::Material()); meshPart._material = std::make_shared<model::Material>();
meshPart._material->setDiffuse(glm::vec3(1.0, 1.0, 1.0)); meshPart._material->setDiffuse(glm::vec3(1.0, 1.0, 1.0));
meshPart._material->setOpacity(1.0); meshPart._material->setOpacity(1.0);
meshPart._material->setMetallic(0.0); meshPart._material->setMetallic(0.0);

View file

@ -40,97 +40,99 @@ const GLBackend::GLState::Commands makeResetStateCommands() {
// and we have a 50/50 chance that State::DEFAULT is not yet initialized. // and we have a 50/50 chance that State::DEFAULT is not yet initialized.
// Since State::DEFAULT = State::Data() it is much easier to not use the actual State::DEFAULT // Since State::DEFAULT = State::Data() it is much easier to not use the actual State::DEFAULT
// but another State::Data object with a default initialization. // but another State::Data object with a default initialization.
State::Data DEFAULT = State::Data(); const State::Data DEFAULT = State::Data();
CommandPointer depthBiasCommand = CommandPointer(new CommandDepthBias(&GLBackend::do_setStateDepthBias, Vec2(DEFAULT.depthBias, DEFAULT.depthBiasSlopeScale))); auto depthBiasCommand = std::make_shared<CommandDepthBias>(&GLBackend::do_setStateDepthBias,
CommandPointer stencilCommand = CommandPointer(new CommandStencil(&GLBackend::do_setStateStencil, DEFAULT.stencilActivation, DEFAULT.stencilTestFront, DEFAULT.stencilTestBack)); Vec2(DEFAULT.depthBias, DEFAULT.depthBiasSlopeScale));
auto stencilCommand = std::make_shared<CommandStencil>(&GLBackend::do_setStateStencil, DEFAULT.stencilActivation,
DEFAULT.stencilTestFront, DEFAULT.stencilTestBack);
// The state commands to reset to default, // The state commands to reset to default,
// WARNING depending on the order of the State::Field enum // WARNING depending on the order of the State::Field enum
return { return {
CommandPointer(new Command1I(&GLBackend::do_setStateFillMode, DEFAULT.fillMode)), std::make_shared<Command1I>(&GLBackend::do_setStateFillMode, DEFAULT.fillMode),
CommandPointer(new Command1I(&GLBackend::do_setStateCullMode, DEFAULT.cullMode)), std::make_shared<Command1I>(&GLBackend::do_setStateCullMode, DEFAULT.cullMode),
CommandPointer(new Command1B(&GLBackend::do_setStateFrontFaceClockwise, DEFAULT.frontFaceClockwise)), std::make_shared<Command1B>(&GLBackend::do_setStateFrontFaceClockwise, DEFAULT.frontFaceClockwise),
CommandPointer(new Command1B(&GLBackend::do_setStateDepthClipEnable, DEFAULT.depthClipEnable)), std::make_shared<Command1B>(&GLBackend::do_setStateDepthClipEnable, DEFAULT.depthClipEnable),
CommandPointer(new Command1B(&GLBackend::do_setStateScissorEnable, DEFAULT.scissorEnable)), std::make_shared<Command1B>(&GLBackend::do_setStateScissorEnable, DEFAULT.scissorEnable),
CommandPointer(new Command1B(&GLBackend::do_setStateMultisampleEnable, DEFAULT.multisampleEnable)), std::make_shared<Command1B>(&GLBackend::do_setStateMultisampleEnable, DEFAULT.multisampleEnable),
CommandPointer(new Command1B(&GLBackend::do_setStateAntialiasedLineEnable, DEFAULT.antialisedLineEnable)), std::make_shared<Command1B>(&GLBackend::do_setStateAntialiasedLineEnable, DEFAULT.antialisedLineEnable),
// Depth bias has 2 fields in State but really one call in GLBackend // Depth bias has 2 fields in State but really one call in GLBackend
CommandPointer(depthBiasCommand), CommandPointer(depthBiasCommand),
CommandPointer(depthBiasCommand), CommandPointer(depthBiasCommand),
CommandPointer(new CommandDepthTest(&GLBackend::do_setStateDepthTest, DEFAULT.depthTest)), std::make_shared<CommandDepthTest>(&GLBackend::do_setStateDepthTest, DEFAULT.depthTest),
// Depth bias has 3 fields in State but really one call in GLBackend // Depth bias has 3 fields in State but really one call in GLBackend
CommandPointer(stencilCommand), CommandPointer(stencilCommand),
CommandPointer(stencilCommand), CommandPointer(stencilCommand),
CommandPointer(stencilCommand), CommandPointer(stencilCommand),
CommandPointer(new Command1B(&GLBackend::do_setStateAlphaToCoverageEnable, DEFAULT.alphaToCoverageEnable)), std::make_shared<Command1B>(&GLBackend::do_setStateAlphaToCoverageEnable, DEFAULT.alphaToCoverageEnable),
CommandPointer(new Command1U(&GLBackend::do_setStateSampleMask, DEFAULT.sampleMask)), std::make_shared<Command1U>(&GLBackend::do_setStateSampleMask, DEFAULT.sampleMask),
CommandPointer(new CommandBlend(&GLBackend::do_setStateBlend, DEFAULT.blendFunction)), std::make_shared<CommandBlend>(&GLBackend::do_setStateBlend, DEFAULT.blendFunction),
CommandPointer(new Command1U(&GLBackend::do_setStateColorWriteMask, DEFAULT.colorWriteMask)) std::make_shared<Command1U>(&GLBackend::do_setStateColorWriteMask, DEFAULT.colorWriteMask)
}; };
} }
void generateFillMode(GLBackend::GLState::Commands& commands, State::FillMode fillMode) { void generateFillMode(GLBackend::GLState::Commands& commands, State::FillMode fillMode) {
commands.push_back(CommandPointer(new Command1I(&GLBackend::do_setStateFillMode, int32(fillMode)))); commands.push_back(std::make_shared<Command1I>(&GLBackend::do_setStateFillMode, int32(fillMode)));
} }
void generateCullMode(GLBackend::GLState::Commands& commands, State::CullMode cullMode) { void generateCullMode(GLBackend::GLState::Commands& commands, State::CullMode cullMode) {
commands.push_back(CommandPointer(new Command1I(&GLBackend::do_setStateCullMode, int32(cullMode)))); commands.push_back(std::make_shared<Command1I>(&GLBackend::do_setStateCullMode, int32(cullMode)));
} }
void generateFrontFaceClockwise(GLBackend::GLState::Commands& commands, bool isClockwise) { void generateFrontFaceClockwise(GLBackend::GLState::Commands& commands, bool isClockwise) {
commands.push_back(CommandPointer(new Command1B(&GLBackend::do_setStateFrontFaceClockwise, isClockwise))); commands.push_back(std::make_shared<Command1B>(&GLBackend::do_setStateFrontFaceClockwise, isClockwise));
} }
void generateDepthClipEnable(GLBackend::GLState::Commands& commands, bool enable) { void generateDepthClipEnable(GLBackend::GLState::Commands& commands, bool enable) {
commands.push_back(CommandPointer(new Command1B(&GLBackend::do_setStateDepthClipEnable, enable))); commands.push_back(std::make_shared<Command1B>(&GLBackend::do_setStateDepthClipEnable, enable));
} }
void generateScissorEnable(GLBackend::GLState::Commands& commands, bool enable) { void generateScissorEnable(GLBackend::GLState::Commands& commands, bool enable) {
commands.push_back(CommandPointer(new Command1B(&GLBackend::do_setStateScissorEnable, enable))); commands.push_back(std::make_shared<Command1B>(&GLBackend::do_setStateScissorEnable, enable));
} }
void generateMultisampleEnable(GLBackend::GLState::Commands& commands, bool enable) { void generateMultisampleEnable(GLBackend::GLState::Commands& commands, bool enable) {
commands.push_back(CommandPointer(new Command1B(&GLBackend::do_setStateMultisampleEnable, enable))); commands.push_back(std::make_shared<Command1B>(&GLBackend::do_setStateMultisampleEnable, enable));
} }
void generateAntialiasedLineEnable(GLBackend::GLState::Commands& commands, bool enable) { void generateAntialiasedLineEnable(GLBackend::GLState::Commands& commands, bool enable) {
commands.push_back(CommandPointer(new Command1B(&GLBackend::do_setStateAntialiasedLineEnable, enable))); commands.push_back(std::make_shared<Command1B>(&GLBackend::do_setStateAntialiasedLineEnable, enable));
} }
void generateDepthBias(GLBackend::GLState::Commands& commands, const State& state) { void generateDepthBias(GLBackend::GLState::Commands& commands, const State& state) {
commands.push_back(CommandPointer(new CommandDepthBias(&GLBackend::do_setStateDepthBias, Vec2(state.getDepthBias(), state.getDepthBiasSlopeScale())))); commands.push_back(std::make_shared<CommandDepthBias>(&GLBackend::do_setStateDepthBias, Vec2(state.getDepthBias(), state.getDepthBiasSlopeScale())));
} }
void generateDepthTest(GLBackend::GLState::Commands& commands, const State::DepthTest& test) { void generateDepthTest(GLBackend::GLState::Commands& commands, const State::DepthTest& test) {
commands.push_back(CommandPointer(new CommandDepthTest(&GLBackend::do_setStateDepthTest, int32(test.getRaw())))); commands.push_back(std::make_shared<CommandDepthTest>(&GLBackend::do_setStateDepthTest, int32(test.getRaw())));
} }
void generateStencil(GLBackend::GLState::Commands& commands, const State& state) { void generateStencil(GLBackend::GLState::Commands& commands, const State& state) {
commands.push_back(CommandPointer(new CommandStencil(&GLBackend::do_setStateStencil, state.getStencilActivation(), state.getStencilTestFront(), state.getStencilTestBack()))); commands.push_back(std::make_shared<CommandStencil>(&GLBackend::do_setStateStencil, state.getStencilActivation(), state.getStencilTestFront(), state.getStencilTestBack()));
} }
void generateAlphaToCoverageEnable(GLBackend::GLState::Commands& commands, bool enable) { void generateAlphaToCoverageEnable(GLBackend::GLState::Commands& commands, bool enable) {
commands.push_back(CommandPointer(new Command1B(&GLBackend::do_setStateAlphaToCoverageEnable, enable))); commands.push_back(std::make_shared<Command1B>(&GLBackend::do_setStateAlphaToCoverageEnable, enable));
} }
void generateSampleMask(GLBackend::GLState::Commands& commands, uint32 mask) { void generateSampleMask(GLBackend::GLState::Commands& commands, uint32 mask) {
commands.push_back(CommandPointer(new Command1U(&GLBackend::do_setStateSampleMask, mask))); commands.push_back(std::make_shared<Command1U>(&GLBackend::do_setStateSampleMask, mask));
} }
void generateBlend(GLBackend::GLState::Commands& commands, const State& state) { void generateBlend(GLBackend::GLState::Commands& commands, const State& state) {
commands.push_back(CommandPointer(new CommandBlend(&GLBackend::do_setStateBlend, state.getBlendFunction()))); commands.push_back(std::make_shared<CommandBlend>(&GLBackend::do_setStateBlend, state.getBlendFunction()));
} }
void generateColorWriteMask(GLBackend::GLState::Commands& commands, uint32 mask) { void generateColorWriteMask(GLBackend::GLState::Commands& commands, uint32 mask) {
commands.push_back(CommandPointer(new Command1U(&GLBackend::do_setStateColorWriteMask, mask))); commands.push_back(std::make_shared<Command1U>(&GLBackend::do_setStateColorWriteMask, mask));
} }
GLBackend::GLState* GLBackend::syncGPUObject(const State& state) { GLBackend::GLState* GLBackend::syncGPUObject(const State& state) {

View file

@ -80,7 +80,7 @@ bool Texture::Storage::allocateMip(uint16 level) {
auto& mip = _mips[level]; auto& mip = _mips[level];
for (auto& face : mip) { for (auto& face : mip) {
if (!face) { if (!face) {
face.reset(new Pixels()); face = std::make_shared<Pixels>();
changed = true; changed = true;
} }
} }
@ -419,7 +419,7 @@ bool Texture::generateIrradiance() {
return false; return false;
} }
if (!_irradiance) { if (!_irradiance) {
_irradiance.reset(new SphericalHarmonics()); _irradiance = std::make_shared<SphericalHarmonics>();
} }
_irradiance->evalFromTexture(*this); _irradiance->evalFromTexture(*this);
@ -563,7 +563,7 @@ glm::vec3 linearTosRGB(glm::vec3& color) {
return glm::pow(color, glm::vec3(GAMMA_CORRECTION_INV)); return glm::pow(color, glm::vec3(GAMMA_CORRECTION_INV));
} }
// Originial code for the Spherical Harmonics taken from "Sun and Black Cat- Igor Dykhta (igor dykhta email) © 2007-2014 " // Originial code for the Spherical Harmonics taken from "Sun and Black Cat- Igor Dykhta (igor dykhta email) <EFBFBD> 2007-2014 "
void sphericalHarmonicsAdd(float * result, int order, const float * inputA, const float * inputB) { void sphericalHarmonicsAdd(float * result, int order, const float * inputA, const float * inputB) {
const int numCoeff = order * order; const int numCoeff = order * order;
for(int i=0; i < numCoeff; i++) { for(int i=0; i < numCoeff; i++) {

View file

@ -18,7 +18,7 @@ Light::Light() :
_transform() { _transform() {
// only if created from nothing shall we create the Buffer to store the properties // only if created from nothing shall we create the Buffer to store the properties
Schema schema; Schema schema;
_schemaBuffer = gpu::BufferView(new gpu::Buffer(sizeof(Schema), (const gpu::Byte*) &schema)); _schemaBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(sizeof(Schema), (const gpu::Byte*) &schema));
} }
Light::Light(const Light& light) : Light::Light(const Light& light) :

View file

@ -20,7 +20,7 @@ Material::Material() :
// only if created from nothing shall we create the Buffer to store the properties // only if created from nothing shall we create the Buffer to store the properties
Schema schema; Schema schema;
_schemaBuffer = gpu::BufferView(new gpu::Buffer(sizeof(Schema), (const gpu::Byte*) &schema)); _schemaBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(sizeof(Schema), (const gpu::Byte*) &schema));
} }

View file

@ -68,19 +68,19 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky
SKYBOX_CONSTANTS_SLOT = skyShader->getUniforms().findLocation("skyboxBuffer"); SKYBOX_CONSTANTS_SLOT = skyShader->getUniforms().findLocation("skyboxBuffer");
} }
auto skyState = gpu::StatePointer(new gpu::State()); auto skyState = std::make_shared<gpu::State>();
thePipeline = gpu::PipelinePointer(gpu::Pipeline::create(skyShader, skyState)); thePipeline = gpu::PipelinePointer(gpu::Pipeline::create(skyShader, skyState));
const float CLIP = 1.0f; const float CLIP = 1.0f;
const glm::vec2 vertices[4] = { {-CLIP, -CLIP}, {CLIP, -CLIP}, {-CLIP, CLIP}, {CLIP, CLIP}}; const glm::vec2 vertices[4] = { {-CLIP, -CLIP}, {CLIP, -CLIP}, {-CLIP, CLIP}, {CLIP, CLIP}};
theBuffer.reset(new gpu::Buffer(sizeof(vertices), (const gpu::Byte*) vertices)); theBuffer = std::make_shared<gpu::Buffer>(sizeof(vertices), (const gpu::Byte*) vertices);
theFormat.reset(new gpu::Stream::Format()); theFormat = std::make_shared<gpu::Stream::Format>();
theFormat->setAttribute(gpu::Stream::POSITION, gpu::Stream::POSITION, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::XYZ)); theFormat->setAttribute(gpu::Stream::POSITION, gpu::Stream::POSITION, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::XYZ));
auto color = glm::vec4(1.0f); auto color = glm::vec4(1.0f);
theConstants.reset(new gpu::Buffer(sizeof(color), (const gpu::Byte*) &color)); theConstants = std::make_shared<gpu::Buffer>(sizeof(color), (const gpu::Byte*) &color);
} }
glm::mat4 projMat; glm::mat4 projMat;

View file

@ -136,7 +136,7 @@ void EarthSunModel::setSunLongitude(float lon) {
Atmosphere::Atmosphere() { Atmosphere::Atmosphere() {
// only if created from nothing shall we create the Buffer to store the properties // only if created from nothing shall we create the Buffer to store the properties
Data data; Data data;
_dataBuffer = gpu::BufferView(new gpu::Buffer(sizeof(Data), (const gpu::Byte*) &data)); _dataBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(sizeof(Data), (const gpu::Byte*) &data));
setScatteringWavelength(_scatteringWavelength); setScatteringWavelength(_scatteringWavelength);
setRayleighScattering(_rayleighScattering); setRayleighScattering(_rayleighScattering);
@ -188,8 +188,8 @@ const float NUM_HOURS_PER_DAY = 24.0f;
const float NUM_HOURS_PER_HALF_DAY = NUM_HOURS_PER_DAY * 0.5f; const float NUM_HOURS_PER_HALF_DAY = NUM_HOURS_PER_DAY * 0.5f;
SunSkyStage::SunSkyStage() : SunSkyStage::SunSkyStage() :
_sunLight(new Light()), _sunLight(std::make_shared<Light>()),
_skybox(new Skybox()) _skybox(std::make_shared<Skybox>())
{ {
_sunLight->setType(Light::SUN); _sunLight->setType(Light::SUN);
@ -204,9 +204,8 @@ SunSkyStage::SunSkyStage() :
// Begining of march // Begining of march
setYearTime(60.0f); setYearTime(60.0f);
_skybox.reset(new Skybox()); _skybox = std::make_shared<Skybox>();
_skybox->setColor(Color(1.0f, 0.0f, 0.0f)); _skybox->setColor(Color(1.0f, 0.0f, 0.0f));
} }
SunSkyStage::~SunSkyStage() { SunSkyStage::~SunSkyStage() {

View file

@ -216,7 +216,7 @@ static QHash<QUuid, BandwidthRecorderPtr> PEER_BANDWIDTH;
BandwidthRecorder& getBandwidthRecorder(const QUuid & uuid) { BandwidthRecorder& getBandwidthRecorder(const QUuid & uuid) {
if (!PEER_BANDWIDTH.count(uuid)) { if (!PEER_BANDWIDTH.count(uuid)) {
PEER_BANDWIDTH.insert(uuid, BandwidthRecorderPtr(new BandwidthRecorder())); PEER_BANDWIDTH.insert(uuid, QSharedPointer<BandwidthRecorder>::create());
} }
return *PEER_BANDWIDTH[uuid].data(); return *PEER_BANDWIDTH[uuid].data();
} }

View file

@ -62,7 +62,7 @@ void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) {
gpu::Shader::makeProgram(*program, slotBindings); gpu::Shader::makeProgram(*program, slotBindings);
gpu::Shader::makeProgram(*programTextured, slotBindings); gpu::Shader::makeProgram(*programTextured, slotBindings);
gpu::StatePointer state = gpu::StatePointer(new gpu::State()); auto state = std::make_shared<gpu::State>();
state->setCullMode(gpu::State::CULL_BACK); state->setCullMode(gpu::State::CULL_BACK);
state->setDepthTest(true, true, gpu::LESS_EQUAL); state->setDepthTest(true, true, gpu::LESS_EQUAL);
state->setBlendFunction(false, state->setBlendFunction(false,
@ -70,7 +70,7 @@ void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) {
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
gpu::StatePointer stateCullNone = gpu::StatePointer(new gpu::State()); auto stateCullNone = std::make_shared<gpu::State>();
stateCullNone->setCullMode(gpu::State::CULL_NONE); stateCullNone->setCullMode(gpu::State::CULL_NONE);
stateCullNone->setDepthTest(true, true, gpu::LESS_EQUAL); stateCullNone->setDepthTest(true, true, gpu::LESS_EQUAL);
stateCullNone->setBlendFunction(false, stateCullNone->setBlendFunction(false,
@ -106,7 +106,7 @@ void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) {
// Allocate a global light representing the Global Directional light casting shadow (the sun) and the ambient light // Allocate a global light representing the Global Directional light casting shadow (the sun) and the ambient light
_globalLights.push_back(0); _globalLights.push_back(0);
_allocatedLights.push_back(model::LightPointer(new model::Light())); _allocatedLights.push_back(std::make_shared<model::Light>());
model::LightPointer lp = _allocatedLights[0]; model::LightPointer lp = _allocatedLights[0];
@ -187,7 +187,7 @@ void DeferredLightingEffect::addSpotLight(const glm::vec3& position, float radiu
unsigned int lightID = _pointLights.size() + _spotLights.size() + _globalLights.size(); unsigned int lightID = _pointLights.size() + _spotLights.size() + _globalLights.size();
if (lightID >= _allocatedLights.size()) { if (lightID >= _allocatedLights.size()) {
_allocatedLights.push_back(model::LightPointer(new model::Light())); _allocatedLights.push_back(std::make_shared<model::Light>());
} }
model::LightPointer lp = _allocatedLights[lightID]; model::LightPointer lp = _allocatedLights[lightID];

View file

@ -68,7 +68,7 @@ void Environment::setupAtmosphereProgram(const char* vertSource, const char* fra
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
gpu::Shader::makeProgram(*program, slotBindings); gpu::Shader::makeProgram(*program, slotBindings);
gpu::StatePointer state = gpu::StatePointer(new gpu::State()); auto state = std::make_shared<gpu::State>();
state->setCullMode(gpu::State::CULL_NONE); state->setCullMode(gpu::State::CULL_NONE);
state->setDepthTest(false); state->setDepthTest(false);

View file

@ -84,7 +84,7 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in
#endif #endif
} }
gpu::BufferPointer verticesBuffer(new gpu::Buffer()); auto verticesBuffer = std::make_shared<gpu::Buffer>();
if (registered) { if (registered) {
_registeredSphereVertices[id] = verticesBuffer; _registeredSphereVertices[id] = verticesBuffer;
_lastRegisteredSphereVertices[id] = radiusKey; _lastRegisteredSphereVertices[id] = radiusKey;
@ -148,7 +148,7 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in
#endif #endif
} }
gpu::BufferPointer indicesBuffer(new gpu::Buffer()); auto indicesBuffer = std::make_shared<gpu::Buffer>();
if (registered) { if (registered) {
_registeredSphereIndices[id] = indicesBuffer; _registeredSphereIndices[id] = indicesBuffer;
_lastRegisteredSphereIndices[id] = slicesStacksKey; _lastRegisteredSphereIndices[id] = slicesStacksKey;
@ -234,7 +234,7 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in
#endif #endif
} }
gpu::BufferPointer colorBuffer(new gpu::Buffer()); auto colorBuffer = std::make_shared<gpu::Buffer>();
if (registered) { if (registered) {
_registeredSphereColors[id] = colorBuffer; _registeredSphereColors[id] = colorBuffer;
_lastRegisteredSphereColors[id] = colorKey; _lastRegisteredSphereColors[id] = colorKey;
@ -279,7 +279,7 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in
const int VERTICES_SLOT = 0; const int VERTICES_SLOT = 0;
const int NORMALS_SLOT = 1; const int NORMALS_SLOT = 1;
const int COLOR_SLOT = 2; const int COLOR_SLOT = 2;
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); // 1 for everyone auto streamFormat = std::make_shared<gpu::Stream::Format>(); // 1 for everyone
streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0);
streamFormat->setAttribute(gpu::Stream::NORMAL, NORMALS_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); streamFormat->setAttribute(gpu::Stream::NORMAL, NORMALS_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ));
streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA));
@ -414,7 +414,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions
int vertices = (xDivisions + 1 + yDivisions + 1) * 2; int vertices = (xDivisions + 1 + yDivisions + 1) * 2;
if (!_gridBuffers.contains(key)) { if (!_gridBuffers.contains(key)) {
gpu::BufferPointer verticesBuffer(new gpu::Buffer()); auto verticesBuffer = std::make_shared<gpu::Buffer>();
GLfloat* vertexData = new GLfloat[vertices * 2]; GLfloat* vertexData = new GLfloat[vertices * 2];
GLfloat* vertex = vertexData; GLfloat* vertex = vertexData;
@ -445,7 +445,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions
} }
if (!_gridColors.contains(colorKey)) { if (!_gridColors.contains(colorKey)) {
gpu::BufferPointer colorBuffer(new gpu::Buffer()); auto colorBuffer = std::make_shared<gpu::Buffer>();
_gridColors[colorKey] = colorBuffer; _gridColors[colorKey] = colorBuffer;
int compactColor = ((int(color.x * 255.0f) & 0xFF)) | int compactColor = ((int(color.x * 255.0f) & 0xFF)) |
@ -468,7 +468,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions
const int VERTICES_SLOT = 0; const int VERTICES_SLOT = 0;
const int COLOR_SLOT = 1; const int COLOR_SLOT = 1;
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); // 1 for everyone auto streamFormat = std::make_shared<gpu::Stream::Format>(); // 1 for everyone
streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::XYZ), 0); streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::XYZ), 0);
streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA));
@ -507,7 +507,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int h
int vertices = (cols + 1 + rows + 1) * 2; int vertices = (cols + 1 + rows + 1) * 2;
if ((registered && !_registeredAlternateGridBuffers.contains(id)) || (!registered && !_alternateGridBuffers.contains(key))) { if ((registered && !_registeredAlternateGridBuffers.contains(id)) || (!registered && !_alternateGridBuffers.contains(key))) {
gpu::BufferPointer verticesBuffer(new gpu::Buffer()); auto verticesBuffer = std::make_shared<gpu::Buffer>();
GLfloat* vertexData = new GLfloat[vertices * 2]; GLfloat* vertexData = new GLfloat[vertices * 2];
GLfloat* vertex = vertexData; GLfloat* vertex = vertexData;
@ -550,7 +550,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int h
} }
if (!_gridColors.contains(colorKey)) { if (!_gridColors.contains(colorKey)) {
gpu::BufferPointer colorBuffer(new gpu::Buffer()); auto colorBuffer = std::make_shared<gpu::Buffer>();
_gridColors[colorKey] = colorBuffer; _gridColors[colorKey] = colorBuffer;
int compactColor = ((int(color.x * 255.0f) & 0xFF)) | int compactColor = ((int(color.x * 255.0f) & 0xFF)) |
@ -575,7 +575,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int h
const int VERTICES_SLOT = 0; const int VERTICES_SLOT = 0;
const int COLOR_SLOT = 1; const int COLOR_SLOT = 1;
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); // 1 for everyone auto streamFormat = std::make_shared<gpu::Stream::Format>(); // 1 for everyone
streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::XYZ), 0); streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::XYZ), 0);
streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA));
@ -604,10 +604,10 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, con
details.vertices = points.size(); details.vertices = points.size();
details.vertexSize = FLOATS_PER_VERTEX; details.vertexSize = FLOATS_PER_VERTEX;
gpu::BufferPointer verticesBuffer(new gpu::Buffer()); auto verticesBuffer = std::make_shared<gpu::Buffer>();
gpu::BufferPointer colorBuffer(new gpu::Buffer()); auto colorBuffer = std::make_shared<gpu::Buffer>();
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); auto streamFormat = std::make_shared<gpu::Stream::Format>();
gpu::BufferStreamPointer stream(new gpu::BufferStream()); auto stream = std::make_shared<gpu::BufferStream>();
details.verticesBuffer = verticesBuffer; details.verticesBuffer = verticesBuffer;
details.colorBuffer = colorBuffer; details.colorBuffer = colorBuffer;
@ -665,10 +665,10 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con
details.vertices = points.size(); details.vertices = points.size();
details.vertexSize = FLOATS_PER_VERTEX; details.vertexSize = FLOATS_PER_VERTEX;
gpu::BufferPointer verticesBuffer(new gpu::Buffer()); auto verticesBuffer = std::make_shared<gpu::Buffer>();
gpu::BufferPointer colorBuffer(new gpu::Buffer()); auto colorBuffer = std::make_shared<gpu::Buffer>();
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); auto streamFormat = std::make_shared<gpu::Stream::Format>();
gpu::BufferStreamPointer stream(new gpu::BufferStream()); auto stream = std::make_shared<gpu::BufferStream>();
details.verticesBuffer = verticesBuffer; details.verticesBuffer = verticesBuffer;
details.colorBuffer = colorBuffer; details.colorBuffer = colorBuffer;
@ -728,10 +728,10 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con
details.vertices = points.size(); details.vertices = points.size();
details.vertexSize = FLOATS_PER_VERTEX; details.vertexSize = FLOATS_PER_VERTEX;
gpu::BufferPointer verticesBuffer(new gpu::Buffer()); auto verticesBuffer = std::make_shared<gpu::Buffer>();
gpu::BufferPointer colorBuffer(new gpu::Buffer()); auto colorBuffer = std::make_shared<gpu::Buffer>();
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); auto streamFormat = std::make_shared<gpu::Stream::Format>();
gpu::BufferStreamPointer stream(new gpu::BufferStream()); auto stream = std::make_shared<gpu::BufferStream>();
details.verticesBuffer = verticesBuffer; details.verticesBuffer = verticesBuffer;
details.colorBuffer = colorBuffer; details.colorBuffer = colorBuffer;
@ -818,7 +818,7 @@ void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::ve
const int NORMALS_OFFSET = sizeof(GLfloat) * FLOATS_PER_VERTEX; const int NORMALS_OFFSET = sizeof(GLfloat) * FLOATS_PER_VERTEX;
if (!_solidCubeVertices.contains(size)) { if (!_solidCubeVertices.contains(size)) {
gpu::BufferPointer verticesBuffer(new gpu::Buffer()); auto verticesBuffer = std::make_shared<gpu::Buffer>();
_solidCubeVertices[size] = verticesBuffer; _solidCubeVertices[size] = verticesBuffer;
GLfloat* vertexData = new GLfloat[vertexPoints * 2]; // vertices and normals GLfloat* vertexData = new GLfloat[vertexPoints * 2]; // vertices and normals
@ -870,14 +870,14 @@ void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::ve
16,17,18, 18,19,16, // bottom 16,17,18, 18,19,16, // bottom
20,21,22, 22,23,20 }; // back 20,21,22, 22,23,20 }; // back
gpu::BufferPointer indexBuffer(new gpu::Buffer()); auto indexBuffer = std::make_shared<gpu::Buffer>();
_solidCubeIndexBuffer = indexBuffer; _solidCubeIndexBuffer = indexBuffer;
_solidCubeIndexBuffer->append(sizeof(cannonicalIndices), (gpu::Byte*) cannonicalIndices); _solidCubeIndexBuffer->append(sizeof(cannonicalIndices), (gpu::Byte*) cannonicalIndices);
} }
if (!_solidCubeColors.contains(colorKey)) { if (!_solidCubeColors.contains(colorKey)) {
gpu::BufferPointer colorBuffer(new gpu::Buffer()); auto colorBuffer = std::make_shared<gpu::Buffer>();
_solidCubeColors[colorKey] = colorBuffer; _solidCubeColors[colorKey] = colorBuffer;
const int NUM_COLOR_SCALARS_PER_CUBE = 24; const int NUM_COLOR_SCALARS_PER_CUBE = 24;
@ -900,7 +900,7 @@ void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::ve
const int VERTICES_SLOT = 0; const int VERTICES_SLOT = 0;
const int NORMALS_SLOT = 1; const int NORMALS_SLOT = 1;
const int COLOR_SLOT = 2; const int COLOR_SLOT = 2;
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); // 1 for everyone auto streamFormat = std::make_shared<gpu::Stream::Format>(); // 1 for everyone
streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0);
streamFormat->setAttribute(gpu::Stream::NORMAL, NORMALS_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); streamFormat->setAttribute(gpu::Stream::NORMAL, NORMALS_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ));
@ -935,7 +935,7 @@ void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec
const int indices = (TOP_EDGES + BOTTOM_EDGES + SIDE_EDGES) * VERTICES_PER_EDGE; const int indices = (TOP_EDGES + BOTTOM_EDGES + SIDE_EDGES) * VERTICES_PER_EDGE;
if (!_cubeVerticies.contains(size)) { if (!_cubeVerticies.contains(size)) {
gpu::BufferPointer verticesBuffer(new gpu::Buffer()); auto verticesBuffer = std::make_shared<gpu::Buffer>();
_cubeVerticies[size] = verticesBuffer; _cubeVerticies[size] = verticesBuffer;
int vertexPoints = vertices * FLOATS_PER_VERTEX; int vertexPoints = vertices * FLOATS_PER_VERTEX;
@ -962,14 +962,14 @@ void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec
0, 4, 1, 5, 2, 6, 3, 7, // (side edges) 0, 4, 1, 5, 2, 6, 3, 7, // (side edges)
}; };
gpu::BufferPointer indexBuffer(new gpu::Buffer()); auto indexBuffer = std::make_shared<gpu::Buffer>();
_wireCubeIndexBuffer = indexBuffer; _wireCubeIndexBuffer = indexBuffer;
_wireCubeIndexBuffer->append(sizeof(cannonicalIndices), (gpu::Byte*) cannonicalIndices); _wireCubeIndexBuffer->append(sizeof(cannonicalIndices), (gpu::Byte*) cannonicalIndices);
} }
if (!_cubeColors.contains(colorKey)) { if (!_cubeColors.contains(colorKey)) {
gpu::BufferPointer colorBuffer(new gpu::Buffer()); auto colorBuffer = std::make_shared<gpu::Buffer>();
_cubeColors[colorKey] = colorBuffer; _cubeColors[colorKey] = colorBuffer;
const int NUM_COLOR_SCALARS_PER_CUBE = 8; const int NUM_COLOR_SCALARS_PER_CUBE = 8;
@ -987,7 +987,7 @@ void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec
const int VERTICES_SLOT = 0; const int VERTICES_SLOT = 0;
const int COLOR_SLOT = 1; const int COLOR_SLOT = 1;
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); // 1 for everyone auto streamFormat = std::make_shared<gpu::Stream::Format>(); // 1 for everyone
streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0);
streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA));
@ -1037,10 +1037,10 @@ void GeometryCache::renderBevelCornersRect(gpu::Batch& batch, int x, int y, int
details.vertices = NUM_VERTICES; details.vertices = NUM_VERTICES;
details.vertexSize = FLOATS_PER_VERTEX; details.vertexSize = FLOATS_PER_VERTEX;
gpu::BufferPointer verticesBuffer(new gpu::Buffer()); auto verticesBuffer = std::make_shared<gpu::Buffer>();
gpu::BufferPointer colorBuffer(new gpu::Buffer()); auto colorBuffer = std::make_shared<gpu::Buffer>();
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); auto streamFormat = std::make_shared<gpu::Stream::Format>();
gpu::BufferStreamPointer stream(new gpu::BufferStream()); auto stream = std::make_shared<gpu::BufferStream>();
details.verticesBuffer = verticesBuffer; details.verticesBuffer = verticesBuffer;
details.colorBuffer = colorBuffer; details.colorBuffer = colorBuffer;
@ -1145,10 +1145,10 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co
details.vertices = vertices; details.vertices = vertices;
details.vertexSize = FLOATS_PER_VERTEX; details.vertexSize = FLOATS_PER_VERTEX;
gpu::BufferPointer verticesBuffer(new gpu::Buffer()); auto verticesBuffer = std::make_shared<gpu::Buffer>();
gpu::BufferPointer colorBuffer(new gpu::Buffer()); auto colorBuffer = std::make_shared<gpu::Buffer>();
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); auto streamFormat = std::make_shared<gpu::Stream::Format>();
gpu::BufferStreamPointer stream(new gpu::BufferStream()); auto stream = std::make_shared<gpu::BufferStream>();
details.verticesBuffer = verticesBuffer; details.verticesBuffer = verticesBuffer;
details.colorBuffer = colorBuffer; details.colorBuffer = colorBuffer;
@ -1251,10 +1251,10 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co
details.vertices = vertices; details.vertices = vertices;
details.vertexSize = FLOATS_PER_VERTEX; details.vertexSize = FLOATS_PER_VERTEX;
gpu::BufferPointer verticesBuffer(new gpu::Buffer()); auto verticesBuffer = std::make_shared<gpu::Buffer>();
gpu::BufferPointer colorBuffer(new gpu::Buffer()); auto colorBuffer = std::make_shared<gpu::Buffer>();
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); auto streamFormat = std::make_shared<gpu::Stream::Format>();
gpu::BufferStreamPointer stream(new gpu::BufferStream()); auto stream = std::make_shared<gpu::BufferStream>();
details.verticesBuffer = verticesBuffer; details.verticesBuffer = verticesBuffer;
details.colorBuffer = colorBuffer; details.colorBuffer = colorBuffer;
@ -1330,10 +1330,10 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, co
details.vertices = vertices; details.vertices = vertices;
details.vertexSize = FLOATS_PER_VERTEX; details.vertexSize = FLOATS_PER_VERTEX;
gpu::BufferPointer verticesBuffer(new gpu::Buffer()); auto verticesBuffer = std::make_shared<gpu::Buffer>();
gpu::BufferPointer colorBuffer(new gpu::Buffer()); auto colorBuffer = std::make_shared<gpu::Buffer>();
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); auto streamFormat = std::make_shared<gpu::Stream::Format>();
gpu::BufferStreamPointer stream(new gpu::BufferStream()); auto stream = std::make_shared<gpu::BufferStream>();
details.verticesBuffer = verticesBuffer; details.verticesBuffer = verticesBuffer;
details.colorBuffer = colorBuffer; details.colorBuffer = colorBuffer;
@ -1433,10 +1433,10 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, cons
details.vertices = vertices; details.vertices = vertices;
details.vertexSize = FLOATS_PER_VERTEX; // NOTE: this isn't used for BatchItemDetails maybe we can get rid of it details.vertexSize = FLOATS_PER_VERTEX; // NOTE: this isn't used for BatchItemDetails maybe we can get rid of it
gpu::BufferPointer verticesBuffer(new gpu::Buffer()); auto verticesBuffer = std::make_shared<gpu::Buffer>();
gpu::BufferPointer colorBuffer(new gpu::Buffer()); auto colorBuffer = std::make_shared<gpu::Buffer>();
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); auto streamFormat = std::make_shared<gpu::Stream::Format>();
gpu::BufferStreamPointer stream(new gpu::BufferStream()); auto stream = std::make_shared<gpu::BufferStream>();
details.verticesBuffer = verticesBuffer; details.verticesBuffer = verticesBuffer;
details.colorBuffer = colorBuffer; details.colorBuffer = colorBuffer;
@ -1520,10 +1520,10 @@ void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start,
details.vertexSize = FLOATS_PER_VERTEX; details.vertexSize = FLOATS_PER_VERTEX;
details.isCreated = true; details.isCreated = true;
gpu::BufferPointer verticesBuffer(new gpu::Buffer()); auto verticesBuffer = std::make_shared<gpu::Buffer>();
gpu::BufferPointer colorBuffer(new gpu::Buffer()); auto colorBuffer = std::make_shared<gpu::Buffer>();
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); auto streamFormat = std::make_shared<gpu::Stream::Format>();
gpu::BufferStreamPointer stream(new gpu::BufferStream()); auto stream = std::make_shared<gpu::BufferStream>();
details.verticesBuffer = verticesBuffer; details.verticesBuffer = verticesBuffer;
details.colorBuffer = colorBuffer; details.colorBuffer = colorBuffer;
@ -1685,10 +1685,10 @@ void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm
details.vertices = vertices; details.vertices = vertices;
details.vertexSize = FLOATS_PER_VERTEX; details.vertexSize = FLOATS_PER_VERTEX;
gpu::BufferPointer verticesBuffer(new gpu::Buffer()); auto verticesBuffer = std::make_shared<gpu::Buffer>();
gpu::BufferPointer colorBuffer(new gpu::Buffer()); auto colorBuffer = std::make_shared<gpu::Buffer>();
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); auto streamFormat = std::make_shared<gpu::Stream::Format>();
gpu::BufferStreamPointer stream(new gpu::BufferStream()); auto stream = std::make_shared<gpu::BufferStream>();
details.verticesBuffer = verticesBuffer; details.verticesBuffer = verticesBuffer;
details.colorBuffer = colorBuffer; details.colorBuffer = colorBuffer;
@ -1775,10 +1775,10 @@ void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm
details.vertices = vertices; details.vertices = vertices;
details.vertexSize = FLOATS_PER_VERTEX; details.vertexSize = FLOATS_PER_VERTEX;
gpu::BufferPointer verticesBuffer(new gpu::Buffer()); auto verticesBuffer = std::make_shared<gpu::Buffer>();
gpu::BufferPointer colorBuffer(new gpu::Buffer()); auto colorBuffer = std::make_shared<gpu::Buffer>();
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); auto streamFormat = std::make_shared<gpu::Stream::Format>();
gpu::BufferStreamPointer stream(new gpu::BufferStream()); auto stream = std::make_shared<gpu::BufferStream>();
details.verticesBuffer = verticesBuffer; details.verticesBuffer = verticesBuffer;
details.colorBuffer = colorBuffer; details.colorBuffer = colorBuffer;
@ -1835,7 +1835,7 @@ void GeometryCache::useSimpleDrawPipeline(gpu::Batch& batch) {
auto program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps)); auto program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps));
gpu::Shader::makeProgram((*program)); gpu::Shader::makeProgram((*program));
auto state = gpu::StatePointer(new gpu::State()); auto state = std::make_shared<gpu::State>();
// enable decal blend // enable decal blend
state->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA); state->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA);
@ -2213,8 +2213,8 @@ void NetworkGeometry::downloadFinished(QNetworkReply* reply) {
} }
QVariantHash lods = _mapping.value("lod").toHash(); QVariantHash lods = _mapping.value("lod").toHash();
for (QVariantHash::const_iterator it = lods.begin(); it != lods.end(); it++) { for (QVariantHash::const_iterator it = lods.begin(); it != lods.end(); it++) {
QSharedPointer<NetworkGeometry> geometry(new NetworkGeometry(url.resolved(it.key()), auto geometry = QSharedPointer<NetworkGeometry>::create(url.resolved(it.key()),
QSharedPointer<NetworkGeometry>(), true, _mapping, _textureBase)); QSharedPointer<NetworkGeometry>(), true, _mapping, _textureBase);
geometry->setSelf(geometry.staticCast<Resource>()); geometry->setSelf(geometry.staticCast<Resource>());
geometry->setLODParent(_lodParent); geometry->setLODParent(_lodParent);
_lods.insert(it.value().toFloat(), geometry); _lods.insert(it.value().toFloat(), geometry);
@ -2290,7 +2290,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
} }
{ {
networkMesh._indexBuffer = gpu::BufferPointer(new gpu::Buffer()); networkMesh._indexBuffer = std::make_shared<gpu::Buffer>();
networkMesh._indexBuffer->resize(totalIndices * sizeof(int)); networkMesh._indexBuffer->resize(totalIndices * sizeof(int));
int offset = 0; int offset = 0;
foreach(const FBXMeshPart& part, mesh.parts) { foreach(const FBXMeshPart& part, mesh.parts) {
@ -2304,7 +2304,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
} }
{ {
networkMesh._vertexBuffer = gpu::BufferPointer(new gpu::Buffer()); networkMesh._vertexBuffer = std::make_shared<gpu::Buffer>();
// if we don't need to do any blending, the positions/normals can be static // if we don't need to do any blending, the positions/normals can be static
if (mesh.blendshapes.isEmpty()) { if (mesh.blendshapes.isEmpty()) {
int normalsOffset = mesh.vertices.size() * sizeof(glm::vec3); int normalsOffset = mesh.vertices.size() * sizeof(glm::vec3);
@ -2332,7 +2332,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
mesh.clusterWeights.size() * sizeof(glm::vec4), (gpu::Byte*) mesh.clusterWeights.constData()); mesh.clusterWeights.size() * sizeof(glm::vec4), (gpu::Byte*) mesh.clusterWeights.constData());
// otherwise, at least the cluster indices/weights can be static // otherwise, at least the cluster indices/weights can be static
networkMesh._vertexStream = gpu::BufferStreamPointer(new gpu::BufferStream()); networkMesh._vertexStream = std::make_shared<gpu::BufferStream>();
networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, 0, sizeof(glm::vec3)); networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, 0, sizeof(glm::vec3));
if (mesh.normals.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, normalsOffset, sizeof(glm::vec3)); if (mesh.normals.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, normalsOffset, sizeof(glm::vec3));
if (mesh.tangents.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, tangentsOffset, sizeof(glm::vec3)); if (mesh.tangents.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, tangentsOffset, sizeof(glm::vec3));
@ -2343,7 +2343,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
if (mesh.clusterWeights.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, clusterWeightsOffset, sizeof(glm::vec4)); if (mesh.clusterWeights.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, clusterWeightsOffset, sizeof(glm::vec4));
int channelNum = 0; int channelNum = 0;
networkMesh._vertexFormat = gpu::Stream::FormatPointer(new gpu::Stream::Format()); networkMesh._vertexFormat = std::make_shared<gpu::Stream::Format>();
networkMesh._vertexFormat->setAttribute(gpu::Stream::POSITION, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); networkMesh._vertexFormat->setAttribute(gpu::Stream::POSITION, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0);
if (mesh.normals.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::NORMAL, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); if (mesh.normals.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::NORMAL, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ));
if (mesh.tangents.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TANGENT, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); if (mesh.tangents.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TANGENT, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ));
@ -2374,7 +2374,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
networkMesh._vertexBuffer->setSubData(clusterWeightsOffset, networkMesh._vertexBuffer->setSubData(clusterWeightsOffset,
mesh.clusterWeights.size() * sizeof(glm::vec4), (gpu::Byte*) mesh.clusterWeights.constData()); mesh.clusterWeights.size() * sizeof(glm::vec4), (gpu::Byte*) mesh.clusterWeights.constData());
networkMesh._vertexStream = gpu::BufferStreamPointer(new gpu::BufferStream()); networkMesh._vertexStream = std::make_shared<gpu::BufferStream>();
if (mesh.tangents.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, 0, sizeof(glm::vec3)); if (mesh.tangents.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, 0, sizeof(glm::vec3));
if (mesh.colors.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, colorsOffset, sizeof(glm::vec3)); if (mesh.colors.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, colorsOffset, sizeof(glm::vec3));
if (mesh.texCoords.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, texCoordsOffset, sizeof(glm::vec2)); if (mesh.texCoords.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, texCoordsOffset, sizeof(glm::vec2));
@ -2382,7 +2382,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
if (mesh.clusterWeights.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, clusterWeightsOffset, sizeof(glm::vec4)); if (mesh.clusterWeights.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, clusterWeightsOffset, sizeof(glm::vec4));
int channelNum = 0; int channelNum = 0;
networkMesh._vertexFormat = gpu::Stream::FormatPointer(new gpu::Stream::Format()); networkMesh._vertexFormat = std::make_shared<gpu::Stream::Format>();
networkMesh._vertexFormat->setAttribute(gpu::Stream::POSITION, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); networkMesh._vertexFormat->setAttribute(gpu::Stream::POSITION, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ));
if (mesh.normals.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::NORMAL, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); if (mesh.normals.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::NORMAL, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ));
if (mesh.tangents.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TANGENT, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); if (mesh.tangents.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TANGENT, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ));

View file

@ -121,11 +121,11 @@ void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey key,
gpu::Shader::makeProgram(*program, slotBindings); gpu::Shader::makeProgram(*program, slotBindings);
auto locations = std::shared_ptr<Locations>(new Locations()); auto locations = std::make_shared<Locations>();
initLocations(program, *locations); initLocations(program, *locations);
gpu::StatePointer state = gpu::StatePointer(new gpu::State()); auto state = std::make_shared<gpu::State>();
// Backface on shadow // Backface on shadow
if (key.isShadow()) { if (key.isShadow()) {
@ -152,7 +152,7 @@ void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey key,
if (!key.isWireFrame()) { if (!key.isWireFrame()) {
RenderKey wireframeKey(key.getRaw() | RenderKey::IS_WIREFRAME); RenderKey wireframeKey(key.getRaw() | RenderKey::IS_WIREFRAME);
gpu::StatePointer wireframeState = gpu::StatePointer(new gpu::State(state->getValues())); auto wireframeState = std::make_shared<gpu::State>(state->getValues());
wireframeState->setFillMode(gpu::State::FILL_LINE); wireframeState->setFillMode(gpu::State::FILL_LINE);
@ -165,7 +165,7 @@ void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey key,
if (!key.isShadow()) { if (!key.isShadow()) {
RenderKey mirrorKey(key.getRaw() | RenderKey::IS_MIRROR); RenderKey mirrorKey(key.getRaw() | RenderKey::IS_MIRROR);
gpu::StatePointer mirrorState = gpu::StatePointer(new gpu::State(state->getValues())); auto mirrorState = std::make_shared<gpu::State>(state->getValues());
mirrorState->setFrontFaceClockwise(true); mirrorState->setFrontFaceClockwise(true);
@ -175,7 +175,7 @@ void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey key,
if (!key.isWireFrame()) { if (!key.isWireFrame()) {
RenderKey wireframeKey(key.getRaw() | RenderKey::IS_MIRROR | RenderKey::IS_WIREFRAME); RenderKey wireframeKey(key.getRaw() | RenderKey::IS_MIRROR | RenderKey::IS_WIREFRAME);
gpu::StatePointer wireframeState = gpu::StatePointer(new gpu::State(state->getValues()));; auto wireframeState = std::make_shared<gpu::State>(state->getValues());
wireframeState->setFillMode(gpu::State::FILL_LINE); wireframeState->setFillMode(gpu::State::FILL_LINE);
@ -482,7 +482,7 @@ bool Model::updateGeometry() {
state.clusterMatrices.resize(mesh.clusters.size()); state.clusterMatrices.resize(mesh.clusters.size());
_meshStates.append(state); _meshStates.append(state);
gpu::BufferPointer buffer(new gpu::Buffer()); auto buffer = std::make_shared<gpu::Buffer>();
if (!mesh.blendshapes.isEmpty()) { if (!mesh.blendshapes.isEmpty()) {
buffer->resize((mesh.vertices.size() + mesh.normals.size()) * sizeof(glm::vec3)); buffer->resize((mesh.vertices.size() + mesh.normals.size()) * sizeof(glm::vec3));
buffer->setSubData(0, mesh.vertices.size() * sizeof(glm::vec3), (gpu::Byte*) mesh.vertices.constData()); buffer->setSubData(0, mesh.vertices.size() * sizeof(glm::vec3), (gpu::Byte*) mesh.vertices.constData());
@ -890,7 +890,7 @@ bool Model::addToScene(std::shared_ptr<render::Scene> scene, render::PendingChan
foreach (auto renderItem, _transparentRenderItems) { foreach (auto renderItem, _transparentRenderItems) {
auto item = scene->allocateID(); auto item = scene->allocateID();
auto renderData = MeshPartPayload::Pointer(renderItem); auto renderData = MeshPartPayload::Pointer(renderItem);
auto renderPayload = render::PayloadPointer(new MeshPartPayload::Payload(renderData)); auto renderPayload = std::make_shared<MeshPartPayload::Payload>(renderData);
pendingChanges.resetItem(item, renderPayload); pendingChanges.resetItem(item, renderPayload);
_renderItems.insert(item, renderPayload); _renderItems.insert(item, renderPayload);
somethingAdded = true; somethingAdded = true;
@ -899,7 +899,7 @@ bool Model::addToScene(std::shared_ptr<render::Scene> scene, render::PendingChan
foreach (auto renderItem, _opaqueRenderItems) { foreach (auto renderItem, _opaqueRenderItems) {
auto item = scene->allocateID(); auto item = scene->allocateID();
auto renderData = MeshPartPayload::Pointer(renderItem); auto renderData = MeshPartPayload::Pointer(renderItem);
auto renderPayload = render::PayloadPointer(new MeshPartPayload::Payload(renderData)); auto renderPayload = std::make_shared<MeshPartPayload::Payload>(renderData);
pendingChanges.resetItem(item, renderPayload); pendingChanges.resetItem(item, renderPayload);
_renderItems.insert(item, renderPayload); _renderItems.insert(item, renderPayload);
somethingAdded = true; somethingAdded = true;
@ -2103,9 +2103,9 @@ void Model::segregateMeshGroups() {
for (int partIndex = 0; partIndex < totalParts; partIndex++) { for (int partIndex = 0; partIndex < totalParts; partIndex++) {
// this is a good place to create our renderPayloads // this is a good place to create our renderPayloads
if (translucentMesh) { if (translucentMesh) {
_transparentRenderItems << std::shared_ptr<MeshPartPayload>(new MeshPartPayload(true, this, i, partIndex)); _transparentRenderItems << std::make_shared<MeshPartPayload>(true, this, i, partIndex);
} else { } else {
_opaqueRenderItems << std::shared_ptr<MeshPartPayload>(new MeshPartPayload(false, this, i, partIndex)); _opaqueRenderItems << std::make_shared<MeshPartPayload>(false, this, i, partIndex);
} }
} }
} }
@ -2152,7 +2152,7 @@ bool Model::initWhenReady(render::ScenePointer scene) {
foreach (auto renderItem, _transparentRenderItems) { foreach (auto renderItem, _transparentRenderItems) {
auto item = scene->allocateID(); auto item = scene->allocateID();
auto renderData = MeshPartPayload::Pointer(renderItem); auto renderData = MeshPartPayload::Pointer(renderItem);
auto renderPayload = render::PayloadPointer(new MeshPartPayload::Payload(renderData)); auto renderPayload = std::make_shared<MeshPartPayload::Payload>(renderData);
_renderItems.insert(item, renderPayload); _renderItems.insert(item, renderPayload);
pendingChanges.resetItem(item, renderPayload); pendingChanges.resetItem(item, renderPayload);
} }
@ -2160,7 +2160,7 @@ bool Model::initWhenReady(render::ScenePointer scene) {
foreach (auto renderItem, _opaqueRenderItems) { foreach (auto renderItem, _opaqueRenderItems) {
auto item = scene->allocateID(); auto item = scene->allocateID();
auto renderData = MeshPartPayload::Pointer(renderItem); auto renderData = MeshPartPayload::Pointer(renderItem);
auto renderPayload = render::PayloadPointer(new MeshPartPayload::Payload(renderData)); auto renderPayload = std::make_shared<MeshPartPayload::Payload>(renderData);
_renderItems.insert(item, renderPayload); _renderItems.insert(item, renderPayload);
pendingChanges.resetItem(item, renderPayload); pendingChanges.resetItem(item, renderPayload);
} }

View file

@ -57,7 +57,7 @@ ProgramPtr loadDefaultShader() {
void compileProgram(ProgramPtr & result, const std::string& vs, const std::string& fs) { void compileProgram(ProgramPtr & result, const std::string& vs, const std::string& fs) {
using namespace oglplus; using namespace oglplus;
try { try {
result = ProgramPtr(new Program()); result = QSharedPointer<Program>::create();
// attach the shaders to the program // attach the shaders to the program
result->AttachShader( result->AttachShader(
VertexShader() VertexShader()

View file

@ -181,7 +181,7 @@ const gpu::PipelinePointer& DrawOverlay3D::getOpaquePipeline() {
auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(overlay3D_frag))); auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(overlay3D_frag)));
auto program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps)); auto program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps));
auto state = gpu::StatePointer(new gpu::State()); auto state = std::make_shared<gpu::State>();
state->setDepthTest(true, true, gpu::LESS_EQUAL); state->setDepthTest(true, true, gpu::LESS_EQUAL);
_opaquePipeline.reset(gpu::Pipeline::create(program, state)); _opaquePipeline.reset(gpu::Pipeline::create(program, state));

View file

@ -340,7 +340,7 @@ void Font3D::setupGPU() {
_outlineLoc = program->getUniforms().findLocation("Outline"); _outlineLoc = program->getUniforms().findLocation("Outline");
_colorLoc = program->getUniforms().findLocation("Color"); _colorLoc = program->getUniforms().findLocation("Color");
gpu::StatePointer state = gpu::StatePointer(new gpu::State()); auto state = std::make_shared<gpu::State>();
state->setCullMode(gpu::State::CULL_BACK); state->setCullMode(gpu::State::CULL_BACK);
state->setDepthTest(true, true, gpu::LESS_EQUAL); state->setDepthTest(true, true, gpu::LESS_EQUAL);
state->setBlendFunction(false, state->setBlendFunction(false,
@ -356,7 +356,7 @@ void Font3D::setupGPU() {
assert(sizeof(QuadBuilder) == 4 * sizeof(TextureVertex)); assert(sizeof(QuadBuilder) == 4 * sizeof(TextureVertex));
// Setup rendering structures // Setup rendering structures
_format.reset(new gpu::Stream::Format()); _format = std::make_shared<gpu::Stream::Format>();
_format->setAttribute(gpu::Stream::POSITION, 0, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::XYZ), 0); _format->setAttribute(gpu::Stream::POSITION, 0, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::XYZ), 0);
_format->setAttribute(gpu::Stream::TEXCOORD, 0, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV), OFFSET); _format->setAttribute(gpu::Stream::TEXCOORD, 0, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV), OFFSET);
} }
@ -369,7 +369,7 @@ void Font3D::drawString(gpu::Batch& batch, float x, float y, const QString& str,
} }
if (str != _lastStringRendered || bounds != _lastBounds) { if (str != _lastStringRendered || bounds != _lastBounds) {
_verticesBuffer.reset(new gpu::Buffer()); _verticesBuffer = std::make_shared<gpu::Buffer>();
_numVertices = 0; _numVertices = 0;
_lastStringRendered = str; _lastStringRendered = str;
_lastBounds = bounds; _lastBounds = bounds;

View file

@ -43,11 +43,11 @@ public:
Varying() {} Varying() {}
template <class T> template <class T>
Varying(const T& data) : _concept(new Job::Varying::Model<T>(data)) {} Varying(const T& data) : _concept(std::make_shared<Job::Varying::Model<T>>(data)) {}
// Access the _data contained win the concept explicitely // Access the _data contained win the concept explicitely
template <class T> T& edit() { return (static_cast<Model<T>*> (_concept.get())->_data); } template <class T> T& edit() { return std::static_pointer_cast<Model<T>>(_concept)->_data; }
template <class T> const T& get() const { return (static_cast<const Model<T>*> (_concept.get())->_data); } template <class T> const T& get() const { return std::static_pointer_cast<const Model<T>>(_concept)->_data; }
protected: protected:
friend class Job; friend class Job;

View file

@ -15,8 +15,8 @@ using namespace render;
Engine::Engine() : Engine::Engine() :
_sceneContext(new SceneContext()), _sceneContext(std::make_shared<SceneContext>()),
_renderContext(new RenderContext()) _renderContext(std::make_shared<RenderContext>())
{ {
} }
@ -45,6 +45,6 @@ void Engine::buildStandardTaskPipeline() {
_tasks.clear(); _tasks.clear();
} }
addTask(TaskPointer(new DrawSceneTask())); addTask(std::make_shared<DrawSceneTask>());
} }

View file

@ -398,7 +398,7 @@ public:
void removeItem(ItemID id); void removeItem(ItemID id);
template <class T> void updateItem(ItemID id, std::function<void(T&)> func) { template <class T> void updateItem(ItemID id, std::function<void(T&)> func) {
updateItem(id, UpdateFunctorPointer(new UpdateFunctor<T>(func))); updateItem(id, std::make_shared<UpdateFunctor<T>>(func));
} }
void updateItem(ItemID id, const UpdateFunctorPointer& functor); void updateItem(ItemID id, const UpdateFunctorPointer& functor);

View file

@ -113,7 +113,7 @@ protected:
SceneScriptingInterface() {}; SceneScriptingInterface() {};
~SceneScriptingInterface() {}; ~SceneScriptingInterface() {};
model::SunSkyStagePointer _skyStage = model::SunSkyStagePointer(new model::SunSkyStage()); model::SunSkyStagePointer _skyStage = std::make_shared<model::SunSkyStage>();
bool _shouldRenderAvatars = true; bool _shouldRenderAvatars = true;
bool _shouldRenderEntities = true; bool _shouldRenderEntities = true;

View file

@ -156,8 +156,7 @@ protected:
mutable Flags _flags; mutable Flags _flags;
// Cached transform // Cached transform
// TODO: replace this auto ptr by a "unique ptr" as soon as we are compiling in C++11 mutable std::unique_ptr<Mat4> _matrix;
mutable std::auto_ptr<Mat4> _matrix;
bool isCacheInvalid() const { return _flags[FLAG_CACHE_INVALID]; } bool isCacheInvalid() const { return _flags[FLAG_CACHE_INVALID]; }
void validCache() const { _flags.set(FLAG_CACHE_INVALID, false); } void validCache() const { _flags.set(FLAG_CACHE_INVALID, false); }

View file

@ -42,7 +42,7 @@ const TextTemplatePointer TextTemplate::Config::addInclude(const ConfigPointer&
String includeStream; String includeStream;
if (config->_includerCallback(config, include, includeStream)) { if (config->_includerCallback(config, include, includeStream)) {
// ok, then create a new Template on the include file with this as lib // ok, then create a new Template on the include file with this as lib
included = TextTemplatePointer(new TextTemplate(include, config)); included = std::make_shared<TextTemplate>(include, config);
std::stringstream src(includeStream); std::stringstream src(includeStream);
@ -398,7 +398,7 @@ const BlockPointer TextTemplate::processStepVar(const BlockPointer& block, Strin
BlockPointer parent = Block::getCurrentBlock(block); BlockPointer parent = Block::getCurrentBlock(block);
// Add a new BLock // Add a new BLock
BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); BlockPointer newBlock = std::make_shared<Block>(_root->sourceName);
(newBlock->ostr) << grabbed; (newBlock->ostr) << grabbed;
newBlock->command.type = Command::VAR; newBlock->command.type = Command::VAR;
@ -460,7 +460,7 @@ const BlockPointer TextTemplate::processStepDef(const BlockPointer& block, Strin
BlockPointer parent = Block::getCurrentBlock(block); BlockPointer parent = Block::getCurrentBlock(block);
// Add a new BLock // Add a new BLock
BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); BlockPointer newBlock = std::make_shared<Block>(_root->sourceName);
(newBlock->ostr) << grabbed; (newBlock->ostr) << grabbed;
newBlock->command.type = Command::DEF; newBlock->command.type = Command::DEF;
@ -482,12 +482,12 @@ const BlockPointer TextTemplate::processStepCommandIf(const BlockPointer& block,
BlockPointer parent = Block::getCurrentBlock(block); BlockPointer parent = Block::getCurrentBlock(block);
// Add a new BLock depth // Add a new BLock depth
BlockPointer newIfBlock = BlockPointer(new Block(_root->sourceName)); BlockPointer newIfBlock = std::make_shared<Block>(_root->sourceName);
newIfBlock->command.type = Command::IFBLOCK; newIfBlock->command.type = Command::IFBLOCK;
Block::addNewBlock(parent, newIfBlock); Block::addNewBlock(parent, newIfBlock);
BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); BlockPointer newBlock = std::make_shared<Block>(_root->sourceName);
(newBlock->ostr) << grabbed; (newBlock->ostr) << grabbed;
newBlock->command.type = Command::IF; newBlock->command.type = Command::IF;
@ -506,7 +506,7 @@ const BlockPointer TextTemplate::processStepCommandEndIf(const BlockPointer& blo
if ((parent->command.type == Command::IF) if ((parent->command.type == Command::IF)
|| (parent->command.type == Command::ELIF) || (parent->command.type == Command::ELIF)
|| (parent->command.type == Command::ELSE)) { || (parent->command.type == Command::ELSE)) {
BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); BlockPointer newBlock = std::make_shared<Block>(_root->sourceName);
(newBlock->ostr) << grabbed; (newBlock->ostr) << grabbed;
newBlock->command.type = Command::ENDIF; newBlock->command.type = Command::ENDIF;
@ -533,7 +533,7 @@ const BlockPointer TextTemplate::processStepCommandElse(const BlockPointer& bloc
parent = parent->parent; parent = parent->parent;
// Add a new BLock depth // Add a new BLock depth
BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); BlockPointer newBlock = std::make_shared<Block>(_root->sourceName);
newBlock->ostr << grabbed; newBlock->ostr << grabbed;
newBlock->command.type = Command::ELSE; newBlock->command.type = Command::ELSE;
newBlock->command.arguments.push_back(expression); newBlock->command.arguments.push_back(expression);
@ -562,7 +562,7 @@ const BlockPointer TextTemplate::processStepCommandElif(const BlockPointer& bloc
parent = parent->parent; parent = parent->parent;
// Add a new BLock depth // Add a new BLock depth
BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); BlockPointer newBlock = std::make_shared<Block>(_root->sourceName);
(newBlock->ostr) << grabbed; (newBlock->ostr) << grabbed;
newBlock->command.type = Command::ELIF; newBlock->command.type = Command::ELIF;
@ -595,7 +595,7 @@ const BlockPointer TextTemplate::processStepInclude(const BlockPointer& block, S
BlockPointer parent = Block::getCurrentBlock(block); BlockPointer parent = Block::getCurrentBlock(block);
// Add a new BLock // Add a new BLock
BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); BlockPointer newBlock = std::make_shared<Block>(_root->sourceName);
(newBlock->ostr) << grabbed; (newBlock->ostr) << grabbed;
newBlock->command.type = Command::INCLUDE; newBlock->command.type = Command::INCLUDE;
@ -631,7 +631,7 @@ const BlockPointer TextTemplate::processStepFunc(const BlockPointer& block, Stri
BlockPointer parent = Block::getCurrentBlock(block); BlockPointer parent = Block::getCurrentBlock(block);
// Add a new BLock // Add a new BLock
BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); BlockPointer newBlock = std::make_shared<Block>(_root->sourceName);
(newBlock->ostr) << grabbed; (newBlock->ostr) << grabbed;
newBlock->command.type = Command::FUNC; newBlock->command.type = Command::FUNC;
@ -660,7 +660,7 @@ const BlockPointer TextTemplate::processStepEndFunc(const BlockPointer& block, S
// Everything is cool , so let's unplugg the FUnc block from this tree and just put the EndFunc block // Everything is cool , so let's unplugg the FUnc block from this tree and just put the EndFunc block
BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); BlockPointer newBlock = std::make_shared<Block>(_root->sourceName);
(newBlock->ostr) << grabbed; (newBlock->ostr) << grabbed;
newBlock->command.type = Command::ENDFUNC; newBlock->command.type = Command::ENDFUNC;

View file

@ -141,7 +141,7 @@ public:
static bool loadFile(const Config::Pointer& config, const char* filename, String& source); static bool loadFile(const Config::Pointer& config, const char* filename, String& source);
TextTemplate(const String& name, const Config::Pointer& config = Config::Pointer(new Config())); TextTemplate(const String& name, const Config::Pointer& config = std::make_shared<Config>());
~TextTemplate(); ~TextTemplate();
// Scibe does all the job of parsing an inout template stream and then gneerating theresulting stream using the vars // Scibe does all the job of parsing an inout template stream and then gneerating theresulting stream using the vars

View file

@ -31,7 +31,7 @@ int main (int argc, char** argv) {
bool showParseTree = false; bool showParseTree = false;
bool makeCPlusPlus = false; bool makeCPlusPlus = false;
TextTemplate::Config::Pointer config(new TextTemplate::Config()); auto config = std::make_shared<TextTemplate::Config>();
enum Mode { enum Mode {
READY = 0, READY = 0,
@ -165,7 +165,7 @@ int main (int argc, char** argv) {
return 0; return 0;
} }
TextTemplate::Pointer scribe(new TextTemplate(srcFilename, config)); auto scribe = std::make_shared<TextTemplate>(srcFilename, config);
// ready to parse and generate // ready to parse and generate
std::ostringstream destStringStream; std::ostringstream destStringStream;