1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 03:12:36 +01:00

Remove raw ptr from DebugDraw

This commit is contained in:
Filip Gawin 2018-08-25 19:35:51 +02:00
parent 4ff4356986
commit ffb1092077
2 changed files with 5 additions and 12 deletions

View File

@ -14,8 +14,6 @@
#include "render/GameRenderer.hpp"
DebugDraw::DebugDraw() {
lineBuff = new GeometryBuffer;
dbuff = new DrawBuffer;
dbuff->setFaceType(GL_LINES);
glGenTextures(1, &texture);
@ -31,11 +29,6 @@ DebugDraw::DebugDraw() {
maxlines = 0;
}
DebugDraw::~DebugDraw() {
delete dbuff;
delete lineBuff;
}
void DebugDraw::drawLine(const btVector3 &from, const btVector3 &to,
const btVector3 &color) {
btVector3 c = color * 255;
@ -65,7 +58,7 @@ void DebugDraw::flush(GameRenderer *renderer) {
renderer->getRenderer()->useProgram(shaderProgram);
lineBuff->uploadVertices(lines);
dbuff->addGeometry(lineBuff);
dbuff->addGeometry(lineBuff.get());
Renderer::DrawParameters dp;
dp.textures = {texture};
@ -75,7 +68,7 @@ void DebugDraw::flush(GameRenderer *renderer) {
dp.count = lines.size();
dp.diffuse = 1.f;
renderer->getRenderer()->drawArrays(glm::mat4(1.f), dbuff, dp);
renderer->getRenderer()->drawArrays(glm::mat4(1.f), dbuff.get(), dp);
renderer->getRenderer()->invalidate();

View File

@ -20,7 +20,7 @@ class GeometryBuffer;
class DebugDraw final : public btIDebugDraw {
public:
DebugDraw();
~DebugDraw() override;
~DebugDraw() override = default;
void drawLine(const btVector3 &from, const btVector3 &to,
const btVector3 &color) override;
@ -43,8 +43,8 @@ protected:
std::vector<GeometryVertex> lines;
size_t maxlines;
GeometryBuffer *lineBuff;
DrawBuffer *dbuff;
std::unique_ptr<GeometryBuffer> lineBuff = std::make_unique<GeometryBuffer>();
std::unique_ptr<DrawBuffer> dbuff = std::make_unique<DrawBuffer>();
//Ownership is handled by worldProg in renderer
Renderer::ShaderProgram *shaderProgram = nullptr;