mirror of
https://github.com/Linloir/SceneEditor.git
synced 2025-12-17 07:28:12 +08:00
[CORE][ADD] Enable cross context model transferring
- Reload texture on another context - Copy meshes - [BUG] memory leak (not fixed yet)
This commit is contained in:
parent
e6bab8a345
commit
2fd1d6db24
@ -6,6 +6,10 @@ Renderable::Renderable(Model* model) : _model(model) {}
|
||||
|
||||
Renderable::Renderable(Model* model, glm::vec3 position) : _model(model), _position(position) {}
|
||||
|
||||
void Renderable::setModel(Model* model) {
|
||||
_model = model;
|
||||
}
|
||||
|
||||
void Renderable::move(glm::vec3 deltaVec) {
|
||||
_position += deltaVec;
|
||||
}
|
||||
@ -31,6 +35,11 @@ void Renderable::setScale(float scale) {
|
||||
}
|
||||
|
||||
void Renderable::render(ShaderProgram shader) {
|
||||
// Check if initialized
|
||||
if (_model == nullptr) {
|
||||
Logger::error("Tries to render an uninitialized renderable object");
|
||||
return;
|
||||
}
|
||||
// Set model matrix
|
||||
shader.setUniform("model", modelMatrix());
|
||||
// Render
|
||||
|
||||
@ -7,8 +7,16 @@
|
||||
#include "shader.h"
|
||||
|
||||
class Renderable {
|
||||
public:
|
||||
static Renderable empty() {
|
||||
return Renderable();
|
||||
}
|
||||
|
||||
private:
|
||||
Model* _model;
|
||||
Renderable() {}
|
||||
|
||||
private:
|
||||
Model* _model = nullptr;
|
||||
glm::vec3 _position = glm::vec3(0.0f);
|
||||
glm::mat4 _rotation = glm::mat4(1.0f);
|
||||
glm::vec3 _scale = glm::vec3(1.0f);
|
||||
@ -18,6 +26,7 @@ public:
|
||||
Renderable(Model* model, glm::vec3 position);
|
||||
|
||||
public:
|
||||
void setModel(Model* model);
|
||||
void move(glm::vec3 deltaVec);
|
||||
void setPosition(glm::vec3 position);
|
||||
void rotate(glm::vec3 axis, float deltaAngle);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user