mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-07 18:59:39 +02:00
Drawing full bounding box
This commit is contained in:
parent
2f2d5815db
commit
aa55de46c2
3 changed files with 55 additions and 75 deletions
|
@ -33,23 +33,23 @@ using namespace render;
|
||||||
|
|
||||||
const gpu::PipelinePointer& DrawStatus::getDrawItemBoundsPipeline() {
|
const gpu::PipelinePointer& DrawStatus::getDrawItemBoundsPipeline() {
|
||||||
if (!_drawItemBoundsPipeline) {
|
if (!_drawItemBoundsPipeline) {
|
||||||
auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(drawItemBounds_vert)));
|
auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(drawItemBounds_vert)));
|
||||||
auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(drawItemBounds_frag)));
|
auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(drawItemBounds_frag)));
|
||||||
gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps));
|
gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps));
|
||||||
|
|
||||||
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());
|
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||||
|
|
||||||
state->setDepthTest(true, false, gpu::LESS_EQUAL);
|
state->setDepthTest(true, false, gpu::LESS_EQUAL);
|
||||||
|
|
||||||
// Blend on transparent
|
// Blend on transparent
|
||||||
state->setBlendFunction(true,
|
state->setBlendFunction(true,
|
||||||
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
||||||
gpu::State::DEST_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ZERO);
|
gpu::State::DEST_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ZERO);
|
||||||
|
|
||||||
// Good to go add the brand new pipeline
|
// Good to go add the brand new pipeline
|
||||||
_drawItemBoundsPipeline.reset(gpu::Pipeline::create(program, state));
|
_drawItemBoundsPipeline.reset(gpu::Pipeline::create(program, state));
|
||||||
}
|
}
|
||||||
return _drawItemBoundsPipeline;
|
return _drawItemBoundsPipeline;
|
||||||
|
@ -88,7 +88,7 @@ void DrawStatus::run(const SceneContextPointer& sceneContext, const RenderContex
|
||||||
}
|
}
|
||||||
|
|
||||||
batch.setModelTransform(model);
|
batch.setModelTransform(model);
|
||||||
batch.draw(gpu::LINE_STRIP, 13, 0);
|
batch.draw(gpu::LINES, 24, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
//
|
|
||||||
// Stats.h
|
|
||||||
// render/src/render
|
|
||||||
//
|
|
||||||
// Created by Niraj Venkat on 6/29/15.
|
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef hifi_render_Stats_h
|
|
||||||
#define hifi_render_Stats_h
|
|
||||||
|
|
||||||
#include "DrawTask.h"
|
|
||||||
#include "gpu/Batch.h"
|
|
||||||
#include <PerfStat.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace render {
|
|
||||||
class DrawStats {
|
|
||||||
public:
|
|
||||||
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems);
|
|
||||||
|
|
||||||
typedef Job::ModelI<DrawStats, ItemIDsBounds> JobModel;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // hifi_render_Stats_h
|
|
|
@ -1,38 +1,47 @@
|
||||||
<@include gpu/Config.slh@>
|
<@include gpu/Config.slh@>
|
||||||
<$VERSION_HEADER$>
|
<$VERSION_HEADER$>
|
||||||
// Generated on <$_SCRIBE_DATE$>
|
// Generated on <$_SCRIBE_DATE$>
|
||||||
//
|
//
|
||||||
// drawItemBounds.slv
|
// drawItemBounds.slv
|
||||||
// vertex shader
|
// vertex shader
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 6/29/2015.
|
// Created by Sam Gateau on 6/29/2015.
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
|
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
const vec4 UNIT_BOX[13] = vec4[13](
|
const vec4 UNIT_BOX[8] = vec4[8](
|
||||||
vec4(0.0, 0.0, 0.0, 1.0),
|
vec4(0.0, 0.0, 0.0, 1.0),
|
||||||
vec4(1.0, 0.0, 0.0, 1.0),
|
vec4(1.0, 0.0, 0.0, 1.0),
|
||||||
|
vec4(0.0, 1.0, 0.0, 1.0),
|
||||||
vec4(1.0, 1.0, 0.0, 1.0),
|
vec4(1.0, 1.0, 0.0, 1.0),
|
||||||
vec4(0.0, 1.0, 0.0, 1.0),
|
vec4(0.0, 0.0, 1.0, 1.0),
|
||||||
vec4(0.0, 0.0, 0.0, 1.0),
|
|
||||||
vec4(1.0, 0.0, 0.0, 1.0),
|
|
||||||
vec4(1.0, 0.0, 1.0, 1.0),
|
vec4(1.0, 0.0, 1.0, 1.0),
|
||||||
vec4(0.0, 0.0, 1.0, 1.0),
|
|
||||||
vec4(0.0, 0.0, 0.0, 1.0),
|
|
||||||
vec4(0.0, 1.0, 0.0, 1.0),
|
|
||||||
vec4(0.0, 1.0, 1.0, 1.0),
|
vec4(0.0, 1.0, 1.0, 1.0),
|
||||||
vec4(0.0, 0.0, 1.0, 1.0),
|
vec4(1.0, 1.0, 1.0, 1.0)
|
||||||
vec4(0.0, 0.0, 0.0, 1.0)
|
|
||||||
);
|
);
|
||||||
vec4 pos = UNIT_BOX[gl_VertexID];
|
const int UNIT_BOX_LINE_INDICES[24] = int[24](
|
||||||
|
0, 1,
|
||||||
|
1, 3,
|
||||||
|
3, 2,
|
||||||
|
2, 0,
|
||||||
|
4, 5,
|
||||||
|
5, 7,
|
||||||
|
7, 6,
|
||||||
|
6, 4,
|
||||||
|
2, 6,
|
||||||
|
3, 7,
|
||||||
|
0, 4,
|
||||||
|
1, 5
|
||||||
|
);
|
||||||
|
vec4 pos = UNIT_BOX[UNIT_BOX_LINE_INDICES[gl_VertexID]];
|
||||||
|
|
||||||
// standard transform
|
// standard transform
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
|
|
Loading…
Reference in a new issue